mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
Tint/GLSL: rename identifiers containing double-underscores.
This is prohibited by the GLSL ES spec: "In addition, all identifiers containing two consecutive underscores (__) are reserved for use by underlying software layers. Defining such a name in a shader does not itself result in an error, but may result in unintended behaviors that stem from having multiple definitions of the same name." (https://registry.khronos.org/OpenGL/specs/es/3.1/GLSL_ES_Specification_3.10.withchanges.pdf, section 3.7). However, while glslang validation will not give an error on this, NVidia ES drivers will. So I've added a Dawn end2end test instead of a WGSL test. Bug: tint:1944 Change-Id: I4b965af00039ca7a232bc11be884483f8e02ccf6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/134140 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
4957327cc9
commit
0c7a99f894
@@ -1462,6 +1462,48 @@ fn main(@location(0) value : f32) -> @location(0) vec4f {
|
||||
EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8(255, 255, 255, 255), renderPass.color, 0, 0);
|
||||
}
|
||||
|
||||
// Test that identifiers containing double underscores are renamed in the GLSL backend.
|
||||
TEST_P(ShaderTests, DoubleUnderscore) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
@vertex
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
|
||||
const pos = array(
|
||||
vec2( 1.0, -1.0),
|
||||
vec2(-1.0, -1.0),
|
||||
vec2( 0.0, 1.0),
|
||||
);
|
||||
return vec4(pos[VertexIndex], 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
diagnostic(off, derivative_uniformity);
|
||||
|
||||
@fragment
|
||||
fn main() -> @location(0) vec4f {
|
||||
let re__sult = vec4f(1.0);
|
||||
return re__sult;
|
||||
})");
|
||||
|
||||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
|
||||
|
||||
utils::ComboRenderPipelineDescriptor descriptor;
|
||||
descriptor.vertex.module = vsModule;
|
||||
descriptor.cFragment.module = fsModule;
|
||||
descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
|
||||
descriptor.cTargets[0].format = renderPass.colorFormat;
|
||||
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.Draw(3);
|
||||
pass.End();
|
||||
wgpu::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8(255, 255, 255, 255), renderPass.color, 0, 0);
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(ShaderTests,
|
||||
D3D11Backend(),
|
||||
D3D12Backend(),
|
||||
|
||||
@@ -1350,7 +1350,7 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
|
||||
kReservedKeywordsGLSL +
|
||||
sizeof(kReservedKeywordsGLSL) / sizeof(const char*),
|
||||
name) ||
|
||||
name.compare(0, 3, "gl_") == 0;
|
||||
name.compare(0, 3, "gl_") == 0 || name.find("__") != std::string::npos;
|
||||
case Target::kHlslKeywords:
|
||||
return std::binary_search(
|
||||
kReservedKeywordsHLSL,
|
||||
|
||||
Reference in New Issue
Block a user