Skip to content

Commit

Permalink
[gl] Rename buffer variables in the printer
Browse files Browse the repository at this point in the history
This fixes an issue where user identifiers were still be included in
declarations that we emit in the backend, which is potential security
issue.

This also prepares the backend for handling symbol renaming entirely
inside the printer, instead of with a transform run by Dawn.

Fixed: 382744100
Change-Id: Ieacb9a3b5c5ed65bda0af8b4c77e0b95b3c3edd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218617
Reviewed-by: Antonio Maiorano <[email protected]>
Commit-Queue: James Price <[email protected]>
  • Loading branch information
jrprice authored and Dawn LUCI CQ committed Dec 13, 2024
1 parent 505a2d7 commit 2312bfa
Show file tree
Hide file tree
Showing 3,112 changed files with 3,855 additions and 3,853 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
15 changes: 0 additions & 15 deletions src/dawn/native/opengl/ShaderModuleGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ using InterstageLocationAndName = std::pair<uint32_t, std::string>;
X(LimitsForCompilationRequest, limits) \
X(bool, disableSymbolRenaming) \
X(std::vector<InterstageLocationAndName>, interstageVariables) \
X(std::vector<std::string>, bufferBindingVariables) \
X(tint::glsl::writer::Options, tintOptions) \
X(CacheKey::UnsafeUnkeyedValue<dawn::platform::Platform*>, platform)

Expand Down Expand Up @@ -329,12 +328,6 @@ std::pair<tint::glsl::writer::Bindings, BindingMap> GenerateBindingInfo(
std::get_if<BufferBindingInfo>(&shaderBindingInfo.bindingInfo);

if (bufferBindingInfo) {
// For buffer bindings that can be shareable across stages, we need to rename them
// to avoid GL program link failures due to block naming issues.
if (stage != SingleShaderStage::Compute) {
req.bufferBindingVariables.emplace_back(shaderBindingInfo.name);
}

switch (bufferBindingInfo->type) {
case wgpu::BufferBindingType::Uniform:
bindings.uniform.emplace(
Expand Down Expand Up @@ -520,14 +513,6 @@ ResultOrError<GLuint> ShaderModule::CompileShader(
it.second, "dawn_interstage_location_" + std::to_string(it.first));
}

// Prepend v_ or f_ to buffer binding variable names in order to avoid collisions in
// renamed interface blocks.
for (const auto& variableName : r.bufferBindingVariables) {
assignedRenamings.emplace(
variableName,
(r.stage == SingleShaderStage::Vertex ? "v_" : "f_") + variableName);
}

// Needs to run early so that they can use builtin names safely.
// TODO(dawn:2180): move this transform into Tint.
transformManager.Add<tint::ast::transform::Renamer>();
Expand Down
Loading

0 comments on commit 2312bfa

Please sign in to comment.