From 424fd828893ea55630414f396ee72f4b1f4725db Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Wed, 13 Jan 2021 03:10:54 +0000 Subject: [PATCH] Update DepthStencilStateTests to use WGSL Bug: dawn:572 Change-Id: Ia0bc64304cfa91e3c5f0179781eeef0eab21323a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33761 Reviewed-by: Corentin Wallez Commit-Queue: Austin Eng --- src/tests/end2end/DepthStencilStateTests.cpp | 56 +++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/tests/end2end/DepthStencilStateTests.cpp b/src/tests/end2end/DepthStencilStateTests.cpp index 25cfaacce7..1dee59ab4b 100644 --- a/src/tests/end2end/DepthStencilStateTests.cpp +++ b/src/tests/end2end/DepthStencilStateTests.cpp @@ -52,32 +52,38 @@ class DepthStencilStateTest : public DawnTest { depthTextureView = depthTexture.CreateView(); - vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - layout(set = 0, binding = 0) uniform myBlock { - vec3 color; - float depth; - } myUbo; - void main() { - const vec2 pos[6] = vec2[6]( - vec2(-1.f, 1.f), vec2(-1.f, -1.f), vec2(1.f, -1.f), // front-facing - vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(1.f, -1.f) // back-facing - ); - gl_Position = vec4(pos[gl_VertexIndex], myUbo.depth, 1.f); - } - )"); + vsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[block]] struct UBO { + [[offset(0)]] color : vec3; + [[offset(12)]] depth : f32; + }; + [[set(0), binding(0)]] var ubo : UBO; + [[builtin(vertex_idx)]] var VertexIndex : u32; + [[builtin(position)]] var Position : vec4; - fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - layout(set = 0, binding = 0) uniform myBlock { - vec3 color; - float depth; - } myUbo; - layout(location = 0) out vec4 fragColor; - void main() { - fragColor = vec4(myUbo.color, 1.f); - } - )"); + [[stage(vertex)]] fn main() -> void { + const pos : array, 6> = array, 6>( + vec2(-1.0, 1.0), + vec2(-1.0, -1.0), + vec2( 1.0, -1.0), # front-facing + vec2(-1.0, 1.0), + vec2( 1.0, 1.0), + vec2( 1.0, -1.0)); # back-facing + Position = vec4(pos[VertexIndex], ubo.depth, 1.0); + })"); + + fsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[block]] struct UBO { + [[offset(0)]] color : vec3; + [[offset(12)]] depth : f32; + }; + [[set(0), binding(0)]] var ubo : UBO; + + [[location(0)]] var fragColor : vec4; + + [[stage(fragment)]] fn main() -> void { + fragColor = vec4(ubo.color, 1.0); + })"); } struct TestSpec {