mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 02:15:43 +00:00
tint/writer/msl: Generate an array<T,N> helper
And remove the WrapArraysInStructs transform. Wrapping arrays in structures becomes troublesome for `const` arrays, as currently WGSL does not allow `const` structures. MSL 2.0+ has a builtin array<> helper, but we're targetting MSL 1.2, so we have to emit our own. Fortunately, it can be done with a few lines of templated code. This produces significantly cleaner output. Change-Id: Ifc92ef21e09befa252a07c856c4b5afdc51cc2e4 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94540 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
3c054304a8
commit
f47887d207
@@ -0,0 +1,85 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 51
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main" %local_invocation_index_1
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %local_invocation_index_1 "local_invocation_index_1"
|
||||
OpName %zero "zero"
|
||||
OpName %main_inner "main_inner"
|
||||
OpName %local_invocation_index "local_invocation_index"
|
||||
OpName %idx "idx"
|
||||
OpName %v "v"
|
||||
OpName %main "main"
|
||||
OpDecorate %local_invocation_index_1 BuiltIn LocalInvocationIndex
|
||||
OpDecorate %_arr_int_uint_3 ArrayStride 4
|
||||
OpDecorate %_arr__arr_int_uint_3_uint_2 ArrayStride 12
|
||||
%uint = OpTypeInt 32 0
|
||||
%_ptr_Input_uint = OpTypePointer Input %uint
|
||||
%local_invocation_index_1 = OpVariable %_ptr_Input_uint Input
|
||||
%int = OpTypeInt 32 1
|
||||
%uint_3 = OpConstant %uint 3
|
||||
%_arr_int_uint_3 = OpTypeArray %int %uint_3
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%_arr__arr_int_uint_3_uint_2 = OpTypeArray %_arr_int_uint_3 %uint_2
|
||||
%_ptr_Workgroup__arr__arr_int_uint_3_uint_2 = OpTypePointer Workgroup %_arr__arr_int_uint_3_uint_2
|
||||
%zero = OpVariable %_ptr_Workgroup__arr__arr_int_uint_3_uint_2 Workgroup
|
||||
%void = OpTypeVoid
|
||||
%11 = OpTypeFunction %void %uint
|
||||
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||
%18 = OpConstantNull %uint
|
||||
%uint_6 = OpConstant %uint 6
|
||||
%bool = OpTypeBool
|
||||
%_ptr_Workgroup_int = OpTypePointer Workgroup %int
|
||||
%36 = OpConstantNull %int
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%uint_264 = OpConstant %uint 264
|
||||
%_ptr_Function__arr__arr_int_uint_3_uint_2 = OpTypePointer Function %_arr__arr_int_uint_3_uint_2
|
||||
%45 = OpConstantNull %_arr__arr_int_uint_3_uint_2
|
||||
%46 = OpTypeFunction %void
|
||||
%main_inner = OpFunction %void None %11
|
||||
%local_invocation_index = OpFunctionParameter %uint
|
||||
%15 = OpLabel
|
||||
%idx = OpVariable %_ptr_Function_uint Function %18
|
||||
%v = OpVariable %_ptr_Function__arr__arr_int_uint_3_uint_2 Function %45
|
||||
OpStore %idx %local_invocation_index
|
||||
OpBranch %19
|
||||
%19 = OpLabel
|
||||
OpLoopMerge %20 %21 None
|
||||
OpBranch %22
|
||||
%22 = OpLabel
|
||||
%24 = OpLoad %uint %idx
|
||||
%26 = OpULessThan %bool %24 %uint_6
|
||||
%23 = OpLogicalNot %bool %26
|
||||
OpSelectionMerge %28 None
|
||||
OpBranchConditional %23 %29 %28
|
||||
%29 = OpLabel
|
||||
OpBranch %20
|
||||
%28 = OpLabel
|
||||
%30 = OpLoad %uint %idx
|
||||
%31 = OpUDiv %uint %30 %uint_3
|
||||
%32 = OpLoad %uint %idx
|
||||
%33 = OpUMod %uint %32 %uint_3
|
||||
%35 = OpAccessChain %_ptr_Workgroup_int %zero %31 %33
|
||||
OpStore %35 %36
|
||||
OpBranch %21
|
||||
%21 = OpLabel
|
||||
%37 = OpLoad %uint %idx
|
||||
%39 = OpIAdd %uint %37 %uint_1
|
||||
OpStore %idx %39
|
||||
OpBranch %19
|
||||
%20 = OpLabel
|
||||
OpControlBarrier %uint_2 %uint_2 %uint_264
|
||||
%42 = OpLoad %_arr__arr_int_uint_3_uint_2 %zero
|
||||
OpStore %v %42
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main = OpFunction %void None %46
|
||||
%48 = OpLabel
|
||||
%50 = OpLoad %uint %local_invocation_index_1
|
||||
%49 = OpFunctionCall %void %main_inner %50
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
Reference in New Issue
Block a user