diff --git a/Test/baseResults/spv.specConstant.vert.out b/Test/baseResults/spv.specConstant.vert.out index ea4e542a3503ed222215969c16ab2149b338609d..2f11c2c62fa7db3b3cc5c58176d7cdc175ba8093 100644 --- a/Test/baseResults/spv.specConstant.vert.out +++ b/Test/baseResults/spv.specConstant.vert.out @@ -13,7 +13,7 @@ Warning, version 400 is not yet complete; most version-specific features are pre Source GLSL 400 Name 4 "main" Name 9 "arraySize" - Name 14 "foo(vf4[s1518];" + Name 14 "foo(vf4[s1521];" Name 13 "p" Name 17 "builtin_spec_constant(" Name 20 "color" @@ -104,10 +104,10 @@ Warning, version 400 is not yet complete; most version-specific features are pre Store 20(color) 46 48: 10 Load 22(ucol) Store 47(param) 48 - 49: 2 FunctionCall 14(foo(vf4[s1518];) 47(param) + 49: 2 FunctionCall 14(foo(vf4[s1521];) 47(param) Return FunctionEnd -14(foo(vf4[s1518];): 2 Function None 12 +14(foo(vf4[s1521];): 2 Function None 12 13(p): 11(ptr) FunctionParameter 15: Label 54: 24(ptr) AccessChain 53(dupUcol) 23 diff --git a/Test/baseResults/spv.textureBuffer.vert.out b/Test/baseResults/spv.textureBuffer.vert.out new file mode 100755 index 0000000000000000000000000000000000000000..8c287468ab7dbdd4d8ee43a8924b4408037d27d3 --- /dev/null +++ b/Test/baseResults/spv.textureBuffer.vert.out @@ -0,0 +1,66 @@ +spv.textureBuffer.vert +Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 42 + + Capability Shader + Capability SampledBuffer + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" + Source GLSL 450 + Name 4 "main" + Name 9 "tBuf" + Name 13 "s" + Name 23 "sBuf" + Name 32 "utBuf" + Name 38 "itBuf" + Decorate 9(tBuf) DescriptorSet 0 + Decorate 13(s) DescriptorSet 0 + Decorate 23(sBuf) DescriptorSet 0 + Decorate 32(utBuf) DescriptorSet 0 + Decorate 38(itBuf) DescriptorSet 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeImage 6(float) Buffer sampled format:Unknown + 8: TypePointer UniformConstant 7 + 9(tBuf): 8(ptr) Variable UniformConstant + 11: TypeSampler + 12: TypePointer UniformConstant 11 + 13(s): 12(ptr) Variable UniformConstant + 15: TypeSampledImage 7 + 17: TypeInt 32 1 + 18: 17(int) Constant 13 + 20: TypeVector 6(float) 4 + 22: TypePointer UniformConstant 15 + 23(sBuf): 22(ptr) Variable UniformConstant + 29: TypeInt 32 0 + 30: TypeImage 29(int) Buffer sampled format:Unknown + 31: TypePointer UniformConstant 30 + 32(utBuf): 31(ptr) Variable UniformConstant + 34: TypeVector 29(int) 4 + 36: TypeImage 17(int) Buffer sampled format:Unknown + 37: TypePointer UniformConstant 36 + 38(itBuf): 37(ptr) Variable UniformConstant + 40: TypeVector 17(int) 4 + 4(main): 2 Function None 3 + 5: Label + 10: 7 Load 9(tBuf) + 14: 11 Load 13(s) + 16: 15 SampledImage 10 14 + 19: 7 Image 16 + 21: 20(fvec4) ImageFetch 19 18 + 24: 15 Load 23(sBuf) + 25: 7 Image 24 + 26: 20(fvec4) ImageFetch 25 18 + 27: 7 Load 9(tBuf) + 28: 20(fvec4) ImageFetch 27 18 + 33: 30 Load 32(utBuf) + 35: 34(ivec4) ImageFetch 33 18 + 39: 36 Load 38(itBuf) + 41: 40(ivec4) ImageFetch 39 18 + Return + FunctionEnd diff --git a/Test/spv.textureBuffer.vert b/Test/spv.textureBuffer.vert new file mode 100644 index 0000000000000000000000000000000000000000..fc6fa3acaa6acef2fcb03d3dcf8275e0022417bd --- /dev/null +++ b/Test/spv.textureBuffer.vert @@ -0,0 +1,17 @@ +#version 450 + +uniform textureBuffer tBuf; +uniform sampler s; +uniform samplerBuffer sBuf; + +uniform utextureBuffer utBuf; +uniform itextureBuffer itBuf; + +void main() +{ + texelFetch(samplerBuffer(tBuf, s), 13); + texelFetch(sBuf, 13); + texelFetch(tBuf, 13); + texelFetch(utBuf, 13); + texelFetch(itBuf, 13); +} diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 2c46e4f3cc87e6a26a1819cf20ad4743a921082d..d47f771e73f7332262232d8a242d3d03836358af 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -3844,6 +3844,15 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, c else { addSamplingFunctions(sampler, typeName, version, profile); addGatherFunctions(sampler, typeName, version, profile); + if (spvVersion.vulkan > 0 && sampler.dim == EsdBuffer && sampler.isCombined()) { + // Vulkan wants a textureBuffer to allow texelFetch() -- + // a sampled image with no sampler. + // So, add sampling functions for both the + // samplerBuffer and textureBuffer types. + sampler.setTexture(sampler.type, sampler.dim, sampler.arrayed, sampler.shadow, + sampler.ms); + addSamplingFunctions(sampler, sampler.getString(), version, profile); + } } } } diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index e05900b93605dc5591a9385dab2d0ecd9007d805..fd9c585c72db4be7f0d2dbf680942d6d79888c58 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -283,6 +283,7 @@ INSTANTIATE_TEST_CASE_P( "spv.test.vert", "spv.texture.frag", "spv.texture.vert", + "spv.textureBuffer.vert", "spv.image.frag", "spv.types.frag", "spv.uint.frag",