From 303c5c2d29145bd6e37d995e128a44f3614327c6 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 26 Nov 2020 15:36:56 +0000 Subject: [PATCH] Update RenderPassTests to use WGSL Bug: dawn:572 Change-Id: I4a892249dfcb1b1badffd8fb7bd6e509eb654234 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33767 Commit-Queue: Corentin Wallez Reviewed-by: Ben Clayton --- src/tests/end2end/RenderPassTests.cpp | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/tests/end2end/RenderPassTests.cpp b/src/tests/end2end/RenderPassTests.cpp index cc325778c9..cf469f31a2 100644 --- a/src/tests/end2end/RenderPassTests.cpp +++ b/src/tests/end2end/RenderPassTests.cpp @@ -26,21 +26,24 @@ class RenderPassTest : public DawnTest { DawnTest::SetUp(); // Shaders to draw a bottom-left triangle in blue. - mVSModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - void main() { - const vec2 pos[3] = vec2[3]( - vec2(-1.f, 1.f), vec2(1.f, -1.f), vec2(-1.f, -1.f)); - gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f); - })"); + mVSModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[builtin(vertex_idx)]] var VertexIndex : u32; + [[builtin(position)]] var Position : vec4; - wgpu::ShaderModule fsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - layout(location = 0) out vec4 fragColor; - void main() { - fragColor = vec4(0.0, 0.0, 1.0, 1.0); - })"); + [[stage(vertex)]] fn main() -> void { + const pos : array, 3> = array, 3>( + vec2(-1.0, 1.0), + vec2( 1.0, -1.0), + vec2(-1.0, -1.0)); + + Position = vec4(pos[VertexIndex], 0.0, 1.0); + })"); + + wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[location(0)]] var fragColor : vec4; + [[stage(fragment)]] fn main() -> void { + fragColor = vec4(0.0, 0.0, 1.0, 1.0); + })"); utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.vertexStage.module = mVSModule; @@ -137,11 +140,9 @@ TEST_P(RenderPassTest, NoCorrespondingFragmentShaderOutputs) { { // Next we use a pipeline whose fragment shader has no outputs. - wgpu::ShaderModule fsModule = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - void main() { - })"); + wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[stage(fragment)]] fn main() -> void { + })"); utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.vertexStage.module = mVSModule; descriptor.cFragmentStage.module = fsModule;