From 92aff546329c768d5b7287eb634e48bade25e86b Mon Sep 17 00:00:00 2001 From: LoopDawg Date: Tue, 12 Jul 2016 14:45:05 -0600 Subject: [PATCH] HLSL: add offset Sample() form and arrayed texture support --- .../hlsl.sample.basicarraydx10.frag.out | 446 +++++++++++++++ .../hlsl.sample.offsetarraydx10.frag.out | 358 ++++++++++++ .../hlsl.sample.offsetdx10.frag.out | 509 ++++++++++++++++++ Test/hlsl.sample.basicarraydx10.frag | 43 ++ Test/hlsl.sample.offsetarraydx10.frag | 37 ++ Test/hlsl.sample.offsetdx10.frag | 49 ++ gtests/Hlsl.FromFile.cpp | 3 + hlsl/hlslParseHelper.cpp | 18 +- hlsl/hlslParseables.cpp | 163 ++++-- 9 files changed, 1566 insertions(+), 60 deletions(-) create mode 100644 Test/baseResults/hlsl.sample.basicarraydx10.frag.out create mode 100644 Test/baseResults/hlsl.sample.offsetarraydx10.frag.out create mode 100644 Test/baseResults/hlsl.sample.offsetdx10.frag.out create mode 100644 Test/hlsl.sample.basicarraydx10.frag create mode 100644 Test/hlsl.sample.offsetarraydx10.frag create mode 100644 Test/hlsl.sample.offsetdx10.frag diff --git a/Test/baseResults/hlsl.sample.basicarraydx10.frag.out b/Test/baseResults/hlsl.sample.basicarraydx10.frag.out new file mode 100644 index 00000000..de92747a --- /dev/null +++ b/Test/baseResults/hlsl.sample.basicarraydx10.frag.out @@ -0,0 +1,446 @@ +hlsl.sample.basicarraydx10.frag +Shader version: 450 +gl_FragCoord origin is upper left +0:? Sequence +0:44 Function Definition: main( (global structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:24 Function Parameters: +0:? Sequence +0:27 Sequence +0:27 move second child to first child (temp 4-component vector of float) +0:27 'txval10' (temp 4-component vector of float) +0:27 texture (global 4-component vector of float) +0:27 Construct combined texture-sampler (temp sampler1DArray) +0:27 'g_tTex1df4' (uniform texture1DArray) +0:27 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:28 Sequence +0:28 move second child to first child (temp 4-component vector of int) +0:28 'txval11' (temp 4-component vector of int) +0:28 texture (global 4-component vector of int) +0:28 Construct combined texture-sampler (temp isampler1DArray) +0:28 'g_tTex1di4' (uniform itexture1DArray) +0:28 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.200000 +0:? 0.300000 +0:29 Sequence +0:29 move second child to first child (temp 4-component vector of uint) +0:29 'txval12' (temp 4-component vector of uint) +0:29 texture (global 4-component vector of uint) +0:29 Construct combined texture-sampler (temp usampler1DArray) +0:29 'g_tTex1du4' (uniform utexture1DArray) +0:29 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:31 Sequence +0:31 move second child to first child (temp 4-component vector of float) +0:31 'txval20' (temp 4-component vector of float) +0:31 texture (global 4-component vector of float) +0:31 Construct combined texture-sampler (temp sampler2DArray) +0:31 'g_tTex2df4' (uniform texture2DArray) +0:31 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:32 Sequence +0:32 move second child to first child (temp 4-component vector of int) +0:32 'txval21' (temp 4-component vector of int) +0:32 texture (global 4-component vector of int) +0:32 Construct combined texture-sampler (temp isampler2DArray) +0:32 'g_tTex2di4' (uniform itexture2DArray) +0:32 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:? 0.500000 +0:33 Sequence +0:33 move second child to first child (temp 4-component vector of uint) +0:33 'txval22' (temp 4-component vector of uint) +0:33 texture (global 4-component vector of uint) +0:33 Construct combined texture-sampler (temp usampler2DArray) +0:33 'g_tTex2du4' (uniform utexture2DArray) +0:33 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.500000 +0:? 0.600000 +0:? 0.700000 +0:35 Sequence +0:35 move second child to first child (temp 4-component vector of float) +0:35 'txval40' (temp 4-component vector of float) +0:35 texture (global 4-component vector of float) +0:35 Construct combined texture-sampler (temp samplerCubeArray) +0:35 'g_tTexcdf4' (uniform textureCubeArray) +0:35 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:? 0.400000 +0:36 Sequence +0:36 move second child to first child (temp 4-component vector of int) +0:36 'txval41' (temp 4-component vector of int) +0:36 texture (global 4-component vector of int) +0:36 Construct combined texture-sampler (temp isamplerCubeArray) +0:36 'g_tTexcdi4' (uniform itextureCubeArray) +0:36 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.400000 +0:? 0.500000 +0:? 0.600000 +0:? 0.700000 +0:37 Sequence +0:37 move second child to first child (temp 4-component vector of uint) +0:37 'txval42' (temp 4-component vector of uint) +0:37 texture (global 4-component vector of uint) +0:37 Construct combined texture-sampler (temp usamplerCubeArray) +0:37 'g_tTexcdu4' (uniform utextureCubeArray) +0:37 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.700000 +0:? 0.800000 +0:? 0.900000 +0:? 1.000000 +0:40 move second child to first child (temp float) +0:40 Depth: direct index for structure (temp float FragDepth) +0:40 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:40 Constant: +0:40 1 (const int) +0:40 Constant: +0:40 1.000000 +0:42 Branch: Return with expression +0:42 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:? Linker Objects +0:? 'g_sSamp' (uniform sampler) +0:? 'g_tTex1df4a' (uniform texture1DArray) +0:? 'g_tTex1df4' (uniform texture1DArray) +0:? 'g_tTex1di4' (uniform itexture1DArray) +0:? 'g_tTex1du4' (uniform utexture1DArray) +0:? 'g_tTex2df4' (uniform texture2DArray) +0:? 'g_tTex2di4' (uniform itexture2DArray) +0:? 'g_tTex2du4' (uniform utexture2DArray) +0:? 'g_tTexcdf4' (uniform textureCubeArray) +0:? 'g_tTexcdi4' (uniform itextureCubeArray) +0:? 'g_tTexcdu4' (uniform utextureCubeArray) + + +Linked fragment stage: + + +Shader version: 450 +gl_FragCoord origin is upper left +0:? Sequence +0:44 Function Definition: main( (global structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:24 Function Parameters: +0:? Sequence +0:27 Sequence +0:27 move second child to first child (temp 4-component vector of float) +0:27 'txval10' (temp 4-component vector of float) +0:27 texture (global 4-component vector of float) +0:27 Construct combined texture-sampler (temp sampler1DArray) +0:27 'g_tTex1df4' (uniform texture1DArray) +0:27 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:28 Sequence +0:28 move second child to first child (temp 4-component vector of int) +0:28 'txval11' (temp 4-component vector of int) +0:28 texture (global 4-component vector of int) +0:28 Construct combined texture-sampler (temp isampler1DArray) +0:28 'g_tTex1di4' (uniform itexture1DArray) +0:28 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.200000 +0:? 0.300000 +0:29 Sequence +0:29 move second child to first child (temp 4-component vector of uint) +0:29 'txval12' (temp 4-component vector of uint) +0:29 texture (global 4-component vector of uint) +0:29 Construct combined texture-sampler (temp usampler1DArray) +0:29 'g_tTex1du4' (uniform utexture1DArray) +0:29 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:31 Sequence +0:31 move second child to first child (temp 4-component vector of float) +0:31 'txval20' (temp 4-component vector of float) +0:31 texture (global 4-component vector of float) +0:31 Construct combined texture-sampler (temp sampler2DArray) +0:31 'g_tTex2df4' (uniform texture2DArray) +0:31 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:32 Sequence +0:32 move second child to first child (temp 4-component vector of int) +0:32 'txval21' (temp 4-component vector of int) +0:32 texture (global 4-component vector of int) +0:32 Construct combined texture-sampler (temp isampler2DArray) +0:32 'g_tTex2di4' (uniform itexture2DArray) +0:32 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:? 0.500000 +0:33 Sequence +0:33 move second child to first child (temp 4-component vector of uint) +0:33 'txval22' (temp 4-component vector of uint) +0:33 texture (global 4-component vector of uint) +0:33 Construct combined texture-sampler (temp usampler2DArray) +0:33 'g_tTex2du4' (uniform utexture2DArray) +0:33 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.500000 +0:? 0.600000 +0:? 0.700000 +0:35 Sequence +0:35 move second child to first child (temp 4-component vector of float) +0:35 'txval40' (temp 4-component vector of float) +0:35 texture (global 4-component vector of float) +0:35 Construct combined texture-sampler (temp samplerCubeArray) +0:35 'g_tTexcdf4' (uniform textureCubeArray) +0:35 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:? 0.400000 +0:36 Sequence +0:36 move second child to first child (temp 4-component vector of int) +0:36 'txval41' (temp 4-component vector of int) +0:36 texture (global 4-component vector of int) +0:36 Construct combined texture-sampler (temp isamplerCubeArray) +0:36 'g_tTexcdi4' (uniform itextureCubeArray) +0:36 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.400000 +0:? 0.500000 +0:? 0.600000 +0:? 0.700000 +0:37 Sequence +0:37 move second child to first child (temp 4-component vector of uint) +0:37 'txval42' (temp 4-component vector of uint) +0:37 texture (global 4-component vector of uint) +0:37 Construct combined texture-sampler (temp usamplerCubeArray) +0:37 'g_tTexcdu4' (uniform utextureCubeArray) +0:37 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.700000 +0:? 0.800000 +0:? 0.900000 +0:? 1.000000 +0:40 move second child to first child (temp float) +0:40 Depth: direct index for structure (temp float FragDepth) +0:40 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:40 Constant: +0:40 1 (const int) +0:40 Constant: +0:40 1.000000 +0:42 Branch: Return with expression +0:42 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:? Linker Objects +0:? 'g_sSamp' (uniform sampler) +0:? 'g_tTex1df4a' (uniform texture1DArray) +0:? 'g_tTex1df4' (uniform texture1DArray) +0:? 'g_tTex1di4' (uniform itexture1DArray) +0:? 'g_tTex1du4' (uniform utexture1DArray) +0:? 'g_tTex2df4' (uniform texture2DArray) +0:? 'g_tTex2di4' (uniform itexture2DArray) +0:? 'g_tTex2du4' (uniform utexture2DArray) +0:? 'g_tTexcdf4' (uniform textureCubeArray) +0:? 'g_tTexcdi4' (uniform itextureCubeArray) +0:? 'g_tTexcdu4' (uniform utextureCubeArray) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 129 + + Capability Shader + Capability Sampled1D + Capability SampledCubeArray + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" + ExecutionMode 4 OriginUpperLeft + Source HLSL 450 + Name 4 "main" + Name 9 "txval10" + Name 12 "g_tTex1df4" + Name 16 "g_sSamp" + Name 28 "txval11" + Name 31 "g_tTex1di4" + Name 42 "txval12" + Name 45 "g_tTex1du4" + Name 53 "txval20" + Name 56 "g_tTex2df4" + Name 64 "txval21" + Name 67 "g_tTex2di4" + Name 75 "txval22" + Name 78 "g_tTex2du4" + Name 87 "txval40" + Name 90 "g_tTexcdf4" + Name 97 "txval41" + Name 100 "g_tTexcdi4" + Name 107 "txval42" + Name 110 "g_tTexcdu4" + Name 120 "PS_OUTPUT" + MemberName 120(PS_OUTPUT) 0 "Color" + MemberName 120(PS_OUTPUT) 1 "Depth" + Name 122 "psout" + Name 128 "g_tTex1df4a" + Decorate 12(g_tTex1df4) DescriptorSet 0 + Decorate 16(g_sSamp) DescriptorSet 0 + Decorate 31(g_tTex1di4) DescriptorSet 0 + Decorate 45(g_tTex1du4) DescriptorSet 0 + Decorate 56(g_tTex2df4) DescriptorSet 0 + Decorate 67(g_tTex2di4) DescriptorSet 0 + Decorate 78(g_tTex2du4) DescriptorSet 0 + Decorate 90(g_tTexcdf4) DescriptorSet 0 + Decorate 100(g_tTexcdi4) DescriptorSet 0 + Decorate 110(g_tTexcdu4) DescriptorSet 0 + MemberDecorate 120(PS_OUTPUT) 1 BuiltIn FragDepth + Decorate 128(g_tTex1df4a) DescriptorSet 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) + 10: TypeImage 6(float) 1D array sampled format:Unknown + 11: TypePointer UniformConstant 10 + 12(g_tTex1df4): 11(ptr) Variable UniformConstant + 14: TypeSampler + 15: TypePointer UniformConstant 14 + 16(g_sSamp): 15(ptr) Variable UniformConstant + 18: TypeSampledImage 10 + 20: TypeVector 6(float) 2 + 21: 6(float) Constant 1036831949 + 22: 6(float) Constant 1045220557 + 23: 20(fvec2) ConstantComposite 21 22 + 25: TypeInt 32 1 + 26: TypeVector 25(int) 4 + 27: TypePointer Function 26(ivec4) + 29: TypeImage 25(int) 1D array sampled format:Unknown + 30: TypePointer UniformConstant 29 + 31(g_tTex1di4): 30(ptr) Variable UniformConstant + 34: TypeSampledImage 29 + 36: 6(float) Constant 1050253722 + 37: 20(fvec2) ConstantComposite 22 36 + 39: TypeInt 32 0 + 40: TypeVector 39(int) 4 + 41: TypePointer Function 40(ivec4) + 43: TypeImage 39(int) 1D array sampled format:Unknown + 44: TypePointer UniformConstant 43 + 45(g_tTex1du4): 44(ptr) Variable UniformConstant + 48: TypeSampledImage 43 + 50: 6(float) Constant 1053609165 + 51: 20(fvec2) ConstantComposite 36 50 + 54: TypeImage 6(float) 2D array sampled format:Unknown + 55: TypePointer UniformConstant 54 + 56(g_tTex2df4): 55(ptr) Variable UniformConstant + 59: TypeSampledImage 54 + 61: TypeVector 6(float) 3 + 62: 61(fvec3) ConstantComposite 21 22 36 + 65: TypeImage 25(int) 2D array sampled format:Unknown + 66: TypePointer UniformConstant 65 + 67(g_tTex2di4): 66(ptr) Variable UniformConstant + 70: TypeSampledImage 65 + 72: 6(float) Constant 1056964608 + 73: 61(fvec3) ConstantComposite 36 50 72 + 76: TypeImage 39(int) 2D array sampled format:Unknown + 77: TypePointer UniformConstant 76 + 78(g_tTex2du4): 77(ptr) Variable UniformConstant + 81: TypeSampledImage 76 + 83: 6(float) Constant 1058642330 + 84: 6(float) Constant 1060320051 + 85: 61(fvec3) ConstantComposite 72 83 84 + 88: TypeImage 6(float) Cube array sampled format:Unknown + 89: TypePointer UniformConstant 88 + 90(g_tTexcdf4): 89(ptr) Variable UniformConstant + 93: TypeSampledImage 88 + 95: 7(fvec4) ConstantComposite 21 22 36 50 + 98: TypeImage 25(int) Cube array sampled format:Unknown + 99: TypePointer UniformConstant 98 + 100(g_tTexcdi4): 99(ptr) Variable UniformConstant + 103: TypeSampledImage 98 + 105: 7(fvec4) ConstantComposite 50 72 83 84 + 108: TypeImage 39(int) Cube array sampled format:Unknown + 109: TypePointer UniformConstant 108 + 110(g_tTexcdu4): 109(ptr) Variable UniformConstant + 113: TypeSampledImage 108 + 115: 6(float) Constant 1061997773 + 116: 6(float) Constant 1063675494 + 117: 6(float) Constant 1065353216 + 118: 7(fvec4) ConstantComposite 84 115 116 117 + 120(PS_OUTPUT): TypeStruct 7(fvec4) 6(float) + 121: TypePointer Function 120(PS_OUTPUT) + 123: 25(int) Constant 1 + 124: TypePointer Function 6(float) +128(g_tTex1df4a): 11(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(txval10): 8(ptr) Variable Function + 28(txval11): 27(ptr) Variable Function + 42(txval12): 41(ptr) Variable Function + 53(txval20): 8(ptr) Variable Function + 64(txval21): 27(ptr) Variable Function + 75(txval22): 41(ptr) Variable Function + 87(txval40): 8(ptr) Variable Function + 97(txval41): 27(ptr) Variable Function + 107(txval42): 41(ptr) Variable Function + 122(psout): 121(ptr) Variable Function + 13: 10 Load 12(g_tTex1df4) + 17: 14 Load 16(g_sSamp) + 19: 18 SampledImage 13 17 + 24: 7(fvec4) ImageSampleImplicitLod 19 23 + Store 9(txval10) 24 + 32: 29 Load 31(g_tTex1di4) + 33: 14 Load 16(g_sSamp) + 35: 34 SampledImage 32 33 + 38: 26(ivec4) ImageSampleImplicitLod 35 37 + Store 28(txval11) 38 + 46: 43 Load 45(g_tTex1du4) + 47: 14 Load 16(g_sSamp) + 49: 48 SampledImage 46 47 + 52: 40(ivec4) ImageSampleImplicitLod 49 51 + Store 42(txval12) 52 + 57: 54 Load 56(g_tTex2df4) + 58: 14 Load 16(g_sSamp) + 60: 59 SampledImage 57 58 + 63: 7(fvec4) ImageSampleImplicitLod 60 62 + Store 53(txval20) 63 + 68: 65 Load 67(g_tTex2di4) + 69: 14 Load 16(g_sSamp) + 71: 70 SampledImage 68 69 + 74: 26(ivec4) ImageSampleImplicitLod 71 73 + Store 64(txval21) 74 + 79: 76 Load 78(g_tTex2du4) + 80: 14 Load 16(g_sSamp) + 82: 81 SampledImage 79 80 + 86: 40(ivec4) ImageSampleImplicitLod 82 85 + Store 75(txval22) 86 + 91: 88 Load 90(g_tTexcdf4) + 92: 14 Load 16(g_sSamp) + 94: 93 SampledImage 91 92 + 96: 7(fvec4) ImageSampleImplicitLod 94 95 + Store 87(txval40) 96 + 101: 98 Load 100(g_tTexcdi4) + 102: 14 Load 16(g_sSamp) + 104: 103 SampledImage 101 102 + 106: 26(ivec4) ImageSampleImplicitLod 104 105 + Store 97(txval41) 106 + 111: 108 Load 110(g_tTexcdu4) + 112: 14 Load 16(g_sSamp) + 114: 113 SampledImage 111 112 + 119: 40(ivec4) ImageSampleImplicitLod 114 118 + Store 107(txval42) 119 + 125: 124(ptr) AccessChain 122(psout) 123 + Store 125 117 + 126:120(PS_OUTPUT) Load 122(psout) + ReturnValue 126 + FunctionEnd diff --git a/Test/baseResults/hlsl.sample.offsetarraydx10.frag.out b/Test/baseResults/hlsl.sample.offsetarraydx10.frag.out new file mode 100644 index 00000000..40e3ecd9 --- /dev/null +++ b/Test/baseResults/hlsl.sample.offsetarraydx10.frag.out @@ -0,0 +1,358 @@ +hlsl.sample.offsetarraydx10.frag +Shader version: 450 +gl_FragCoord origin is upper left +0:? Sequence +0:38 Function Definition: main( (global structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:20 Function Parameters: +0:? Sequence +0:23 Sequence +0:23 move second child to first child (temp 4-component vector of float) +0:23 'txval10' (temp 4-component vector of float) +0:23 textureOffset (global 4-component vector of float) +0:23 Construct combined texture-sampler (temp sampler1DArray) +0:23 'g_tTex1df4' (uniform texture1DArray) +0:23 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:23 Constant: +0:23 0 (const int) +0:24 Sequence +0:24 move second child to first child (temp 4-component vector of int) +0:24 'txval11' (temp 4-component vector of int) +0:24 textureOffset (global 4-component vector of int) +0:24 Construct combined texture-sampler (temp isampler1DArray) +0:24 'g_tTex1di4' (uniform itexture1DArray) +0:24 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.200000 +0:? 0.300000 +0:24 Constant: +0:24 1 (const int) +0:25 Sequence +0:25 move second child to first child (temp 4-component vector of uint) +0:25 'txval12' (temp 4-component vector of uint) +0:25 textureOffset (global 4-component vector of uint) +0:25 Construct combined texture-sampler (temp usampler1DArray) +0:25 'g_tTex1du4' (uniform utexture1DArray) +0:25 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:25 Constant: +0:25 2 (const int) +0:27 Sequence +0:27 move second child to first child (temp 4-component vector of float) +0:27 'txval20' (temp 4-component vector of float) +0:27 textureOffset (global 4-component vector of float) +0:27 Construct combined texture-sampler (temp sampler2DArray) +0:27 'g_tTex2df4' (uniform texture2DArray) +0:27 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:? Constant: +0:? 0 (const int) +0:? 0 (const int) +0:28 Sequence +0:28 move second child to first child (temp 4-component vector of int) +0:28 'txval21' (temp 4-component vector of int) +0:28 textureOffset (global 4-component vector of int) +0:28 Construct combined texture-sampler (temp isampler2DArray) +0:28 'g_tTex2di4' (uniform itexture2DArray) +0:28 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:? 0.500000 +0:? Constant: +0:? 0 (const int) +0:? 0 (const int) +0:29 Sequence +0:29 move second child to first child (temp 4-component vector of uint) +0:29 'txval22' (temp 4-component vector of uint) +0:29 textureOffset (global 4-component vector of uint) +0:29 Construct combined texture-sampler (temp usampler2DArray) +0:29 'g_tTex2du4' (uniform utexture2DArray) +0:29 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.500000 +0:? 0.600000 +0:? 0.700000 +0:? Constant: +0:? 0 (const int) +0:? 1 (const int) +0:34 move second child to first child (temp float) +0:34 Depth: direct index for structure (temp float FragDepth) +0:34 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:34 Constant: +0:34 1 (const int) +0:34 Constant: +0:34 1.000000 +0:36 Branch: Return with expression +0:36 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:? Linker Objects +0:? 'g_sSamp' (uniform sampler) +0:? 'g_tTex1df4a' (uniform texture1DArray) +0:? 'g_tTex1df4' (uniform texture1DArray) +0:? 'g_tTex1di4' (uniform itexture1DArray) +0:? 'g_tTex1du4' (uniform utexture1DArray) +0:? 'g_tTex2df4' (uniform texture2DArray) +0:? 'g_tTex2di4' (uniform itexture2DArray) +0:? 'g_tTex2du4' (uniform utexture2DArray) + + +Linked fragment stage: + + +Shader version: 450 +gl_FragCoord origin is upper left +0:? Sequence +0:38 Function Definition: main( (global structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:20 Function Parameters: +0:? Sequence +0:23 Sequence +0:23 move second child to first child (temp 4-component vector of float) +0:23 'txval10' (temp 4-component vector of float) +0:23 textureOffset (global 4-component vector of float) +0:23 Construct combined texture-sampler (temp sampler1DArray) +0:23 'g_tTex1df4' (uniform texture1DArray) +0:23 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:23 Constant: +0:23 0 (const int) +0:24 Sequence +0:24 move second child to first child (temp 4-component vector of int) +0:24 'txval11' (temp 4-component vector of int) +0:24 textureOffset (global 4-component vector of int) +0:24 Construct combined texture-sampler (temp isampler1DArray) +0:24 'g_tTex1di4' (uniform itexture1DArray) +0:24 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.200000 +0:? 0.300000 +0:24 Constant: +0:24 1 (const int) +0:25 Sequence +0:25 move second child to first child (temp 4-component vector of uint) +0:25 'txval12' (temp 4-component vector of uint) +0:25 textureOffset (global 4-component vector of uint) +0:25 Construct combined texture-sampler (temp usampler1DArray) +0:25 'g_tTex1du4' (uniform utexture1DArray) +0:25 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:25 Constant: +0:25 2 (const int) +0:27 Sequence +0:27 move second child to first child (temp 4-component vector of float) +0:27 'txval20' (temp 4-component vector of float) +0:27 textureOffset (global 4-component vector of float) +0:27 Construct combined texture-sampler (temp sampler2DArray) +0:27 'g_tTex2df4' (uniform texture2DArray) +0:27 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:? Constant: +0:? 0 (const int) +0:? 0 (const int) +0:28 Sequence +0:28 move second child to first child (temp 4-component vector of int) +0:28 'txval21' (temp 4-component vector of int) +0:28 textureOffset (global 4-component vector of int) +0:28 Construct combined texture-sampler (temp isampler2DArray) +0:28 'g_tTex2di4' (uniform itexture2DArray) +0:28 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:? 0.500000 +0:? Constant: +0:? 0 (const int) +0:? 0 (const int) +0:29 Sequence +0:29 move second child to first child (temp 4-component vector of uint) +0:29 'txval22' (temp 4-component vector of uint) +0:29 textureOffset (global 4-component vector of uint) +0:29 Construct combined texture-sampler (temp usampler2DArray) +0:29 'g_tTex2du4' (uniform utexture2DArray) +0:29 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.500000 +0:? 0.600000 +0:? 0.700000 +0:? Constant: +0:? 0 (const int) +0:? 1 (const int) +0:34 move second child to first child (temp float) +0:34 Depth: direct index for structure (temp float FragDepth) +0:34 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:34 Constant: +0:34 1 (const int) +0:34 Constant: +0:34 1.000000 +0:36 Branch: Return with expression +0:36 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:? Linker Objects +0:? 'g_sSamp' (uniform sampler) +0:? 'g_tTex1df4a' (uniform texture1DArray) +0:? 'g_tTex1df4' (uniform texture1DArray) +0:? 'g_tTex1di4' (uniform itexture1DArray) +0:? 'g_tTex1du4' (uniform utexture1DArray) +0:? 'g_tTex2df4' (uniform texture2DArray) +0:? 'g_tTex2di4' (uniform itexture2DArray) +0:? 'g_tTex2du4' (uniform utexture2DArray) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 102 + + Capability Shader + Capability Sampled1D + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" + ExecutionMode 4 OriginUpperLeft + Source HLSL 450 + Name 4 "main" + Name 9 "txval10" + Name 12 "g_tTex1df4" + Name 16 "g_sSamp" + Name 29 "txval11" + Name 32 "g_tTex1di4" + Name 44 "txval12" + Name 47 "g_tTex1du4" + Name 56 "txval20" + Name 59 "g_tTex2df4" + Name 69 "txval21" + Name 72 "g_tTex2di4" + Name 80 "txval22" + Name 83 "g_tTex2du4" + Name 93 "PS_OUTPUT" + MemberName 93(PS_OUTPUT) 0 "Color" + MemberName 93(PS_OUTPUT) 1 "Depth" + Name 95 "psout" + Name 101 "g_tTex1df4a" + Decorate 12(g_tTex1df4) DescriptorSet 0 + Decorate 16(g_sSamp) DescriptorSet 0 + Decorate 32(g_tTex1di4) DescriptorSet 0 + Decorate 47(g_tTex1du4) DescriptorSet 0 + Decorate 59(g_tTex2df4) DescriptorSet 0 + Decorate 72(g_tTex2di4) DescriptorSet 0 + Decorate 83(g_tTex2du4) DescriptorSet 0 + MemberDecorate 93(PS_OUTPUT) 1 BuiltIn FragDepth + Decorate 101(g_tTex1df4a) DescriptorSet 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) + 10: TypeImage 6(float) 1D array sampled format:Unknown + 11: TypePointer UniformConstant 10 + 12(g_tTex1df4): 11(ptr) Variable UniformConstant + 14: TypeSampler + 15: TypePointer UniformConstant 14 + 16(g_sSamp): 15(ptr) Variable UniformConstant + 18: TypeSampledImage 10 + 20: TypeVector 6(float) 2 + 21: 6(float) Constant 1036831949 + 22: 6(float) Constant 1045220557 + 23: 20(fvec2) ConstantComposite 21 22 + 24: TypeInt 32 1 + 25: 24(int) Constant 0 + 27: TypeVector 24(int) 4 + 28: TypePointer Function 27(ivec4) + 30: TypeImage 24(int) 1D array sampled format:Unknown + 31: TypePointer UniformConstant 30 + 32(g_tTex1di4): 31(ptr) Variable UniformConstant + 35: TypeSampledImage 30 + 37: 6(float) Constant 1050253722 + 38: 20(fvec2) ConstantComposite 22 37 + 39: 24(int) Constant 1 + 41: TypeInt 32 0 + 42: TypeVector 41(int) 4 + 43: TypePointer Function 42(ivec4) + 45: TypeImage 41(int) 1D array sampled format:Unknown + 46: TypePointer UniformConstant 45 + 47(g_tTex1du4): 46(ptr) Variable UniformConstant + 50: TypeSampledImage 45 + 52: 6(float) Constant 1053609165 + 53: 20(fvec2) ConstantComposite 37 52 + 54: 24(int) Constant 2 + 57: TypeImage 6(float) 2D array sampled format:Unknown + 58: TypePointer UniformConstant 57 + 59(g_tTex2df4): 58(ptr) Variable UniformConstant + 62: TypeSampledImage 57 + 64: TypeVector 6(float) 3 + 65: 64(fvec3) ConstantComposite 21 22 37 + 66: TypeVector 24(int) 2 + 67: 66(ivec2) ConstantComposite 25 25 + 70: TypeImage 24(int) 2D array sampled format:Unknown + 71: TypePointer UniformConstant 70 + 72(g_tTex2di4): 71(ptr) Variable UniformConstant + 75: TypeSampledImage 70 + 77: 6(float) Constant 1056964608 + 78: 64(fvec3) ConstantComposite 37 52 77 + 81: TypeImage 41(int) 2D array sampled format:Unknown + 82: TypePointer UniformConstant 81 + 83(g_tTex2du4): 82(ptr) Variable UniformConstant + 86: TypeSampledImage 81 + 88: 6(float) Constant 1058642330 + 89: 6(float) Constant 1060320051 + 90: 64(fvec3) ConstantComposite 77 88 89 + 91: 66(ivec2) ConstantComposite 25 39 + 93(PS_OUTPUT): TypeStruct 7(fvec4) 6(float) + 94: TypePointer Function 93(PS_OUTPUT) + 96: 6(float) Constant 1065353216 + 97: TypePointer Function 6(float) +101(g_tTex1df4a): 11(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(txval10): 8(ptr) Variable Function + 29(txval11): 28(ptr) Variable Function + 44(txval12): 43(ptr) Variable Function + 56(txval20): 8(ptr) Variable Function + 69(txval21): 28(ptr) Variable Function + 80(txval22): 43(ptr) Variable Function + 95(psout): 94(ptr) Variable Function + 13: 10 Load 12(g_tTex1df4) + 17: 14 Load 16(g_sSamp) + 19: 18 SampledImage 13 17 + 26: 7(fvec4) ImageSampleImplicitLod 19 23 ConstOffset 25 + Store 9(txval10) 26 + 33: 30 Load 32(g_tTex1di4) + 34: 14 Load 16(g_sSamp) + 36: 35 SampledImage 33 34 + 40: 27(ivec4) ImageSampleImplicitLod 36 38 ConstOffset 39 + Store 29(txval11) 40 + 48: 45 Load 47(g_tTex1du4) + 49: 14 Load 16(g_sSamp) + 51: 50 SampledImage 48 49 + 55: 42(ivec4) ImageSampleImplicitLod 51 53 ConstOffset 54 + Store 44(txval12) 55 + 60: 57 Load 59(g_tTex2df4) + 61: 14 Load 16(g_sSamp) + 63: 62 SampledImage 60 61 + 68: 7(fvec4) ImageSampleImplicitLod 63 65 ConstOffset 67 + Store 56(txval20) 68 + 73: 70 Load 72(g_tTex2di4) + 74: 14 Load 16(g_sSamp) + 76: 75 SampledImage 73 74 + 79: 27(ivec4) ImageSampleImplicitLod 76 78 ConstOffset 67 + Store 69(txval21) 79 + 84: 81 Load 83(g_tTex2du4) + 85: 14 Load 16(g_sSamp) + 87: 86 SampledImage 84 85 + 92: 42(ivec4) ImageSampleImplicitLod 87 90 ConstOffset 91 + Store 80(txval22) 92 + 98: 97(ptr) AccessChain 95(psout) 39 + Store 98 96 + 99:93(PS_OUTPUT) Load 95(psout) + ReturnValue 99 + FunctionEnd diff --git a/Test/baseResults/hlsl.sample.offsetdx10.frag.out b/Test/baseResults/hlsl.sample.offsetdx10.frag.out new file mode 100644 index 00000000..d75de25b --- /dev/null +++ b/Test/baseResults/hlsl.sample.offsetdx10.frag.out @@ -0,0 +1,509 @@ +hlsl.sample.offsetdx10.frag +Shader version: 450 +gl_FragCoord origin is upper left +0:? Sequence +0:50 Function Definition: main( (global structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:28 Function Parameters: +0:? Sequence +0:31 Sequence +0:31 move second child to first child (temp 4-component vector of float) +0:31 'txval10' (temp 4-component vector of float) +0:31 textureOffset (global 4-component vector of float) +0:31 Construct combined texture-sampler (temp sampler1D) +0:31 'g_tTex1df4' (uniform texture1D) +0:31 'g_sSamp' (uniform sampler) +0:31 Constant: +0:31 0.100000 +0:31 Constant: +0:31 1 (const int) +0:32 Sequence +0:32 move second child to first child (temp 4-component vector of int) +0:32 'txval11' (temp 4-component vector of int) +0:32 textureOffset (global 4-component vector of int) +0:32 Construct combined texture-sampler (temp isampler1D) +0:32 'g_tTex1di4' (uniform itexture1D) +0:32 'g_sSamp' (uniform sampler) +0:32 Constant: +0:32 0.200000 +0:32 Constant: +0:32 1 (const int) +0:33 Sequence +0:33 move second child to first child (temp 4-component vector of uint) +0:33 'txval12' (temp 4-component vector of uint) +0:33 textureOffset (global 4-component vector of uint) +0:33 Construct combined texture-sampler (temp usampler1D) +0:33 'g_tTex1du4' (uniform utexture1D) +0:33 'g_sSamp' (uniform sampler) +0:33 Constant: +0:33 0.300000 +0:33 Constant: +0:33 1 (const int) +0:35 Sequence +0:35 move second child to first child (temp 4-component vector of float) +0:35 'txval20' (temp 4-component vector of float) +0:35 textureOffset (global 4-component vector of float) +0:35 Construct combined texture-sampler (temp sampler2D) +0:35 'g_tTex2df4' (uniform texture2D) +0:35 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? Constant: +0:? 1 (const int) +0:? 0 (const int) +0:36 Sequence +0:36 move second child to first child (temp 4-component vector of int) +0:36 'txval21' (temp 4-component vector of int) +0:36 textureOffset (global 4-component vector of int) +0:36 Construct combined texture-sampler (temp isampler2D) +0:36 'g_tTex2di4' (uniform itexture2D) +0:36 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:? Constant: +0:? 1 (const int) +0:? 1 (const int) +0:37 Sequence +0:37 move second child to first child (temp 4-component vector of uint) +0:37 'txval22' (temp 4-component vector of uint) +0:37 textureOffset (global 4-component vector of uint) +0:37 Construct combined texture-sampler (temp usampler2D) +0:37 'g_tTex2du4' (uniform utexture2D) +0:37 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.500000 +0:? 0.600000 +0:? Constant: +0:? 1 (const int) +0:? -1 (const int) +0:39 Sequence +0:39 move second child to first child (temp 4-component vector of float) +0:39 'txval30' (temp 4-component vector of float) +0:39 textureOffset (global 4-component vector of float) +0:39 Construct combined texture-sampler (temp sampler3D) +0:39 'g_tTex3df4' (uniform texture3D) +0:39 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:? Constant: +0:? 1 (const int) +0:? 0 (const int) +0:? 1 (const int) +0:40 Sequence +0:40 move second child to first child (temp 4-component vector of int) +0:40 'txval31' (temp 4-component vector of int) +0:40 textureOffset (global 4-component vector of int) +0:40 Construct combined texture-sampler (temp isampler3D) +0:40 'g_tTex3di4' (uniform itexture3D) +0:40 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.400000 +0:? 0.500000 +0:? 0.600000 +0:? Constant: +0:? 1 (const int) +0:? 1 (const int) +0:? 1 (const int) +0:41 Sequence +0:41 move second child to first child (temp 4-component vector of uint) +0:41 'txval32' (temp 4-component vector of uint) +0:41 textureOffset (global 4-component vector of uint) +0:41 Construct combined texture-sampler (temp usampler3D) +0:41 'g_tTex3du4' (uniform utexture3D) +0:41 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.700000 +0:? 0.800000 +0:? 0.900000 +0:? Constant: +0:? 1 (const int) +0:? 0 (const int) +0:? -1 (const int) +0:46 move second child to first child (temp float) +0:46 Depth: direct index for structure (temp float FragDepth) +0:46 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:46 Constant: +0:46 1 (const int) +0:46 Constant: +0:46 1.000000 +0:48 Branch: Return with expression +0:48 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:? Linker Objects +0:? 'g_sSamp' (uniform sampler) +0:? 'g_tTex1df4a' (uniform texture1D) +0:? 'g_tTex1df4' (uniform texture1D) +0:? 'g_tTex1di4' (uniform itexture1D) +0:? 'g_tTex1du4' (uniform utexture1D) +0:? 'g_tTex2df4' (uniform texture2D) +0:? 'g_tTex2di4' (uniform itexture2D) +0:? 'g_tTex2du4' (uniform utexture2D) +0:? 'g_tTex3df4' (uniform texture3D) +0:? 'g_tTex3di4' (uniform itexture3D) +0:? 'g_tTex3du4' (uniform utexture3D) +0:? 'g_tTexcdf4' (uniform textureCube) +0:? 'g_tTexcdi4' (uniform itextureCube) +0:? 'g_tTexcdu4' (uniform utextureCube) + + +Linked fragment stage: + + +Shader version: 450 +gl_FragCoord origin is upper left +0:? Sequence +0:50 Function Definition: main( (global structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:28 Function Parameters: +0:? Sequence +0:31 Sequence +0:31 move second child to first child (temp 4-component vector of float) +0:31 'txval10' (temp 4-component vector of float) +0:31 textureOffset (global 4-component vector of float) +0:31 Construct combined texture-sampler (temp sampler1D) +0:31 'g_tTex1df4' (uniform texture1D) +0:31 'g_sSamp' (uniform sampler) +0:31 Constant: +0:31 0.100000 +0:31 Constant: +0:31 1 (const int) +0:32 Sequence +0:32 move second child to first child (temp 4-component vector of int) +0:32 'txval11' (temp 4-component vector of int) +0:32 textureOffset (global 4-component vector of int) +0:32 Construct combined texture-sampler (temp isampler1D) +0:32 'g_tTex1di4' (uniform itexture1D) +0:32 'g_sSamp' (uniform sampler) +0:32 Constant: +0:32 0.200000 +0:32 Constant: +0:32 1 (const int) +0:33 Sequence +0:33 move second child to first child (temp 4-component vector of uint) +0:33 'txval12' (temp 4-component vector of uint) +0:33 textureOffset (global 4-component vector of uint) +0:33 Construct combined texture-sampler (temp usampler1D) +0:33 'g_tTex1du4' (uniform utexture1D) +0:33 'g_sSamp' (uniform sampler) +0:33 Constant: +0:33 0.300000 +0:33 Constant: +0:33 1 (const int) +0:35 Sequence +0:35 move second child to first child (temp 4-component vector of float) +0:35 'txval20' (temp 4-component vector of float) +0:35 textureOffset (global 4-component vector of float) +0:35 Construct combined texture-sampler (temp sampler2D) +0:35 'g_tTex2df4' (uniform texture2D) +0:35 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? Constant: +0:? 1 (const int) +0:? 0 (const int) +0:36 Sequence +0:36 move second child to first child (temp 4-component vector of int) +0:36 'txval21' (temp 4-component vector of int) +0:36 textureOffset (global 4-component vector of int) +0:36 Construct combined texture-sampler (temp isampler2D) +0:36 'g_tTex2di4' (uniform itexture2D) +0:36 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.300000 +0:? 0.400000 +0:? Constant: +0:? 1 (const int) +0:? 1 (const int) +0:37 Sequence +0:37 move second child to first child (temp 4-component vector of uint) +0:37 'txval22' (temp 4-component vector of uint) +0:37 textureOffset (global 4-component vector of uint) +0:37 Construct combined texture-sampler (temp usampler2D) +0:37 'g_tTex2du4' (uniform utexture2D) +0:37 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.500000 +0:? 0.600000 +0:? Constant: +0:? 1 (const int) +0:? -1 (const int) +0:39 Sequence +0:39 move second child to first child (temp 4-component vector of float) +0:39 'txval30' (temp 4-component vector of float) +0:39 textureOffset (global 4-component vector of float) +0:39 Construct combined texture-sampler (temp sampler3D) +0:39 'g_tTex3df4' (uniform texture3D) +0:39 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.100000 +0:? 0.200000 +0:? 0.300000 +0:? Constant: +0:? 1 (const int) +0:? 0 (const int) +0:? 1 (const int) +0:40 Sequence +0:40 move second child to first child (temp 4-component vector of int) +0:40 'txval31' (temp 4-component vector of int) +0:40 textureOffset (global 4-component vector of int) +0:40 Construct combined texture-sampler (temp isampler3D) +0:40 'g_tTex3di4' (uniform itexture3D) +0:40 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.400000 +0:? 0.500000 +0:? 0.600000 +0:? Constant: +0:? 1 (const int) +0:? 1 (const int) +0:? 1 (const int) +0:41 Sequence +0:41 move second child to first child (temp 4-component vector of uint) +0:41 'txval32' (temp 4-component vector of uint) +0:41 textureOffset (global 4-component vector of uint) +0:41 Construct combined texture-sampler (temp usampler3D) +0:41 'g_tTex3du4' (uniform utexture3D) +0:41 'g_sSamp' (uniform sampler) +0:? Constant: +0:? 0.700000 +0:? 0.800000 +0:? 0.900000 +0:? Constant: +0:? 1 (const int) +0:? 0 (const int) +0:? -1 (const int) +0:46 move second child to first child (temp float) +0:46 Depth: direct index for structure (temp float FragDepth) +0:46 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:46 Constant: +0:46 1 (const int) +0:46 Constant: +0:46 1.000000 +0:48 Branch: Return with expression +0:48 'psout' (temp structure{temp 4-component vector of float Color, temp float FragDepth Depth}) +0:? Linker Objects +0:? 'g_sSamp' (uniform sampler) +0:? 'g_tTex1df4a' (uniform texture1D) +0:? 'g_tTex1df4' (uniform texture1D) +0:? 'g_tTex1di4' (uniform itexture1D) +0:? 'g_tTex1du4' (uniform utexture1D) +0:? 'g_tTex2df4' (uniform texture2D) +0:? 'g_tTex2di4' (uniform itexture2D) +0:? 'g_tTex2du4' (uniform utexture2D) +0:? 'g_tTex3df4' (uniform texture3D) +0:? 'g_tTex3di4' (uniform itexture3D) +0:? 'g_tTex3du4' (uniform utexture3D) +0:? 'g_tTexcdf4' (uniform textureCube) +0:? 'g_tTexcdi4' (uniform itextureCube) +0:? 'g_tTexcdu4' (uniform utextureCube) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 145 + + Capability Shader + Capability Sampled1D + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" + ExecutionMode 4 OriginUpperLeft + Source HLSL 450 + Name 4 "main" + Name 9 "txval10" + Name 12 "g_tTex1df4" + Name 16 "g_sSamp" + Name 26 "txval11" + Name 29 "g_tTex1di4" + Name 39 "txval12" + Name 42 "g_tTex1du4" + Name 49 "txval20" + Name 52 "g_tTex2df4" + Name 63 "txval21" + Name 66 "g_tTex2di4" + Name 75 "txval22" + Name 78 "g_tTex2du4" + Name 89 "txval30" + Name 92 "g_tTex3df4" + Name 102 "txval31" + Name 105 "g_tTex3di4" + Name 113 "txval32" + Name 116 "g_tTex3du4" + Name 127 "PS_OUTPUT" + MemberName 127(PS_OUTPUT) 0 "Color" + MemberName 127(PS_OUTPUT) 1 "Depth" + Name 129 "psout" + Name 135 "g_tTex1df4a" + Name 138 "g_tTexcdf4" + Name 141 "g_tTexcdi4" + Name 144 "g_tTexcdu4" + Decorate 12(g_tTex1df4) DescriptorSet 0 + Decorate 16(g_sSamp) DescriptorSet 0 + Decorate 29(g_tTex1di4) DescriptorSet 0 + Decorate 42(g_tTex1du4) DescriptorSet 0 + Decorate 52(g_tTex2df4) DescriptorSet 0 + Decorate 66(g_tTex2di4) DescriptorSet 0 + Decorate 78(g_tTex2du4) DescriptorSet 0 + Decorate 92(g_tTex3df4) DescriptorSet 0 + Decorate 105(g_tTex3di4) DescriptorSet 0 + Decorate 116(g_tTex3du4) DescriptorSet 0 + MemberDecorate 127(PS_OUTPUT) 1 BuiltIn FragDepth + Decorate 135(g_tTex1df4a) DescriptorSet 0 + Decorate 138(g_tTexcdf4) DescriptorSet 0 + Decorate 141(g_tTexcdi4) DescriptorSet 0 + Decorate 144(g_tTexcdu4) DescriptorSet 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) + 10: TypeImage 6(float) 1D sampled format:Unknown + 11: TypePointer UniformConstant 10 + 12(g_tTex1df4): 11(ptr) Variable UniformConstant + 14: TypeSampler + 15: TypePointer UniformConstant 14 + 16(g_sSamp): 15(ptr) Variable UniformConstant + 18: TypeSampledImage 10 + 20: 6(float) Constant 1036831949 + 21: TypeInt 32 1 + 22: 21(int) Constant 1 + 24: TypeVector 21(int) 4 + 25: TypePointer Function 24(ivec4) + 27: TypeImage 21(int) 1D sampled format:Unknown + 28: TypePointer UniformConstant 27 + 29(g_tTex1di4): 28(ptr) Variable UniformConstant + 32: TypeSampledImage 27 + 34: 6(float) Constant 1045220557 + 36: TypeInt 32 0 + 37: TypeVector 36(int) 4 + 38: TypePointer Function 37(ivec4) + 40: TypeImage 36(int) 1D sampled format:Unknown + 41: TypePointer UniformConstant 40 + 42(g_tTex1du4): 41(ptr) Variable UniformConstant + 45: TypeSampledImage 40 + 47: 6(float) Constant 1050253722 + 50: TypeImage 6(float) 2D sampled format:Unknown + 51: TypePointer UniformConstant 50 + 52(g_tTex2df4): 51(ptr) Variable UniformConstant + 55: TypeSampledImage 50 + 57: TypeVector 6(float) 2 + 58: 57(fvec2) ConstantComposite 20 34 + 59: TypeVector 21(int) 2 + 60: 21(int) Constant 0 + 61: 59(ivec2) ConstantComposite 22 60 + 64: TypeImage 21(int) 2D sampled format:Unknown + 65: TypePointer UniformConstant 64 + 66(g_tTex2di4): 65(ptr) Variable UniformConstant + 69: TypeSampledImage 64 + 71: 6(float) Constant 1053609165 + 72: 57(fvec2) ConstantComposite 47 71 + 73: 59(ivec2) ConstantComposite 22 22 + 76: TypeImage 36(int) 2D sampled format:Unknown + 77: TypePointer UniformConstant 76 + 78(g_tTex2du4): 77(ptr) Variable UniformConstant + 81: TypeSampledImage 76 + 83: 6(float) Constant 1056964608 + 84: 6(float) Constant 1058642330 + 85: 57(fvec2) ConstantComposite 83 84 + 86: 21(int) Constant 4294967295 + 87: 59(ivec2) ConstantComposite 22 86 + 90: TypeImage 6(float) 3D sampled format:Unknown + 91: TypePointer UniformConstant 90 + 92(g_tTex3df4): 91(ptr) Variable UniformConstant + 95: TypeSampledImage 90 + 97: TypeVector 6(float) 3 + 98: 97(fvec3) ConstantComposite 20 34 47 + 99: TypeVector 21(int) 3 + 100: 99(ivec3) ConstantComposite 22 60 22 + 103: TypeImage 21(int) 3D sampled format:Unknown + 104: TypePointer UniformConstant 103 + 105(g_tTex3di4): 104(ptr) Variable UniformConstant + 108: TypeSampledImage 103 + 110: 97(fvec3) ConstantComposite 71 83 84 + 111: 99(ivec3) ConstantComposite 22 22 22 + 114: TypeImage 36(int) 3D sampled format:Unknown + 115: TypePointer UniformConstant 114 + 116(g_tTex3du4): 115(ptr) Variable UniformConstant + 119: TypeSampledImage 114 + 121: 6(float) Constant 1060320051 + 122: 6(float) Constant 1061997773 + 123: 6(float) Constant 1063675494 + 124: 97(fvec3) ConstantComposite 121 122 123 + 125: 99(ivec3) ConstantComposite 22 60 86 + 127(PS_OUTPUT): TypeStruct 7(fvec4) 6(float) + 128: TypePointer Function 127(PS_OUTPUT) + 130: 6(float) Constant 1065353216 + 131: TypePointer Function 6(float) +135(g_tTex1df4a): 11(ptr) Variable UniformConstant + 136: TypeImage 6(float) Cube sampled format:Unknown + 137: TypePointer UniformConstant 136 + 138(g_tTexcdf4): 137(ptr) Variable UniformConstant + 139: TypeImage 21(int) Cube sampled format:Unknown + 140: TypePointer UniformConstant 139 + 141(g_tTexcdi4): 140(ptr) Variable UniformConstant + 142: TypeImage 36(int) Cube sampled format:Unknown + 143: TypePointer UniformConstant 142 + 144(g_tTexcdu4): 143(ptr) Variable UniformConstant + 4(main): 2 Function None 3 + 5: Label + 9(txval10): 8(ptr) Variable Function + 26(txval11): 25(ptr) Variable Function + 39(txval12): 38(ptr) Variable Function + 49(txval20): 8(ptr) Variable Function + 63(txval21): 25(ptr) Variable Function + 75(txval22): 38(ptr) Variable Function + 89(txval30): 8(ptr) Variable Function + 102(txval31): 25(ptr) Variable Function + 113(txval32): 38(ptr) Variable Function + 129(psout): 128(ptr) Variable Function + 13: 10 Load 12(g_tTex1df4) + 17: 14 Load 16(g_sSamp) + 19: 18 SampledImage 13 17 + 23: 7(fvec4) ImageSampleImplicitLod 19 20 ConstOffset 22 + Store 9(txval10) 23 + 30: 27 Load 29(g_tTex1di4) + 31: 14 Load 16(g_sSamp) + 33: 32 SampledImage 30 31 + 35: 24(ivec4) ImageSampleImplicitLod 33 34 ConstOffset 22 + Store 26(txval11) 35 + 43: 40 Load 42(g_tTex1du4) + 44: 14 Load 16(g_sSamp) + 46: 45 SampledImage 43 44 + 48: 37(ivec4) ImageSampleImplicitLod 46 47 ConstOffset 22 + Store 39(txval12) 48 + 53: 50 Load 52(g_tTex2df4) + 54: 14 Load 16(g_sSamp) + 56: 55 SampledImage 53 54 + 62: 7(fvec4) ImageSampleImplicitLod 56 58 ConstOffset 61 + Store 49(txval20) 62 + 67: 64 Load 66(g_tTex2di4) + 68: 14 Load 16(g_sSamp) + 70: 69 SampledImage 67 68 + 74: 24(ivec4) ImageSampleImplicitLod 70 72 ConstOffset 73 + Store 63(txval21) 74 + 79: 76 Load 78(g_tTex2du4) + 80: 14 Load 16(g_sSamp) + 82: 81 SampledImage 79 80 + 88: 37(ivec4) ImageSampleImplicitLod 82 85 ConstOffset 87 + Store 75(txval22) 88 + 93: 90 Load 92(g_tTex3df4) + 94: 14 Load 16(g_sSamp) + 96: 95 SampledImage 93 94 + 101: 7(fvec4) ImageSampleImplicitLod 96 98 ConstOffset 100 + Store 89(txval30) 101 + 106: 103 Load 105(g_tTex3di4) + 107: 14 Load 16(g_sSamp) + 109: 108 SampledImage 106 107 + 112: 24(ivec4) ImageSampleImplicitLod 109 110 ConstOffset 111 + Store 102(txval31) 112 + 117: 114 Load 116(g_tTex3du4) + 118: 14 Load 16(g_sSamp) + 120: 119 SampledImage 117 118 + 126: 37(ivec4) ImageSampleImplicitLod 120 124 ConstOffset 125 + Store 113(txval32) 126 + 132: 131(ptr) AccessChain 129(psout) 22 + Store 132 130 + 133:127(PS_OUTPUT) Load 129(psout) + ReturnValue 133 + FunctionEnd diff --git a/Test/hlsl.sample.basicarraydx10.frag b/Test/hlsl.sample.basicarraydx10.frag new file mode 100644 index 00000000..2c680045 --- /dev/null +++ b/Test/hlsl.sample.basicarraydx10.frag @@ -0,0 +1,43 @@ +SamplerState g_sSamp : register(s0); + +Texture1DArray g_tTex1df4a : register(t1); + +uniform Texture1DArray g_tTex1df4 : register(t0); +Texture1DArray g_tTex1di4; +Texture1DArray g_tTex1du4; + +Texture2DArray g_tTex2df4; +Texture2DArray g_tTex2di4; +Texture2DArray g_tTex2du4; + +TextureCubeArray g_tTexcdf4; +TextureCubeArray g_tTexcdi4; +TextureCubeArray g_tTexcdu4; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float Depth : SV_Depth; +}; + +PS_OUTPUT main() +{ + PS_OUTPUT psout; + + float4 txval10 = g_tTex1df4 . Sample(g_sSamp, float2(0.1, 0.2)); + int4 txval11 = g_tTex1di4 . Sample(g_sSamp, float2(0.2, 0.3)); + uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, float2(0.3, 0.4)); + + float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3)); + int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float3(0.3, 0.4, 0.5)); + uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float3(0.5, 0.6, 0.7)); + + float4 txval40 = g_tTexcdf4 . Sample(g_sSamp, float4(0.1, 0.2, 0.3, 0.4)); + int4 txval41 = g_tTexcdi4 . Sample(g_sSamp, float4(0.4, 0.5, 0.6, 0.7)); + uint4 txval42 = g_tTexcdu4 . Sample(g_sSamp, float4(0.7, 0.8, 0.9, 1.0)); + + psout.Color = 1.0; + psout.Depth = 1.0; + + return psout; +} diff --git a/Test/hlsl.sample.offsetarraydx10.frag b/Test/hlsl.sample.offsetarraydx10.frag new file mode 100644 index 00000000..616c8ddd --- /dev/null +++ b/Test/hlsl.sample.offsetarraydx10.frag @@ -0,0 +1,37 @@ +SamplerState g_sSamp : register(s0); + +Texture1DArray g_tTex1df4a : register(t1); + +uniform Texture1DArray g_tTex1df4 : register(t0); +Texture1DArray g_tTex1di4; +Texture1DArray g_tTex1du4; + +Texture2DArray g_tTex2df4; +Texture2DArray g_tTex2di4; +Texture2DArray g_tTex2du4; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float Depth : SV_Depth; +}; + +PS_OUTPUT main() +{ + PS_OUTPUT psout; + + float4 txval10 = g_tTex1df4 . Sample(g_sSamp, float2(0.1, 0.2), 0); + int4 txval11 = g_tTex1di4 . Sample(g_sSamp, float2(0.2, 0.3), 1); + uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, float2(0.3, 0.4), 2); + + float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3), int2(0,0)); + int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float3(0.3, 0.4, 0.5), int2(0,0)); + uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float3(0.5, 0.6, 0.7), int2(0,1)); + + // No offset array forms for 3D or cube + + psout.Color = 1.0; + psout.Depth = 1.0; + + return psout; +} diff --git a/Test/hlsl.sample.offsetdx10.frag b/Test/hlsl.sample.offsetdx10.frag new file mode 100644 index 00000000..65ce7e48 --- /dev/null +++ b/Test/hlsl.sample.offsetdx10.frag @@ -0,0 +1,49 @@ +SamplerState g_sSamp : register(s0); + +Texture1D g_tTex1df4a : register(t1); + +uniform Texture1D g_tTex1df4 : register(t0); +Texture1D g_tTex1di4; +Texture1D g_tTex1du4; + +Texture2D g_tTex2df4; +Texture2D g_tTex2di4; +Texture2D g_tTex2du4; + +Texture3D g_tTex3df4; +Texture3D g_tTex3di4; +Texture3D g_tTex3du4; + +TextureCube g_tTexcdf4; +TextureCube g_tTexcdi4; +TextureCube g_tTexcdu4; + +struct PS_OUTPUT +{ + float4 Color : SV_Target0; + float Depth : SV_Depth; +}; + +PS_OUTPUT main() +{ + PS_OUTPUT psout; + + float4 txval10 = g_tTex1df4 . Sample(g_sSamp, 0.1, 1); + int4 txval11 = g_tTex1di4 . Sample(g_sSamp, 0.2, 1); + uint4 txval12 = g_tTex1du4 . Sample(g_sSamp, 0.3, 1); + + float4 txval20 = g_tTex2df4 . Sample(g_sSamp, float2(0.1, 0.2), int2(1,0)); + int4 txval21 = g_tTex2di4 . Sample(g_sSamp, float2(0.3, 0.4), int2(1,1)); + uint4 txval22 = g_tTex2du4 . Sample(g_sSamp, float2(0.5, 0.6), int2(1,-1)); + + float4 txval30 = g_tTex3df4 . Sample(g_sSamp, float3(0.1, 0.2, 0.3), int3(1,0,1)); + int4 txval31 = g_tTex3di4 . Sample(g_sSamp, float3(0.4, 0.5, 0.6), int3(1,1,1)); + uint4 txval32 = g_tTex3du4 . Sample(g_sSamp, float3(0.7, 0.8, 0.9), int3(1,0,-1)); + + // There are no offset forms of cube textures, so we do not test them. + + psout.Color = 1.0; + psout.Depth = 1.0; + + return psout; +} diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index 2acbfc40..8b364aa0 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -93,7 +93,10 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.intrinsics.negative.comp", "ComputeShaderFunction"}, {"hlsl.intrinsics.negative.frag", "PixelShaderFunction"}, {"hlsl.intrinsics.negative.vert", "VertexShaderFunction"}, + {"hlsl.sample.basicarraydx10.frag", "main"}, {"hlsl.sample.basicdx10.frag", "main"}, + {"hlsl.sample.offsetdx10.frag", "main"}, + {"hlsl.sample.offsetarraydx10.frag", "main"}, {"hlsl.intrinsics.vert", "VertexShaderFunction"}, {"hlsl.matType.frag", "PixelShaderFunction"}, {"hlsl.max.frag", "PixelShaderFunction"}, diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index dc0f2dbd..b3566da6 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -1236,9 +1236,17 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType switch (op) { case EOpMethodSample: { - TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped(); - TIntermTyped* argSamp = argAggregate->getSequence()[1]->getAsTyped(); - TIntermTyped* argCoord = argAggregate->getSequence()[2]->getAsTyped(); + TIntermTyped* argTex = argAggregate->getSequence()[0]->getAsTyped(); + TIntermTyped* argSamp = argAggregate->getSequence()[1]->getAsTyped(); + TIntermTyped* argCoord = argAggregate->getSequence()[2]->getAsTyped(); + TIntermTyped* argOffset = nullptr; + + TOperator textureOp = EOpTexture; + + if (argAggregate->getSequence().size() == 4) { // 4th parameter is offset form + textureOp = EOpTextureOffset; + argOffset = argAggregate->getSequence()[3]->getAsTyped(); + } TIntermAggregate* txcombine = new TIntermAggregate(EOpConstructTextureSampler); @@ -1249,9 +1257,11 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType txcombine->setType(TType(samplerType, EvqTemporary)); txcombine->setLoc(loc); - TIntermAggregate* txsample = new TIntermAggregate(EOpTexture); + TIntermAggregate* txsample = new TIntermAggregate(textureOp); txsample->getSequence().push_back(txcombine); txsample->getSequence().push_back(argCoord); + if (argOffset != nullptr) + txsample->getSequence().push_back(argOffset); txsample->setType(node->getType()); txsample->setLoc(loc); node = txsample; diff --git a/hlsl/hlslParseables.cpp b/hlsl/hlslParseables.cpp index 4085800f..2bb3d8d7 100755 --- a/hlsl/hlslParseables.cpp +++ b/hlsl/hlslParseables.cpp @@ -51,14 +51,15 @@ #include "hlslParseables.h" #include #include +#include namespace { // anonymous namespace functions const bool UseHlslTypes = false; -const char* BaseTypeName(const char* argOrder, const char* scalarName, const char* vecName, const char* matName) +const char* BaseTypeName(const char argOrder, const char* scalarName, const char* vecName, const char* matName) { - switch (*argOrder) { + switch (argOrder) { case 'S': return scalarName; case 'V': return vecName; case 'M': return matName; @@ -66,11 +67,28 @@ const char* BaseTypeName(const char* argOrder, const char* scalarName, const cha } } -bool IsTextureType(const char argType) -{ - return argType == 'T' || argType == 'i' || argType == 'u'; -} +bool IsTextureType(const char argOrder) { return argOrder == '%' || argOrder == '@'; } +bool IsTextureArrayed(const char argOrder) { return argOrder == '@'; } +// Reject certain combinations that are illegal sample methods. For example, +// 3D arrays. +bool IsIllegalSample(const glslang::TString& name, const char* argOrder, int dim0) +{ + const bool isArrayed = IsTextureArrayed(*argOrder); + + if (isArrayed && dim0 == 3) // there are no 3D arrayed textures. + return true; + + const int numArgs = int(std::count(argOrder, argOrder + strlen(argOrder), ',')) + 1; + + // Reject invalid offset arrayed forms. + if (isArrayed && dim0 == 4) { + if (name == "Sample" && numArgs == 4) + return true; + } + + return false; +} // Create and return a type name. This is done in GLSL, not HLSL conventions, until such // time as builtins are parsed using the HLSL parser. @@ -81,43 +99,62 @@ bool IsTextureType(const char argType) // dim1 = matrix 2nd dimension glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, const char* argType, int dim0, int dim1) { - const bool transpose = (argOrder[0] == '^'); - const bool matMul = (argOrder[0] == '#'); + const bool isTranspose = (argOrder[0] == '^'); + const bool isMatMul = (argOrder[0] == '#'); + const bool isTexture = IsTextureType(argOrder[0]); + const bool isArrayed = IsTextureArrayed(argOrder[0]); - if (transpose) { // Take transpose of matrix dimensions + char order = *argOrder; + char type = *argType; + + if (isTranspose) { // Take transpose of matrix dimensions + order = *++argOrder; std::swap(dim0, dim1); - ++argOrder; - } else if (matMul) { - dim0 = dim1; // set vector dimension to mat col - ++argOrder; + } else if (isMatMul) { + order = *++argOrder; + dim0 = dim1; // set vector dimension to mat col + } else if (isTexture) { + order = *++argOrder; + if (type == 'F') // map base type to texture of that type. + type = 'T'; // e.g, int -> itexture, uint -> utexture, etc. + else if (type == 'I') + type = 'i'; + else if (type == 'U') + type = 'u'; } if (UseHlslTypes) { - switch (*argType) { - case '-': s += "void"; break; - case 'F': s += "float"; break; - case 'D': s += "double"; break; - case 'I': s += "int"; break; - case 'U': s += "uint"; break; - case 'B': s += "bool"; break; - case 'S': s += "sampler"; break; - case 'T': s += "Texture"; break; - case 'i': assert(0); // TODO: ... - case 'u': assert(0); // TODO: ... - default: s += "UNKNOWN_TYPE"; break; + switch (type) { + case '-': s += "void"; break; + case 'F': s += "float"; break; + case 'D': s += "double"; break; + case 'I': s += "int"; break; + case 'U': s += "uint"; break; + case 'B': s += "bool"; break; + case 'S': s += "sampler"; break; + case 'T': s += "Texture"; break; + case 'i': s += "Texture "; break; + case 'u': s += "Texture "; break; + default: s += "UNKNOWN_TYPE"; break; } } else { - switch (*argType) { + switch (type) { case '-': s += "void"; break; - case 'F': s += BaseTypeName(argOrder, "float", "vec", "mat"); break; - case 'D': s += BaseTypeName(argOrder, "double", "dvec", "dmat"); break; - case 'I': s += BaseTypeName(argOrder, "int", "ivec", "imat"); break; - case 'U': s += BaseTypeName(argOrder, "uint", "uvec", "umat"); break; - case 'B': s += BaseTypeName(argOrder, "bool", "bvec", "bmat"); break; - case 'S': s += BaseTypeName(argOrder, "sampler", "sampler", "sampler"); break; - case 'T': s += BaseTypeName(argOrder, "texture", "texture", "texture"); break; - case 'i': s += BaseTypeName(argOrder, "itexture", "itexture", "itexture"); break; - case 'u': s += BaseTypeName(argOrder, "utexture", "utexture", "utexture"); break; + case 'F': s += BaseTypeName(order, "float", "vec", "mat"); break; + case 'D': s += BaseTypeName(order, "double", "dvec", "dmat"); break; + case 'I': s += BaseTypeName(order, "int", "ivec", "imat"); break; + case 'U': s += BaseTypeName(order, "uint", "uvec", "umat"); break; + case 'B': s += BaseTypeName(order, "bool", "bvec", "bmat"); break; + case 'S': s += "sampler"; break; + case 'T': // fall through + case 'i': // ... + case 'u': // ... + if (type != 'T') + s += type; + + s += "texture"; + break; + default: s += "UNKNOWN_TYPE"; break; } } @@ -128,8 +165,8 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons dim0 = dim1 = fixedVecSize; // Add sampler dimensions - if (*argType == 'S' || IsTextureType(*argType)) { - if (*argOrder == 'V') { + if (type == 'S' || isTexture) { + if (order == 'V') { switch (dim0) { case 1: s += "1D"; break; case 2: s += "2D"; break; @@ -141,13 +178,13 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons } else { // Non-sampler type: // verify dimensions - if (((*argOrder == 'V' || *argOrder == 'M') && (dim0 < 1 || dim0 > 4)) || - (*argOrder == 'M' && (dim1 < 1 || dim1 > 4))) { + if (((order == 'V' || order == 'M') && (dim0 < 1 || dim0 > 4)) || + (order == 'M' && (dim1 < 1 || dim1 > 4))) { s += "UNKNOWN_DIMENSION"; return s; } - switch (*argOrder) { + switch (order) { case '-': break; // no dimensions for voids case 'S': break; // no dimensions on scalars case 'V': s += ('0' + (char)dim0); break; @@ -163,19 +200,23 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons } } + // handle arrayed textures + if (isArrayed) + s += "Array"; + return s; } // TODO: the GLSL parser is currently used to parse HLSL prototypes. However, many valid HLSL prototypes // are not valid GLSL prototypes. This rejects the invalid ones. Thus, there is a single switch below // to enable creation of the entire HLSL space. -inline bool IsValidGlsl(const char* cname, char retOrder, char retType, char /*argOrder*/, char argType, +inline bool IsValidGlsl(const char* cname, char retOrder, char retType, char argOrder, char argType, int dim0, int dim1, int dim0Max, int dim1Max) { const bool isVec = dim0Max > 1 || argType == 'V'; const bool isMat = dim1Max > 1 || argType == 'M'; - if (!IsTextureType(argType) && + if (!IsTextureType(argOrder) && ((isVec && dim0 == 1) || // avoid vec1 (isMat && dim0 == 1 && dim1 == 1))) // avoid mat1x1 return false; @@ -300,13 +341,14 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c // orderKey can be: // S = scalar, V = vector, M = matrix, - = void // typekey can be: - // D = double, F = float, U = uint, I = int, B = bool, - // S = sampler, T = texture, i = itexture, u = utexture, - = void + // D = double, F = float, U = uint, I = int, B = bool, S = sampler // An empty order or type key repeats the first one. E.g: SVM,, means 3 args each of SVM. // '>' as first letter of order creates an output parameter // '<' as first letter of order creates an input parameter // '^' as first letter of order takes transpose dimensions // '#' as first letter of order sets rows=cols for mats + // '%' as first letter of order creates texture of given F/I/U type (texture, itexture, etc) + // '@' as first letter of order creates arrayed texture of given type static const struct { const char* name; // intrinsic name @@ -474,10 +516,11 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c { "trunc", nullptr, nullptr, "SVM", "F", EShLangAll }, // Texture object methods. Return type can be overridden by shader declaration. - { "Sample", "V4", "F", "V,S,V", "T,S,F", EShLangFragmentMask }, - { "Sample", "V4", "I", "V,S,V", "i,S,F", EShLangFragmentMask }, - { "Sample", "V4", "U", "V,S,V", "u,S,F", EShLangFragmentMask }, - // TODO: forms with texel-space offset parameter + // !O = no offset, O = offset, !A = no array, A = array + { "Sample", /*!O !A*/ "V4", nullptr, "%V,S,V", "FIU,S,F", EShLangFragmentMask }, + { "Sample", /* O !A*/ "V4", nullptr, "%V,S,V,V", "FIU,S,F,I", EShLangFragmentMask }, + { "Sample", /*!O A*/ "V4", nullptr, "@V,S,V", "FIU,S,F", EShLangFragmentMask }, + { "Sample", /* O A*/ "V4", nullptr, "@V,S,V,V", "FIU,S,F,I", EShLangFragmentMask }, // Mark end of list, since we want to avoid a range-based for, as some compilers don't handle it yet. { nullptr, nullptr, nullptr, nullptr, nullptr, 0 }, @@ -499,6 +542,8 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c TString& s = (intrinsic.stage == EShLangAll) ? commonBuiltins : stageBuiltins[stage]; for (const char* argOrder = intrinsic.argOrder; !IsEndOfArg(argOrder); ++argOrder) { // for each order... + const bool isTexture = IsTextureType(*argOrder); + const bool isArrayed = IsTextureArrayed(*argOrder); const int fixedVecSize = isdigit(argOrder[1]) ? (argOrder[1] - '0') : 0; // calculate min and max vector and matrix dimensions @@ -519,13 +564,15 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c dim0, dim1, dim0Max, dim1Max)) continue; + // Reject some forms of sample methods that don't exist. + if (isTexture && IsIllegalSample(s, argOrder, dim0)) + continue; + AppendTypeName(s, retOrder, retType, dim0, dim1); // add return type s.append(" "); // space between type and name s.append(intrinsic.name); // intrinsic name s.append("("); // open paren - const bool isTexture = IsTextureType(*argType); - // Append argument types, if any. for (int arg = 0; ; ++arg) { const char* nthArgOrder(NthArg(argOrder, arg)); @@ -534,12 +581,16 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c if (nthArgOrder == nullptr || nthArgType == nullptr) break; - // For textures, the 1D case isn't a 1-vector, but a scalar. - if (isTexture && dim0 == 1 && arg > 0 && *nthArgOrder == 'V') - nthArgOrder = "S"; - // cube textures use vec3 coordinates - const int argDim0 = isTexture && arg > 0 ? std::min(dim0, 3) : dim0; + int argDim0 = isTexture && arg > 0 ? std::min(dim0, 3) : dim0; + + // arrayed textures have one extra coordinate dimension + if (isArrayed && arg == 2) + argDim0++; + + // For textures, the 1D case isn't a 1-vector, but a scalar. + if (isTexture && argDim0 == 1 && arg > 0 && *nthArgOrder == 'V') + nthArgOrder = "S"; s.append(arg > 0 ? ", ": ""); // comma separator if needed @@ -563,7 +614,7 @@ void TBuiltInParseablesHlsl::initialize(int /*version*/, EProfile /*profile*/, c } } - if (fixedVecSize > 0) // skip over number for fixed size vectors + if (fixedVecSize > 0 || isTexture) // skip over special characters ++argOrder; }