[hlsl][ir] Remove the `use_tint_ir` flag from the HLSL backend
Use the IR path unconditionally in the HLSL backend.
Bug: 421916945
Change-Id: I4806e6b5c0185b8c52566448fd67f4483b4ae082
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/248294
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/dawn/native/ProgrammableEncoder.cpp b/src/dawn/native/ProgrammableEncoder.cpp
index 9a4ea58..e5a61ec 100644
--- a/src/dawn/native/ProgrammableEncoder.cpp
+++ b/src/dawn/native/ProgrammableEncoder.cpp
@@ -137,14 +137,6 @@
DAWN_INVALID_IF(size > maxImmediateSize - offset,
"offset (%u) + size (%u): is larger than maxImmediateSize (%u).",
offset, size, maxImmediateSize);
- if (GetDevice()->GetPhysicalDevice()->GetBackendType() ==
- wgpu::BackendType::D3D11 ||
- GetDevice()->GetPhysicalDevice()->GetBackendType() ==
- wgpu::BackendType::D3D12) {
- const bool useTintIR = GetDevice()->IsToggleEnabled(Toggle::UseTintIR);
- DAWN_INVALID_IF(!useTintIR,
- "SetImmediateData should not be used without tint ir.");
- }
}
// Skip SetImmediateData when uploading constants are empty.
diff --git a/src/dawn/native/d3d/D3DCompilationRequest.h b/src/dawn/native/d3d/D3DCompilationRequest.h
index bd3c8b9..1e3bcd0 100644
--- a/src/dawn/native/d3d/D3DCompilationRequest.h
+++ b/src/dawn/native/d3d/D3DCompilationRequest.h
@@ -79,8 +79,7 @@
X(UnsafeUnserializedValue<LimitsForCompilationRequest>, adapterSupportedLimits) \
X(uint32_t, maxSubgroupSize) \
X(bool, disableSymbolRenaming) \
- X(bool, dumpShaders) \
- X(bool, useTintIR)
+ X(bool, dumpShaders)
#define D3D_BYTECODE_COMPILATION_REQUEST_MEMBERS(X) \
X(bool, hasShaderF16Feature) \
diff --git a/src/dawn/native/d3d/ShaderUtils.cpp b/src/dawn/native/d3d/ShaderUtils.cpp
index 10ad37b..3724664 100644
--- a/src/dawn/native/d3d/ShaderUtils.cpp
+++ b/src/dawn/native/d3d/ShaderUtils.cpp
@@ -47,24 +47,6 @@
namespace {
-ResultOrError<tint::Program> RunTransforms(tint::ast::transform::Manager* transformManager,
- const tint::Program* program,
- const tint::ast::transform::DataMap& inputs,
- tint::ast::transform::DataMap* outputs,
- ParsedCompilationMessages* outMessages) {
- DAWN_ASSERT(program != nullptr);
- tint::ast::transform::DataMap transform_outputs;
- tint::Program result = transformManager->Run(*program, inputs, transform_outputs);
- if (outMessages != nullptr) {
- DAWN_TRY(outMessages->AddMessages(result.Diagnostics()));
- }
- DAWN_INVALID_IF(!result.IsValid(), "Tint program failure: %s\n", result.Diagnostics().Str());
- if (outputs != nullptr) {
- *outputs = std::move(transform_outputs);
- }
- return std::move(result);
-}
-
// Be careful that the return vector may contain the pointers that point to non-static memory.
std::vector<const wchar_t*> GetDXCArguments(std::wstring_view entryPointNameW,
const d3d::D3DBytecodeCompilationRequest& r) {
@@ -230,139 +212,74 @@
MaybeError TranslateToHLSL(d3d::HlslCompilationRequest r,
UnsafeUnserializedValue<dawn::platform::Platform*> tracePlatform,
CompiledShader* compiledShader) {
- tint::ast::transform::Manager transformManager;
- tint::ast::transform::DataMap transformInputs;
-
- // Run before the renamer so that the entry point name matches `entryPointName` still.
- transformManager.Add<tint::ast::transform::SingleEntryPoint>();
- transformInputs.Add<tint::ast::transform::SingleEntryPoint::Config>(r.entryPointName.data());
-
- if (r.useTintIR) {
- r.tintOptions.strip_all_names = !r.disableSymbolRenaming;
- } else {
- // Needs to run before all other transforms so that they can use builtin names safely.
- tint::ast::transform::Renamer::Remappings requestedNames = {
- {std::string(r.entryPointName), r.tintOptions.remapped_entry_point_name}};
- transformManager.Add<tint::ast::transform::Renamer>();
- transformInputs.Add<tint::ast::transform::Renamer::Config>(
- r.disableSymbolRenaming ? tint::ast::transform::Renamer::Target::kHlslKeywords
- : tint::ast::transform::Renamer::Target::kAll,
- std::move(requestedNames));
- }
-
- if (!r.useTintIR && r.stage == SingleShaderStage::Vertex) {
- transformManager.Add<tint::ast::transform::FirstIndexOffset>();
- transformInputs.Add<tint::ast::transform::FirstIndexOffset::BindingPoint>(
- r.firstIndexOffsetShaderRegister, r.firstIndexOffsetRegisterSpace);
- }
-
- if (!r.useTintIR) {
- tint::ast::transform::SubstituteOverride::Config cfg;
- cfg.map = std::move(r.substituteOverrideConfig);
-
- // This needs to run after SingleEntryPoint transform which removes unused overrides for
- // current entry point.
- transformManager.Add<tint::ast::transform::SubstituteOverride>();
- transformInputs.Add<tint::ast::transform::SubstituteOverride::Config>(cfg);
- }
-
- // Requires Tint Program here right before actual using.
- auto inputProgram = r.inputProgram.UnsafeGetValue()->GetTintProgram();
- const tint::Program* tintInputProgram = &(inputProgram->program);
- tint::Program transformedProgram;
- tint::ast::transform::DataMap transformOutputs;
- if (!r.useTintIR) {
- TRACE_EVENT0(tracePlatform.UnsafeGetValue(), General, "RunTransforms");
- DAWN_TRY_ASSIGN(transformedProgram,
- RunTransforms(&transformManager, tintInputProgram, transformInputs,
- &transformOutputs, nullptr));
- }
-
- bool usesVertexIndex = false;
- bool usesInstanceIndex = false;
- if (!r.useTintIR && r.stage == SingleShaderStage::Vertex) {
- if (auto* data = transformOutputs.Get<tint::ast::transform::FirstIndexOffset::Data>()) {
- usesVertexIndex = data->has_vertex_index;
- usesInstanceIndex = data->has_instance_index;
- } else {
- return DAWN_VALIDATION_ERROR("Transform output missing first index offset data.");
- }
- }
+ r.tintOptions.strip_all_names = !r.disableSymbolRenaming;
TRACE_EVENT0(tracePlatform.UnsafeGetValue(), General, "tint::hlsl::writer::Generate");
+
+ // Convert the AST program to an IR module.
+ tint::Result<tint::core::ir::Module> ir;
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
+ "ShaderModuleProgramToIR");
+
+ // Requires Tint Program here right before actual using.
+ auto inputProgram = r.inputProgram.UnsafeGetValue()->GetTintProgram();
+ const tint::Program* tintInputProgram = &(inputProgram->program);
+
+ ir = tint::wgsl::reader::ProgramToLoweredIR(*tintInputProgram);
+ DAWN_INVALID_IF(ir != tint::Success, "An error occurred while generating Tint IR\n%s",
+ ir.Failure().reason);
+ }
+
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
+ "ShaderModuleSingleEntryPoint");
+ auto singleEntryPointResult =
+ tint::core::ir::transform::SingleEntryPoint(ir.Get(), r.entryPointName);
+ DAWN_INVALID_IF(singleEntryPointResult != tint::Success,
+ "Pipeline single entry point (IR) failed:\n%s",
+ singleEntryPointResult.Failure().reason);
+ }
+
+ // this needs to run after SingleEntryPoint transform which removes unused
+ // overrides for the current entry point.
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
+ "ShaderModuleSubstituteOverrides");
+ tint::core::ir::transform::SubstituteOverridesConfig cfg;
+ cfg.map = std::move(r.substituteOverrideConfig);
+ auto substituteOverridesResult =
+ tint::core::ir::transform::SubstituteOverrides(ir.Get(), cfg);
+
+ DAWN_INVALID_IF(substituteOverridesResult != tint::Success,
+ "Pipeline override substitution (IR) failed:\n%s",
+ substituteOverridesResult.Failure().reason);
+ }
+
tint::Result<tint::hlsl::writer::Output> result;
- if (r.useTintIR) {
- // Convert the AST program to an IR module.
- tint::Result<tint::core::ir::Module> ir;
- {
- SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
- "ShaderModuleProgramToIR");
- ir = tint::wgsl::reader::ProgramToLoweredIR(*tintInputProgram);
- DAWN_INVALID_IF(ir != tint::Success, "An error occurred while generating Tint IR\n%s",
- ir.Failure().reason);
- }
-
- {
- SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
- "ShaderModuleSingleEntryPoint");
- auto singleEntryPointResult =
- tint::core::ir::transform::SingleEntryPoint(ir.Get(), r.entryPointName);
- DAWN_INVALID_IF(singleEntryPointResult != tint::Success,
- "Pipeline single entry point (IR) failed:\n%s",
- singleEntryPointResult.Failure().reason);
- }
-
- // this needs to run after SingleEntryPoint transform which removes unused
- // overrides for the current entry point.
- {
- SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
- "ShaderModuleSubstituteOverrides");
- tint::core::ir::transform::SubstituteOverridesConfig cfg;
- cfg.map = std::move(r.substituteOverrideConfig);
- auto substituteOverridesResult =
- tint::core::ir::transform::SubstituteOverrides(ir.Get(), cfg);
-
- DAWN_INVALID_IF(substituteOverridesResult != tint::Success,
- "Pipeline override substitution (IR) failed:\n%s",
- substituteOverridesResult.Failure().reason);
- }
-
- {
- SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
- "ShaderModuleGenerateHLSL");
- result = tint::hlsl::writer::Generate(ir.Get(), r.tintOptions);
- DAWN_INVALID_IF(result != tint::Success, "An error occurred while generating HLSL:\n%s",
- result.Failure().reason);
- }
-
- // 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, /* usesSubgroupMatrix */ false,
- r.maxSubgroupSize, r.limits, r.adapterSupportedLimits.UnsafeGetValue()));
- }
- } else {
- // Validate workgroup size after program runs transforms.
- if (r.stage == SingleShaderStage::Compute) {
- Extent3D _;
- DAWN_TRY_ASSIGN(_,
- ValidateComputeStageWorkgroupSize(
- transformedProgram, r.tintOptions.remapped_entry_point_name.c_str(),
- /* usesSubgroupMatrix */ false, r.maxSubgroupSize, r.limits,
- r.adapterSupportedLimits.UnsafeGetValue()));
- }
-
- result = tint::hlsl::writer::Generate(transformedProgram, r.tintOptions);
+ {
+ SCOPED_DAWN_HISTOGRAM_TIMER_MICROS(tracePlatform.UnsafeGetValue(),
+ "ShaderModuleGenerateHLSL");
+ result = tint::hlsl::writer::Generate(ir.Get(), r.tintOptions);
DAWN_INVALID_IF(result != tint::Success, "An error occurred while generating HLSL:\n%s",
result.Failure().reason);
}
- if (r.useTintIR && r.stage == SingleShaderStage::Vertex) {
+ // 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, /* usesSubgroupMatrix */ false,
+ r.maxSubgroupSize, r.limits, r.adapterSupportedLimits.UnsafeGetValue()));
+ }
+
+ bool usesVertexIndex = false;
+ bool usesInstanceIndex = false;
+ if (r.stage == SingleShaderStage::Vertex) {
usesVertexIndex = result->has_vertex_index;
usesInstanceIndex = result->has_instance_index;
}
diff --git a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp
index 210dafb..070ecbc 100644
--- a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp
+++ b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp
@@ -339,10 +339,6 @@
deviceToggles->Default(Toggle::ClearColorWithDraw, true);
}
- // Use the Tint IR backend by default if the corresponding platform feature is enabled.
- deviceToggles->Default(Toggle::UseTintIR,
- platform->IsFeatureEnabled(platform::Features::kWebGPUUseTintIR));
-
// Enable the integer range analysis for shader robustness by default if the corresponding
// platform feature is enabled.
deviceToggles->Default(
diff --git a/src/dawn/native/d3d11/ShaderModuleD3D11.cpp b/src/dawn/native/d3d11/ShaderModuleD3D11.cpp
index 3da7465..8ef732d 100644
--- a/src/dawn/native/d3d11/ShaderModuleD3D11.cpp
+++ b/src/dawn/native/d3d11/ShaderModuleD3D11.cpp
@@ -86,14 +86,12 @@
DAWN_ASSERT(!IsError());
const EntryPointMetadata& entryPoint = GetEntryPoint(programmableStage.entryPoint);
- const bool useTintIR = device->IsToggleEnabled(Toggle::UseTintIR);
d3d::D3DCompilationRequest req = {};
req.tracePlatform = UnsafeUnserializedValue(device->GetPlatform());
req.hlsl.shaderModel = 50;
req.hlsl.disableSymbolRenaming = device->IsToggleEnabled(Toggle::DisableSymbolRenaming);
req.hlsl.dumpShaders = device->IsToggleEnabled(Toggle::DumpShaders);
- req.hlsl.useTintIR = useTintIR;
req.hlsl.tintOptions.remapped_entry_point_name = device->GetIsolatedEntryPointName();
req.bytecode.hasShaderF16Feature = false;
@@ -193,37 +191,6 @@
req.hlsl.inputProgram = UnsafeUnserializedValue(UseTintProgram());
req.hlsl.entryPointName = programmableStage.entryPoint.c_str();
req.hlsl.stage = stage;
-
- if (!useTintIR) {
- if (stage == SingleShaderStage::Vertex) {
- // Put the firstIndex into the internally reserved group and binding to avoid
- // conflicting with any existing bindings.
- req.hlsl.firstIndexOffsetRegisterSpace =
- PipelineLayout::kReservedConstantsBindGroupIndex;
- req.hlsl.firstIndexOffsetShaderRegister =
- PipelineLayout::kFirstIndexOffsetBindingNumber;
- // Remap to the desired space and binding, [0, kFirstIndexOffsetConstantBufferSlot].
- {
- tint::BindingPoint srcBindingPoint{req.hlsl.firstIndexOffsetRegisterSpace,
- req.hlsl.firstIndexOffsetShaderRegister};
- // D3D11 (HLSL SM5.0) doesn't support spaces, so we have to put the firstIndex in
- // the default space(0)
- tint::BindingPoint dstBindingPoint{
- 0u, PipelineLayout::kFirstIndexOffsetConstantBufferSlot};
-
- bindings.uniform.emplace(
- srcBindingPoint, tint::hlsl::writer::binding::Uniform{dstBindingPoint.group,
- dstBindingPoint.binding});
- }
- }
-
- if (entryPoint.usesNumWorkgroups) {
- DAWN_ASSERT(stage == SingleShaderStage::Compute);
- req.hlsl.tintOptions.root_constant_binding_point =
- tint::BindingPoint{0, PipelineLayout::kNumWorkgroupsConstantBufferSlot};
- }
- }
-
req.hlsl.substituteOverrideConfig = BuildSubstituteOverridesTransformConfig(programmableStage);
req.hlsl.limits = LimitsForCompilationRequest::Create(device->GetLimits().v1);
req.hlsl.adapterSupportedLimits = UnsafeUnserializedValue(
@@ -237,20 +204,16 @@
req.hlsl.tintOptions.scalarize_max_min_clamp =
device->IsToggleEnabled(Toggle::ScalarizeMaxMinClamp);
- // Immediate data available in TintIR only.
- if (useTintIR) {
- req.hlsl.tintOptions.immediate_binding_point =
- tint::BindingPoint{0, PipelineLayout::kReservedConstantBufferSlot};
- if (stage == SingleShaderStage::Compute) {
- req.hlsl.tintOptions.num_workgroups_start_offset =
- GetImmediateByteOffsetInPipelineIfAny(&ComputeImmediateConstants::numWorkgroups,
- pipelineImmediateMask);
- } else {
- req.hlsl.tintOptions.first_index_offset = GetImmediateByteOffsetInPipelineIfAny(
- &RenderImmediateConstants::firstVertex, pipelineImmediateMask);
- req.hlsl.tintOptions.first_instance_offset = GetImmediateByteOffsetInPipelineIfAny(
- &RenderImmediateConstants::firstInstance, pipelineImmediateMask);
- }
+ req.hlsl.tintOptions.immediate_binding_point =
+ tint::BindingPoint{0, PipelineLayout::kReservedConstantBufferSlot};
+ if (stage == SingleShaderStage::Compute) {
+ req.hlsl.tintOptions.num_workgroups_start_offset = GetImmediateByteOffsetInPipelineIfAny(
+ &ComputeImmediateConstants::numWorkgroups, pipelineImmediateMask);
+ } else {
+ req.hlsl.tintOptions.first_index_offset = GetImmediateByteOffsetInPipelineIfAny(
+ &RenderImmediateConstants::firstVertex, pipelineImmediateMask);
+ req.hlsl.tintOptions.first_instance_offset = GetImmediateByteOffsetInPipelineIfAny(
+ &RenderImmediateConstants::firstInstance, pipelineImmediateMask);
}
if (stage == SingleShaderStage::Vertex) {
diff --git a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
index e8a8e03..f9083d9 100644
--- a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
+++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
@@ -832,10 +832,6 @@
deviceToggles->Default(Toggle::UsePackedDepth24UnormStencil8Format, true);
}
- // Use the Tint IR backend by default if the corresponding platform feature is enabled.
- deviceToggles->Default(Toggle::UseTintIR,
- platform->IsFeatureEnabled(platform::Features::kWebGPUUseTintIR));
-
// Enable the integer range analysis for shader robustness by default if the corresponding
// platform feature is enabled.
deviceToggles->Default(
diff --git a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
index 84a0b8d..9a9eac2 100644
--- a/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
+++ b/src/dawn/native/d3d12/ShaderModuleD3D12.cpp
@@ -128,7 +128,6 @@
DAWN_ASSERT(!IsError());
const EntryPointMetadata& entryPoint = GetEntryPoint(programmableStage.entryPoint);
- const bool useTintIR = device->IsToggleEnabled(Toggle::UseTintIR);
d3d::D3DCompilationRequest req = {};
req.tracePlatform = UnsafeUnserializedValue(device->GetPlatform());
@@ -136,7 +135,6 @@
->GetAppliedShaderModelUnderToggles(device->GetTogglesState());
req.hlsl.disableSymbolRenaming = device->IsToggleEnabled(Toggle::DisableSymbolRenaming);
req.hlsl.dumpShaders = device->IsToggleEnabled(Toggle::DumpShaders);
- req.hlsl.useTintIR = useTintIR;
req.hlsl.tintOptions.remapped_entry_point_name = device->GetIsolatedEntryPointName();
req.bytecode.hasShaderF16Feature = device->HasFeature(Feature::ShaderF16);
@@ -323,10 +321,6 @@
req.hlsl.inputProgram = UnsafeUnserializedValue(UseTintProgram());
req.hlsl.entryPointName = programmableStage.entryPoint.c_str();
req.hlsl.stage = stage;
- if (!useTintIR) {
- req.hlsl.firstIndexOffsetRegisterSpace = layout->GetFirstIndexOffsetRegisterSpace();
- req.hlsl.firstIndexOffsetShaderRegister = layout->GetFirstIndexOffsetShaderRegister();
- }
req.hlsl.substituteOverrideConfig = BuildSubstituteOverridesTransformConfig(programmableStage);
req.hlsl.tintOptions.disable_robustness = !device->IsRobustnessEnabled();
req.hlsl.tintOptions.disable_workgroup_init =
@@ -341,7 +335,7 @@
DAWN_ASSERT(stage == SingleShaderStage::Compute);
req.hlsl.tintOptions.root_constant_binding_point = tint::BindingPoint{
layout->GetNumWorkgroupsRegisterSpace(), layout->GetNumWorkgroupsShaderRegister()};
- } else if (useTintIR && stage == SingleShaderStage::Vertex) {
+ } else if (stage == SingleShaderStage::Vertex) {
// For vertex shaders, use root constant to add FirstIndexOffset, if needed
req.hlsl.tintOptions.root_constant_binding_point =
tint::BindingPoint{layout->GetFirstIndexOffsetRegisterSpace(),