Update DepthBiasTests to use WGSL

Bug: dawn:572
Change-Id: Ie221813162792229bf53f4123c262be929256f39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32509
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2020-11-13 18:41:32 +00:00 committed by Commit Bot service account
parent b1cdcffef4
commit da1f66c8ce
1 changed files with 33 additions and 18 deletions

View File

@ -36,35 +36,50 @@ class DepthBiasTests : public DawnTest {
case QuadAngle::Flat: case QuadAngle::Flat:
// Draw a square at z = 0.25 // Draw a square at z = 0.25
vertexSource = R"( vertexSource = R"(
#version 450 [[builtin(vertex_idx)]] var<in> VertexIndex : i32;
void main() { [[builtin(position)]] var<out> Position : vec4<f32>;
const vec2 pos[6] = vec2[6](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f), [[stage(vertex)]]
vec2(-1.f, 1.f), vec2(1.f, -1.f), vec2( 1.f, 1.f)); fn main() -> void {
gl_Position = vec4(pos[gl_VertexIndex], 0.25f, 1.f); const pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
Position = vec4<f32>(pos[VertexIndex], 0.25, 1.0);
return;
})"; })";
break; break;
case QuadAngle::TiltedX: case QuadAngle::TiltedX:
// Draw a square ranging from 0 to 0.5, bottom to top // Draw a square ranging from 0 to 0.5, bottom to top
vertexSource = R"( vertexSource = R"(
#version 450 [[builtin(vertex_idx)]] var<in> VertexIndex : i32;
void main() { [[builtin(position)]] var<out> Position : vec4<f32>;
const vec3 pos[6] = vec3[6](vec3(-1.f, -1.f, 0.f ), vec3(1.f, -1.f, 0.f), vec3(-1.f, 1.f, 0.5f), [[stage(vertex)]]
vec3(-1.f, 1.f, 0.5f), vec3(1.f, -1.f, 0.f), vec3( 1.f, 1.f, 0.5f)); fn main() -> void {
gl_Position = vec4(pos[gl_VertexIndex], 1.f); const pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
vec3<f32>(-1.0, -1.0, 0.0),
vec3<f32>( 1.0, -1.0, 0.0),
vec3<f32>(-1.0, 1.0, 0.5),
vec3<f32>(-1.0, 1.0, 0.5),
vec3<f32>( 1.0, -1.0, 0.0),
vec3<f32>( 1.0, 1.0, 0.5));
Position = vec4<f32>(pos[VertexIndex], 1.0);
return;
})"; })";
break; break;
} }
wgpu::ShaderModule vertexModule = wgpu::ShaderModule vertexModule = utils::CreateShaderModuleFromWGSL(device, vertexSource);
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vertexSource);
wgpu::ShaderModule fragmentModule = wgpu::ShaderModule fragmentModule = utils::CreateShaderModuleFromWGSL(device, R"(
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"( [[location(0)]] var<out> fragColor : vec4<f32>;;
#version 450 [[stage(fragment)]]
layout(location = 0) out vec4 fragColor; fn main() -> void {
void main() { fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
fragColor = vec4(1.f, 0.f, 0.f, 1.f); return;
})"); })");
{ {