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>
This commit is contained in:
James Price
2021-08-05 17:34:19 +00:00
committed by Tint LUCI CQ
parent 11e172ab64
commit 11c6fcdb51
1981 changed files with 55207 additions and 57171 deletions

View File

@@ -1,221 +1,217 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 141
; Bound: 137
; Schema: 0
OpCapability Shader
%120 = OpExtInstImport "GLSL.std.450"
%116 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vs_main "vs_main" %tint_pointsize %tint_symbol %tint_symbol_2 %tint_symbol_3
OpEntryPoint Fragment %fs_main "fs_main" %tint_symbol_5 %tint_symbol_7
OpEntryPoint Vertex %vs_main "vs_main" %VertexIndex_1 %texcoords_1 %position_1 %vertex_point_size
OpEntryPoint Fragment %fs_main "fs_main" %texcoord_1 %value
OpExecutionMode %fs_main OriginUpperLeft
OpName %tint_pointsize "tint_pointsize"
OpName %VertexIndex_1 "VertexIndex_1"
OpName %texcoords_1 "texcoords_1"
OpName %position_1 "position_1"
OpName %vertex_point_size "vertex_point_size"
OpName %texcoord_1 "texcoord_1"
OpName %value "value"
OpName %Uniforms "Uniforms"
OpMemberName %Uniforms 0 "u_scale"
OpMemberName %Uniforms 1 "u_offset"
OpName %uniforms "uniforms"
OpName %tint_symbol "tint_symbol"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol_3 "tint_symbol_3"
OpName %mySampler "mySampler"
OpName %myTexture "myTexture"
OpName %tint_symbol_5 "tint_symbol_5"
OpName %tint_symbol_7 "tint_symbol_7"
OpName %VertexOutputs "VertexOutputs"
OpMemberName %VertexOutputs 0 "texcoords"
OpMemberName %VertexOutputs 1 "position"
OpName %tint_symbol_4 "tint_symbol_4"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %vs_main "vs_main"
OpName %vs_main_inner "vs_main_inner"
OpName %VertexIndex "VertexIndex"
OpName %texcoord "texcoord"
OpName %output "output"
OpName %flipY "flipY"
OpName %tint_symbol_8 "tint_symbol_8"
OpName %tint_symbol_6 "tint_symbol_6"
OpName %fs_main "fs_main"
OpName %vs_main "vs_main"
OpName %fs_main_inner "fs_main_inner"
OpName %texcoord_0 "texcoord"
OpName %clampedTexcoord "clampedTexcoord"
OpName %srcColor "srcColor"
OpDecorate %tint_pointsize BuiltIn PointSize
OpName %fs_main "fs_main"
OpDecorate %VertexIndex_1 BuiltIn VertexIndex
OpDecorate %texcoords_1 Location 0
OpDecorate %position_1 BuiltIn Position
OpDecorate %vertex_point_size BuiltIn PointSize
OpDecorate %texcoord_1 Location 0
OpDecorate %value Location 0
OpDecorate %Uniforms Block
OpMemberDecorate %Uniforms 0 Offset 0
OpMemberDecorate %Uniforms 1 Offset 8
OpDecorate %uniforms NonWritable
OpDecorate %uniforms Binding 0
OpDecorate %uniforms DescriptorSet 0
OpDecorate %tint_symbol BuiltIn VertexIndex
OpDecorate %tint_symbol_2 Location 0
OpDecorate %tint_symbol_3 BuiltIn Position
OpDecorate %mySampler Binding 1
OpDecorate %mySampler DescriptorSet 0
OpDecorate %myTexture Binding 2
OpDecorate %myTexture DescriptorSet 0
OpDecorate %tint_symbol_5 Location 0
OpDecorate %tint_symbol_7 Location 0
OpMemberDecorate %VertexOutputs 0 Offset 0
OpMemberDecorate %VertexOutputs 1 Offset 16
OpDecorate %_arr_v2float_uint_3 ArrayStride 8
%uint = OpTypeInt 32 0
%_ptr_Input_uint = OpTypePointer Input %uint
%VertexIndex_1 = OpVariable %_ptr_Input_uint Input
%float = OpTypeFloat 32
%_ptr_Output_float = OpTypePointer Output %float
%4 = OpConstantNull %float
%tint_pointsize = OpVariable %_ptr_Output_float Output %4
%v2float = OpTypeVector %float 2
%_ptr_Output_v2float = OpTypePointer Output %v2float
%8 = OpConstantNull %v2float
%texcoords_1 = OpVariable %_ptr_Output_v2float Output %8
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%12 = OpConstantNull %v4float
%position_1 = OpVariable %_ptr_Output_v4float Output %12
%_ptr_Output_float = OpTypePointer Output %float
%15 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %15
%_ptr_Input_v2float = OpTypePointer Input %v2float
%texcoord_1 = OpVariable %_ptr_Input_v2float Input
%value = OpVariable %_ptr_Output_v4float Output %12
%Uniforms = OpTypeStruct %v2float %v2float
%_ptr_Uniform_Uniforms = OpTypePointer Uniform %Uniforms
%uniforms = OpVariable %_ptr_Uniform_Uniforms Uniform
%uint = OpTypeInt 32 0
%_ptr_Input_uint = OpTypePointer Input %uint
%tint_symbol = OpVariable %_ptr_Input_uint Input
%_ptr_Output_v2float = OpTypePointer Output %v2float
%14 = OpConstantNull %v2float
%tint_symbol_2 = OpVariable %_ptr_Output_v2float Output %14
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%18 = OpConstantNull %v4float
%tint_symbol_3 = OpVariable %_ptr_Output_v4float Output %18
%21 = OpTypeSampler
%_ptr_UniformConstant_21 = OpTypePointer UniformConstant %21
%mySampler = OpVariable %_ptr_UniformConstant_21 UniformConstant
%24 = OpTypeImage %float 2D 0 0 0 1 Unknown
%24 = OpTypeSampler
%_ptr_UniformConstant_24 = OpTypePointer UniformConstant %24
%myTexture = OpVariable %_ptr_UniformConstant_24 UniformConstant
%_ptr_Input_v2float = OpTypePointer Input %v2float
%tint_symbol_5 = OpVariable %_ptr_Input_v2float Input
%tint_symbol_7 = OpVariable %_ptr_Output_v4float Output %18
%void = OpTypeVoid
%mySampler = OpVariable %_ptr_UniformConstant_24 UniformConstant
%27 = OpTypeImage %float 2D 0 0 0 1 Unknown
%_ptr_UniformConstant_27 = OpTypePointer UniformConstant %27
%myTexture = OpVariable %_ptr_UniformConstant_27 UniformConstant
%VertexOutputs = OpTypeStruct %v2float %v4float
%28 = OpTypeFunction %void %VertexOutputs
%36 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%28 = OpTypeFunction %VertexOutputs %uint
%uint_3 = OpConstant %uint 3
%_arr_v2float_uint_3 = OpTypeArray %v2float %uint_3
%float_n0_5 = OpConstant %float -0.5
%float_0 = OpConstant %float 0
%44 = OpConstantComposite %v2float %float_n0_5 %float_0
%37 = OpConstantComposite %v2float %float_n0_5 %float_0
%float_1_5 = OpConstant %float 1.5
%46 = OpConstantComposite %v2float %float_1_5 %float_0
%39 = OpConstantComposite %v2float %float_1_5 %float_0
%float_0_5 = OpConstant %float 0.5
%float_2 = OpConstant %float 2
%49 = OpConstantComposite %v2float %float_0_5 %float_2
%50 = OpConstantComposite %_arr_v2float_uint_3 %44 %46 %49
%42 = OpConstantComposite %v2float %float_0_5 %float_2
%43 = OpConstantComposite %_arr_v2float_uint_3 %37 %39 %42
%_ptr_Function__arr_v2float_uint_3 = OpTypePointer Function %_arr_v2float_uint_3
%53 = OpConstantNull %_arr_v2float_uint_3
%46 = OpConstantNull %_arr_v2float_uint_3
%_ptr_Function_VertexOutputs = OpTypePointer Function %VertexOutputs
%56 = OpConstantNull %VertexOutputs
%49 = OpConstantNull %VertexOutputs
%uint_1 = OpConstant %uint 1
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_ptr_Function_v2float = OpTypePointer Function %v2float
%65 = OpConstantComposite %v2float %float_1 %float_1
%float_1 = OpConstant %float 1
%58 = OpConstantComposite %v2float %float_1 %float_1
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_float = OpTypePointer Uniform %float
%bool = OpTypeBool
%_ptr_Function_bool = OpTypePointer Function %bool
%78 = OpConstantNull %bool
%71 = OpConstantNull %bool
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%float_n1 = OpConstant %float -1
%95 = OpConstantComposite %v2float %float_1 %float_n1
%97 = OpConstantComposite %v2float %float_0 %float_1
%113 = OpTypeFunction %void %v4float
%122 = OpConstantComposite %v2float %float_0 %float_0
%87 = OpConstantComposite %v2float %float_1 %float_n1
%89 = OpConstantComposite %v2float %float_0 %float_1
%void = OpTypeVoid
%103 = OpTypeFunction %void
%111 = OpTypeFunction %v4float %v2float
%117 = OpConstantComposite %v2float %float_0 %float_0
%v2bool = OpTypeVector %bool 2
%135 = OpTypeSampledImage %24
%tint_symbol_4 = OpFunction %void None %28
%tint_symbol_1 = OpFunctionParameter %VertexOutputs
%33 = OpLabel
%34 = OpCompositeExtract %v2float %tint_symbol_1 0
OpStore %tint_symbol_2 %34
%35 = OpCompositeExtract %v4float %tint_symbol_1 1
OpStore %tint_symbol_3 %35
%129 = OpTypeSampledImage %27
%vs_main_inner = OpFunction %VertexOutputs None %28
%VertexIndex = OpFunctionParameter %uint
%32 = OpLabel
%texcoord = OpVariable %_ptr_Function__arr_v2float_uint_3 Function %46
%output = OpVariable %_ptr_Function_VertexOutputs Function %49
%flipY = OpVariable %_ptr_Function_bool Function %71
OpStore %texcoord %43
%52 = OpAccessChain %_ptr_Function_v4float %output %uint_1
%54 = OpAccessChain %_ptr_Function_v2float %texcoord %VertexIndex
%55 = OpLoad %v2float %54
%56 = OpVectorTimesScalar %v2float %55 %float_2
%59 = OpFSub %v2float %56 %58
%60 = OpCompositeExtract %float %59 0
%61 = OpCompositeExtract %float %59 1
%62 = OpCompositeConstruct %v4float %60 %61 %float_0 %float_1
OpStore %52 %62
%65 = OpAccessChain %_ptr_Uniform_float %uniforms %uint_0 %uint_1
%66 = OpLoad %float %65
%67 = OpFOrdLessThan %bool %66 %float_0
OpStore %flipY %67
%72 = OpLoad %bool %flipY
OpSelectionMerge %73 None
OpBranchConditional %72 %74 %75
%74 = OpLabel
%76 = OpAccessChain %_ptr_Function_v2float %output %uint_0
%77 = OpAccessChain %_ptr_Function_v2float %texcoord %VertexIndex
%78 = OpLoad %v2float %77
%80 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_0
%81 = OpLoad %v2float %80
%82 = OpFMul %v2float %78 %81
%83 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_1
%84 = OpLoad %v2float %83
%85 = OpFAdd %v2float %82 %84
%88 = OpFMul %v2float %85 %87
%90 = OpFAdd %v2float %88 %89
OpStore %76 %90
OpBranch %73
%75 = OpLabel
%91 = OpAccessChain %_ptr_Function_v2float %output %uint_0
%92 = OpAccessChain %_ptr_Function_v2float %texcoord %VertexIndex
%93 = OpLoad %v2float %92
%94 = OpFMul %v2float %93 %87
%95 = OpFAdd %v2float %94 %89
%96 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_0
%97 = OpLoad %v2float %96
%98 = OpFMul %v2float %95 %97
%99 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_1
%100 = OpLoad %v2float %99
%101 = OpFAdd %v2float %98 %100
OpStore %91 %101
OpBranch %73
%73 = OpLabel
%102 = OpLoad %VertexOutputs %output
OpReturnValue %102
OpFunctionEnd
%vs_main = OpFunction %void None %103
%106 = OpLabel
%108 = OpLoad %uint %VertexIndex_1
%107 = OpFunctionCall %VertexOutputs %vs_main_inner %108
%109 = OpCompositeExtract %v2float %107 0
OpStore %texcoords_1 %109
%110 = OpCompositeExtract %v4float %107 1
OpStore %position_1 %110
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%vs_main = OpFunction %void None %36
%38 = OpLabel
%texcoord = OpVariable %_ptr_Function__arr_v2float_uint_3 Function %53
%output = OpVariable %_ptr_Function_VertexOutputs Function %56
%flipY = OpVariable %_ptr_Function_bool Function %78
OpStore %tint_pointsize %float_1
OpStore %texcoord %50
%59 = OpAccessChain %_ptr_Function_v4float %output %uint_1
%60 = OpLoad %uint %tint_symbol
%62 = OpAccessChain %_ptr_Function_v2float %texcoord %60
%63 = OpLoad %v2float %62
%64 = OpVectorTimesScalar %v2float %63 %float_2
%66 = OpFSub %v2float %64 %65
%67 = OpCompositeExtract %float %66 0
%68 = OpCompositeExtract %float %66 1
%69 = OpCompositeConstruct %v4float %67 %68 %float_0 %float_1
OpStore %59 %69
%72 = OpAccessChain %_ptr_Uniform_float %uniforms %uint_0 %uint_1
%73 = OpLoad %float %72
%74 = OpFOrdLessThan %bool %73 %float_0
OpStore %flipY %74
%79 = OpLoad %bool %flipY
OpSelectionMerge %80 None
OpBranchConditional %79 %81 %82
%81 = OpLabel
%83 = OpAccessChain %_ptr_Function_v2float %output %uint_0
%84 = OpLoad %uint %tint_symbol
%85 = OpAccessChain %_ptr_Function_v2float %texcoord %84
%86 = OpLoad %v2float %85
%88 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_0
%89 = OpLoad %v2float %88
%90 = OpFMul %v2float %86 %89
%91 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_1
%92 = OpLoad %v2float %91
%93 = OpFAdd %v2float %90 %92
%96 = OpFMul %v2float %93 %95
%98 = OpFAdd %v2float %96 %97
OpStore %83 %98
OpBranch %80
%82 = OpLabel
%99 = OpAccessChain %_ptr_Function_v2float %output %uint_0
%100 = OpLoad %uint %tint_symbol
%101 = OpAccessChain %_ptr_Function_v2float %texcoord %100
%102 = OpLoad %v2float %101
%103 = OpFMul %v2float %102 %95
%104 = OpFAdd %v2float %103 %97
%105 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_0
%106 = OpLoad %v2float %105
%107 = OpFMul %v2float %104 %106
%108 = OpAccessChain %_ptr_Uniform_v2float %uniforms %uint_1
%109 = OpLoad %v2float %108
%110 = OpFAdd %v2float %107 %109
OpStore %99 %110
OpBranch %80
%80 = OpLabel
%112 = OpLoad %VertexOutputs %output
%111 = OpFunctionCall %void %tint_symbol_4 %112
OpReturn
OpFunctionEnd
%tint_symbol_8 = OpFunction %void None %113
%tint_symbol_6 = OpFunctionParameter %v4float
%116 = OpLabel
OpStore %tint_symbol_7 %tint_symbol_6
OpReturn
OpFunctionEnd
%fs_main = OpFunction %void None %36
%118 = OpLabel
%clampedTexcoord = OpVariable %_ptr_Function_v2float Function %14
%srcColor = OpVariable %_ptr_Function_v4float Function %18
%121 = OpLoad %v2float %tint_symbol_5
%119 = OpExtInst %v2float %120 NClamp %121 %122 %65
OpStore %clampedTexcoord %119
%126 = OpLoad %v2float %clampedTexcoord
%127 = OpLoad %v2float %tint_symbol_5
%128 = OpFOrdEqual %v2bool %126 %127
%125 = OpAll %bool %128
%124 = OpLogicalNot %bool %125
OpSelectionMerge %130 None
OpBranchConditional %124 %131 %130
%131 = OpLabel
%fs_main_inner = OpFunction %v4float None %111
%texcoord_0 = OpFunctionParameter %v2float
%114 = OpLabel
%clampedTexcoord = OpVariable %_ptr_Function_v2float Function %8
%srcColor = OpVariable %_ptr_Function_v4float Function %12
%115 = OpExtInst %v2float %116 NClamp %texcoord_0 %117 %58
OpStore %clampedTexcoord %115
%121 = OpLoad %v2float %clampedTexcoord
%122 = OpFOrdEqual %v2bool %121 %texcoord_0
%120 = OpAll %bool %122
%119 = OpLogicalNot %bool %120
OpSelectionMerge %124 None
OpBranchConditional %119 %125 %124
%125 = OpLabel
OpKill
%130 = OpLabel
%133 = OpLoad %21 %mySampler
%134 = OpLoad %24 %myTexture
%136 = OpSampledImage %135 %134 %133
%137 = OpLoad %v2float %tint_symbol_5
%132 = OpImageSampleImplicitLod %v4float %136 %137
OpStore %srcColor %132
%140 = OpLoad %v4float %srcColor
%139 = OpFunctionCall %void %tint_symbol_8 %140
%124 = OpLabel
%127 = OpLoad %24 %mySampler
%128 = OpLoad %27 %myTexture
%130 = OpSampledImage %129 %128 %127
%126 = OpImageSampleImplicitLod %v4float %130 %texcoord_0
OpStore %srcColor %126
%132 = OpLoad %v4float %srcColor
OpReturnValue %132
OpFunctionEnd
%fs_main = OpFunction %void None %103
%134 = OpLabel
%136 = OpLoad %v2float %texcoord_1
%135 = OpFunctionCall %v4float %fs_main_inner %136
OpStore %value %135
OpReturn
OpFunctionEnd