From 4f5cfd2319f2c8697a63200e5ecd16584ea2a22d Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 26 Nov 2020 13:10:16 +0000 Subject: [PATCH] Update IOSurfaceWrappingTests to use WGSL Bug: dawn:572 Change-Id: I806873e1b2af2c5582e49c47592f891ec69146e6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33772 Commit-Queue: Corentin Wallez Reviewed-by: Ben Clayton --- src/tests/end2end/IOSurfaceWrappingTests.cpp | 60 +++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp index 1ae3fa0f27..5fb8133d30 100644 --- a/src/tests/end2end/IOSurfaceWrappingTests.cpp +++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp @@ -247,37 +247,41 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { // The simplest texture sampling pipeline. wgpu::RenderPipeline pipeline; { - wgpu::ShaderModule vs = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - layout (location = 0) out vec2 o_texCoord; - 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)); - const vec2 texCoord[6] = vec2[6](vec2(0.f, 0.f), - vec2(0.f, 1.f), - vec2(1.f, 0.f), - vec2(0.f, 1.f), - vec2(1.f, 0.f), - vec2(1.f, 1.f)); - gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f); - o_texCoord = texCoord[gl_VertexIndex]; + wgpu::ShaderModule vs = utils::CreateShaderModuleFromWGSL(device, R"( + [[builtin(vertex_idx)]] var VertexIndex : u32; + [[location(0)]] var o_texCoord : vec2; + [[builtin(position)]] var Position : vec4; + + [[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)); + + const texCoord : array, 6> = array, 6>( + vec2(0.0, 0.0), + vec2(0.0, 1.0), + vec2(1.0, 0.0), + vec2(0.0, 1.0), + vec2(1.0, 0.0), + vec2(1.0, 1.0)); + + Position = vec4(pos[VertexIndex], 0.0, 1.0); + o_texCoord = texCoord[VertexIndex]; } )"); - wgpu::ShaderModule fs = - 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) in vec2 texCoord; - layout(location = 0) out vec4 fragColor; + wgpu::ShaderModule fs = utils::CreateShaderModuleFromWGSL(device, R"( + [[set(0), binding(0)]] var sampler0 : sampler; + [[set(0), binding(1)]] var texture0 : texture_2d; - void main() { - fragColor = texture(sampler2D(texture0, sampler0), texCoord); + [[location(0)]] var texCoord : vec2; + [[location(0)]] var fragColor : vec4; + + [[stage(fragment)]] fn main() -> void { + fragColor = textureSample(texture0, sampler0, texCoord); } )");