From 7f93d56ef2a9a38e68898896cb9e463220297535 Mon Sep 17 00:00:00 2001 From: LoopDawg Date: Wed, 27 Sep 2017 09:04:43 -0600 Subject: [PATCH] HLSL: add subpass input types and methods Add support for Subpass Input proposal of issue #1069. Subpass input types are given as: layout(input_attachment_index = 1) SubpassInput subpass_f; layout(input_attachment_index = 2) SubpassInput subpass_i; layout(input_attachment_index = 3) SubpassInput subpass_u; layout(input_attachment_index = 1) SubpassInputMS subpass_ms_f; layout(input_attachment_index = 2) SubpassInputMS subpass_ms_i; layout(input_attachment_index = 3) SubpassInputMS subpass_ms_u; The input attachment may also be specified using attribute syntax: [[vk::input_attachment_index(7)]] SubpassInput subpass_2; The template type may be a shorter-than-vec4 vector, but currently user structs are not supported. (An unimplemented error will be issued). The load operations are methods on objects of the above type: float4 result = subpass_f.SubpassLoad(); int4 result = subpass_i.SubpassLoad(); uint4 result = subpass_u.SubpassLoad(); float4 result = subpass_ms_f.SubpassLoad(samp); int4 result = subpass_ms_i.SubpassLoad(samp); uint4 result = subpass_ms_u.SubpassLoad(samp); Additionally, the AST printer could not print EOpSubpass* nodes. Now it can. Fixes #1069 --- Test/baseResults/hlsl.subpass.frag.out | 778 ++++++++++++++++++ .../baseResults/spv.register.subpass.frag.out | 76 ++ Test/hlsl.subpass.frag | 113 +++ Test/spv.register.subpass.frag | 15 + glslang/MachineIndependent/intermOut.cpp | 7 + glslang/MachineIndependent/iomapper.cpp | 3 +- gtests/Hlsl.FromFile.cpp | 1 + gtests/Spv.FromFile.cpp | 1 + hlsl/hlslGrammar.cpp | 68 ++ hlsl/hlslGrammar.h | 1 + hlsl/hlslParseHelper.cpp | 25 + hlsl/hlslParseables.cpp | 58 +- hlsl/hlslScanContext.cpp | 4 + hlsl/hlslTokens.h | 2 + 14 files changed, 1136 insertions(+), 16 deletions(-) create mode 100644 Test/baseResults/hlsl.subpass.frag.out create mode 100644 Test/baseResults/spv.register.subpass.frag.out create mode 100644 Test/hlsl.subpass.frag create mode 100644 Test/spv.register.subpass.frag diff --git a/Test/baseResults/hlsl.subpass.frag.out b/Test/baseResults/hlsl.subpass.frag.out new file mode 100644 index 000000000..32db8fcb1 --- /dev/null +++ b/Test/baseResults/hlsl.subpass.frag.out @@ -0,0 +1,778 @@ +hlsl.subpass.frag +Shader version: 500 +gl_FragCoord origin is upper left +0:? Sequence +0:68 Function Definition: @main( ( temp 4-component vector of float) +0:68 Function Parameters: +0:? Sequence +0:69 Sequence +0:69 move second child to first child ( temp 4-component vector of float) +0:69 'result00' ( temp 4-component vector of float) +0:69 subpassLoad ( temp 4-component vector of float) +0:69 'subpass_f4' (layout( binding=1 input_attachment_index=1) uniform subpassInput) +0:70 Sequence +0:70 move second child to first child ( temp 4-component vector of int) +0:70 'result01' ( temp 4-component vector of int) +0:70 subpassLoad ( temp 4-component vector of int) +0:70 'subpass_i4' ( uniform isubpassInput) +0:71 Sequence +0:71 move second child to first child ( temp 4-component vector of uint) +0:71 'result02' ( temp 4-component vector of uint) +0:71 subpassLoad ( temp 4-component vector of uint) +0:71 'subpass_u4' ( uniform usubpassInput) +0:73 Sequence +0:73 move second child to first child ( temp 4-component vector of float) +0:73 'result10' ( temp 4-component vector of float) +0:73 subpassLoadMS ( temp 4-component vector of float) +0:73 'subpass_ms_f4' ( uniform subpassInputMS) +0:73 Constant: +0:73 3 (const int) +0:74 Sequence +0:74 move second child to first child ( temp 4-component vector of int) +0:74 'result11' ( temp 4-component vector of int) +0:74 subpassLoadMS ( temp 4-component vector of int) +0:74 'subpass_ms_i4' ( uniform isubpassInputMS) +0:74 Constant: +0:74 3 (const int) +0:75 Sequence +0:75 move second child to first child ( temp 4-component vector of uint) +0:75 'result12' ( temp 4-component vector of uint) +0:75 subpassLoadMS ( temp 4-component vector of uint) +0:75 'subpass_ms_u4' ( uniform usubpassInputMS) +0:75 Constant: +0:75 3 (const int) +0:77 Sequence +0:77 move second child to first child ( temp 3-component vector of float) +0:77 'result20' ( temp 3-component vector of float) +0:77 Construct vec3 ( temp 3-component vector of float) +0:77 subpassLoad ( temp 4-component vector of float) +0:77 'subpass_f3' ( uniform subpassInput) +0:78 Sequence +0:78 move second child to first child ( temp 3-component vector of int) +0:78 'result21' ( temp 3-component vector of int) +0:78 Construct ivec3 ( temp 3-component vector of int) +0:78 subpassLoad ( temp 4-component vector of int) +0:78 'subpass_i3' ( uniform isubpassInput) +0:79 Sequence +0:79 move second child to first child ( temp 3-component vector of uint) +0:79 'result22' ( temp 3-component vector of uint) +0:79 Construct uvec3 ( temp 3-component vector of uint) +0:79 subpassLoad ( temp 4-component vector of uint) +0:79 'subpass_u3' ( uniform usubpassInput) +0:81 Sequence +0:81 move second child to first child ( temp 3-component vector of float) +0:81 'result30' ( temp 3-component vector of float) +0:81 Construct vec3 ( temp 3-component vector of float) +0:81 subpassLoadMS ( temp 4-component vector of float) +0:81 'subpass_ms_f3' ( uniform subpassInputMS) +0:81 Constant: +0:81 3 (const int) +0:82 Sequence +0:82 move second child to first child ( temp 3-component vector of int) +0:82 'result31' ( temp 3-component vector of int) +0:82 Construct ivec3 ( temp 3-component vector of int) +0:82 subpassLoadMS ( temp 4-component vector of int) +0:82 'subpass_ms_i3' ( uniform isubpassInputMS) +0:82 Constant: +0:82 3 (const int) +0:83 Sequence +0:83 move second child to first child ( temp 3-component vector of uint) +0:83 'result32' ( temp 3-component vector of uint) +0:83 Construct uvec3 ( temp 3-component vector of uint) +0:83 subpassLoadMS ( temp 4-component vector of uint) +0:83 'subpass_ms_u3' ( uniform usubpassInputMS) +0:83 Constant: +0:83 3 (const int) +0:85 Sequence +0:85 move second child to first child ( temp 2-component vector of float) +0:85 'result40' ( temp 2-component vector of float) +0:85 Construct vec2 ( temp 2-component vector of float) +0:85 subpassLoad ( temp 4-component vector of float) +0:85 'subpass_f2' ( uniform subpassInput) +0:86 Sequence +0:86 move second child to first child ( temp 2-component vector of int) +0:86 'result41' ( temp 2-component vector of int) +0:86 Construct ivec2 ( temp 2-component vector of int) +0:86 subpassLoad ( temp 4-component vector of int) +0:86 'subpass_i2' ( uniform isubpassInput) +0:87 Sequence +0:87 move second child to first child ( temp 2-component vector of uint) +0:87 'result42' ( temp 2-component vector of uint) +0:87 Construct uvec2 ( temp 2-component vector of uint) +0:87 subpassLoad ( temp 4-component vector of uint) +0:87 'subpass_u2' ( uniform usubpassInput) +0:89 Sequence +0:89 move second child to first child ( temp 2-component vector of float) +0:89 'result50' ( temp 2-component vector of float) +0:89 Construct vec2 ( temp 2-component vector of float) +0:89 subpassLoadMS ( temp 4-component vector of float) +0:89 'subpass_ms_f2' ( uniform subpassInputMS) +0:89 Constant: +0:89 2 (const int) +0:90 Sequence +0:90 move second child to first child ( temp 2-component vector of int) +0:90 'result51' ( temp 2-component vector of int) +0:90 Construct ivec2 ( temp 2-component vector of int) +0:90 subpassLoadMS ( temp 4-component vector of int) +0:90 'subpass_ms_i2' ( uniform isubpassInputMS) +0:90 Constant: +0:90 2 (const int) +0:91 Sequence +0:91 move second child to first child ( temp 2-component vector of uint) +0:91 'result52' ( temp 2-component vector of uint) +0:91 Construct uvec2 ( temp 2-component vector of uint) +0:91 subpassLoadMS ( temp 4-component vector of uint) +0:91 'subpass_ms_u2' ( uniform usubpassInputMS) +0:91 Constant: +0:91 2 (const int) +0:93 Sequence +0:93 move second child to first child ( temp float) +0:93 'result60' ( temp float) +0:93 Construct float ( temp float) +0:93 subpassLoad ( temp 4-component vector of float) +0:93 'subpass_f' ( uniform subpassInput) +0:94 Sequence +0:94 move second child to first child ( temp int) +0:94 'result61' ( temp int) +0:94 Construct int ( temp int) +0:94 subpassLoad ( temp 4-component vector of int) +0:94 'subpass_i' ( uniform isubpassInput) +0:95 Sequence +0:95 move second child to first child ( temp uint) +0:95 'result62' ( temp uint) +0:95 Construct uint ( temp uint) +0:95 subpassLoad ( temp 4-component vector of uint) +0:95 'subpass_u' ( uniform usubpassInput) +0:97 Sequence +0:97 move second child to first child ( temp float) +0:97 'result70' ( temp float) +0:97 Construct float ( temp float) +0:97 subpassLoadMS ( temp 4-component vector of float) +0:97 'subpass_ms_f' ( uniform subpassInputMS) +0:97 Constant: +0:97 2 (const int) +0:98 Sequence +0:98 move second child to first child ( temp int) +0:98 'result71' ( temp int) +0:98 Construct int ( temp int) +0:98 subpassLoadMS ( temp 4-component vector of int) +0:98 'subpass_ms_i' ( uniform isubpassInputMS) +0:98 Constant: +0:98 2 (const int) +0:99 Sequence +0:99 move second child to first child ( temp uint) +0:99 'result72' ( temp uint) +0:99 Construct uint ( temp uint) +0:99 subpassLoadMS ( temp 4-component vector of uint) +0:99 'subpass_ms_u' ( uniform usubpassInputMS) +0:99 Constant: +0:99 2 (const int) +0:101 Sequence +0:101 move second child to first child ( temp 4-component vector of float) +0:101 'result73' ( temp 4-component vector of float) +0:101 subpassLoad ( temp 4-component vector of float) +0:101 'subpass_2' ( uniform subpassInput) +0:112 Branch: Return with expression +0:112 Constant: +0:112 0.000000 +0:112 0.000000 +0:112 0.000000 +0:112 0.000000 +0:68 Function Definition: main( ( temp void) +0:68 Function Parameters: +0:? Sequence +0:68 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:68 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'subpass_f4' (layout( binding=1 input_attachment_index=1) uniform subpassInput) +0:? 'subpass_i4' ( uniform isubpassInput) +0:? 'subpass_u4' ( uniform usubpassInput) +0:? 'subpass_ms_f4' ( uniform subpassInputMS) +0:? 'subpass_ms_i4' ( uniform isubpassInputMS) +0:? 'subpass_ms_u4' ( uniform usubpassInputMS) +0:? 'subpass_f3' ( uniform subpassInput) +0:? 'subpass_i3' ( uniform isubpassInput) +0:? 'subpass_u3' ( uniform usubpassInput) +0:? 'subpass_ms_f3' ( uniform subpassInputMS) +0:? 'subpass_ms_i3' ( uniform isubpassInputMS) +0:? 'subpass_ms_u3' ( uniform usubpassInputMS) +0:? 'subpass_f2' ( uniform subpassInput) +0:? 'subpass_i2' ( uniform isubpassInput) +0:? 'subpass_u2' ( uniform usubpassInput) +0:? 'subpass_ms_f2' ( uniform subpassInputMS) +0:? 'subpass_ms_i2' ( uniform isubpassInputMS) +0:? 'subpass_ms_u2' ( uniform usubpassInputMS) +0:? 'subpass_f' ( uniform subpassInput) +0:? 'subpass_i' ( uniform isubpassInput) +0:? 'subpass_u' ( uniform usubpassInput) +0:? 'subpass_ms_f' ( uniform subpassInputMS) +0:? 'subpass_ms_i' ( uniform isubpassInputMS) +0:? 'subpass_ms_u' ( uniform usubpassInputMS) +0:? 'subpass_2' ( uniform subpassInput) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + + +Linked fragment stage: + + +Shader version: 500 +gl_FragCoord origin is upper left +0:? Sequence +0:68 Function Definition: @main( ( temp 4-component vector of float) +0:68 Function Parameters: +0:? Sequence +0:69 Sequence +0:69 move second child to first child ( temp 4-component vector of float) +0:69 'result00' ( temp 4-component vector of float) +0:69 subpassLoad ( temp 4-component vector of float) +0:69 'subpass_f4' (layout( binding=1 input_attachment_index=1) uniform subpassInput) +0:70 Sequence +0:70 move second child to first child ( temp 4-component vector of int) +0:70 'result01' ( temp 4-component vector of int) +0:70 subpassLoad ( temp 4-component vector of int) +0:70 'subpass_i4' ( uniform isubpassInput) +0:71 Sequence +0:71 move second child to first child ( temp 4-component vector of uint) +0:71 'result02' ( temp 4-component vector of uint) +0:71 subpassLoad ( temp 4-component vector of uint) +0:71 'subpass_u4' ( uniform usubpassInput) +0:73 Sequence +0:73 move second child to first child ( temp 4-component vector of float) +0:73 'result10' ( temp 4-component vector of float) +0:73 subpassLoadMS ( temp 4-component vector of float) +0:73 'subpass_ms_f4' ( uniform subpassInputMS) +0:73 Constant: +0:73 3 (const int) +0:74 Sequence +0:74 move second child to first child ( temp 4-component vector of int) +0:74 'result11' ( temp 4-component vector of int) +0:74 subpassLoadMS ( temp 4-component vector of int) +0:74 'subpass_ms_i4' ( uniform isubpassInputMS) +0:74 Constant: +0:74 3 (const int) +0:75 Sequence +0:75 move second child to first child ( temp 4-component vector of uint) +0:75 'result12' ( temp 4-component vector of uint) +0:75 subpassLoadMS ( temp 4-component vector of uint) +0:75 'subpass_ms_u4' ( uniform usubpassInputMS) +0:75 Constant: +0:75 3 (const int) +0:77 Sequence +0:77 move second child to first child ( temp 3-component vector of float) +0:77 'result20' ( temp 3-component vector of float) +0:77 Construct vec3 ( temp 3-component vector of float) +0:77 subpassLoad ( temp 4-component vector of float) +0:77 'subpass_f3' ( uniform subpassInput) +0:78 Sequence +0:78 move second child to first child ( temp 3-component vector of int) +0:78 'result21' ( temp 3-component vector of int) +0:78 Construct ivec3 ( temp 3-component vector of int) +0:78 subpassLoad ( temp 4-component vector of int) +0:78 'subpass_i3' ( uniform isubpassInput) +0:79 Sequence +0:79 move second child to first child ( temp 3-component vector of uint) +0:79 'result22' ( temp 3-component vector of uint) +0:79 Construct uvec3 ( temp 3-component vector of uint) +0:79 subpassLoad ( temp 4-component vector of uint) +0:79 'subpass_u3' ( uniform usubpassInput) +0:81 Sequence +0:81 move second child to first child ( temp 3-component vector of float) +0:81 'result30' ( temp 3-component vector of float) +0:81 Construct vec3 ( temp 3-component vector of float) +0:81 subpassLoadMS ( temp 4-component vector of float) +0:81 'subpass_ms_f3' ( uniform subpassInputMS) +0:81 Constant: +0:81 3 (const int) +0:82 Sequence +0:82 move second child to first child ( temp 3-component vector of int) +0:82 'result31' ( temp 3-component vector of int) +0:82 Construct ivec3 ( temp 3-component vector of int) +0:82 subpassLoadMS ( temp 4-component vector of int) +0:82 'subpass_ms_i3' ( uniform isubpassInputMS) +0:82 Constant: +0:82 3 (const int) +0:83 Sequence +0:83 move second child to first child ( temp 3-component vector of uint) +0:83 'result32' ( temp 3-component vector of uint) +0:83 Construct uvec3 ( temp 3-component vector of uint) +0:83 subpassLoadMS ( temp 4-component vector of uint) +0:83 'subpass_ms_u3' ( uniform usubpassInputMS) +0:83 Constant: +0:83 3 (const int) +0:85 Sequence +0:85 move second child to first child ( temp 2-component vector of float) +0:85 'result40' ( temp 2-component vector of float) +0:85 Construct vec2 ( temp 2-component vector of float) +0:85 subpassLoad ( temp 4-component vector of float) +0:85 'subpass_f2' ( uniform subpassInput) +0:86 Sequence +0:86 move second child to first child ( temp 2-component vector of int) +0:86 'result41' ( temp 2-component vector of int) +0:86 Construct ivec2 ( temp 2-component vector of int) +0:86 subpassLoad ( temp 4-component vector of int) +0:86 'subpass_i2' ( uniform isubpassInput) +0:87 Sequence +0:87 move second child to first child ( temp 2-component vector of uint) +0:87 'result42' ( temp 2-component vector of uint) +0:87 Construct uvec2 ( temp 2-component vector of uint) +0:87 subpassLoad ( temp 4-component vector of uint) +0:87 'subpass_u2' ( uniform usubpassInput) +0:89 Sequence +0:89 move second child to first child ( temp 2-component vector of float) +0:89 'result50' ( temp 2-component vector of float) +0:89 Construct vec2 ( temp 2-component vector of float) +0:89 subpassLoadMS ( temp 4-component vector of float) +0:89 'subpass_ms_f2' ( uniform subpassInputMS) +0:89 Constant: +0:89 2 (const int) +0:90 Sequence +0:90 move second child to first child ( temp 2-component vector of int) +0:90 'result51' ( temp 2-component vector of int) +0:90 Construct ivec2 ( temp 2-component vector of int) +0:90 subpassLoadMS ( temp 4-component vector of int) +0:90 'subpass_ms_i2' ( uniform isubpassInputMS) +0:90 Constant: +0:90 2 (const int) +0:91 Sequence +0:91 move second child to first child ( temp 2-component vector of uint) +0:91 'result52' ( temp 2-component vector of uint) +0:91 Construct uvec2 ( temp 2-component vector of uint) +0:91 subpassLoadMS ( temp 4-component vector of uint) +0:91 'subpass_ms_u2' ( uniform usubpassInputMS) +0:91 Constant: +0:91 2 (const int) +0:93 Sequence +0:93 move second child to first child ( temp float) +0:93 'result60' ( temp float) +0:93 Construct float ( temp float) +0:93 subpassLoad ( temp 4-component vector of float) +0:93 'subpass_f' ( uniform subpassInput) +0:94 Sequence +0:94 move second child to first child ( temp int) +0:94 'result61' ( temp int) +0:94 Construct int ( temp int) +0:94 subpassLoad ( temp 4-component vector of int) +0:94 'subpass_i' ( uniform isubpassInput) +0:95 Sequence +0:95 move second child to first child ( temp uint) +0:95 'result62' ( temp uint) +0:95 Construct uint ( temp uint) +0:95 subpassLoad ( temp 4-component vector of uint) +0:95 'subpass_u' ( uniform usubpassInput) +0:97 Sequence +0:97 move second child to first child ( temp float) +0:97 'result70' ( temp float) +0:97 Construct float ( temp float) +0:97 subpassLoadMS ( temp 4-component vector of float) +0:97 'subpass_ms_f' ( uniform subpassInputMS) +0:97 Constant: +0:97 2 (const int) +0:98 Sequence +0:98 move second child to first child ( temp int) +0:98 'result71' ( temp int) +0:98 Construct int ( temp int) +0:98 subpassLoadMS ( temp 4-component vector of int) +0:98 'subpass_ms_i' ( uniform isubpassInputMS) +0:98 Constant: +0:98 2 (const int) +0:99 Sequence +0:99 move second child to first child ( temp uint) +0:99 'result72' ( temp uint) +0:99 Construct uint ( temp uint) +0:99 subpassLoadMS ( temp 4-component vector of uint) +0:99 'subpass_ms_u' ( uniform usubpassInputMS) +0:99 Constant: +0:99 2 (const int) +0:101 Sequence +0:101 move second child to first child ( temp 4-component vector of float) +0:101 'result73' ( temp 4-component vector of float) +0:101 subpassLoad ( temp 4-component vector of float) +0:101 'subpass_2' ( uniform subpassInput) +0:112 Branch: Return with expression +0:112 Constant: +0:112 0.000000 +0:112 0.000000 +0:112 0.000000 +0:112 0.000000 +0:68 Function Definition: main( ( temp void) +0:68 Function Parameters: +0:? Sequence +0:68 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) +0:68 Function Call: @main( ( temp 4-component vector of float) +0:? Linker Objects +0:? 'subpass_f4' (layout( binding=1 input_attachment_index=1) uniform subpassInput) +0:? 'subpass_i4' ( uniform isubpassInput) +0:? 'subpass_u4' ( uniform usubpassInput) +0:? 'subpass_ms_f4' ( uniform subpassInputMS) +0:? 'subpass_ms_i4' ( uniform isubpassInputMS) +0:? 'subpass_ms_u4' ( uniform usubpassInputMS) +0:? 'subpass_f3' ( uniform subpassInput) +0:? 'subpass_i3' ( uniform isubpassInput) +0:? 'subpass_u3' ( uniform usubpassInput) +0:? 'subpass_ms_f3' ( uniform subpassInputMS) +0:? 'subpass_ms_i3' ( uniform isubpassInputMS) +0:? 'subpass_ms_u3' ( uniform usubpassInputMS) +0:? 'subpass_f2' ( uniform subpassInput) +0:? 'subpass_i2' ( uniform isubpassInput) +0:? 'subpass_u2' ( uniform usubpassInput) +0:? 'subpass_ms_f2' ( uniform subpassInputMS) +0:? 'subpass_ms_i2' ( uniform isubpassInputMS) +0:? 'subpass_ms_u2' ( uniform usubpassInputMS) +0:? 'subpass_f' ( uniform subpassInput) +0:? 'subpass_i' ( uniform isubpassInput) +0:? 'subpass_u' ( uniform usubpassInput) +0:? 'subpass_ms_f' ( uniform subpassInputMS) +0:? 'subpass_ms_i' ( uniform isubpassInputMS) +0:? 'subpass_ms_u' ( uniform usubpassInputMS) +0:? 'subpass_2' ( uniform subpassInput) +0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 204 + + Capability Shader + Capability StorageImageMultisample + Capability InputAttachment + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 202 + ExecutionMode 4 OriginUpperLeft + Source HLSL 500 + Name 4 "main" + Name 9 "@main(" + Name 12 "result00" + Name 15 "subpass_f4" + Name 24 "result01" + Name 27 "subpass_i4" + Name 33 "result02" + Name 36 "subpass_u4" + Name 39 "result10" + Name 42 "subpass_ms_f4" + Name 46 "result11" + Name 49 "subpass_ms_i4" + Name 52 "result12" + Name 55 "subpass_ms_u4" + Name 60 "result20" + Name 61 "subpass_f3" + Name 70 "result21" + Name 71 "subpass_i3" + Name 80 "result22" + Name 81 "subpass_u3" + Name 88 "result30" + Name 89 "subpass_ms_f3" + Name 96 "result31" + Name 97 "subpass_ms_i3" + Name 104 "result32" + Name 105 "subpass_ms_u3" + Name 114 "result40" + Name 115 "subpass_f2" + Name 122 "result41" + Name 123 "subpass_i2" + Name 131 "result42" + Name 132 "subpass_u2" + Name 138 "result50" + Name 139 "subpass_ms_f2" + Name 146 "result51" + Name 147 "subpass_ms_i2" + Name 153 "result52" + Name 154 "subpass_ms_u2" + Name 161 "result60" + Name 162 "subpass_f" + Name 167 "result61" + Name 168 "subpass_i" + Name 173 "result62" + Name 174 "subpass_u" + Name 178 "result70" + Name 179 "subpass_ms_f" + Name 183 "result71" + Name 184 "subpass_ms_i" + Name 188 "result72" + Name 189 "subpass_ms_u" + Name 193 "result73" + Name 194 "subpass_2" + Name 202 "@entryPointOutput" + Decorate 15(subpass_f4) DescriptorSet 0 + Decorate 15(subpass_f4) Binding 1 + Decorate 15(subpass_f4) InputAttachmentIndex 1 + Decorate 27(subpass_i4) DescriptorSet 0 + Decorate 27(subpass_i4) InputAttachmentIndex 2 + Decorate 36(subpass_u4) DescriptorSet 0 + Decorate 36(subpass_u4) InputAttachmentIndex 3 + Decorate 42(subpass_ms_f4) DescriptorSet 0 + Decorate 42(subpass_ms_f4) InputAttachmentIndex 4 + Decorate 49(subpass_ms_i4) DescriptorSet 0 + Decorate 49(subpass_ms_i4) InputAttachmentIndex 5 + Decorate 55(subpass_ms_u4) DescriptorSet 0 + Decorate 55(subpass_ms_u4) InputAttachmentIndex 6 + Decorate 61(subpass_f3) DescriptorSet 0 + Decorate 61(subpass_f3) InputAttachmentIndex 1 + Decorate 71(subpass_i3) DescriptorSet 0 + Decorate 71(subpass_i3) InputAttachmentIndex 2 + Decorate 81(subpass_u3) DescriptorSet 0 + Decorate 81(subpass_u3) InputAttachmentIndex 3 + Decorate 89(subpass_ms_f3) DescriptorSet 0 + Decorate 89(subpass_ms_f3) InputAttachmentIndex 4 + Decorate 97(subpass_ms_i3) DescriptorSet 0 + Decorate 97(subpass_ms_i3) InputAttachmentIndex 5 + Decorate 105(subpass_ms_u3) DescriptorSet 0 + Decorate 105(subpass_ms_u3) InputAttachmentIndex 6 + Decorate 115(subpass_f2) DescriptorSet 0 + Decorate 115(subpass_f2) InputAttachmentIndex 1 + Decorate 123(subpass_i2) DescriptorSet 0 + Decorate 123(subpass_i2) InputAttachmentIndex 2 + Decorate 132(subpass_u2) DescriptorSet 0 + Decorate 132(subpass_u2) InputAttachmentIndex 3 + Decorate 139(subpass_ms_f2) DescriptorSet 0 + Decorate 139(subpass_ms_f2) InputAttachmentIndex 4 + Decorate 147(subpass_ms_i2) DescriptorSet 0 + Decorate 147(subpass_ms_i2) InputAttachmentIndex 5 + Decorate 154(subpass_ms_u2) DescriptorSet 0 + Decorate 154(subpass_ms_u2) InputAttachmentIndex 6 + Decorate 162(subpass_f) DescriptorSet 0 + Decorate 162(subpass_f) InputAttachmentIndex 1 + Decorate 168(subpass_i) DescriptorSet 0 + Decorate 168(subpass_i) InputAttachmentIndex 2 + Decorate 174(subpass_u) DescriptorSet 0 + Decorate 174(subpass_u) InputAttachmentIndex 3 + Decorate 179(subpass_ms_f) DescriptorSet 0 + Decorate 179(subpass_ms_f) InputAttachmentIndex 4 + Decorate 184(subpass_ms_i) DescriptorSet 0 + Decorate 184(subpass_ms_i) InputAttachmentIndex 5 + Decorate 189(subpass_ms_u) DescriptorSet 0 + Decorate 189(subpass_ms_u) InputAttachmentIndex 6 + Decorate 194(subpass_2) DescriptorSet 0 + Decorate 194(subpass_2) InputAttachmentIndex 7 + Decorate 202(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypeFunction 7(fvec4) + 11: TypePointer Function 7(fvec4) + 13: TypeImage 6(float) SubpassData nonsampled format:Unknown + 14: TypePointer UniformConstant 13 + 15(subpass_f4): 14(ptr) Variable UniformConstant + 17: TypeInt 32 1 + 18: 17(int) Constant 0 + 19: TypeVector 17(int) 2 + 20: 19(ivec2) ConstantComposite 18 18 + 22: TypeVector 17(int) 4 + 23: TypePointer Function 22(ivec4) + 25: TypeImage 17(int) SubpassData nonsampled format:Unknown + 26: TypePointer UniformConstant 25 + 27(subpass_i4): 26(ptr) Variable UniformConstant + 30: TypeInt 32 0 + 31: TypeVector 30(int) 4 + 32: TypePointer Function 31(ivec4) + 34: TypeImage 30(int) SubpassData nonsampled format:Unknown + 35: TypePointer UniformConstant 34 + 36(subpass_u4): 35(ptr) Variable UniformConstant + 40: TypeImage 6(float) SubpassData multi-sampled nonsampled format:Unknown + 41: TypePointer UniformConstant 40 +42(subpass_ms_f4): 41(ptr) Variable UniformConstant + 44: 17(int) Constant 3 + 47: TypeImage 17(int) SubpassData multi-sampled nonsampled format:Unknown + 48: TypePointer UniformConstant 47 +49(subpass_ms_i4): 48(ptr) Variable UniformConstant + 53: TypeImage 30(int) SubpassData multi-sampled nonsampled format:Unknown + 54: TypePointer UniformConstant 53 +55(subpass_ms_u4): 54(ptr) Variable UniformConstant + 58: TypeVector 6(float) 3 + 59: TypePointer Function 58(fvec3) + 61(subpass_f3): 14(ptr) Variable UniformConstant + 68: TypeVector 17(int) 3 + 69: TypePointer Function 68(ivec3) + 71(subpass_i3): 26(ptr) Variable UniformConstant + 78: TypeVector 30(int) 3 + 79: TypePointer Function 78(ivec3) + 81(subpass_u3): 35(ptr) Variable UniformConstant +89(subpass_ms_f3): 41(ptr) Variable UniformConstant +97(subpass_ms_i3): 48(ptr) Variable UniformConstant +105(subpass_ms_u3): 54(ptr) Variable UniformConstant + 112: TypeVector 6(float) 2 + 113: TypePointer Function 112(fvec2) + 115(subpass_f2): 14(ptr) Variable UniformConstant + 121: TypePointer Function 19(ivec2) + 123(subpass_i2): 26(ptr) Variable UniformConstant + 129: TypeVector 30(int) 2 + 130: TypePointer Function 129(ivec2) + 132(subpass_u2): 35(ptr) Variable UniformConstant +139(subpass_ms_f2): 41(ptr) Variable UniformConstant + 141: 17(int) Constant 2 +147(subpass_ms_i2): 48(ptr) Variable UniformConstant +154(subpass_ms_u2): 54(ptr) Variable UniformConstant + 160: TypePointer Function 6(float) + 162(subpass_f): 14(ptr) Variable UniformConstant + 166: TypePointer Function 17(int) + 168(subpass_i): 26(ptr) Variable UniformConstant + 172: TypePointer Function 30(int) + 174(subpass_u): 35(ptr) Variable UniformConstant +179(subpass_ms_f): 41(ptr) Variable UniformConstant +184(subpass_ms_i): 48(ptr) Variable UniformConstant +189(subpass_ms_u): 54(ptr) Variable UniformConstant + 194(subpass_2): 14(ptr) Variable UniformConstant + 197: 6(float) Constant 0 + 198: 7(fvec4) ConstantComposite 197 197 197 197 + 201: TypePointer Output 7(fvec4) +202(@entryPointOutput): 201(ptr) Variable Output + 4(main): 2 Function None 3 + 5: Label + 203: 7(fvec4) FunctionCall 9(@main() + Store 202(@entryPointOutput) 203 + Return + FunctionEnd + 9(@main(): 7(fvec4) Function None 8 + 10: Label + 12(result00): 11(ptr) Variable Function + 24(result01): 23(ptr) Variable Function + 33(result02): 32(ptr) Variable Function + 39(result10): 11(ptr) Variable Function + 46(result11): 23(ptr) Variable Function + 52(result12): 32(ptr) Variable Function + 60(result20): 59(ptr) Variable Function + 70(result21): 69(ptr) Variable Function + 80(result22): 79(ptr) Variable Function + 88(result30): 59(ptr) Variable Function + 96(result31): 69(ptr) Variable Function + 104(result32): 79(ptr) Variable Function + 114(result40): 113(ptr) Variable Function + 122(result41): 121(ptr) Variable Function + 131(result42): 130(ptr) Variable Function + 138(result50): 113(ptr) Variable Function + 146(result51): 121(ptr) Variable Function + 153(result52): 130(ptr) Variable Function + 161(result60): 160(ptr) Variable Function + 167(result61): 166(ptr) Variable Function + 173(result62): 172(ptr) Variable Function + 178(result70): 160(ptr) Variable Function + 183(result71): 166(ptr) Variable Function + 188(result72): 172(ptr) Variable Function + 193(result73): 11(ptr) Variable Function + 16: 13 Load 15(subpass_f4) + 21: 7(fvec4) ImageRead 16 20 + Store 12(result00) 21 + 28: 25 Load 27(subpass_i4) + 29: 22(ivec4) ImageRead 28 20 + Store 24(result01) 29 + 37: 34 Load 36(subpass_u4) + 38: 31(ivec4) ImageRead 37 20 + Store 33(result02) 38 + 43: 40 Load 42(subpass_ms_f4) + 45: 7(fvec4) ImageRead 43 20 Sample 44 + Store 39(result10) 45 + 50: 47 Load 49(subpass_ms_i4) + 51: 22(ivec4) ImageRead 50 20 Sample 44 + Store 46(result11) 51 + 56: 53 Load 55(subpass_ms_u4) + 57: 31(ivec4) ImageRead 56 20 Sample 44 + Store 52(result12) 57 + 62: 13 Load 61(subpass_f3) + 63: 7(fvec4) ImageRead 62 20 + 64: 6(float) CompositeExtract 63 0 + 65: 6(float) CompositeExtract 63 1 + 66: 6(float) CompositeExtract 63 2 + 67: 58(fvec3) CompositeConstruct 64 65 66 + Store 60(result20) 67 + 72: 25 Load 71(subpass_i3) + 73: 22(ivec4) ImageRead 72 20 + 74: 17(int) CompositeExtract 73 0 + 75: 17(int) CompositeExtract 73 1 + 76: 17(int) CompositeExtract 73 2 + 77: 68(ivec3) CompositeConstruct 74 75 76 + Store 70(result21) 77 + 82: 34 Load 81(subpass_u3) + 83: 31(ivec4) ImageRead 82 20 + 84: 30(int) CompositeExtract 83 0 + 85: 30(int) CompositeExtract 83 1 + 86: 30(int) CompositeExtract 83 2 + 87: 78(ivec3) CompositeConstruct 84 85 86 + Store 80(result22) 87 + 90: 40 Load 89(subpass_ms_f3) + 91: 7(fvec4) ImageRead 90 20 Sample 44 + 92: 6(float) CompositeExtract 91 0 + 93: 6(float) CompositeExtract 91 1 + 94: 6(float) CompositeExtract 91 2 + 95: 58(fvec3) CompositeConstruct 92 93 94 + Store 88(result30) 95 + 98: 47 Load 97(subpass_ms_i3) + 99: 22(ivec4) ImageRead 98 20 Sample 44 + 100: 17(int) CompositeExtract 99 0 + 101: 17(int) CompositeExtract 99 1 + 102: 17(int) CompositeExtract 99 2 + 103: 68(ivec3) CompositeConstruct 100 101 102 + Store 96(result31) 103 + 106: 53 Load 105(subpass_ms_u3) + 107: 31(ivec4) ImageRead 106 20 Sample 44 + 108: 30(int) CompositeExtract 107 0 + 109: 30(int) CompositeExtract 107 1 + 110: 30(int) CompositeExtract 107 2 + 111: 78(ivec3) CompositeConstruct 108 109 110 + Store 104(result32) 111 + 116: 13 Load 115(subpass_f2) + 117: 7(fvec4) ImageRead 116 20 + 118: 6(float) CompositeExtract 117 0 + 119: 6(float) CompositeExtract 117 1 + 120: 112(fvec2) CompositeConstruct 118 119 + Store 114(result40) 120 + 124: 25 Load 123(subpass_i2) + 125: 22(ivec4) ImageRead 124 20 + 126: 17(int) CompositeExtract 125 0 + 127: 17(int) CompositeExtract 125 1 + 128: 19(ivec2) CompositeConstruct 126 127 + Store 122(result41) 128 + 133: 34 Load 132(subpass_u2) + 134: 31(ivec4) ImageRead 133 20 + 135: 30(int) CompositeExtract 134 0 + 136: 30(int) CompositeExtract 134 1 + 137: 129(ivec2) CompositeConstruct 135 136 + Store 131(result42) 137 + 140: 40 Load 139(subpass_ms_f2) + 142: 7(fvec4) ImageRead 140 20 Sample 141 + 143: 6(float) CompositeExtract 142 0 + 144: 6(float) CompositeExtract 142 1 + 145: 112(fvec2) CompositeConstruct 143 144 + Store 138(result50) 145 + 148: 47 Load 147(subpass_ms_i2) + 149: 22(ivec4) ImageRead 148 20 Sample 141 + 150: 17(int) CompositeExtract 149 0 + 151: 17(int) CompositeExtract 149 1 + 152: 19(ivec2) CompositeConstruct 150 151 + Store 146(result51) 152 + 155: 53 Load 154(subpass_ms_u2) + 156: 31(ivec4) ImageRead 155 20 Sample 141 + 157: 30(int) CompositeExtract 156 0 + 158: 30(int) CompositeExtract 156 1 + 159: 129(ivec2) CompositeConstruct 157 158 + Store 153(result52) 159 + 163: 13 Load 162(subpass_f) + 164: 7(fvec4) ImageRead 163 20 + 165: 6(float) CompositeExtract 164 0 + Store 161(result60) 165 + 169: 25 Load 168(subpass_i) + 170: 22(ivec4) ImageRead 169 20 + 171: 17(int) CompositeExtract 170 0 + Store 167(result61) 171 + 175: 34 Load 174(subpass_u) + 176: 31(ivec4) ImageRead 175 20 + 177: 30(int) CompositeExtract 176 0 + Store 173(result62) 177 + 180: 40 Load 179(subpass_ms_f) + 181: 7(fvec4) ImageRead 180 20 Sample 141 + 182: 6(float) CompositeExtract 181 0 + Store 178(result70) 182 + 185: 47 Load 184(subpass_ms_i) + 186: 22(ivec4) ImageRead 185 20 Sample 141 + 187: 17(int) CompositeExtract 186 0 + Store 183(result71) 187 + 190: 53 Load 189(subpass_ms_u) + 191: 31(ivec4) ImageRead 190 20 Sample 141 + 192: 30(int) CompositeExtract 191 0 + Store 188(result72) 192 + 195: 13 Load 194(subpass_2) + 196: 7(fvec4) ImageRead 195 20 + Store 193(result73) 196 + ReturnValue 198 + FunctionEnd diff --git a/Test/baseResults/spv.register.subpass.frag.out b/Test/baseResults/spv.register.subpass.frag.out new file mode 100644 index 000000000..defc69b55 --- /dev/null +++ b/Test/baseResults/spv.register.subpass.frag.out @@ -0,0 +1,76 @@ +spv.register.subpass.frag +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 40 + + Capability Shader + Capability StorageImageMultisample + Capability InputAttachment + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "main" 38 + ExecutionMode 4 OriginUpperLeft + Source HLSL 500 + Name 4 "main" + Name 9 "@main(" + Name 12 "result00" + Name 15 "subpass_f4" + Name 22 "result10" + Name 25 "subpass_ms_f4" + Name 29 "result73" + Name 30 "subpass_2" + Name 38 "@entryPointOutput" + Decorate 15(subpass_f4) DescriptorSet 0 + Decorate 15(subpass_f4) Binding 21 + Decorate 15(subpass_f4) InputAttachmentIndex 1 + Decorate 25(subpass_ms_f4) DescriptorSet 0 + Decorate 25(subpass_ms_f4) Binding 20 + Decorate 25(subpass_ms_f4) InputAttachmentIndex 4 + Decorate 30(subpass_2) DescriptorSet 0 + Decorate 30(subpass_2) Binding 22 + Decorate 30(subpass_2) InputAttachmentIndex 7 + Decorate 38(@entryPointOutput) Location 0 + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypeFunction 7(fvec4) + 11: TypePointer Function 7(fvec4) + 13: TypeImage 6(float) SubpassData nonsampled format:Unknown + 14: TypePointer UniformConstant 13 + 15(subpass_f4): 14(ptr) Variable UniformConstant + 17: TypeInt 32 1 + 18: 17(int) Constant 0 + 19: TypeVector 17(int) 2 + 20: 19(ivec2) ConstantComposite 18 18 + 23: TypeImage 6(float) SubpassData multi-sampled nonsampled format:Unknown + 24: TypePointer UniformConstant 23 +25(subpass_ms_f4): 24(ptr) Variable UniformConstant + 27: 17(int) Constant 3 + 30(subpass_2): 14(ptr) Variable UniformConstant + 33: 6(float) Constant 0 + 34: 7(fvec4) ConstantComposite 33 33 33 33 + 37: TypePointer Output 7(fvec4) +38(@entryPointOutput): 37(ptr) Variable Output + 4(main): 2 Function None 3 + 5: Label + 39: 7(fvec4) FunctionCall 9(@main() + Store 38(@entryPointOutput) 39 + Return + FunctionEnd + 9(@main(): 7(fvec4) Function None 8 + 10: Label + 12(result00): 11(ptr) Variable Function + 22(result10): 11(ptr) Variable Function + 29(result73): 11(ptr) Variable Function + 16: 13 Load 15(subpass_f4) + 21: 7(fvec4) ImageRead 16 20 + Store 12(result00) 21 + 26: 23 Load 25(subpass_ms_f4) + 28: 7(fvec4) ImageRead 26 20 Sample 27 + Store 22(result10) 28 + 31: 13 Load 30(subpass_2) + 32: 7(fvec4) ImageRead 31 20 + Store 29(result73) 32 + ReturnValue 34 + FunctionEnd diff --git a/Test/hlsl.subpass.frag b/Test/hlsl.subpass.frag new file mode 100644 index 000000000..20a717f8f --- /dev/null +++ b/Test/hlsl.subpass.frag @@ -0,0 +1,113 @@ + +layout(input_attachment_index = 1) SubpassInput subpass_f4 : register(t1); +layout(input_attachment_index = 2) SubpassInput subpass_i4; +layout(input_attachment_index = 3) SubpassInput subpass_u4; + +layout(input_attachment_index = 4) SubpassInputMS subpass_ms_f4; +layout(input_attachment_index = 5) SubpassInputMS subpass_ms_i4; +layout(input_attachment_index = 6) SubpassInputMS subpass_ms_u4; + +layout(input_attachment_index = 1) SubpassInput subpass_f3; +layout(input_attachment_index = 2) SubpassInput subpass_i3; +layout(input_attachment_index = 3) SubpassInput subpass_u3; + +layout(input_attachment_index = 4) SubpassInputMS subpass_ms_f3; +layout(input_attachment_index = 5) SubpassInputMS subpass_ms_i3; +layout(input_attachment_index = 6) SubpassInputMS subpass_ms_u3; + +layout(input_attachment_index = 1) SubpassInput subpass_f2; +layout(input_attachment_index = 2) SubpassInput subpass_i2; +layout(input_attachment_index = 3) SubpassInput subpass_u2; + +layout(input_attachment_index = 4) SubpassInputMS subpass_ms_f2; +layout(input_attachment_index = 5) SubpassInputMS subpass_ms_i2; +layout(input_attachment_index = 6) SubpassInputMS subpass_ms_u2; + +layout(input_attachment_index = 1) SubpassInput subpass_f; +layout(input_attachment_index = 2) SubpassInput subpass_i; +layout(input_attachment_index = 3) SubpassInput subpass_u; + +layout(input_attachment_index = 4) SubpassInputMS subpass_ms_f; +layout(input_attachment_index = 5) SubpassInputMS subpass_ms_i; +layout(input_attachment_index = 6) SubpassInputMS subpass_ms_u; + +[[vk::input_attachment_index(7)]] SubpassInput subpass_2; + +struct mystruct_f_t +{ + float c0; + float2 c1; + float c2; +}; + +struct mystruct_i_t +{ + int c0; + int2 c1; + int c2; +}; + +struct mystruct_u_t +{ + uint c0; + uint2 c1; + uint c2; +}; + +// TODO: ... +// layout(input_attachment_index = 7) SubpassInput subpass_fs; +// layout(input_attachment_index = 8) SubpassInputMS subpass_ms_fs; + +// layout(input_attachment_index = 7) SubpassInput subpass_is; +// layout(input_attachment_index = 8) SubpassInputMS subpass_ms_is; + +// layout(input_attachment_index = 7) SubpassInput subpass_us; +// layout(input_attachment_index = 8) SubpassInputMS subpass_ms_us; + +float4 main() : SV_Target0 +{ + float4 result00 = subpass_f4.SubpassLoad(); + int4 result01 = subpass_i4.SubpassLoad(); + uint4 result02 = subpass_u4.SubpassLoad(); + + float4 result10 = subpass_ms_f4.SubpassLoad(3); + int4 result11 = subpass_ms_i4.SubpassLoad(3); + uint4 result12 = subpass_ms_u4.SubpassLoad(3); + + float3 result20 = subpass_f3.SubpassLoad(); + int3 result21 = subpass_i3.SubpassLoad(); + uint3 result22 = subpass_u3.SubpassLoad(); + + float3 result30 = subpass_ms_f3.SubpassLoad(3); + int3 result31 = subpass_ms_i3.SubpassLoad(3); + uint3 result32 = subpass_ms_u3.SubpassLoad(3); + + float2 result40 = subpass_f2.SubpassLoad(); + int2 result41 = subpass_i2.SubpassLoad(); + uint2 result42 = subpass_u2.SubpassLoad(); + + float2 result50 = subpass_ms_f2.SubpassLoad(2); + int2 result51 = subpass_ms_i2.SubpassLoad(2); + uint2 result52 = subpass_ms_u2.SubpassLoad(2); + + float result60 = subpass_f.SubpassLoad(); + int result61 = subpass_i.SubpassLoad(); + uint result62 = subpass_u.SubpassLoad(); + + float result70 = subpass_ms_f.SubpassLoad(2); + int result71 = subpass_ms_i.SubpassLoad(2); + uint result72 = subpass_ms_u.SubpassLoad(2); + + float4 result73 = subpass_2.SubpassLoad(); + + // TODO: + // mystruct_f_t result80 = subpass_fs.SubpassLoad(); + // mystruct_i_t result81 = subpass_is.SubpassLoad(); + // mystruct_u_t result82 = subpass_us.SubpassLoad(); + + // mystruct_f_t result90 = subpass_ms_sf.SubpassLoad(2); + // mystruct_i_t result91 = subpass_ms_if.SubpassLoad(2); + // mystruct_u_t result92 = subpass_ms_uf.SubpassLoad(2); + + return 0; +} diff --git a/Test/spv.register.subpass.frag b/Test/spv.register.subpass.frag new file mode 100644 index 000000000..281c2f704 --- /dev/null +++ b/Test/spv.register.subpass.frag @@ -0,0 +1,15 @@ + +// Test binding autoassignment and offset for SubpassInput objects + +layout(input_attachment_index = 1) SubpassInput subpass_f4 : register(t1); +layout(input_attachment_index = 4) SubpassInputMS subpass_ms_f4; +[[vk::input_attachment_index(7)]] SubpassInput subpass_2; + +float4 main() : SV_Target0 +{ + float4 result00 = subpass_f4.SubpassLoad(); + float4 result10 = subpass_ms_f4.SubpassLoad(3); + float4 result73 = subpass_2.SubpassLoad(); + + return 0; +} diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index ae68216ae..7e15392da 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -196,6 +196,7 @@ bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node) case EOpLogicalOr: out.debug << "logical-or"; break; case EOpLogicalXor: out.debug << "logical-xor"; break; case EOpLogicalAnd: out.debug << "logical-and"; break; + default: out.debug << ""; } @@ -491,6 +492,9 @@ bool TOutputTraverser::visitUnary(TVisit /* visit */, TIntermUnary* node) case EOpConvUint16ToUint64: out.debug << "Convert uint16 to uint64"; break; #endif + case EOpSubpassLoad: out.debug << "subpassLoad"; break; + case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break; + default: out.debug.message(EPrefixError, "Bad unary op"); } @@ -791,6 +795,9 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node case EOpWorkgroupMemoryBarrier: out.debug << "WorkgroupMemoryBarrier"; break; case EOpWorkgroupMemoryBarrierWithGroupSync: out.debug << "WorkgroupMemoryBarrierWithGroupSync"; break; + case EOpSubpassLoad: out.debug << "subpassLoad"; break; + case EOpSubpassLoadMS: out.debug << "subpassLoadMS"; break; + default: out.debug.message(EPrefixError, "Bad aggregation op"); } diff --git a/glslang/MachineIndependent/iomapper.cpp b/glslang/MachineIndependent/iomapper.cpp index 1758d00a8..4926cf8c6 100644 --- a/glslang/MachineIndependent/iomapper.cpp +++ b/glslang/MachineIndependent/iomapper.cpp @@ -497,7 +497,8 @@ protected: } static bool isTextureType(const glslang::TType& type) { - return type.getBasicType() == glslang::EbtSampler && type.getSampler().isTexture(); + return (type.getBasicType() == glslang::EbtSampler && + (type.getSampler().isTexture() || type.getSampler().isSubpass())); } static bool isUboType(const glslang::TType& type) { diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index dfdadf5ee..0ba399f53 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -318,6 +318,7 @@ INSTANTIATE_TEST_CASE_P( {"hlsl.structin.vert", "main"}, {"hlsl.structIoFourWay.frag", "main"}, {"hlsl.structStructName.frag", "main"}, + {"hlsl.subpass.frag", "main"}, {"hlsl.synthesizeInput.frag", "main"}, {"hlsl.texture.struct.frag", "main"}, {"hlsl.texture.subvec4.frag", "main"}, diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp index c37e46081..63992f196 100644 --- a/gtests/Spv.FromFile.cpp +++ b/gtests/Spv.FromFile.cpp @@ -334,6 +334,7 @@ INSTANTIATE_TEST_CASE_P( { "spv.register.autoassign.frag", "main_ep", 5, 10, 0, 20, 30, true, false }, { "spv.register.noautoassign.frag", "main_ep", 5, 10, 0, 15, 30, false, false }, { "spv.register.autoassign-2.frag", "main", 5, 10, 0, 15, 30, true, true }, + { "spv.register.subpass.frag", "main", 0, 20, 0, 0, 0, true, true }, { "spv.buffer.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true }, { "spv.ssbo.autoassign.frag", "main", 5, 10, 0, 15, 30, true, true }, { "spv.ssboAlias.frag", "main", 0, 0, 0, 0, 83, true, false }, diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp index 4914f20c1..88eacd9c5 100755 --- a/hlsl/hlslGrammar.cpp +++ b/hlsl/hlslGrammar.cpp @@ -1088,6 +1088,69 @@ bool HlslGrammar::acceptAnnotations(TQualifier&) return true; } +// subpass input type +// : SUBPASSINPUT +// | SUBPASSINPUT VECTOR LEFT_ANGLE template_type RIGHT_ANGLE +// | SUBPASSINPUTMS +// | SUBPASSINPUTMS VECTOR LEFT_ANGLE template_type RIGHT_ANGLE +bool HlslGrammar::acceptSubpassInputType(TType& type) +{ + // read subpass type + const EHlslTokenClass subpassInputType = peek(); + + bool multisample; + + switch (subpassInputType) { + case EHTokSubpassInput: multisample = false; break; + case EHTokSubpassInputMS: multisample = true; break; + default: + return false; // not a subpass input declaration + } + + advanceToken(); // consume the sampler type keyword + + TType subpassType(EbtFloat, EvqUniform, 4); // default type is float4 + + if (acceptTokenClass(EHTokLeftAngle)) { + if (! acceptType(subpassType)) { + expected("scalar or vector type"); + return false; + } + + const TBasicType basicRetType = subpassType.getBasicType() ; + + switch (basicRetType) { + case EbtFloat: + case EbtUint: + case EbtInt: + case EbtStruct: + break; + default: + unimplemented("basic type in subpass input"); + return false; + } + + if (! acceptTokenClass(EHTokRightAngle)) { + expected("right angle bracket"); + return false; + } + } + + const TBasicType subpassBasicType = subpassType.isStruct() ? (*subpassType.getStruct())[0].type->getBasicType() + : subpassType.getBasicType(); + + TSampler sampler; + sampler.setSubpass(subpassBasicType, multisample); + + // Remember the declared return type. Function returns false on error. + if (!parseContext.setTextureReturnType(sampler, subpassType, token.loc)) + return false; + + type.shallowCopy(TType(sampler, EvqUniform)); + + return true; +} + // sampler_type // : SAMPLER // | SAMPLER1D @@ -1357,6 +1420,11 @@ bool HlslGrammar::acceptType(TType& type, TIntermNode*& nodeList) return acceptSamplerType(type); break; + case EHTokSubpassInput: // fall through + case EHTokSubpassInputMS: // ... + return acceptSubpassInputType(type); + break; + case EHTokBuffer: // fall through case EHTokTexture1d: // ... case EHTokTexture1darray: // ... diff --git a/hlsl/hlslGrammar.h b/hlsl/hlslGrammar.h index 2db0754c5..f0adfa0b7 100755 --- a/hlsl/hlslGrammar.h +++ b/hlsl/hlslGrammar.h @@ -87,6 +87,7 @@ namespace glslang { bool acceptAnnotations(TQualifier&); bool acceptSamplerType(TType&); bool acceptTextureType(TType&); + bool acceptSubpassInputType(TType&); bool acceptStructBufferType(TType&); bool acceptConstantBufferType(TType&); bool acceptStruct(TType&, TIntermNode*& nodeList); diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index f414085d4..91deb4f5b 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -4215,6 +4215,25 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType break; } + case EOpSubpassLoad: + { + const TIntermTyped* argSubpass = + argAggregate ? argAggregate->getSequence()[0]->getAsTyped() : + arguments->getAsTyped(); + + const TSampler& sampler = argSubpass->getType().getSampler(); + + // subpass load: the multisample form is overloaded. Here, we convert that to + // the EOpSubpassLoadMS opcode. + if (argAggregate != nullptr && argAggregate->getSequence().size() > 1) + node->getAsOperator()->setOp(EOpSubpassLoadMS); + + node = convertReturn(node, sampler); + + break; + } + + default: break; // most pass through unchanged } @@ -8952,6 +8971,12 @@ bool HlslParseContext::setTextureReturnType(TSampler& sampler, const TType& retT return false; } + // TODO: Subpass doesn't handle struct returns, due to some oddities with fn overloading. + if (sampler.isSubpass()) { + error(loc, "Unimplemented: structure template type in subpass input", "", ""); + return false; + } + TTypeList* members = retType.getWritableStruct(); // Check for too many or not enough structure members. diff --git a/hlsl/hlslParseables.cpp b/hlsl/hlslParseables.cpp index db67c39df..31f6801ff 100755 --- a/hlsl/hlslParseables.cpp +++ b/hlsl/hlslParseables.cpp @@ -68,14 +68,21 @@ const char* BaseTypeName(const char argOrder, const char* scalarName, const char } } -bool IsSamplerType(const char argType) { return argType == 'S' || argType == 's'; } -bool IsArrayed(const char argOrder) { return argOrder == '@' || argOrder == '&' || argOrder == '#'; } -bool IsTextureMS(const char argOrder) { return argOrder == '$' || argOrder == '&'; } -bool IsBuffer(const char argOrder) { return argOrder == '*' || argOrder == '~'; } -bool IsImage(const char argOrder) { return argOrder == '!' || argOrder == '#' || argOrder == '~'; } +// arg order queries +bool IsSamplerType(const char argType) { return argType == 'S' || argType == 's'; } +bool IsArrayed(const char argOrder) { return argOrder == '@' || argOrder == '&' || argOrder == '#'; } +bool IsTextureNonMS(const char argOrder) { return argOrder == '%'; } +bool IsSubpassInput(const char argOrder) { return argOrder == '[' || argOrder == ']'; } +bool IsArrayedTexture(const char argOrder) { return argOrder == '@'; } +bool IsTextureMS(const char argOrder) { return argOrder == '$' || argOrder == '&'; } +bool IsMS(const char argOrder) { return IsTextureMS(argOrder) || argOrder == ']'; } +bool IsBuffer(const char argOrder) { return argOrder == '*' || argOrder == '~'; } +bool IsImage(const char argOrder) { return argOrder == '!' || argOrder == '#' || argOrder == '~'; } + bool IsTextureType(const char argOrder) { - return argOrder == '%' || argOrder == '@' || IsTextureMS(argOrder) || IsBuffer(argOrder) | IsImage(argOrder); + return IsTextureNonMS(argOrder) || IsArrayedTexture(argOrder) || + IsTextureMS(argOrder) || IsBuffer(argOrder) || IsImage(argOrder); } // Reject certain combinations that are illegal sample methods. For example, @@ -222,15 +229,16 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons const bool isTexture = IsTextureType(argOrder[0]); const bool isArrayed = IsArrayed(argOrder[0]); const bool isSampler = IsSamplerType(argType[0]); - const bool isMS = IsTextureMS(argOrder[0]); + const bool isMS = IsMS(argOrder[0]); const bool isBuffer = IsBuffer(argOrder[0]); const bool isImage = IsImage(argOrder[0]); + const bool isSubpass = IsSubpassInput(argOrder[0]); char type = *argType; if (isTranspose) { // Take transpose of matrix dimensions std::swap(dim0, dim1); - } else if (isTexture) { + } else if (isTexture || isSubpass) { if (type == 'F') // map base type to texture of that type. type = 'T'; // e.g, int -> itexture, uint -> utexture, etc. else if (type == 'I') @@ -255,16 +263,23 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons case 'S': s += "sampler"; break; case 's': s += "SamplerComparisonState"; break; case 'T': s += ((isBuffer && isImage) ? "RWBuffer" : + isSubpass ? "SubpassInput" : isBuffer ? "Buffer" : isImage ? "RWTexture" : "Texture"); break; case 'i': s += ((isBuffer && isImage) ? "RWBuffer" : + isSubpass ? "SubpassInput" : isBuffer ? "Buffer" : isImage ? "RWTexture" : "Texture"); break; case 'u': s += ((isBuffer && isImage) ? "RWBuffer" : + isSubpass ? "SubpassInput" : isBuffer ? "Buffer" : isImage ? "RWTexture" : "Texture"); break; default: s += "UNKNOWN_TYPE"; break; } + + if (isSubpass && isMS) + s += "MS"; + } else { switch (type) { case '-': s += "void"; break; @@ -282,6 +297,7 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons s += type; s += ((isImage && isBuffer) ? "imageBuffer" : + isSubpass ? "subpassInput" : isImage ? "image" : isBuffer ? "samplerBuffer" : "texture"); @@ -296,6 +312,9 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons if (fixedVecSize != 0) dim0 = dim1 = fixedVecSize; + const char dim0Char = ('0' + char(dim0)); + const char dim1Char = ('0' + char(dim1)); + // Add sampler dimensions if (isSampler || isTexture) { if ((order == 'V' || isTexture) && !isBuffer) { @@ -320,12 +339,12 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons case '-': break; // no dimensions for voids case 'S': break; // no dimensions on scalars case 'V': - s += ('0' + char(dim0)); + s += dim0Char; break; case 'M': - s += ('0' + char(dim0)); + s += dim0Char; s += 'x'; - s += ('0' + char(dim1)); + s += dim1Char; break; default: break; @@ -339,9 +358,9 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons // For HLSL, append return type for texture types if (UseHlslTypes) { switch (type) { - case 'i': s += ""; break; - case 'u': s += ""; break; - case 'T': s += ""; break; + case 'i': s += "