Update TextureSubresourceTests to use WGSL
Bug: dawn:572 Change-Id: I7a008c4c52c7e42cd73c4591854f8910d1a04dc7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33769 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
4f5cfd2319
commit
225074a74a
|
@ -49,21 +49,23 @@ class TextureSubresourceTest : public DawnTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTriangle(const wgpu::TextureView& view) {
|
void DrawTriangle(const wgpu::TextureView& view) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[builtin(vertex_idx)]] var<in> VertexIndex : u32;
|
||||||
#version 450
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
void main() {
|
|
||||||
const vec2 pos[3] = vec2[3](
|
[[stage(vertex)]] fn main() -> void {
|
||||||
vec2(-1.f, 1.f), vec2(-1.f, -1.f), vec2(1.f, -1.f));
|
const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||||
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
|
vec2<f32>(-1.0, 1.0),
|
||||||
|
vec2<f32>(-1.0, -1.0),
|
||||||
|
vec2<f32>( 1.0, -1.0));
|
||||||
|
|
||||||
|
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||||
})");
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[location(0)]] var<out> fragColor : vec4<f32>;
|
||||||
#version 450
|
[[stage(fragment)]] fn main() -> void {
|
||||||
layout(location = 0) out vec4 fragColor;
|
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||||
void main() {
|
|
||||||
fragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
|
||||||
})");
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
|
@ -87,24 +89,32 @@ class TextureSubresourceTest : public DawnTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleAndDraw(const wgpu::TextureView& samplerView, const wgpu::TextureView& renderView) {
|
void SampleAndDraw(const wgpu::TextureView& samplerView, const wgpu::TextureView& renderView) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[builtin(vertex_idx)]] var<in> VertexIndex : u32;
|
||||||
#version 450
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
void main() {
|
|
||||||
const vec2 pos[6] = vec2[6](
|
[[stage(vertex)]] fn main() -> void {
|
||||||
vec2(-1.f, -1.f), vec2(1.f, 1.f), vec2(-1.f, 1.f),
|
const pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
|
||||||
vec2(-1.f, -1.f), vec2(1.f, -1.f), vec2(1.f, 1.f));
|
vec2<f32>(-1.0, -1.0),
|
||||||
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
|
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.0, 1.0);
|
||||||
})");
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[set(0), binding(0)]] var<uniform_constant> samp : sampler;
|
||||||
#version 450
|
[[set(0), binding(1)]] var<uniform_constant> tex : texture_2d<f32>;
|
||||||
layout (set = 0, binding = 0) uniform sampler samp;
|
|
||||||
layout (set = 0, binding = 1) uniform texture2D tex;
|
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
|
||||||
layout (location = 0) out vec4 fragColor;
|
|
||||||
void main() {
|
[[location(0)]] var<out> fragColor : vec4<f32>;
|
||||||
fragColor = texture(sampler2D(tex, samp), gl_FragCoord.xy / 4);
|
|
||||||
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
fragColor = textureSample(tex, samp, FragCoord.xy / vec2<f32>(4.0, 4.0));
|
||||||
})");
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
|
|
Loading…
Reference in New Issue