From e6ca254c7289039b8cca62e3631c05942e0ae864 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 12 Jan 2021 22:11:14 +0000 Subject: [PATCH] Convert WGSL comments to // This CL updates the tests with WGSL sources to use // for comments instead of #. This matches the current WGSL spec. Change-Id: I04e1a18630a16b794955cace7e55a89221c964fe Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37520 Auto-Submit: dan sinclair Commit-Queue: Ben Clayton Reviewed-by: Ben Clayton --- examples/ComputeBoids.cpp | 13 ++++++------ .../CopyTextureForBrowserHelper.cpp | 6 +++--- src/tests/end2end/BindGroupTests.cpp | 20 +++++++++---------- .../ComputeStorageBufferBarrierTests.cpp | 4 ++-- .../end2end/DynamicBufferOffsetTests.cpp | 4 ++-- .../end2end/GpuMemorySynchronizationTests.cpp | 2 +- src/tests/end2end/IndexFormatTests.cpp | 2 +- src/tests/end2end/OpArrayLengthTests.cpp | 10 +++++----- .../end2end/VertexBufferRobustnessTests.cpp | 4 ++-- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp index 2dfc628949..4acc6aa272 100644 --- a/examples/ComputeBoids.cpp +++ b/examples/ComputeBoids.cpp @@ -151,8 +151,7 @@ void initRender() { } void initSim() { - wgpu::ShaderModule module = - utils::CreateShaderModuleFromWGSL(device, R"( + wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( [[block]] struct Particle { [[offset(0)]] pos : vec2; [[offset(8)]] vel : vec2; @@ -175,7 +174,7 @@ void initSim() { [[binding(2), set(0)]] var particlesB : [[access(read_write)]] Particles; [[builtin(global_invocation_id)]] var GlobalInvocationID : vec3; - # https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp + // https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp [[stage(compute)]] fn main() -> void { var index : u32 = GlobalInvocationID.x; @@ -222,12 +221,12 @@ void initSim() { vVel = vVel + (cMass * params.rule1Scale) + (colVel * params.rule2Scale) + (cVel * params.rule3Scale); - # clamp velocity for a more pleasing simulation + // clamp velocity for a more pleasing simulation vVel = normalize(vVel) * clamp(length(vVel), 0.0, 0.1); - # kinematic update + // kinematic update vPos = vPos + (vVel * params.deltaT); - # Wrap around boundary + // Wrap around boundary if (vPos.x < -1.0) { vPos.x = 1.0; } @@ -241,7 +240,7 @@ void initSim() { vPos.y = -1.0; } - # Write back + // Write back particlesB.particles[index].pos = vPos; particlesB.particles[index].vel = vVel; return; diff --git a/src/dawn_native/CopyTextureForBrowserHelper.cpp b/src/dawn_native/CopyTextureForBrowserHelper.cpp index 0662575e73..6bca1f1704 100644 --- a/src/dawn_native/CopyTextureForBrowserHelper.cpp +++ b/src/dawn_native/CopyTextureForBrowserHelper.cpp @@ -49,8 +49,8 @@ namespace dawn_native { [[stage(vertex)]] fn main() -> void { Position = vec4((texcoord[VertexIndex] * 2.0 - vec2(1.0, 1.0)), 0.0, 1.0); - # Texture coordinate takes top-left as origin point. We need to map the - # texture to triangle carefully. + // Texture coordinate takes top-left as origin point. We need to map the + // texture to triangle carefully. v_texcoord = (texcoord[VertexIndex] * vec2(1.0, -1.0) + vec2(0.0, 1.0)) * uniforms.u_scale + uniforms.u_offset; } @@ -62,7 +62,7 @@ namespace dawn_native { [[location(0)]] var v_texcoord : vec2; [[location(0)]] var rgbaColor : vec4; [[stage(fragment)]] fn main() -> void { - # Clamp the texcoord and discard the out-of-bound pixels. + // Clamp the texcoord and discard the out-of-bound pixels. var clampedTexcoord : vec2 = clamp(v_texcoord, vec2(0.0, 0.0), vec2(1.0, 1.0)); if (all(clampedTexcoord == v_texcoord)) { diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp index a47388dccb..268677560d 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -157,7 +157,7 @@ TEST_P(BindGroupTests, ReusedUBO) { utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. + // TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. [[block]] struct VertexUniformBuffer { [[offset(0)]] transform : vec4; }; @@ -245,7 +245,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) { utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. + // TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. [[block]] struct VertexUniformBuffer { [[offset(0)]] transform : vec4; }; @@ -360,8 +360,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) { utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. - # TODO(crbug.com/tint/386): Use the same struct. + // TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly. + // TODO(crbug.com/tint/386): Use the same struct. [[block]] struct VertexUniformBuffer1 { [[offset(0)]] transform : vec4; }; @@ -370,7 +370,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) { [[offset(0)]] transform : vec4; }; - # TODO(crbug.com/tint/386): Use the same struct definition. + // TODO(crbug.com/tint/386): Use the same struct definition. [[set(0), binding(0)]] var vertexUbo1 : VertexUniformBuffer1; [[set(1), binding(0)]] var vertexUbo2 : VertexUniformBuffer2; @@ -390,7 +390,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) { })"); wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/386): Use the same struct + // TODO(crbug.com/tint/386): Use the same struct [[block]] struct FragmentUniformBuffer1 { [[offset(0)]] color : vec4; }; @@ -399,7 +399,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) { [[offset(0)]] color : vec4; }; - # TODO(crbug.com/tint/386): Use the same struct definition. + // TODO(crbug.com/tint/386): Use the same struct definition. [[set(0), binding(1)]] var fragmentUbo1 : FragmentUniformBuffer1; [[set(1), binding(1)]] var fragmentUbo2 : FragmentUniformBuffer2; @@ -846,7 +846,7 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) { wgpu::ComputePipelineDescriptor pipelineDescriptor; pipelineDescriptor.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/386): Use the same struct + // TODO(crbug.com/tint/386): Use the same struct [[block]] struct Buffer0 { [[offset(0)]] value : u32; }; @@ -974,7 +974,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) { })"); wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/386): Use the same struct + // TODO(crbug.com/tint/386): Use the same struct [[block]] struct Ubo1 { [[offset(0)]] color : vec4; }; @@ -987,7 +987,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) { [[offset(0)]] color : vec4; }; - # TODO(crbug.com/tint/386): Use the same struct definition. + // TODO(crbug.com/tint/386): Use the same struct definition. [[set(0), binding(953)]] var ubo1 : Ubo1; [[set(0), binding(47)]] var ubo2 : Ubo2; [[set(0), binding(111)]] var ubo3 : Ubo3; diff --git a/src/tests/end2end/ComputeStorageBufferBarrierTests.cpp b/src/tests/end2end/ComputeStorageBufferBarrierTests.cpp index 69c228a786..56ebfe9722 100644 --- a/src/tests/end2end/ComputeStorageBufferBarrierTests.cpp +++ b/src/tests/end2end/ComputeStorageBufferBarrierTests.cpp @@ -83,7 +83,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) { device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc); wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/386): Use the same struct. + // TODO(crbug.com/tint/386): Use the same struct. [[block]] struct Src { [[offset(0)]] data : [[stride(4)]] array; }; @@ -154,7 +154,7 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc); wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( - # TODO(crbug.com/tint/386): Use the same struct. + // TODO(crbug.com/tint/386): Use the same struct. [[block]] struct Src { [[offset(0)]] data : [[stride(4)]] array; }; diff --git a/src/tests/end2end/DynamicBufferOffsetTests.cpp b/src/tests/end2end/DynamicBufferOffsetTests.cpp index c433a9a5f3..ad948361da 100644 --- a/src/tests/end2end/DynamicBufferOffsetTests.cpp +++ b/src/tests/end2end/DynamicBufferOffsetTests.cpp @@ -108,7 +108,7 @@ class DynamicBufferOffsetTests : public DawnTest { std::ostringstream fs; std::string multipleNumber = isInheritedPipeline ? "2" : "1"; fs << R"( - # TODO(crbug.com/tint/386): Use the same struct. + // TODO(crbug.com/tint/386): Use the same struct. [[block]] struct Buffer1 { [[offset(0)]] value : vec2; }; @@ -177,7 +177,7 @@ class DynamicBufferOffsetTests : public DawnTest { std::ostringstream cs; std::string multipleNumber = isInheritedPipeline ? "2" : "1"; cs << R"( - # TODO(crbug.com/tint/386): Use the same struct. + // TODO(crbug.com/tint/386): Use the same struct. [[block]] struct Buffer1 { [[offset(0)]] value : vec2; }; diff --git a/src/tests/end2end/GpuMemorySynchronizationTests.cpp b/src/tests/end2end/GpuMemorySynchronizationTests.cpp index d268b5bb41..7740cb33f1 100644 --- a/src/tests/end2end/GpuMemorySynchronizationTests.cpp +++ b/src/tests/end2end/GpuMemorySynchronizationTests.cpp @@ -468,7 +468,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) { }; [[set(0), binding(1)]] var ibContents : [[access(read_write)]] IBContents; - # TODO(crbug.com/tint/386): Use the same struct. + // TODO(crbug.com/tint/386): Use the same struct. [[block]] struct ColorContents1 { [[offset(0)]] color : f32; }; diff --git a/src/tests/end2end/IndexFormatTests.cpp b/src/tests/end2end/IndexFormatTests.cpp index 43d9d929e4..3d650399c7 100644 --- a/src/tests/end2end/IndexFormatTests.cpp +++ b/src/tests/end2end/IndexFormatTests.cpp @@ -37,7 +37,7 @@ class IndexFormatTest : public DawnTest { [[builtin(vertex_idx)]] var idx : u32; [[builtin(position)]] var Position : vec4; [[stage(vertex)]] fn main() -> void { - # 0xFFFFFFFE is a designated invalid index used by some tests. + // 0xFFFFFFFE is a designated invalid index used by some tests. if (idx == 0xFFFFFFFEu) { Position = vec4(0.0, 0.0, 0.0, 1.0); } else { diff --git a/src/tests/end2end/OpArrayLengthTests.cpp b/src/tests/end2end/OpArrayLengthTests.cpp index 8cb1e1fc95..a53a0b3d1d 100644 --- a/src/tests/end2end/OpArrayLengthTests.cpp +++ b/src/tests/end2end/OpArrayLengthTests.cpp @@ -56,7 +56,7 @@ class OpArrayLengthTest : public DawnTest { // Common shader code to use these buffers in shaders, assuming they are in bindgroup index // 0. mShaderInterface = R"( - # TODO(crbug.com/tint/386): Use the same struct. + // TODO(crbug.com/tint/386): Use the same struct. [[block]] struct DataBuffer1 { [[offset(0)]] data : [[stride(4)]] array; }; @@ -65,14 +65,14 @@ class OpArrayLengthTest : public DawnTest { [[offset(0)]] data : [[stride(4)]] array; }; - # The length should be 1 because the buffer is 4-byte long. + // The length should be 1 because the buffer is 4-byte long. [[set(0), binding(0)]] var buffer1 : [[access(read)]] DataBuffer1; - # The length should be 64 because the buffer is 256 bytes long. + // The length should be 64 because the buffer is 256 bytes long. [[set(0), binding(1)]] var buffer2 : [[access(read)]] DataBuffer2; - # The length should be (512 - 16*4) / 8 = 56 because the buffer is 512 bytes long - # and the structure is 8 bytes big. + // The length should be (512 - 16*4) / 8 = 56 because the buffer is 512 bytes long + // and the structure is 8 bytes big. struct Buffer3Data { [[offset(0)]] a : f32; [[offset(4)]] b : i32; diff --git a/src/tests/end2end/VertexBufferRobustnessTests.cpp b/src/tests/end2end/VertexBufferRobustnessTests.cpp index 9c9a25a68c..abd6367b28 100644 --- a/src/tests/end2end/VertexBufferRobustnessTests.cpp +++ b/src/tests/end2end/VertexBufferRobustnessTests.cpp @@ -37,10 +37,10 @@ class VertexBufferRobustnessTest : public DawnTest { [[stage(vertex)]] fn main() -> void { if ()" + successExpression + R"() { - # Success case, move the vertex out of the viewport + // Success case, move the vertex out of the viewport Position = vec4(-10.0, 0.0, 0.0, 1.0); } else { - # Failure case, move the vertex inside the viewport + // Failure case, move the vertex inside the viewport Position = vec4(0.0, 0.0, 0.0, 1.0); } return;