From 6c6c6dc2b6aa2739cb3d90ab20881695e9be7d0c Mon Sep 17 00:00:00 2001 From: James Price Date: Fri, 13 Dec 2024 14:04:35 -0800 Subject: [PATCH] [dawn][d3d] Use returned workgroup info for IR path Update Dawn's D3D backends to use the workgroup information returned by the Tint HLSL backend, instead of getting it from the inspector. This is in preparation for moving more transforms into the IR backend. Bug: 380043961 Change-Id: Iceef5f90e5e2a4393a5ec84d37f3a21ed388f1f0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/219474 Reviewed-by: Antonio Maiorano Commit-Queue: James Price --- src/dawn/native/d3d/ShaderUtils.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/dawn/native/d3d/ShaderUtils.cpp b/src/dawn/native/d3d/ShaderUtils.cpp index d0a048b140..a01fc0c64b 100644 --- a/src/dawn/native/d3d/ShaderUtils.cpp +++ b/src/dawn/native/d3d/ShaderUtils.cpp @@ -250,13 +250,6 @@ MaybeError TranslateToHLSL(d3d::HlslCompilationRequest r, &transformOutputs, nullptr)); } - // Validate workgroup size after program runs transforms. - if (r.stage == SingleShaderStage::Compute) { - Extent3D _; - DAWN_TRY_ASSIGN(_, ValidateComputeStageWorkgroupSize(transformedProgram, - kRemappedEntryPointName, r.limits)); - } - bool usesVertexIndex = false; bool usesInstanceIndex = false; if (r.stage == SingleShaderStage::Vertex) { @@ -277,7 +270,25 @@ MaybeError TranslateToHLSL(d3d::HlslCompilationRequest r, ir.Failure().reason.Str()); result = tint::hlsl::writer::Generate(ir.Get(), r.tintOptions); + + // Workgroup validation has to come after `Generate` because it may require overrides to + // have been substituted. + if (r.stage == SingleShaderStage::Compute) { + // Validate workgroup size and workgroup storage size. + Extent3D _; + DAWN_TRY_ASSIGN( + _, ValidateComputeStageWorkgroupSize( + result->workgroup_info.x, result->workgroup_info.y, result->workgroup_info.z, + result->workgroup_info.storage_size, r.limits)); + } } else { + // Validate workgroup size after program runs transforms. + if (r.stage == SingleShaderStage::Compute) { + Extent3D _; + DAWN_TRY_ASSIGN(_, ValidateComputeStageWorkgroupSize( + transformedProgram, kRemappedEntryPointName, r.limits)); + } + result = tint::hlsl::writer::Generate(transformedProgram, r.tintOptions); }