GlslangToSpv: Pass the pointer directly into the client function for opaque types
For opaque types such as samplers, images, and atomic counters, we want to
reference the actual object in the child function. For a long time, we
used a shadow variable and made a copy of the image/sampler. In 76d0ac1a,
this was changed to not shadow samplers. However, this didn't cover all
opaque types and it also didn't get the pointer storage classes right.
This commit fixes both of these issues.
Fixes #324
This commit is contained in:
parent
228546a8af
commit
ed15ef1a5b
2 changed files with 44 additions and 43 deletions
|
|
@ -2272,7 +2272,9 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
|||
for (int p = 0; p < (int)parameters.size(); ++p) {
|
||||
const glslang::TType& paramType = parameters[p]->getAsTyped()->getType();
|
||||
spv::Id typeId = convertGlslangToSpvType(paramType);
|
||||
if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
|
||||
if (paramType.isOpaque())
|
||||
typeId = builder.makePointer(TranslateStorageClass(paramType), typeId);
|
||||
else if (paramType.getQualifier().storage != glslang::EvqConstReadOnly)
|
||||
typeId = builder.makePointer(spv::StorageClassFunction, typeId);
|
||||
else
|
||||
constReadOnlyParameters.insert(parameters[p]->getAsSymbolNode()->getId());
|
||||
|
|
@ -2688,8 +2690,8 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
|
|||
builder.clearAccessChain();
|
||||
glslangArgs[a]->traverse(this);
|
||||
argTypes.push_back(¶mType);
|
||||
// keep outputs as and samplers l-values, evaluate input-only as r-values
|
||||
if (qualifiers[a] != glslang::EvqConstReadOnly || paramType.getBasicType() == glslang::EbtSampler) {
|
||||
// keep outputs as and opaque objects l-values, evaluate input-only as r-values
|
||||
if (qualifiers[a] != glslang::EvqConstReadOnly || paramType.isOpaque()) {
|
||||
// save l-value
|
||||
lValues.push_back(builder.getAccessChain());
|
||||
} else {
|
||||
|
|
@ -2708,7 +2710,7 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg
|
|||
for (int a = 0; a < (int)glslangArgs.size(); ++a) {
|
||||
const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType();
|
||||
spv::Id arg;
|
||||
if (paramType.getBasicType() == glslang::EbtSampler) {
|
||||
if (paramType.isOpaque()) {
|
||||
builder.setAccessChain(lValues[lValueCount]);
|
||||
arg = builder.accessChainGetLValue();
|
||||
++lValueCount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue