From 65ae78ef5242ff993f2c8f878e6272c8d5d20d0d Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Tue, 22 Dec 2020 19:50:18 +0000 Subject: [PATCH] Update ViewportTests to use WGSL Bug: dawn:572 Change-Id: I08672a402205d4bcac278a1bdcf5d1befa46015c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33771 Commit-Queue: Austin Eng Reviewed-by: Corentin Wallez --- src/tests/end2end/ViewportTests.cpp | 55 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/tests/end2end/ViewportTests.cpp b/src/tests/end2end/ViewportTests.cpp index 3dd6032e47..b692b1a5ea 100644 --- a/src/tests/end2end/ViewportTests.cpp +++ b/src/tests/end2end/ViewportTests.cpp @@ -22,26 +22,26 @@ class ViewportTest : public DawnTest { void SetUp() override { DawnTest::SetUp(); - // TODO(crbug.com/tint/398): GLSL builtins don't work with SPIR-V reader. - DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator")); + mQuadVS = utils::CreateShaderModuleFromWGSL(device, R"( + [[builtin(vertex_idx)]] var VertexIndex : u32; + [[builtin(position)]] var Position : vec4; - mQuadVS = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(#version 450 - const vec2 pos[6] = vec2[6](vec2(-1.0f, 1.0f), - vec2(-1.0f, -1.0f), - vec2( 1.0f, 1.0f), - vec2( 1.0f, 1.0f), - vec2(-1.0f, -1.0f), - vec2( 1.0f, -1.0f)); - void main() { - gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0); + const pos : array, 6> = array, 6>( + vec2(-1.0, 1.0), + vec2(-1.0, -1.0), + vec2( 1.0, 1.0), + vec2( 1.0, 1.0), + vec2(-1.0, -1.0), + vec2( 1.0, -1.0)); + + [[stage(vertex)]] fn main() -> void { + Position = vec4(pos[VertexIndex], 0.0, 1.0); })"); - mQuadFS = - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(#version 450 - layout(location = 0) out vec4 fragColor; - void main() { - fragColor = vec4(1.0); + mQuadFS = utils::CreateShaderModuleFromWGSL(device, R"( + [[location(0)]] var fragColor : vec4; + [[stage(fragment)]] fn main() -> void { + fragColor = vec4(1.0, 1.0, 1.0, 1.0); })"); } @@ -95,15 +95,18 @@ class ViewportTest : public DawnTest { void TestViewportDepth(float minDepth, float maxDepth, bool doViewportCall = true) { // Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0. utils::ComboRenderPipelineDescriptor pipelineDesc(device); - pipelineDesc.vertexStage.module = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(#version 450 - const vec3 points[3] = vec3[3](vec3(-0.9f, 0.0f, 1.0f), - vec3( 0.0f, 0.0f, 0.5f), - vec3( 0.9f, 0.0f, 0.0f)); - void main() { - gl_Position = vec4(points[gl_VertexIndex], 1.0); - gl_PointSize = 1.0; - })"); + pipelineDesc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( + [[builtin(vertex_idx)]] var VertexIndex : u32; + [[builtin(position)]] var Position : vec4; + + const points : array, 3> = array, 3>( + vec3(-0.9, 0.0, 1.0), + vec3( 0.0, 0.0, 0.5), + vec3( 0.9, 0.0, 0.0)); + + [[stage(vertex)]] fn main() -> void { + Position = vec4(points[VertexIndex], 1.0); + })"); pipelineDesc.cFragmentStage.module = mQuadFS; pipelineDesc.colorStateCount = 0; pipelineDesc.primitiveTopology = wgpu::PrimitiveTopology::PointList;