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:
|
||||
// 1. The top-left one is counterclockwise (CCW)
|
||||
// 2. The bottom-right one is clockwise (CW)
|
||||
const char* vs =
|
||||
R"(#version 450
|
||||
const vec2 pos[6] = vec2[6](vec2(-1.0f, 1.0f),
|
||||
vec2(-1.0f, 0.0f),
|
||||
vec2( 0.0f, 1.0f),
|
||||
vec2( 0.0f, -1.0f),
|
||||
vec2( 1.0f, 0.0f),
|
||||
vec2( 1.0f, -1.0f));
|
||||
void main() {
|
||||
gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
|
||||
})";
|
||||
pipelineDescriptor.vertexStage.module =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vs);
|
||||
pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||
const pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>(-1.0, 0.0),
|
||||
vec2<f32>( 0.0, 1.0),
|
||||
vec2<f32>( 0.0, -1.0),
|
||||
vec2<f32>( 1.0, 0.0),
|
||||
vec2<f32>( 1.0, -1.0));
|
||||
|
||||
// gl_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 (gl_FragCoord.xy - vec2(0.5)) / 255 in shader code
|
||||
[[builtin(vertex_idx)]] var<in> VertexIndex : i32;
|
||||
[[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.
|
||||
const char* fs =
|
||||
R"(#version 450
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
void main() {
|
||||
fragColor = vec4((gl_FragCoord.xy - vec2(0.5)) / 255, 0.0, 1.0);
|
||||
})";
|
||||
pipelineDescriptor.cFragmentStage.module =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs);
|
||||
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||
[[location(0)]] var<out> fragColor : vec4<f32>;;
|
||||
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main() -> void {
|
||||
fragColor = vec4<f32>(
|
||||
(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
|
||||
pipelineDescriptor.cRasterizationState.frontFace = frontFace;
|
||||
|
|
Loading…
Reference in New Issue