diff --git a/Test/baseResults/spv.specTexture.frag.out b/Test/baseResults/spv.specTexture.frag.out new file mode 100755 index 00000000..a4cf47d1 --- /dev/null +++ b/Test/baseResults/spv.specTexture.frag.out @@ -0,0 +1,43 @@ +spv.specTexture.frag +// Module Version 10000 +// Generated by (magic number): 80008 +// Id's are bound by 23 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 9 + ExecutionMode 4 OriginLowerLeft + Source GLSL 450 + Name 4 "main" + Name 9 "color_out" + Name 13 "tex" + Name 19 "offs" + Decorate 9(color_out) Location 0 + Decorate 13(tex) DescriptorSet 0 + Decorate 13(tex) Binding 0 + Decorate 19(offs) SpecId 1 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Output 7(fvec4) + 9(color_out): 8(ptr) Variable Output + 10: TypeImage 6(float) 2D sampled format:Unknown + 11: TypeSampledImage 10 + 12: TypePointer UniformConstant 11 + 13(tex): 12(ptr) Variable UniformConstant + 15: TypeVector 6(float) 2 + 16: 6(float) Constant 0 + 17: 15(fvec2) ConstantComposite 16 16 + 18: TypeInt 32 1 + 19(offs): 18(int) SpecConstant 0 + 20: TypeVector 18(int) 2 + 21: 20(ivec2) SpecConstantComposite 19(offs) 19(offs) + 4(main): 2 Function None 3 + 5: Label + 14: 11 Load 13(tex) + 22: 7(fvec4) ImageSampleExplicitLod 14 17 Lod ConstOffset 16 21 + Store 9(color_out) 22 + Return + FunctionEnd diff --git a/Test/spv.specTexture.frag b/Test/spv.specTexture.frag new file mode 100644 index 00000000..7fd89f5e --- /dev/null +++ b/Test/spv.specTexture.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(constant_id = 1) const int offs = 0; +layout(binding = 0) uniform sampler2D tex; +layout(location = 0) out vec4 color_out; + +void main(void) +{ + color_out = textureLodOffset(tex, vec2(0.0, 0.0), 0.0, ivec2(offs, offs)); +} \ No newline at end of file diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 4f60bca6..f954802d 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -2013,18 +2013,20 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan if (arg > 0) { #ifndef GLSLANG_WEB - bool f16ShadowCompare = (*argp)[1]->getAsTyped()->getBasicType() == EbtFloat16 && arg0->getType().getSampler().shadow; + bool f16ShadowCompare = (*argp)[1]->getAsTyped()->getBasicType() == EbtFloat16 && + arg0->getType().getSampler().shadow; if (f16ShadowCompare) ++arg; #endif - if (! (*argp)[arg]->getAsConstantUnion()) + if (! (*argp)[arg]->getAsTyped()->getQualifier().isConstant()) error(loc, "argument must be compile-time constant", "texel offset", ""); - else { + else if ((*argp)[arg]->getAsConstantUnion()) { const TType& type = (*argp)[arg]->getAsTyped()->getType(); for (int c = 0; c < type.getVectorSize(); ++c) { int offset = (*argp)[arg]->getAsConstantUnion()->getConstArray()[c].getIConst(); if (offset > resources.maxProgramTexelOffset || offset < resources.minProgramTexelOffset) - error(loc, "value is out of range:", "texel offset", "[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]"); + error(loc, "value is out of range:", "texel offset", + "[gl_MinProgramTexelOffset, gl_MaxProgramTexelOffset]"); } } } diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index 7b2b4574..1d061fb3 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -598,6 +598,7 @@ INSTANTIATE_TEST_CASE_P( "spv.glFragColor.frag", "spv.rankShift.comp", "spv.specConst.vert", + "spv.specTexture.frag", "spv.OVR_multiview.vert", "spv.xfbOffsetOnBlockMembersAssignment.vert", "spv.xfbOffsetOnStructMembersAssignment.vert",