diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 950f7bdd3c6e260d01a325e54a788d23c12f1a1a..d6ae94157b71e9b2aab3f1ab4c235437d5fd567c 100755 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -2652,12 +2652,13 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg std::vector<spv::Id> rValues; std::vector<const glslang::TType*> argTypes; for (int a = 0; a < (int)glslangArgs.size(); ++a) { + const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType(); // build l-value builder.clearAccessChain(); glslangArgs[a]->traverse(this); - argTypes.push_back(&glslangArgs[a]->getAsTyped()->getType()); - // keep outputs as l-values, evaluate input-only as r-values - if (qualifiers[a] != glslang::EvqConstReadOnly) { + 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) { // save l-value lValues.push_back(builder.getAccessChain()); } else { @@ -2674,10 +2675,14 @@ spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAgg int rValueCount = 0; std::vector<spv::Id> spvArgs; for (int a = 0; a < (int)glslangArgs.size(); ++a) { + const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType(); spv::Id arg; - if (qualifiers[a] != glslang::EvqConstReadOnly) { + if (paramType.getBasicType() == glslang::EbtSampler) { + builder.setAccessChain(lValues[lValueCount]); + arg = builder.accessChainGetLValue(); + ++lValueCount; + } else if (qualifiers[a] != glslang::EvqConstReadOnly) { // need space to hold the copy - const glslang::TType& paramType = glslangArgs[a]->getAsTyped()->getType(); arg = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(paramType), "param"); if (qualifiers[a] == glslang::EvqIn || qualifiers[a] == glslang::EvqInOut) { // need to copy the input into output space diff --git a/Test/baseResults/spv.subpass.frag.out b/Test/baseResults/spv.subpass.frag.out index 6393f6f221e06f08746d232eda1be10f076810a5..4b972aca77ab3e8da37a544c2235e63828246da2 100644 --- a/Test/baseResults/spv.subpass.frag.out +++ b/Test/baseResults/spv.subpass.frag.out @@ -7,7 +7,7 @@ Linked fragment stage: // Module Version 10000 // Generated by (magic number): 80001 -// Id's are bound by 70 +// Id's are bound by 68 Capability Shader Capability InputAttachment @@ -28,7 +28,6 @@ Linked fragment stage: Name 54 "ucolor" Name 57 "usub" Name 62 "usubMS" - Name 67 "param" Decorate 30(sub) DescriptorSet 0 Decorate 30(sub) InputAttachmentIndex 1 Decorate 35(subMS) DescriptorSet 0 @@ -81,7 +80,6 @@ Linked fragment stage: 62(usubMS): 61(ptr) Variable UniformConstant 4(main): 2 Function None 3 5: Label - 67(param): 8(ptr) Variable Function 31: 28 Load 30(sub) 32: 25(fvec4) ImageRead 31 20 Store 27(color) 32 @@ -106,9 +104,7 @@ Linked fragment stage: 65: 52(ivec4) Load 54(ucolor) 66: 52(ivec4) IAdd 65 64 Store 54(ucolor) 66 - 68: 7 Load 46(isubMS) - Store 67(param) 68 - 69: 2 FunctionCall 11(foo(iIPM1;) 67(param) + 67: 2 FunctionCall 11(foo(iIPM1;) 46(isubMS) Return FunctionEnd 11(foo(iIPM1;): 2 Function None 9