mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-16 12:21:35 +00:00
The continuing block can exit the loop in very constrained ways: When a break statement is placed such that it would exit from a loop’s § 7.3.8 Continuing Statement, then: - The break statement must appear as either: - The only statement in the if clause of an if statement that has: - no else clause or an empty else clause - no elseif clauses - The only statement in the else clause of an if statement that has an empty if clause and no elseif clauses. - That if statement must appear last in the continuing clause. By design, this allows a lossless round-trip from SPIR-V to WGSL and back to SPIR-V. But that requires this special case construct in WGSL to be translated to an OpBranchConditional with one target being the loop's megre block (which is where 'break' branches to), and the other targets the loop header (which is the loop backedge). That OpBranchConditional takes the place of the normal case of an unconditional backedge. Avoids errors like this: continue construct with the continue target X is not post dominated by the back-edge block Y Fixed: 1034 Change-Id: If472a179380b8d77af746a3cd8e279c8a5e56b37 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59800 Auto-Submit: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: David Neto <dneto@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
166 lines
6.3 KiB
Plaintext
166 lines
6.3 KiB
Plaintext
; SPIR-V
|
|
; Version: 1.3
|
|
; Generator: Google Tint Compiler; 0
|
|
; Bound: 99
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint Fragment %main "main" %tint_symbol_1
|
|
OpExecutionMode %main OriginUpperLeft
|
|
OpName %x_GLF_global_loop_count "x_GLF_global_loop_count"
|
|
OpName %buf0 "buf0"
|
|
OpMemberName %buf0 0 "x_GLF_uniform_int_values"
|
|
OpName %x_7 "x_7"
|
|
OpName %x_GLF_color "x_GLF_color"
|
|
OpName %tint_symbol_1 "tint_symbol_1"
|
|
OpName %func_ "func_"
|
|
OpName %main_1 "main_1"
|
|
OpName %a "a"
|
|
OpName %main_out "main_out"
|
|
OpMemberName %main_out 0 "x_GLF_color_1"
|
|
OpName %tint_symbol_2 "tint_symbol_2"
|
|
OpName %tint_symbol "tint_symbol"
|
|
OpName %main "main"
|
|
OpDecorate %buf0 Block
|
|
OpMemberDecorate %buf0 0 Offset 0
|
|
OpDecorate %_arr_int_uint_3 ArrayStride 16
|
|
OpDecorate %x_7 NonWritable
|
|
OpDecorate %x_7 DescriptorSet 0
|
|
OpDecorate %x_7 Binding 0
|
|
OpDecorate %tint_symbol_1 Location 0
|
|
OpMemberDecorate %main_out 0 Offset 0
|
|
%int = OpTypeInt 32 1
|
|
%_ptr_Private_int = OpTypePointer Private %int
|
|
%4 = OpConstantNull %int
|
|
%x_GLF_global_loop_count = OpVariable %_ptr_Private_int Private %4
|
|
%uint = OpTypeInt 32 0
|
|
%uint_3 = OpConstant %uint 3
|
|
%_arr_int_uint_3 = OpTypeArray %int %uint_3
|
|
%buf0 = OpTypeStruct %_arr_int_uint_3
|
|
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
|
|
%x_7 = OpVariable %_ptr_Uniform_buf0 Uniform
|
|
%float = OpTypeFloat 32
|
|
%v4float = OpTypeVector %float 4
|
|
%_ptr_Private_v4float = OpTypePointer Private %v4float
|
|
%15 = OpConstantNull %v4float
|
|
%x_GLF_color = OpVariable %_ptr_Private_v4float Private %15
|
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
|
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %15
|
|
%18 = OpTypeFunction %int
|
|
%int_100 = OpConstant %int 100
|
|
%bool = OpTypeBool
|
|
%int_1 = OpConstant %int 1
|
|
%uint_0 = OpConstant %uint 0
|
|
%int_0 = OpConstant %int 0
|
|
%_ptr_Uniform_int = OpTypePointer Uniform %int
|
|
%int_2 = OpConstant %int 2
|
|
%void = OpTypeVoid
|
|
%43 = OpTypeFunction %void
|
|
%_ptr_Function_int = OpTypePointer Function %int
|
|
%false = OpConstantFalse %bool
|
|
%true = OpConstantTrue %bool
|
|
%main_out = OpTypeStruct %v4float
|
|
%87 = OpTypeFunction %void %main_out
|
|
%func_ = OpFunction %int None %18
|
|
%20 = OpLabel
|
|
OpBranch %21
|
|
%21 = OpLabel
|
|
OpLoopMerge %22 %23 None
|
|
OpBranch %24
|
|
%24 = OpLabel
|
|
%25 = OpLoad %int %x_GLF_global_loop_count
|
|
%27 = OpSLessThan %bool %25 %int_100
|
|
OpSelectionMerge %29 None
|
|
OpBranchConditional %27 %30 %31
|
|
%30 = OpLabel
|
|
OpBranch %29
|
|
%31 = OpLabel
|
|
OpBranch %22
|
|
%29 = OpLabel
|
|
%32 = OpLoad %int %x_GLF_global_loop_count
|
|
%34 = OpIAdd %int %32 %int_1
|
|
OpStore %x_GLF_global_loop_count %34
|
|
%38 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_0
|
|
%39 = OpLoad %int %38
|
|
OpReturnValue %39
|
|
%23 = OpLabel
|
|
OpBranch %21
|
|
%22 = OpLabel
|
|
%41 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_2
|
|
%42 = OpLoad %int %41
|
|
OpReturnValue %42
|
|
OpFunctionEnd
|
|
%main_1 = OpFunction %void None %43
|
|
%46 = OpLabel
|
|
%a = OpVariable %_ptr_Function_int Function %4
|
|
OpStore %x_GLF_global_loop_count %int_0
|
|
OpBranch %49
|
|
%49 = OpLabel
|
|
OpLoopMerge %50 %51 None
|
|
OpBranch %52
|
|
%52 = OpLabel
|
|
%53 = OpLoad %int %x_GLF_global_loop_count
|
|
%54 = OpIAdd %int %53 %int_1
|
|
OpStore %x_GLF_global_loop_count %54
|
|
OpSelectionMerge %56 None
|
|
OpBranchConditional %false %57 %56
|
|
%57 = OpLabel
|
|
OpReturn
|
|
%56 = OpLabel
|
|
OpBranch %51
|
|
%51 = OpLabel
|
|
%58 = OpLoad %int %x_GLF_global_loop_count
|
|
%60 = OpSLessThan %bool %58 %int_100
|
|
%61 = OpLogicalAnd %bool %true %60
|
|
OpBranchConditional %61 %49 %50
|
|
%50 = OpLabel
|
|
%62 = OpFunctionCall %int %func_
|
|
OpStore %a %62
|
|
%63 = OpLoad %int %a
|
|
%64 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_2
|
|
%65 = OpLoad %int %64
|
|
%66 = OpIEqual %bool %63 %65
|
|
OpSelectionMerge %67 None
|
|
OpBranchConditional %66 %68 %69
|
|
%68 = OpLabel
|
|
%70 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_0
|
|
%71 = OpLoad %int %70
|
|
%72 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_1
|
|
%73 = OpLoad %int %72
|
|
%74 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_1
|
|
%75 = OpLoad %int %74
|
|
%76 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_0
|
|
%77 = OpLoad %int %76
|
|
%78 = OpConvertSToF %float %71
|
|
%79 = OpConvertSToF %float %73
|
|
%80 = OpConvertSToF %float %75
|
|
%81 = OpConvertSToF %float %77
|
|
%82 = OpCompositeConstruct %v4float %78 %79 %80 %81
|
|
OpStore %x_GLF_color %82
|
|
OpBranch %67
|
|
%69 = OpLabel
|
|
%83 = OpAccessChain %_ptr_Uniform_int %x_7 %uint_0 %int_1
|
|
%84 = OpLoad %int %83
|
|
%85 = OpConvertSToF %float %84
|
|
%86 = OpCompositeConstruct %v4float %85 %85 %85 %85
|
|
OpStore %x_GLF_color %86
|
|
OpBranch %67
|
|
%67 = OpLabel
|
|
OpReturn
|
|
OpFunctionEnd
|
|
%tint_symbol_2 = OpFunction %void None %87
|
|
%tint_symbol = OpFunctionParameter %main_out
|
|
%91 = OpLabel
|
|
%92 = OpCompositeExtract %v4float %tint_symbol 0
|
|
OpStore %tint_symbol_1 %92
|
|
OpReturn
|
|
OpFunctionEnd
|
|
%main = OpFunction %void None %43
|
|
%94 = OpLabel
|
|
%95 = OpFunctionCall %void %main_1
|
|
%97 = OpLoad %v4float %x_GLF_color
|
|
%98 = OpCompositeConstruct %main_out %97
|
|
%96 = OpFunctionCall %void %tint_symbol_2 %98
|
|
OpReturn
|
|
OpFunctionEnd
|