Update ClipSpaceTests to use WGSL
Bug: dawn:572
Change-Id: Iad55df4f39dfa91ef4554908acb9e2bb45703124
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32502
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/tests/end2end/ClipSpaceTests.cpp b/src/tests/end2end/ClipSpaceTests.cpp
index cb58525..980fe1e 100644
--- a/src/tests/end2end/ClipSpaceTests.cpp
+++ b/src/tests/end2end/ClipSpaceTests.cpp
@@ -25,28 +25,31 @@
// Draw two triangles:
// 1. The depth value of the top-left one is >= 0.5
// 2. The depth value of the bottom-right one is <= 0.5
- const char* vs =
- R"(#version 450
- const vec3 pos[6] = vec3[6](vec3(-1.0f, 1.0f, 1.0f),
- vec3(-1.0f, -1.0f, 0.5f),
- vec3( 1.0f, 1.0f, 0.5f),
- vec3( 1.0f, 1.0f, 0.5f),
- vec3(-1.0f, -1.0f, 0.5f),
- vec3( 1.0f, -1.0f, 0.0f));
- void main() {
- gl_Position = vec4(pos[gl_VertexIndex], 1.0);
- })";
- pipelineDescriptor.vertexStage.module =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vs);
+ pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
+ const pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
+ vec3<f32>(-1.0, 1.0, 1.0),
+ vec3<f32>(-1.0, -1.0, 0.5),
+ vec3<f32>( 1.0, 1.0, 0.5),
+ vec3<f32>( 1.0, 1.0, 0.5),
+ vec3<f32>(-1.0, -1.0, 0.5),
+ vec3<f32>( 1.0, -1.0, 0.0));
- const char* fs =
- R"(#version 450
- layout(location = 0) out vec4 fragColor;
- void main() {
- fragColor = vec4(1.0, 0.0, 0.0, 1.0);
- })";
- pipelineDescriptor.cFragmentStage.module =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs);
+ [[builtin(vertex_idx)]] var<in> VertexIndex : i32;
+ [[builtin(position)]] var<out> Position : vec4<f32>;
+
+ [[stage(vertex)]]
+ fn main() -> void {
+ Position = vec4<f32>(pos[VertexIndex], 1.0);
+ return;
+ })");
+
+ pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
+ [[location(0)]] var<out> fragColor : vec4<f32>;;
+ [[stage(fragment)]]
+ fn main() -> void {
+ fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
+ return;
+ })");
pipelineDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::LessEqual;
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState;