Skip to content

Commit

Permalink
[dawn][opengl] Pass remapped entry point name to Tint
Browse files Browse the repository at this point in the history
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: Ie7055d49a15de73cd7dd9dbe97c16a5ae2f48d36
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218141
Commit-Queue: James Price <[email protected]>
Reviewed-by: dan sinclair <[email protected]>
  • Loading branch information
jrprice authored and Dawn LUCI CQ committed Dec 5, 2024
1 parent 81bdb4e commit 35e6b8e
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/dawn/native/opengl/ShaderModuleGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,16 @@ ResultOrError<GLuint> ShaderModule::CompileShader(
DAWN_TRY_LOAD_OR_RUN(
compilationResult, GetDevice(), std::move(req), GLSLCompilation::FromBlob,
[](GLSLCompilationRequest r) -> ResultOrError<GLSLCompilation> {
constexpr char kRemappedEntryPointName[] = "dawn_entry_point";
tint::ast::transform::Manager transformManager;
tint::ast::transform::DataMap transformInputs;

transformManager.Add<tint::ast::transform::SingleEntryPoint>();
transformInputs.Add<tint::ast::transform::SingleEntryPoint::Config>(r.entryPointName);

{
tint::ast::transform::Renamer::Remappings assignedRenamings = {};
tint::ast::transform::Renamer::Remappings assignedRenamings = {
{r.entryPointName, kRemappedEntryPointName}};

// Give explicit renaming mappings for interstage variables
// Because GLSL requires interstage IO names to match.
Expand Down Expand Up @@ -548,35 +550,18 @@ ResultOrError<GLuint> ShaderModule::CompileShader(
DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, r.inputProgram,
transformInputs, &transformOutputs, nullptr));

// TODO(dawn:2180): refactor out.
// Get the entry point name after the renamer pass.
// In the case of the entry-point name being a reserved GLSL keyword
// (including `main`) the entry-point would have been renamed
// regardless of the `disableSymbolRenaming` flag. Always check the
// rename map, and if the name was changed, get the new one.
auto* data = transformOutputs.Get<tint::ast::transform::Renamer::Data>();
DAWN_ASSERT(data != nullptr);
auto it = data->remappings.find(r.entryPointName.data());
std::string remappedEntryPoint;
if (it != data->remappings.end()) {
remappedEntryPoint = it->second;
} else {
remappedEntryPoint = r.entryPointName;
}
DAWN_ASSERT(remappedEntryPoint != "");

if (r.stage == SingleShaderStage::Compute) {
// Validate workgroup size after program runs transforms.
Extent3D _;
DAWN_TRY_ASSIGN(_, ValidateComputeStageWorkgroupSize(
program, remappedEntryPoint.c_str(), r.limits));
program, kRemappedEntryPointName, r.limits));
}

// Intentionally assign entry point to empty to avoid a redundant 'SingleEntryPoint'
// transform in Tint.
// TODO(crbug.com/356424898): In the long run, we want to move SingleEntryPoint to Tint,
// but that has interactions with SubstituteOverrides which need to be handled first.
remappedEntryPoint = "";
const std::string remappedEntryPoint = "";

// Convert the AST program to an IR module.
auto ir = tint::wgsl::reader::ProgramToLoweredIR(program);
Expand Down

0 comments on commit 35e6b8e

Please sign in to comment.