mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
sanitizers: Use the ZeroInitWorkgroupMemory transform
Zero the workgroup memory for all backends. We can probably disable this for the backends that support workgroup zeroing, but that's an optimization we can perform later. Fixed: tint:280 Change-Id: I9cad919ba3a15b8cedfe6939317d1f6b95425453 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55244 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
groupshared int i;
|
||||
|
||||
struct tint_symbol_1 {
|
||||
uint local_invocation_index : SV_GroupIndex;
|
||||
};
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main() {
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
const uint local_invocation_index = tint_symbol.local_invocation_index;
|
||||
if ((local_invocation_index == 0u)) {
|
||||
i = 0;
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
i = 123;
|
||||
const int use = (i + 1);
|
||||
return;
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include <metal_stdlib>
|
||||
|
||||
using namespace metal;
|
||||
kernel void tint_symbol() {
|
||||
threadgroup int tint_symbol_1 = 0;
|
||||
tint_symbol_1 = 123;
|
||||
int const use = (tint_symbol_1 + 1);
|
||||
kernel void tint_symbol(uint local_invocation_index [[thread_index_in_threadgroup]]) {
|
||||
threadgroup int tint_symbol_2;
|
||||
if ((local_invocation_index == 0u)) {
|
||||
tint_symbol_2 = int();
|
||||
}
|
||||
threadgroup_barrier(mem_flags::mem_threadgroup);
|
||||
tint_symbol_2 = 123;
|
||||
int const use = (tint_symbol_2 + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,44 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 12
|
||||
; Bound: 25
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpEntryPoint GLCompute %main "main" %tint_symbol
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpName %i "i"
|
||||
OpName %tint_symbol "tint_symbol"
|
||||
OpName %main "main"
|
||||
OpDecorate %tint_symbol BuiltIn LocalInvocationIndex
|
||||
%int = OpTypeInt 32 1
|
||||
%_ptr_Workgroup_int = OpTypePointer Workgroup %int
|
||||
%i = OpVariable %_ptr_Workgroup_int Workgroup
|
||||
%uint = OpTypeInt 32 0
|
||||
%_ptr_Input_uint = OpTypePointer Input %uint
|
||||
%tint_symbol = OpVariable %_ptr_Input_uint Input
|
||||
%void = OpTypeVoid
|
||||
%4 = OpTypeFunction %void
|
||||
%7 = OpTypeFunction %void
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%bool = OpTypeBool
|
||||
%17 = OpConstantNull %int
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%uint_264 = OpConstant %uint 264
|
||||
%int_123 = OpConstant %int 123
|
||||
%int_1 = OpConstant %int 1
|
||||
%main = OpFunction %void None %4
|
||||
%7 = OpLabel
|
||||
%main = OpFunction %void None %7
|
||||
%10 = OpLabel
|
||||
%11 = OpLoad %uint %tint_symbol
|
||||
%13 = OpIEqual %bool %11 %uint_0
|
||||
OpSelectionMerge %15 None
|
||||
OpBranchConditional %13 %16 %15
|
||||
%16 = OpLabel
|
||||
OpStore %i %17
|
||||
OpBranch %15
|
||||
%15 = OpLabel
|
||||
OpControlBarrier %uint_2 %uint_2 %uint_264
|
||||
OpStore %i %int_123
|
||||
%9 = OpLoad %int %i
|
||||
%11 = OpIAdd %int %9 %int_1
|
||||
%22 = OpLoad %int %i
|
||||
%24 = OpIAdd %int %22 %int_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
Reference in New Issue
Block a user