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:
// Draw a square at z = 0.25
vertexSource = R"(
#version 450
void main() {
const vec2 pos[6] = vec2[6](vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(-1.f, 1.f),
vec2(-1.f, 1.f), vec2(1.f, -1.f), vec2( 1.f, 1.f));
gl_Position = vec4(pos[gl_VertexIndex], 0.25f, 1.f);
[[builtin(vertex_idx)]] var<in> VertexIndex : i32;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]]
fn main() -> void {
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;
case QuadAngle::TiltedX:
// Draw a square ranging from 0 to 0.5, bottom to top
vertexSource = R"(
#version 450
void main() {
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),
vec3(-1.f, 1.f, 0.5f), vec3(1.f, -1.f, 0.f), vec3( 1.f, 1.f, 0.5f));
gl_Position = vec4(pos[gl_VertexIndex], 1.f);
[[builtin(vertex_idx)]] var<in> VertexIndex : i32;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]]
fn main() -> void {
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;
}
wgpu::ShaderModule vertexModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vertexSource);
wgpu::ShaderModule vertexModule = utils::CreateShaderModuleFromWGSL(device, vertexSource);
wgpu::ShaderModule fragmentModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(1.f, 0.f, 0.f, 1.f);
wgpu::ShaderModule fragmentModule = 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;
})");
{