spirv: Use generic transform to process shader IO
The refactored CanonicalizeEntryPointIO transform makes it much easier
to handle SPIR-V style IO as well, and doing this removes a lot of
duplicated code. Remove all of the SPIR-V transform code for shader IO
and vertex point size.
Bug: tint:920
Change-Id: Id1b97517619b4d2fd09b45d5aee848259f3dfa77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60840
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/test/shader_io/fragment_output_mixed.wgsl.expected.spvasm b/test/shader_io/fragment_output_mixed.wgsl.expected.spvasm
index 164fdf0..4002fe6 100644
--- a/test/shader_io/fragment_output_mixed.wgsl.expected.spvasm
+++ b/test/shader_io/fragment_output_mixed.wgsl.expected.spvasm
@@ -1,19 +1,19 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 49
+; Bound: 48
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main" %tint_symbol_1 %tint_symbol_2 %tint_symbol_3 %tint_symbol_4 %tint_symbol_5 %tint_symbol_6
+ OpEntryPoint Fragment %main "main" %loc0_1 %frag_depth_1 %loc1_1 %loc2_1 %sample_mask_1 %loc3_1
OpExecutionMode %main OriginUpperLeft
OpExecutionMode %main DepthReplacing
- OpName %tint_symbol_1 "tint_symbol_1"
- OpName %tint_symbol_2 "tint_symbol_2"
- OpName %tint_symbol_3 "tint_symbol_3"
- OpName %tint_symbol_4 "tint_symbol_4"
- OpName %tint_symbol_5 "tint_symbol_5"
- OpName %tint_symbol_6 "tint_symbol_6"
+ OpName %loc0_1 "loc0_1"
+ OpName %frag_depth_1 "frag_depth_1"
+ OpName %loc1_1 "loc1_1"
+ OpName %loc2_1 "loc2_1"
+ OpName %sample_mask_1 "sample_mask_1"
+ OpName %loc3_1 "loc3_1"
OpName %FragmentOutputs "FragmentOutputs"
OpMemberName %FragmentOutputs 0 "loc0"
OpMemberName %FragmentOutputs 1 "frag_depth"
@@ -21,16 +21,15 @@
OpMemberName %FragmentOutputs 3 "loc2"
OpMemberName %FragmentOutputs 4 "sample_mask"
OpMemberName %FragmentOutputs 5 "loc3"
- OpName %tint_symbol_7 "tint_symbol_7"
- OpName %tint_symbol "tint_symbol"
+ OpName %main_inner "main_inner"
OpName %main "main"
- OpDecorate %tint_symbol_1 Location 0
- OpDecorate %tint_symbol_2 BuiltIn FragDepth
- OpDecorate %tint_symbol_3 Location 1
- OpDecorate %tint_symbol_4 Location 2
+ OpDecorate %loc0_1 Location 0
+ OpDecorate %frag_depth_1 BuiltIn FragDepth
+ OpDecorate %loc1_1 Location 1
+ OpDecorate %loc2_1 Location 2
OpDecorate %_arr_uint_uint_1 ArrayStride 4
- OpDecorate %tint_symbol_5 BuiltIn SampleMask
- OpDecorate %tint_symbol_6 Location 3
+ OpDecorate %sample_mask_1 BuiltIn SampleMask
+ OpDecorate %loc3_1 Location 3
OpMemberDecorate %FragmentOutputs 0 Offset 0
OpMemberDecorate %FragmentOutputs 1 Offset 4
OpMemberDecorate %FragmentOutputs 2 Offset 8
@@ -40,58 +39,57 @@
%int = OpTypeInt 32 1
%_ptr_Output_int = OpTypePointer Output %int
%4 = OpConstantNull %int
-%tint_symbol_1 = OpVariable %_ptr_Output_int Output %4
+ %loc0_1 = OpVariable %_ptr_Output_int Output %4
%float = OpTypeFloat 32
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
-%tint_symbol_2 = OpVariable %_ptr_Output_float Output %8
+%frag_depth_1 = OpVariable %_ptr_Output_float Output %8
%uint = OpTypeInt 32 0
%_ptr_Output_uint = OpTypePointer Output %uint
%12 = OpConstantNull %uint
-%tint_symbol_3 = OpVariable %_ptr_Output_uint Output %12
-%tint_symbol_4 = OpVariable %_ptr_Output_float Output %8
+ %loc1_1 = OpVariable %_ptr_Output_uint Output %12
+ %loc2_1 = OpVariable %_ptr_Output_float Output %8
%uint_1 = OpConstant %uint 1
%_arr_uint_uint_1 = OpTypeArray %uint %uint_1
%_ptr_Output__arr_uint_uint_1 = OpTypePointer Output %_arr_uint_uint_1
%18 = OpConstantNull %_arr_uint_uint_1
-%tint_symbol_5 = OpVariable %_ptr_Output__arr_uint_uint_1 Output %18
+%sample_mask_1 = OpVariable %_ptr_Output__arr_uint_uint_1 Output %18
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%22 = OpConstantNull %v4float
-%tint_symbol_6 = OpVariable %_ptr_Output_v4float Output %22
- %void = OpTypeVoid
+ %loc3_1 = OpVariable %_ptr_Output_v4float Output %22
%FragmentOutputs = OpTypeStruct %int %float %uint %float %uint %v4float
- %23 = OpTypeFunction %void %FragmentOutputs
- %int_0 = OpConstant %int 0
- %37 = OpTypeFunction %void
+ %23 = OpTypeFunction %FragmentOutputs
%int_1 = OpConstant %int 1
%float_2 = OpConstant %float 2
%float_1 = OpConstant %float 1
%uint_2 = OpConstant %uint 2
%float_3 = OpConstant %float 3
%float_4 = OpConstant %float 4
- %47 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
- %48 = OpConstantComposite %FragmentOutputs %int_1 %float_2 %uint_1 %float_1 %uint_2 %47
-%tint_symbol_7 = OpFunction %void None %23
-%tint_symbol = OpFunctionParameter %FragmentOutputs
- %28 = OpLabel
- %29 = OpCompositeExtract %int %tint_symbol 0
- OpStore %tint_symbol_1 %29
- %30 = OpCompositeExtract %float %tint_symbol 1
- OpStore %tint_symbol_2 %30
- %31 = OpCompositeExtract %uint %tint_symbol 2
- OpStore %tint_symbol_3 %31
- %32 = OpCompositeExtract %float %tint_symbol 3
- OpStore %tint_symbol_4 %32
- %34 = OpAccessChain %_ptr_Output_uint %tint_symbol_5 %int_0
- %35 = OpCompositeExtract %uint %tint_symbol 4
- OpStore %34 %35
- %36 = OpCompositeExtract %v4float %tint_symbol 5
- OpStore %tint_symbol_6 %36
- OpReturn
+ %33 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
+ %34 = OpConstantComposite %FragmentOutputs %int_1 %float_2 %uint_1 %float_1 %uint_2 %33
+ %void = OpTypeVoid
+ %35 = OpTypeFunction %void
+ %int_0 = OpConstant %int 0
+ %main_inner = OpFunction %FragmentOutputs None %23
+ %26 = OpLabel
+ OpReturnValue %34
OpFunctionEnd
- %main = OpFunction %void None %37
- %39 = OpLabel
- %40 = OpFunctionCall %void %tint_symbol_7 %48
+ %main = OpFunction %void None %35
+ %38 = OpLabel
+ %39 = OpFunctionCall %FragmentOutputs %main_inner
+ %40 = OpCompositeExtract %int %39 0
+ OpStore %loc0_1 %40
+ %41 = OpCompositeExtract %float %39 1
+ OpStore %frag_depth_1 %41
+ %42 = OpCompositeExtract %uint %39 2
+ OpStore %loc1_1 %42
+ %43 = OpCompositeExtract %float %39 3
+ OpStore %loc2_1 %43
+ %45 = OpAccessChain %_ptr_Output_uint %sample_mask_1 %int_0
+ %46 = OpCompositeExtract %uint %39 4
+ OpStore %45 %46
+ %47 = OpCompositeExtract %v4float %39 5
+ OpStore %loc3_1 %47
OpReturn
OpFunctionEnd