From 69afcb41e78505adc3005d1cf0f78ce31dc07eb0 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 26 Nov 2020 13:41:55 +0000 Subject: [PATCH] Update SamplerTests to use WGSL Bug: dawn:572 Change-Id: I008d142c61a09e5453cb51e38b1dfaee17a4e81a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33882 Commit-Queue: Corentin Wallez Reviewed-by: Ben Clayton --- src/tests/end2end/SamplerTests.cpp | 42 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/tests/end2end/SamplerTests.cpp b/src/tests/end2end/SamplerTests.cpp index b3483d6496..fa08b80ced 100644 --- a/src/tests/end2end/SamplerTests.cpp +++ b/src/tests/end2end/SamplerTests.cpp @@ -54,28 +54,32 @@ class SamplerTest : public DawnTest { DawnTest::SetUp(); mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); - auto vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - void main() { - const vec2 pos[6] = vec2[6](vec2(-2.f, -2.f), - vec2(-2.f, 2.f), - vec2( 2.f, -2.f), - vec2(-2.f, 2.f), - vec2( 2.f, -2.f), - vec2( 2.f, 2.f)); - gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f); - } - )"); - auto fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( - #version 450 - layout(set = 0, binding = 0) uniform sampler sampler0; - layout(set = 0, binding = 1) uniform texture2D texture0; - layout(location = 0) out vec4 fragColor; + auto vsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[builtin(vertex_idx)]] var VertexIndex : u32; + [[builtin(position)]] var Position : vec4; - void main() { - fragColor = texture(sampler2D(texture0, sampler0), gl_FragCoord.xy / 2.0); + [[stage(vertex)]] fn main() -> void { + const pos : array, 6> = array, 6>( + vec2(-2.0, -2.0), + vec2(-2.0, 2.0), + vec2( 2.0, -2.0), + vec2(-2.0, 2.0), + vec2( 2.0, -2.0), + vec2( 2.0, 2.0)); + Position = vec4(pos[VertexIndex], 0.0, 1.0); } )"); + auto fsModule = utils::CreateShaderModuleFromWGSL(device, R"( + [[set(0), binding(0)]] var sampler0 : sampler; + [[set(0), binding(1)]] var texture0 : texture_2d; + + [[builtin(frag_coord)]] var FragCoord : vec4; + + [[location(0)]] var fragColor : vec4; + + [[stage(fragment)]] fn main() -> void { + fragColor = textureSample(texture0, sampler0, FragCoord.xy / vec2(2.0, 2.0)); + })"); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); pipelineDescriptor.vertexStage.module = vsModule;