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 <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair 2021-01-12 22:11:14 +00:00 committed by Commit Bot service account
parent 22eff1eb8c
commit e6ca254c72
9 changed files with 32 additions and 33 deletions

View File

@ -151,8 +151,7 @@ void initRender() {
} }
void initSim() { void initSim() {
wgpu::ShaderModule module = wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Particle { [[block]] struct Particle {
[[offset(0)]] pos : vec2<f32>; [[offset(0)]] pos : vec2<f32>;
[[offset(8)]] vel : vec2<f32>; [[offset(8)]] vel : vec2<f32>;
@ -175,7 +174,7 @@ void initSim() {
[[binding(2), set(0)]] var<storage_buffer> particlesB : [[access(read_write)]] Particles; [[binding(2), set(0)]] var<storage_buffer> particlesB : [[access(read_write)]] Particles;
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>; [[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
# 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)]] [[stage(compute)]]
fn main() -> void { fn main() -> void {
var index : u32 = GlobalInvocationID.x; var index : u32 = GlobalInvocationID.x;
@ -222,12 +221,12 @@ void initSim() {
vVel = vVel + (cMass * params.rule1Scale) + (colVel * params.rule2Scale) + vVel = vVel + (cMass * params.rule1Scale) + (colVel * params.rule2Scale) +
(cVel * params.rule3Scale); (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); vVel = normalize(vVel) * clamp(length(vVel), 0.0, 0.1);
# kinematic update // kinematic update
vPos = vPos + (vVel * params.deltaT); vPos = vPos + (vVel * params.deltaT);
# Wrap around boundary // Wrap around boundary
if (vPos.x < -1.0) { if (vPos.x < -1.0) {
vPos.x = 1.0; vPos.x = 1.0;
} }
@ -241,7 +240,7 @@ void initSim() {
vPos.y = -1.0; vPos.y = -1.0;
} }
# Write back // Write back
particlesB.particles[index].pos = vPos; particlesB.particles[index].pos = vPos;
particlesB.particles[index].vel = vVel; particlesB.particles[index].vel = vVel;
return; return;

View File

@ -49,8 +49,8 @@ namespace dawn_native {
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>((texcoord[VertexIndex] * 2.0 - vec2<f32>(1.0, 1.0)), 0.0, 1.0); Position = vec4<f32>((texcoord[VertexIndex] * 2.0 - vec2<f32>(1.0, 1.0)), 0.0, 1.0);
# Texture coordinate takes top-left as origin point. We need to map the // Texture coordinate takes top-left as origin point. We need to map the
# texture to triangle carefully. // texture to triangle carefully.
v_texcoord = (texcoord[VertexIndex] * vec2<f32>(1.0, -1.0) + vec2<f32>(0.0, 1.0)) * v_texcoord = (texcoord[VertexIndex] * vec2<f32>(1.0, -1.0) + vec2<f32>(0.0, 1.0)) *
uniforms.u_scale + uniforms.u_offset; uniforms.u_scale + uniforms.u_offset;
} }
@ -62,7 +62,7 @@ namespace dawn_native {
[[location(0)]] var<in> v_texcoord : vec2<f32>; [[location(0)]] var<in> v_texcoord : vec2<f32>;
[[location(0)]] var<out> rgbaColor : vec4<f32>; [[location(0)]] var<out> rgbaColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[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<f32> = var clampedTexcoord : vec2<f32> =
clamp(v_texcoord, vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 1.0)); clamp(v_texcoord, vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 1.0));
if (all(clampedTexcoord == v_texcoord)) { if (all(clampedTexcoord == v_texcoord)) {

View File

@ -157,7 +157,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( 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 { [[block]] struct VertexUniformBuffer {
[[offset(0)]] transform : vec4<f32>; [[offset(0)]] transform : vec4<f32>;
}; };
@ -245,7 +245,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( 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 { [[block]] struct VertexUniformBuffer {
[[offset(0)]] transform : vec4<f32>; [[offset(0)]] transform : vec4<f32>;
}; };
@ -360,8 +360,8 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( 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.
# TODO(crbug.com/tint/386): Use the same struct. // TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct VertexUniformBuffer1 { [[block]] struct VertexUniformBuffer1 {
[[offset(0)]] transform : vec4<f32>; [[offset(0)]] transform : vec4<f32>;
}; };
@ -370,7 +370,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
[[offset(0)]] transform : vec4<f32>; [[offset(0)]] transform : vec4<f32>;
}; };
# 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 <uniform> vertexUbo1 : VertexUniformBuffer1; [[set(0), binding(0)]] var <uniform> vertexUbo1 : VertexUniformBuffer1;
[[set(1), binding(0)]] var <uniform> vertexUbo2 : VertexUniformBuffer2; [[set(1), binding(0)]] var <uniform> vertexUbo2 : VertexUniformBuffer2;
@ -390,7 +390,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( 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 { [[block]] struct FragmentUniformBuffer1 {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
@ -399,7 +399,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
# 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 <uniform> fragmentUbo1 : FragmentUniformBuffer1; [[set(0), binding(1)]] var <uniform> fragmentUbo1 : FragmentUniformBuffer1;
[[set(1), binding(1)]] var <uniform> fragmentUbo2 : FragmentUniformBuffer2; [[set(1), binding(1)]] var <uniform> fragmentUbo2 : FragmentUniformBuffer2;
@ -846,7 +846,7 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"( 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 { [[block]] struct Buffer0 {
[[offset(0)]] value : u32; [[offset(0)]] value : u32;
}; };
@ -974,7 +974,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( 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 { [[block]] struct Ubo1 {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
@ -987,7 +987,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
[[offset(0)]] color : vec4<f32>; [[offset(0)]] color : vec4<f32>;
}; };
# 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 <uniform> ubo1 : Ubo1; [[set(0), binding(953)]] var <uniform> ubo1 : Ubo1;
[[set(0), binding(47)]] var <uniform> ubo2 : Ubo2; [[set(0), binding(47)]] var <uniform> ubo2 : Ubo2;
[[set(0), binding(111)]] var <uniform> ubo3 : Ubo3; [[set(0), binding(111)]] var <uniform> ubo3 : Ubo3;

View File

@ -83,7 +83,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc); device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( 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 { [[block]] struct Src {
[[offset(0)]] data : [[stride(4)]] array<u32, 100>; [[offset(0)]] data : [[stride(4)]] array<u32, 100>;
}; };
@ -154,7 +154,7 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc); device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"( 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 { [[block]] struct Src {
[[offset(0)]] data : [[stride(4)]] array<u32, 100>; [[offset(0)]] data : [[stride(4)]] array<u32, 100>;
}; };

View File

@ -108,7 +108,7 @@ class DynamicBufferOffsetTests : public DawnTest {
std::ostringstream fs; std::ostringstream fs;
std::string multipleNumber = isInheritedPipeline ? "2" : "1"; std::string multipleNumber = isInheritedPipeline ? "2" : "1";
fs << R"( fs << R"(
# TODO(crbug.com/tint/386): Use the same struct. // TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct Buffer1 { [[block]] struct Buffer1 {
[[offset(0)]] value : vec2<u32>; [[offset(0)]] value : vec2<u32>;
}; };
@ -177,7 +177,7 @@ class DynamicBufferOffsetTests : public DawnTest {
std::ostringstream cs; std::ostringstream cs;
std::string multipleNumber = isInheritedPipeline ? "2" : "1"; std::string multipleNumber = isInheritedPipeline ? "2" : "1";
cs << R"( cs << R"(
# TODO(crbug.com/tint/386): Use the same struct. // TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct Buffer1 { [[block]] struct Buffer1 {
[[offset(0)]] value : vec2<u32>; [[offset(0)]] value : vec2<u32>;
}; };

View File

@ -468,7 +468,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
}; };
[[set(0), binding(1)]] var<storage_buffer> ibContents : [[access(read_write)]] IBContents; [[set(0), binding(1)]] var<storage_buffer> 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 { [[block]] struct ColorContents1 {
[[offset(0)]] color : f32; [[offset(0)]] color : f32;
}; };

View File

@ -37,7 +37,7 @@ class IndexFormatTest : public DawnTest {
[[builtin(vertex_idx)]] var<in> idx : u32; [[builtin(vertex_idx)]] var<in> idx : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[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) { if (idx == 0xFFFFFFFEu) {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
} else { } else {

View File

@ -56,7 +56,7 @@ class OpArrayLengthTest : public DawnTest {
// Common shader code to use these buffers in shaders, assuming they are in bindgroup index // Common shader code to use these buffers in shaders, assuming they are in bindgroup index
// 0. // 0.
mShaderInterface = R"( mShaderInterface = R"(
# TODO(crbug.com/tint/386): Use the same struct. // TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct DataBuffer1 { [[block]] struct DataBuffer1 {
[[offset(0)]] data : [[stride(4)]] array<f32>; [[offset(0)]] data : [[stride(4)]] array<f32>;
}; };
@ -65,14 +65,14 @@ class OpArrayLengthTest : public DawnTest {
[[offset(0)]] data : [[stride(4)]] array<f32>; [[offset(0)]] data : [[stride(4)]] array<f32>;
}; };
# 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<storage_buffer> buffer1 : [[access(read)]] DataBuffer1; [[set(0), binding(0)]] var<storage_buffer> 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<storage_buffer> buffer2 : [[access(read)]] DataBuffer2; [[set(0), binding(1)]] var<storage_buffer> buffer2 : [[access(read)]] DataBuffer2;
# The length should be (512 - 16*4) / 8 = 56 because the buffer is 512 bytes long // The length should be (512 - 16*4) / 8 = 56 because the buffer is 512 bytes long
# and the structure is 8 bytes big. // and the structure is 8 bytes big.
struct Buffer3Data { struct Buffer3Data {
[[offset(0)]] a : f32; [[offset(0)]] a : f32;
[[offset(4)]] b : i32; [[offset(4)]] b : i32;

View File

@ -37,10 +37,10 @@ class VertexBufferRobustnessTest : public DawnTest {
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
if ()" + successExpression + R"() { if ()" + successExpression + R"() {
# Success case, move the vertex out of the viewport // Success case, move the vertex out of the viewport
Position = vec4<f32>(-10.0, 0.0, 0.0, 1.0); Position = vec4<f32>(-10.0, 0.0, 0.0, 1.0);
} else { } else {
# Failure case, move the vertex inside the viewport // Failure case, move the vertex inside the viewport
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
} }
return; return;