Update CullingTests to use WGSL
Bug: dawn:572 Change-Id: Iacaec3b0a56b357159c8beff26229812538c68b6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32508 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:
parent
53c5cbeaf5
commit
b1cdcffef4
|
@ -25,31 +25,38 @@ class CullingTest : public DawnTest {
|
||||||
// Draw two triangles with different winding orders:
|
// Draw two triangles with different winding orders:
|
||||||
// 1. The top-left one is counterclockwise (CCW)
|
// 1. The top-left one is counterclockwise (CCW)
|
||||||
// 2. The bottom-right one is clockwise (CW)
|
// 2. The bottom-right one is clockwise (CW)
|
||||||
const char* vs =
|
pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
R"(#version 450
|
const pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
|
||||||
const vec2 pos[6] = vec2[6](vec2(-1.0f, 1.0f),
|
vec2<f32>(-1.0, 1.0),
|
||||||
vec2(-1.0f, 0.0f),
|
vec2<f32>(-1.0, 0.0),
|
||||||
vec2( 0.0f, 1.0f),
|
vec2<f32>( 0.0, 1.0),
|
||||||
vec2( 0.0f, -1.0f),
|
vec2<f32>( 0.0, -1.0),
|
||||||
vec2( 1.0f, 0.0f),
|
vec2<f32>( 1.0, 0.0),
|
||||||
vec2( 1.0f, -1.0f));
|
vec2<f32>( 1.0, -1.0));
|
||||||
void main() {
|
|
||||||
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
|
|
||||||
})";
|
|
||||||
pipelineDescriptor.vertexStage.module =
|
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vs);
|
|
||||||
|
|
||||||
// gl_FragCoord of pixel(x, y) in framebuffer coordinate is (x + 0.5, y + 0.5). And we use
|
[[builtin(vertex_idx)]] var<in> VertexIndex : i32;
|
||||||
// RGBA8 format for the back buffer. So (gl_FragCoord.xy - vec2(0.5)) / 255 in shader code
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
|
|
||||||
|
[[stage(vertex)]]
|
||||||
|
fn main() -> void {
|
||||||
|
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||||
|
return;
|
||||||
|
})");
|
||||||
|
|
||||||
|
// FragCoord of pixel(x, y) in framebuffer coordinate is (x + 0.5, y + 0.5). And we use
|
||||||
|
// RGBA8 format for the back buffer. So (FragCoord.xy - vec2(0.5)) / 255 in shader code
|
||||||
// will make the pixel's R and G channels exactly equal to the pixel's x and y coordinates.
|
// will make the pixel's R and G channels exactly equal to the pixel's x and y coordinates.
|
||||||
const char* fs =
|
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
R"(#version 450
|
[[location(0)]] var<out> fragColor : vec4<f32>;;
|
||||||
layout(location = 0) out vec4 fragColor;
|
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
|
||||||
void main() {
|
|
||||||
fragColor = vec4((gl_FragCoord.xy - vec2(0.5)) / 255, 0.0, 1.0);
|
[[stage(fragment)]]
|
||||||
})";
|
fn main() -> void {
|
||||||
pipelineDescriptor.cFragmentStage.module =
|
fragColor = vec4<f32>(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs);
|
(FragCoord.xy - vec2<f32>(0.5, 0.5)) / vec2<f32>(255.0, 255.0),
|
||||||
|
0.0, 1.0);
|
||||||
|
return;
|
||||||
|
})");
|
||||||
|
|
||||||
// Set culling mode and front face according to the parameters
|
// Set culling mode and front face according to the parameters
|
||||||
pipelineDescriptor.cRasterizationState.frontFace = frontFace;
|
pipelineDescriptor.cRasterizationState.frontFace = frontFace;
|
||||||
|
|
Loading…
Reference in New Issue