mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
writer/spirv: Generate load of atomic value arguments
Fixed: tint:926 Change-Id: Ia27abe605ebfb46a7524b50500ecebd6e4656d1d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55883 Reviewed-by: David Neto <dneto@google.com> Commit-Queue: David Neto <dneto@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
9d3e2acd35
commit
07b59ca230
14
test/bug/tint/926.wgsl
Normal file
14
test/bug/tint/926.wgsl
Normal file
@@ -0,0 +1,14 @@
|
||||
[[block]] struct DrawIndirectArgs {
|
||||
vertexCount : atomic<u32>;
|
||||
};
|
||||
[[group(0), binding(5)]] var<storage, read_write> drawOut : DrawIndirectArgs;
|
||||
|
||||
var<private> cubeVerts : u32 = 0u;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn computeMain([[builtin(global_invocation_id)]] global_id : vec3<u32>) {
|
||||
// Increment cubeVerts based on some criteria...
|
||||
|
||||
// This fails SPIR-V validation
|
||||
let firstVertex : u32 = atomicAdd(&drawOut.vertexCount, cubeVerts);
|
||||
}
|
||||
15
test/bug/tint/926.wgsl.expected.hlsl
Normal file
15
test/bug/tint/926.wgsl.expected.hlsl
Normal file
@@ -0,0 +1,15 @@
|
||||
RWByteAddressBuffer drawOut : register(u5, space0);
|
||||
static uint cubeVerts = 0u;
|
||||
|
||||
struct tint_symbol_1 {
|
||||
uint3 global_id : SV_DispatchThreadID;
|
||||
};
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void computeMain(tint_symbol_1 tint_symbol) {
|
||||
const uint3 global_id = tint_symbol.global_id;
|
||||
uint atomic_result = 0u;
|
||||
drawOut.InterlockedAdd(0u, 0u, atomic_result);
|
||||
const uint firstVertex = atomic_result;
|
||||
return;
|
||||
}
|
||||
17
test/bug/tint/926.wgsl.expected.msl
Normal file
17
test/bug/tint/926.wgsl.expected.msl
Normal file
@@ -0,0 +1,17 @@
|
||||
SKIP: FAILED
|
||||
|
||||
|
||||
[[block]]
|
||||
struct DrawIndirectArgs {
|
||||
vertexCount : atomic<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(5)]] var<storage, read_write> drawOut : DrawIndirectArgs;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn computeMain([[builtin(global_invocation_id)]] global_id : vec3<u32>) {
|
||||
[[internal(disable_validation__function_var_storage_class)]] var<private> tint_symbol_1 : u32 = 0u;
|
||||
let firstVertex : u32 = atomicAdd(&(drawOut.vertexCount), tint_symbol_1);
|
||||
}
|
||||
|
||||
Failed to generate: error: unknown type in EmitType: __atomic__u32
|
||||
41
test/bug/tint/926.wgsl.expected.spvasm
Normal file
41
test/bug/tint/926.wgsl.expected.spvasm
Normal file
@@ -0,0 +1,41 @@
|
||||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 21
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %computeMain "computeMain"
|
||||
OpExecutionMode %computeMain LocalSize 1 1 1
|
||||
OpName %DrawIndirectArgs "DrawIndirectArgs"
|
||||
OpMemberName %DrawIndirectArgs 0 "vertexCount"
|
||||
OpName %drawOut "drawOut"
|
||||
OpName %cubeVerts "cubeVerts"
|
||||
OpName %tint_symbol "tint_symbol"
|
||||
OpName %computeMain "computeMain"
|
||||
OpDecorate %DrawIndirectArgs Block
|
||||
OpMemberDecorate %DrawIndirectArgs 0 Offset 0
|
||||
OpDecorate %drawOut DescriptorSet 0
|
||||
OpDecorate %drawOut Binding 5
|
||||
OpDecorate %tint_symbol BuiltIn GlobalInvocationId
|
||||
%uint = OpTypeInt 32 0
|
||||
%DrawIndirectArgs = OpTypeStruct %uint
|
||||
%_ptr_StorageBuffer_DrawIndirectArgs = OpTypePointer StorageBuffer %DrawIndirectArgs
|
||||
%drawOut = OpVariable %_ptr_StorageBuffer_DrawIndirectArgs StorageBuffer
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_Private_uint = OpTypePointer Private %uint
|
||||
%cubeVerts = OpVariable %_ptr_Private_uint Private %uint_0
|
||||
%v3uint = OpTypeVector %uint 3
|
||||
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
|
||||
%tint_symbol = OpVariable %_ptr_Input_v3uint Input
|
||||
%void = OpTypeVoid
|
||||
%11 = OpTypeFunction %void
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
||||
%computeMain = OpFunction %void None %11
|
||||
%14 = OpLabel
|
||||
%19 = OpAccessChain %_ptr_StorageBuffer_uint %drawOut %uint_0
|
||||
%20 = OpLoad %uint %cubeVerts
|
||||
%15 = OpAtomicIAdd %uint %19 %uint_1 %uint_0 %20
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
13
test/bug/tint/926.wgsl.expected.wgsl
Normal file
13
test/bug/tint/926.wgsl.expected.wgsl
Normal file
@@ -0,0 +1,13 @@
|
||||
[[block]]
|
||||
struct DrawIndirectArgs {
|
||||
vertexCount : atomic<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(5)]] var<storage, read_write> drawOut : DrawIndirectArgs;
|
||||
|
||||
var<private> cubeVerts : u32 = 0u;
|
||||
|
||||
[[stage(compute)]]
|
||||
fn computeMain([[builtin(global_invocation_id)]] global_id : vec3<u32>) {
|
||||
let firstVertex : u32 = atomicAdd(&(drawOut.vertexCount), cubeVerts);
|
||||
}
|
||||
Reference in New Issue
Block a user