mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-30 02:13:30 +00:00
Update MultisampledSamplingTests to use WGSL
Bug: dawn:572 Change-Id: Id488b3e08c57036508f4f0a5120d6bf020b4a782 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33884 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
02436022ae
commit
ee977a0df8
@ -53,21 +53,19 @@ class MultisampledSamplingTest : public DawnTest {
|
|||||||
{
|
{
|
||||||
utils::ComboRenderPipelineDescriptor desc(device);
|
utils::ComboRenderPipelineDescriptor desc(device);
|
||||||
|
|
||||||
desc.vertexStage.module =
|
desc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex,
|
[[location(0)]] var<in> pos : vec2<f32>;
|
||||||
R"(#version 450
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
layout(location=0) in vec2 pos;
|
[[stage(vertex)]] fn main() -> void {
|
||||||
void main() {
|
Position = vec4<f32>(pos, 0.0, 1.0);
|
||||||
gl_Position = vec4(pos, 0.0, 1.0);
|
|
||||||
})");
|
})");
|
||||||
|
|
||||||
desc.cFragmentStage.module =
|
desc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment,
|
[[location(0)]] var<out> fragColor : f32;
|
||||||
R"(#version 450
|
[[builtin(frag_depth)]] var<out> FragDepth : f32;
|
||||||
layout(location = 0) out float fragColor;
|
[[stage(fragment)]] fn main() -> void {
|
||||||
void main() {
|
|
||||||
fragColor = 1.0;
|
fragColor = 1.0;
|
||||||
gl_FragDepth = 0.7;
|
FragDepth = 0.7;
|
||||||
})");
|
})");
|
||||||
|
|
||||||
desc.cVertexState.indexFormat = wgpu::IndexFormat::Uint32;
|
desc.cVertexState.indexFormat = wgpu::IndexFormat::Uint32;
|
||||||
@ -91,25 +89,20 @@ class MultisampledSamplingTest : public DawnTest {
|
|||||||
{
|
{
|
||||||
wgpu::ComputePipelineDescriptor desc = {};
|
wgpu::ComputePipelineDescriptor desc = {};
|
||||||
desc.computeStage.entryPoint = "main";
|
desc.computeStage.entryPoint = "main";
|
||||||
desc.computeStage.module =
|
desc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute,
|
[[set(0), binding(0)]] var<uniform_constant> texture0 : texture_multisampled_2d<f32>;
|
||||||
R"(#version 450
|
[[set(0), binding(1)]] var<uniform_constant> texture1 : texture_multisampled_2d<f32>;
|
||||||
layout(set = 0, binding = 0) uniform sampler sampler0;
|
|
||||||
layout(set = 0, binding = 1) uniform texture2DMS texture0;
|
|
||||||
layout(set = 0, binding = 2) uniform texture2DMS texture1;
|
|
||||||
|
|
||||||
layout(set = 0, binding = 3, std430) buffer Results {
|
[[block]] struct Results {
|
||||||
float colorSamples[4];
|
[[offset(0)]] colorSamples : [[stride(4)]] array<f32, 4>;
|
||||||
float depthSamples[4];
|
[[offset(16)]] depthSamples : [[stride(4)]] array<f32, 4>;
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(2)]] var<storage_buffer> results : [[access(read_write)]] Results;
|
||||||
|
|
||||||
void main() {
|
[[stage(compute)]] fn main() -> void {
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (var i : i32 = 0; i < 4; i = i + 1) {
|
||||||
colorSamples[i] =
|
results.colorSamples[i] = textureLoad(texture0, vec2<i32>(0, 0), i).x;
|
||||||
texelFetch(sampler2DMS(texture0, sampler0), ivec2(0, 0), i).x;
|
results.depthSamples[i] = textureLoad(texture1, vec2<i32>(0, 0), i).x;
|
||||||
|
|
||||||
depthSamples[i] =
|
|
||||||
texelFetch(sampler2DMS(texture1, sampler0), ivec2(0, 0), i).x;
|
|
||||||
}
|
}
|
||||||
})");
|
})");
|
||||||
|
|
||||||
@ -182,8 +175,6 @@ TEST_P(MultisampledSamplingTest, SamplePositions) {
|
|||||||
|
|
||||||
static constexpr uint32_t kQuadNumBytes = 8 * sizeof(float);
|
static constexpr uint32_t kQuadNumBytes = 8 * sizeof(float);
|
||||||
|
|
||||||
wgpu::SamplerDescriptor samplerDesc = {};
|
|
||||||
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
|
||||||
wgpu::TextureView colorView = colorTexture.CreateView();
|
wgpu::TextureView colorView = colorTexture.CreateView();
|
||||||
wgpu::TextureView depthView = depthTexture.CreateView();
|
wgpu::TextureView depthView = depthTexture.CreateView();
|
||||||
|
|
||||||
@ -215,10 +206,9 @@ TEST_P(MultisampledSamplingTest, SamplePositions) {
|
|||||||
computePassEncoder.SetBindGroup(
|
computePassEncoder.SetBindGroup(
|
||||||
0, utils::MakeBindGroup(
|
0, utils::MakeBindGroup(
|
||||||
device, checkSamplePipeline.GetBindGroupLayout(0),
|
device, checkSamplePipeline.GetBindGroupLayout(0),
|
||||||
{{0, sampler},
|
{{0, colorView},
|
||||||
{1, colorView},
|
{1, depthView},
|
||||||
{2, depthView},
|
{2, outputBuffer, alignedResultSize * sampleOffset, kResultSize}}));
|
||||||
{3, outputBuffer, alignedResultSize * sampleOffset, kResultSize}}));
|
|
||||||
computePassEncoder.Dispatch(1);
|
computePassEncoder.Dispatch(1);
|
||||||
computePassEncoder.EndPass();
|
computePassEncoder.EndPass();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user