[dawn][d3d] Pass remapped entry point name to Tint
Have Dawn tell Tint's renamer what entry point name to use when
renaming entry points, instead of reflecting it back from Tint to
Dawn.
This is a prerequisite for moving the Renamer into the backends
completely.
Bug: 375192379
Change-Id: I9734ce6fd572d1a00ac9012d5f0eb8b37a13d7b2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218140
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/src/dawn/native/d3d/ShaderUtils.cpp b/src/dawn/native/d3d/ShaderUtils.cpp
index 0bf0afd..d0a048b 100644
--- a/src/dawn/native/d3d/ShaderUtils.cpp
+++ b/src/dawn/native/d3d/ShaderUtils.cpp
@@ -47,6 +47,9 @@
namespace {
+// The remapped name to use when remapping shader entry point names.
+constexpr char kRemappedEntryPointName[] = "dawn_entry_point";
+
// 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) {
@@ -204,7 +207,6 @@
MaybeError TranslateToHLSL(d3d::HlslCompilationRequest r,
CacheKey::UnsafeUnkeyedValue<dawn::platform::Platform*> tracePlatform,
- std::string* remappedEntryPointName,
CompiledShader* compiledShader) {
std::ostringstream errorStream;
errorStream << "Tint HLSL failure:\n";
@@ -217,12 +219,13 @@
transformInputs.Add<tint::ast::transform::SingleEntryPoint::Config>(r.entryPointName.data());
// 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), kRemappedEntryPointName}};
transformManager.Add<tint::ast::transform::Renamer>();
- if (r.disableSymbolRenaming) {
- // We still need to rename HLSL reserved keywords
- transformInputs.Add<tint::ast::transform::Renamer::Config>(
- tint::ast::transform::Renamer::Target::kHlslKeywords);
- }
+ 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.stage == SingleShaderStage::Vertex) {
transformManager.Add<tint::ast::transform::FirstIndexOffset>();
@@ -247,26 +250,11 @@
&transformOutputs, nullptr));
}
- // TODO(dawn:2180): refactor out.
- if (auto* data = transformOutputs.Get<tint::ast::transform::Renamer::Data>()) {
- auto it = data->remappings.find(r.entryPointName.data());
- if (it != data->remappings.end()) {
- *remappedEntryPointName = it->second;
- } else {
- DAWN_INVALID_IF(!r.disableSymbolRenaming,
- "Could not find remapped name for entry point.");
-
- *remappedEntryPointName = r.entryPointName;
- }
- } else {
- return DAWN_VALIDATION_ERROR("Transform output missing renamer data.");
- }
-
// Validate workgroup size after program runs transforms.
if (r.stage == SingleShaderStage::Compute) {
Extent3D _;
- DAWN_TRY_ASSIGN(_, ValidateComputeStageWorkgroupSize(
- transformedProgram, remappedEntryPointName->data(), r.limits));
+ DAWN_TRY_ASSIGN(_, ValidateComputeStageWorkgroupSize(transformedProgram,
+ kRemappedEntryPointName, r.limits));
}
bool usesVertexIndex = false;
@@ -370,16 +358,14 @@
CompiledShader compiledShader;
bool dumpShaders = r.hlsl.dumpShaders;
// Compile the source shader to HLSL.
- std::string remappedEntryPoint;
- DAWN_TRY(
- TranslateToHLSL(std::move(r.hlsl), r.tracePlatform, &remappedEntryPoint, &compiledShader));
+ DAWN_TRY(TranslateToHLSL(std::move(r.hlsl), r.tracePlatform, &compiledShader));
switch (r.bytecode.compiler) {
case d3d::Compiler::DXC: {
TRACE_EVENT0(r.tracePlatform.UnsafeGetValue(), General, "CompileShaderDXC");
ComPtr<IDxcBlob> compiledDXCShader;
DAWN_TRY_ASSIGN(compiledDXCShader,
- CompileShaderDXC(r.bytecode, remappedEntryPoint,
+ CompileShaderDXC(r.bytecode, kRemappedEntryPointName,
compiledShader.hlslSource, dumpShaders));
compiledShader.shaderBlob = CreateBlob(std::move(compiledDXCShader));
break;
@@ -388,7 +374,7 @@
TRACE_EVENT0(r.tracePlatform.UnsafeGetValue(), General, "CompileShaderFXC");
ComPtr<ID3DBlob> compiledFXCShader;
DAWN_TRY_ASSIGN(compiledFXCShader,
- CompileShaderFXC(r.bytecode, remappedEntryPoint,
+ CompileShaderFXC(r.bytecode, kRemappedEntryPointName,
compiledShader.hlslSource, dumpShaders));
compiledShader.shaderBlob = CreateBlob(std::move(compiledFXCShader));
break;