Autoformat all tests and examples
Bug: none
Change-Id: I69904944db1d4c2fbcca74bb8b66b5a7524e76bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24642
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/tests/end2end/BasicTests.cpp b/src/tests/end2end/BasicTests.cpp
index 98ecb2e..4a0409f 100644
--- a/src/tests/end2end/BasicTests.cpp
+++ b/src/tests/end2end/BasicTests.cpp
@@ -16,8 +16,7 @@
#include "utils/WGPUHelpers.h"
-class BasicTests : public DawnTest {
-};
+class BasicTests : public DawnTest {};
// Test adapter filter by vendor id.
TEST_P(BasicTests, VendorIdFilter) {
diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp
index 118a4ee..780f482 100644
--- a/src/tests/end2end/BindGroupTests.cpp
+++ b/src/tests/end2end/BindGroupTests.cpp
@@ -22,102 +22,102 @@
constexpr static uint32_t kRTSize = 8;
class BindGroupTests : public DawnTest {
-protected:
- wgpu::CommandBuffer CreateSimpleComputeCommandBuffer(const wgpu::ComputePipeline& pipeline,
- const wgpu::BindGroup& bindGroup) {
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
- wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
- pass.SetPipeline(pipeline);
- pass.SetBindGroup(0, bindGroup);
- pass.Dispatch(1);
- pass.EndPass();
- return encoder.Finish();
- }
+ protected:
+ wgpu::CommandBuffer CreateSimpleComputeCommandBuffer(const wgpu::ComputePipeline& pipeline,
+ const wgpu::BindGroup& bindGroup) {
+ wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
+ pass.SetPipeline(pipeline);
+ pass.SetBindGroup(0, bindGroup);
+ pass.Dispatch(1);
+ pass.EndPass();
+ return encoder.Finish();
+ }
- wgpu::PipelineLayout MakeBasicPipelineLayout(
- std::vector<wgpu::BindGroupLayout> bindingInitializer) const {
- wgpu::PipelineLayoutDescriptor descriptor;
+ wgpu::PipelineLayout MakeBasicPipelineLayout(
+ std::vector<wgpu::BindGroupLayout> bindingInitializer) const {
+ wgpu::PipelineLayoutDescriptor descriptor;
- descriptor.bindGroupLayoutCount = bindingInitializer.size();
- descriptor.bindGroupLayouts = bindingInitializer.data();
+ descriptor.bindGroupLayoutCount = bindingInitializer.size();
+ descriptor.bindGroupLayouts = bindingInitializer.data();
- return device.CreatePipelineLayout(&descriptor);
- }
+ return device.CreatePipelineLayout(&descriptor);
+ }
- wgpu::ShaderModule MakeSimpleVSModule() const {
- return utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
+ wgpu::ShaderModule MakeSimpleVSModule() const {
+ return utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
void main() {
const vec2 pos[3] = vec2[3](vec2(-1.f, 1.f), vec2(1.f, 1.f), vec2(-1.f, -1.f));
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
})");
- }
+ }
- wgpu::ShaderModule MakeFSModule(std::vector<wgpu::BindingType> bindingTypes) const {
- ASSERT(bindingTypes.size() <= kMaxBindGroups);
+ wgpu::ShaderModule MakeFSModule(std::vector<wgpu::BindingType> bindingTypes) const {
+ ASSERT(bindingTypes.size() <= kMaxBindGroups);
- std::ostringstream fs;
- fs << R"(
+ std::ostringstream fs;
+ fs << R"(
#version 450
layout(location = 0) out vec4 fragColor;
)";
- for (size_t i = 0; i < bindingTypes.size(); ++i) {
- switch (bindingTypes[i]) {
- case wgpu::BindingType::UniformBuffer:
- fs << "layout (std140, set = " << i << ", binding = 0) uniform UniformBuffer" << i
- << R"( {
+ for (size_t i = 0; i < bindingTypes.size(); ++i) {
+ switch (bindingTypes[i]) {
+ case wgpu::BindingType::UniformBuffer:
+ fs << "layout (std140, set = " << i << ", binding = 0) uniform UniformBuffer"
+ << i << R"( {
vec4 color;
} buffer)"
- << i << ";\n";
- break;
- case wgpu::BindingType::StorageBuffer:
- fs << "layout (std430, set = " << i << ", binding = 0) buffer StorageBuffer" << i
- << R"( {
+ << i << ";\n";
+ break;
+ case wgpu::BindingType::StorageBuffer:
+ fs << "layout (std430, set = " << i << ", binding = 0) buffer StorageBuffer"
+ << i << R"( {
vec4 color;
} buffer)"
- << i << ";\n";
- break;
- default:
- UNREACHABLE();
- }
- }
+ << i << ";\n";
+ break;
+ default:
+ UNREACHABLE();
+ }
+ }
- fs << R"(
+ fs << R"(
void main() {
fragColor = vec4(0.0);
)";
- for (size_t i = 0; i < bindingTypes.size(); ++i) {
- fs << "fragColor += buffer" << i << ".color;\n";
- }
- fs << "}\n";
+ for (size_t i = 0; i < bindingTypes.size(); ++i) {
+ fs << "fragColor += buffer" << i << ".color;\n";
+ }
+ fs << "}\n";
- return utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment,
- fs.str().c_str());
- }
+ return utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment,
+ fs.str().c_str());
+ }
- wgpu::RenderPipeline MakeTestPipeline(const utils::BasicRenderPass& renderPass,
- std::vector<wgpu::BindingType> bindingTypes,
- std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
- wgpu::ShaderModule vsModule = MakeSimpleVSModule();
- wgpu::ShaderModule fsModule = MakeFSModule(bindingTypes);
+ wgpu::RenderPipeline MakeTestPipeline(const utils::BasicRenderPass& renderPass,
+ std::vector<wgpu::BindingType> bindingTypes,
+ std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
+ wgpu::ShaderModule vsModule = MakeSimpleVSModule();
+ wgpu::ShaderModule fsModule = MakeFSModule(bindingTypes);
- wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(bindGroupLayouts);
+ wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(bindGroupLayouts);
- utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
- pipelineDescriptor.layout = pipelineLayout;
- pipelineDescriptor.vertexStage.module = vsModule;
- pipelineDescriptor.cFragmentStage.module = fsModule;
- pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat;
- pipelineDescriptor.cColorStates[0].colorBlend.operation = wgpu::BlendOperation::Add;
- pipelineDescriptor.cColorStates[0].colorBlend.srcFactor = wgpu::BlendFactor::One;
- pipelineDescriptor.cColorStates[0].colorBlend.dstFactor = wgpu::BlendFactor::One;
- pipelineDescriptor.cColorStates[0].alphaBlend.operation = wgpu::BlendOperation::Add;
- pipelineDescriptor.cColorStates[0].alphaBlend.srcFactor = wgpu::BlendFactor::One;
- pipelineDescriptor.cColorStates[0].alphaBlend.dstFactor = wgpu::BlendFactor::One;
+ utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
+ pipelineDescriptor.layout = pipelineLayout;
+ pipelineDescriptor.vertexStage.module = vsModule;
+ pipelineDescriptor.cFragmentStage.module = fsModule;
+ pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat;
+ pipelineDescriptor.cColorStates[0].colorBlend.operation = wgpu::BlendOperation::Add;
+ pipelineDescriptor.cColorStates[0].colorBlend.srcFactor = wgpu::BlendFactor::One;
+ pipelineDescriptor.cColorStates[0].colorBlend.dstFactor = wgpu::BlendFactor::One;
+ pipelineDescriptor.cColorStates[0].alphaBlend.operation = wgpu::BlendOperation::Add;
+ pipelineDescriptor.cColorStates[0].alphaBlend.srcFactor = wgpu::BlendFactor::One;
+ pipelineDescriptor.cColorStates[0].alphaBlend.dstFactor = wgpu::BlendFactor::One;
- return device.CreateRenderPipeline(&pipelineDescriptor);
- }
+ return device.CreateRenderPipeline(&pipelineDescriptor);
+ }
};
// Test a bindgroup reused in two command buffers in the same call to queue.Submit().
@@ -195,10 +195,10 @@
};
ASSERT(offsetof(Data, color) == 256);
constexpr float dummy = 0.0f;
- Data data {
- { 1.f, 0.f, dummy, dummy, 0.f, 1.0f, dummy, dummy },
- { 0 },
- { 0.f, 1.f, 0.f, 1.f },
+ Data data{
+ {1.f, 0.f, dummy, dummy, 0.f, 1.0f, dummy, dummy},
+ {0},
+ {0.f, 1.f, 0.f, 1.f},
};
wgpu::Buffer buffer =
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Uniform);
@@ -219,15 +219,15 @@
RGBA8 filled(0, 255, 0, 255);
RGBA8 notFilled(0, 0, 0, 0);
uint32_t min = 1, max = kRTSize - 3;
- EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, min);
- EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, max, min);
- EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, max);
+ EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, min);
+ EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, max, min);
+ EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, max);
EXPECT_PIXEL_RGBA8_EQ(notFilled, renderPass.color, max, max);
}
-// Test a bindgroup containing a UBO in the vertex shader and a sampler and texture in the fragment shader.
-// In D3D12 for example, these different types of bindings end up in different namespaces, but the register
-// offsets used must match between the shader module and descriptor range.
+// Test a bindgroup containing a UBO in the vertex shader and a sampler and texture in the fragment
+// shader. In D3D12 for example, these different types of bindings end up in different namespaces,
+// but the register offsets used must match between the shader module and descriptor range.
TEST_P(BindGroupTests, UBOSamplerAndTexture) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
@@ -260,7 +260,7 @@
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
constexpr float dummy = 0.0f;
- constexpr float transform[] = { 1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy };
+ constexpr float transform[] = {1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy};
wgpu::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform),
wgpu::BufferUsage::Uniform);
@@ -320,9 +320,9 @@
RGBA8 filled(0, 255, 0, 255);
RGBA8 notFilled(0, 0, 0, 0);
uint32_t min = 1, max = kRTSize - 3;
- EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, min);
- EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, max, min);
- EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, max);
+ EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, min);
+ EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, max, min);
+ EXPECT_PIXEL_RGBA8_EQ(filled, renderPass.color, min, max);
EXPECT_PIXEL_RGBA8_EQ(notFilled, renderPass.color, max, max);
}
@@ -1091,4 +1091,8 @@
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 0, 0);
}
-DAWN_INSTANTIATE_TEST(BindGroupTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(BindGroupTests,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/BufferTests.cpp b/src/tests/end2end/BufferTests.cpp
index f010be6..4b626ee 100644
--- a/src/tests/end2end/BufferTests.cpp
+++ b/src/tests/end2end/BufferTests.cpp
@@ -17,34 +17,34 @@
#include <cstring>
class BufferMapReadTests : public DawnTest {
- protected:
- static void MapReadCallback(WGPUBufferMapAsyncStatus status,
- const void* data,
- uint64_t,
- void* userdata) {
- ASSERT_EQ(WGPUBufferMapAsyncStatus_Success, status);
- ASSERT_NE(nullptr, data);
+ protected:
+ static void MapReadCallback(WGPUBufferMapAsyncStatus status,
+ const void* data,
+ uint64_t,
+ void* userdata) {
+ ASSERT_EQ(WGPUBufferMapAsyncStatus_Success, status);
+ ASSERT_NE(nullptr, data);
- static_cast<BufferMapReadTests*>(userdata)->mappedData = data;
- }
+ static_cast<BufferMapReadTests*>(userdata)->mappedData = data;
+ }
- const void* MapReadAsyncAndWait(const wgpu::Buffer& buffer) {
- buffer.MapReadAsync(MapReadCallback, this);
+ const void* MapReadAsyncAndWait(const wgpu::Buffer& buffer) {
+ buffer.MapReadAsync(MapReadCallback, this);
- while (mappedData == nullptr) {
- WaitABit();
- }
+ while (mappedData == nullptr) {
+ WaitABit();
+ }
- return mappedData;
- }
+ return mappedData;
+ }
- void UnmapBuffer(const wgpu::Buffer& buffer) {
- buffer.Unmap();
- mappedData = nullptr;
- }
+ void UnmapBuffer(const wgpu::Buffer& buffer) {
+ buffer.Unmap();
+ mappedData = nullptr;
+ }
- private:
- const void* mappedData = nullptr;
+ private:
+ const void* mappedData = nullptr;
};
// Test that the simplest map read works.
@@ -145,41 +145,45 @@
UnmapBuffer(buffer);
}
-DAWN_INSTANTIATE_TEST(BufferMapReadTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(BufferMapReadTests,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
class BufferMapWriteTests : public DawnTest {
- protected:
- static void MapWriteCallback(WGPUBufferMapAsyncStatus status,
- void* data,
- uint64_t,
- void* userdata) {
- ASSERT_EQ(WGPUBufferMapAsyncStatus_Success, status);
- ASSERT_NE(nullptr, data);
+ protected:
+ static void MapWriteCallback(WGPUBufferMapAsyncStatus status,
+ void* data,
+ uint64_t,
+ void* userdata) {
+ ASSERT_EQ(WGPUBufferMapAsyncStatus_Success, status);
+ ASSERT_NE(nullptr, data);
- static_cast<BufferMapWriteTests*>(userdata)->mappedData = data;
- }
+ static_cast<BufferMapWriteTests*>(userdata)->mappedData = data;
+ }
- void* MapWriteAsyncAndWait(const wgpu::Buffer& buffer) {
- buffer.MapWriteAsync(MapWriteCallback, this);
+ void* MapWriteAsyncAndWait(const wgpu::Buffer& buffer) {
+ buffer.MapWriteAsync(MapWriteCallback, this);
- while (mappedData == nullptr) {
- WaitABit();
- }
+ while (mappedData == nullptr) {
+ WaitABit();
+ }
- // Ensure the prior write's status is updated.
- void* resultPointer = mappedData;
- mappedData = nullptr;
+ // Ensure the prior write's status is updated.
+ void* resultPointer = mappedData;
+ mappedData = nullptr;
- return resultPointer;
- }
+ return resultPointer;
+ }
- void UnmapBuffer(const wgpu::Buffer& buffer) {
- buffer.Unmap();
- mappedData = nullptr;
- }
+ void UnmapBuffer(const wgpu::Buffer& buffer) {
+ buffer.Unmap();
+ mappedData = nullptr;
+ }
- private:
- void* mappedData = nullptr;
+ private:
+ void* mappedData = nullptr;
};
// Test that the simplest map write works.
@@ -307,64 +311,68 @@
UnmapBuffer(buffer);
}
-DAWN_INSTANTIATE_TEST(BufferMapWriteTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(BufferMapWriteTests,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
class CreateBufferMappedTests : public DawnTest {
- protected:
- static void MapReadCallback(WGPUBufferMapAsyncStatus status,
- const void* data,
- uint64_t,
- void* userdata) {
- ASSERT_EQ(WGPUBufferMapAsyncStatus_Success, status);
- ASSERT_NE(nullptr, data);
+ protected:
+ static void MapReadCallback(WGPUBufferMapAsyncStatus status,
+ const void* data,
+ uint64_t,
+ void* userdata) {
+ ASSERT_EQ(WGPUBufferMapAsyncStatus_Success, status);
+ ASSERT_NE(nullptr, data);
- static_cast<CreateBufferMappedTests*>(userdata)->mappedData = data;
- }
+ static_cast<CreateBufferMappedTests*>(userdata)->mappedData = data;
+ }
- const void* MapReadAsyncAndWait(const wgpu::Buffer& buffer) {
- buffer.MapReadAsync(MapReadCallback, this);
+ const void* MapReadAsyncAndWait(const wgpu::Buffer& buffer) {
+ buffer.MapReadAsync(MapReadCallback, this);
- while (mappedData == nullptr) {
- WaitABit();
- }
+ while (mappedData == nullptr) {
+ WaitABit();
+ }
- return mappedData;
- }
+ return mappedData;
+ }
- void UnmapBuffer(const wgpu::Buffer& buffer) {
- buffer.Unmap();
- mappedData = nullptr;
- }
+ void UnmapBuffer(const wgpu::Buffer& buffer) {
+ buffer.Unmap();
+ mappedData = nullptr;
+ }
- void CheckResultStartsZeroed(const wgpu::CreateBufferMappedResult& result, uint64_t size) {
- ASSERT_EQ(result.dataLength, size);
- for (uint64_t i = 0; i < result.dataLength; ++i) {
- uint8_t value = *(reinterpret_cast<uint8_t*>(result.data) + i);
- ASSERT_EQ(value, 0u);
- }
- }
+ void CheckResultStartsZeroed(const wgpu::CreateBufferMappedResult& result, uint64_t size) {
+ ASSERT_EQ(result.dataLength, size);
+ for (uint64_t i = 0; i < result.dataLength; ++i) {
+ uint8_t value = *(reinterpret_cast<uint8_t*>(result.data) + i);
+ ASSERT_EQ(value, 0u);
+ }
+ }
- wgpu::CreateBufferMappedResult CreateBufferMapped(wgpu::BufferUsage usage, uint64_t size) {
- wgpu::BufferDescriptor descriptor = {};
- descriptor.size = size;
- descriptor.usage = usage;
+ wgpu::CreateBufferMappedResult CreateBufferMapped(wgpu::BufferUsage usage, uint64_t size) {
+ wgpu::BufferDescriptor descriptor = {};
+ descriptor.size = size;
+ descriptor.usage = usage;
- wgpu::CreateBufferMappedResult result = device.CreateBufferMapped(&descriptor);
- CheckResultStartsZeroed(result, size);
- return result;
- }
+ wgpu::CreateBufferMappedResult result = device.CreateBufferMapped(&descriptor);
+ CheckResultStartsZeroed(result, size);
+ return result;
+ }
- wgpu::CreateBufferMappedResult CreateBufferMappedWithData(wgpu::BufferUsage usage,
- const std::vector<uint32_t>& data) {
- size_t byteLength = data.size() * sizeof(uint32_t);
- wgpu::CreateBufferMappedResult result = CreateBufferMapped(usage, byteLength);
- memcpy(result.data, data.data(), byteLength);
+ wgpu::CreateBufferMappedResult CreateBufferMappedWithData(wgpu::BufferUsage usage,
+ const std::vector<uint32_t>& data) {
+ size_t byteLength = data.size() * sizeof(uint32_t);
+ wgpu::CreateBufferMappedResult result = CreateBufferMapped(usage, byteLength);
+ memcpy(result.data, data.data(), byteLength);
- return result;
- }
+ return result;
+ }
- private:
- const void* mappedData = nullptr;
+ private:
+ const void* mappedData = nullptr;
};
// Test that the simplest CreateBufferMapped works for MapWrite buffers.
diff --git a/src/tests/end2end/ClipSpaceTests.cpp b/src/tests/end2end/ClipSpaceTests.cpp
index be97ced..33c78e9 100644
--- a/src/tests/end2end/ClipSpaceTests.cpp
+++ b/src/tests/end2end/ClipSpaceTests.cpp
@@ -97,4 +97,8 @@
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, colorTexture, 0, 0);
}
-DAWN_INSTANTIATE_TEST(ClipSpaceTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(ClipSpaceTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/ColorStateTests.cpp b/src/tests/end2end/ColorStateTests.cpp
index f0fa1e5..b4f935d 100644
--- a/src/tests/end2end/ColorStateTests.cpp
+++ b/src/tests/end2end/ColorStateTests.cpp
@@ -758,8 +758,8 @@
renderTargetViews[i] = renderTargets[i].CreateView();
}
- utils::ComboRenderPassDescriptor renderPass({renderTargetViews[0], renderTargetViews[1],
- renderTargetViews[2], renderTargetViews[3]});
+ utils::ComboRenderPassDescriptor renderPass(
+ {renderTargetViews[0], renderTargetViews[1], renderTargetViews[2], renderTargetViews[3]});
wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
@@ -1047,4 +1047,8 @@
EXPECT_PIXEL_RGBA8_EQ(expected, renderPass.color, kRTSize / 2, kRTSize / 2);
}
-DAWN_INSTANTIATE_TEST(ColorStateTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(ColorStateTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/ComputeCopyStorageBufferTests.cpp b/src/tests/end2end/ComputeCopyStorageBufferTests.cpp
index dcb762e..f127acd 100644
--- a/src/tests/end2end/ComputeCopyStorageBufferTests.cpp
+++ b/src/tests/end2end/ComputeCopyStorageBufferTests.cpp
@@ -173,7 +173,7 @@
}
DAWN_INSTANTIATE_TEST(ComputeCopyStorageBufferTests,
- D3D12Backend(),
- MetalBackend(),
- OpenGLBackend(),
- VulkanBackend());
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/ComputeSharedMemoryTests.cpp b/src/tests/end2end/ComputeSharedMemoryTests.cpp
index bb33856..a11c01a 100644
--- a/src/tests/end2end/ComputeSharedMemoryTests.cpp
+++ b/src/tests/end2end/ComputeSharedMemoryTests.cpp
@@ -98,7 +98,7 @@
}
DAWN_INSTANTIATE_TEST(ComputeSharedMemoryTests,
- D3D12Backend(),
- MetalBackend(),
- OpenGLBackend(),
- VulkanBackend());
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/CopyTests.cpp b/src/tests/end2end/CopyTests.cpp
index 5d592a1..75de2f6 100644
--- a/src/tests/end2end/CopyTests.cpp
+++ b/src/tests/end2end/CopyTests.cpp
@@ -21,164 +21,164 @@
#include "utils/WGPUHelpers.h"
class CopyTests : public DawnTest {
- protected:
- static constexpr wgpu::TextureFormat kTextureFormat = wgpu::TextureFormat::RGBA8Unorm;
+ protected:
+ static constexpr wgpu::TextureFormat kTextureFormat = wgpu::TextureFormat::RGBA8Unorm;
- struct TextureSpec {
- wgpu::Origin3D copyOrigin;
- wgpu::Extent3D textureSize;
- uint32_t level;
- };
+ struct TextureSpec {
+ wgpu::Origin3D copyOrigin;
+ wgpu::Extent3D textureSize;
+ uint32_t level;
+ };
- struct BufferSpec {
- uint64_t size;
- uint64_t offset;
- uint32_t bytesPerRow;
- uint32_t rowsPerImage;
- };
+ struct BufferSpec {
+ uint64_t size;
+ uint64_t offset;
+ uint32_t bytesPerRow;
+ uint32_t rowsPerImage;
+ };
- static std::vector<RGBA8> GetExpectedTextureData(
- const utils::BufferTextureCopyLayout& layout) {
- std::vector<RGBA8> textureData(layout.texelBlockCount);
- for (uint32_t layer = 0; layer < layout.mipSize.depth; ++layer) {
- const uint32_t texelIndexOffsetPerSlice = layout.texelBlocksPerImage * layer;
- for (uint32_t y = 0; y < layout.mipSize.height; ++y) {
- for (uint32_t x = 0; x < layout.mipSize.width; ++x) {
- uint32_t i = x + y * layout.texelBlocksPerRow;
- textureData[texelIndexOffsetPerSlice + i] =
- RGBA8(static_cast<uint8_t>((x + layer * x) % 256),
- static_cast<uint8_t>((y + layer * y) % 256),
- static_cast<uint8_t>(x / 256), static_cast<uint8_t>(y / 256));
- }
- }
- }
-
- return textureData;
- }
-
- static BufferSpec MinimumBufferSpec(uint32_t width,
- uint32_t rowsPerImage,
- uint32_t arrayLayer = 1,
- bool testZeroRowsPerImage = true) {
- const uint32_t bytesPerRow = utils::GetMinimumBytesPerRow(kTextureFormat, width);
- const uint32_t totalBufferSize = utils::GetBytesInBufferTextureCopy(
- kTextureFormat, width, bytesPerRow, rowsPerImage, arrayLayer);
- uint32_t appliedRowsPerImage = testZeroRowsPerImage ? 0 : rowsPerImage;
- return {totalBufferSize, 0, bytesPerRow, appliedRowsPerImage};
- }
-
- static void PackTextureData(const RGBA8* srcData, uint32_t width, uint32_t height, uint32_t srcTexelsPerRow, RGBA8* dstData, uint32_t dstTexelsPerRow) {
- for (unsigned int y = 0; y < height; ++y) {
- for (unsigned int x = 0; x < width; ++x) {
- unsigned int src = x + y * srcTexelsPerRow;
- unsigned int dst = x + y * dstTexelsPerRow;
- dstData[dst] = srcData[src];
+ static std::vector<RGBA8> GetExpectedTextureData(const utils::BufferTextureCopyLayout& layout) {
+ std::vector<RGBA8> textureData(layout.texelBlockCount);
+ for (uint32_t layer = 0; layer < layout.mipSize.depth; ++layer) {
+ const uint32_t texelIndexOffsetPerSlice = layout.texelBlocksPerImage * layer;
+ for (uint32_t y = 0; y < layout.mipSize.height; ++y) {
+ for (uint32_t x = 0; x < layout.mipSize.width; ++x) {
+ uint32_t i = x + y * layout.texelBlocksPerRow;
+ textureData[texelIndexOffsetPerSlice + i] =
+ RGBA8(static_cast<uint8_t>((x + layer * x) % 256),
+ static_cast<uint8_t>((y + layer * y) % 256),
+ static_cast<uint8_t>(x / 256), static_cast<uint8_t>(y / 256));
}
}
}
+
+ return textureData;
+ }
+
+ static BufferSpec MinimumBufferSpec(uint32_t width,
+ uint32_t rowsPerImage,
+ uint32_t arrayLayer = 1,
+ bool testZeroRowsPerImage = true) {
+ const uint32_t bytesPerRow = utils::GetMinimumBytesPerRow(kTextureFormat, width);
+ const uint32_t totalBufferSize = utils::GetBytesInBufferTextureCopy(
+ kTextureFormat, width, bytesPerRow, rowsPerImage, arrayLayer);
+ uint32_t appliedRowsPerImage = testZeroRowsPerImage ? 0 : rowsPerImage;
+ return {totalBufferSize, 0, bytesPerRow, appliedRowsPerImage};
+ }
+
+ static void PackTextureData(const RGBA8* srcData,
+ uint32_t width,
+ uint32_t height,
+ uint32_t srcTexelsPerRow,
+ RGBA8* dstData,
+ uint32_t dstTexelsPerRow) {
+ for (unsigned int y = 0; y < height; ++y) {
+ for (unsigned int x = 0; x < width; ++x) {
+ unsigned int src = x + y * srcTexelsPerRow;
+ unsigned int dst = x + y * dstTexelsPerRow;
+ dstData[dst] = srcData[src];
+ }
+ }
+ }
};
class CopyTests_T2B : public CopyTests {
- protected:
- void DoTest(const TextureSpec& textureSpec,
- const BufferSpec& bufferSpec,
- const wgpu::Extent3D& copySize) {
- // Create a texture that is `width` x `height` with (`level` + 1) mip levels.
- wgpu::TextureDescriptor descriptor;
- descriptor.dimension = wgpu::TextureDimension::e2D;
- descriptor.size = textureSpec.textureSize;
- descriptor.sampleCount = 1;
- descriptor.format = kTextureFormat;
- descriptor.mipLevelCount = textureSpec.level + 1;
- descriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
- wgpu::Texture texture = device.CreateTexture(&descriptor);
+ protected:
+ void DoTest(const TextureSpec& textureSpec,
+ const BufferSpec& bufferSpec,
+ const wgpu::Extent3D& copySize) {
+ // Create a texture that is `width` x `height` with (`level` + 1) mip levels.
+ wgpu::TextureDescriptor descriptor;
+ descriptor.dimension = wgpu::TextureDimension::e2D;
+ descriptor.size = textureSpec.textureSize;
+ descriptor.sampleCount = 1;
+ descriptor.format = kTextureFormat;
+ descriptor.mipLevelCount = textureSpec.level + 1;
+ descriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
+ wgpu::Texture texture = device.CreateTexture(&descriptor);
- const utils::BufferTextureCopyLayout copyLayout =
- utils::GetBufferTextureCopyLayoutForTexture2DAtLevel(
- kTextureFormat, textureSpec.textureSize, textureSpec.level,
- bufferSpec.rowsPerImage);
+ const utils::BufferTextureCopyLayout copyLayout =
+ utils::GetBufferTextureCopyLayoutForTexture2DAtLevel(
+ kTextureFormat, textureSpec.textureSize, textureSpec.level,
+ bufferSpec.rowsPerImage);
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
- // Initialize the source texture
- std::vector<RGBA8> textureArrayData = GetExpectedTextureData(copyLayout);
- {
- wgpu::Buffer uploadBuffer =
- utils::CreateBufferFromData(device, textureArrayData.data(),
- copyLayout.byteLength, wgpu::BufferUsage::CopySrc);
- wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(
- uploadBuffer, 0, copyLayout.bytesPerRow, bufferSpec.rowsPerImage);
- wgpu::TextureCopyView textureCopyView =
- utils::CreateTextureCopyView(texture, textureSpec.level, {0, 0, 0});
- encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Layout.mipSize);
- }
+ // Initialize the source texture
+ std::vector<RGBA8> textureArrayData = GetExpectedTextureData(copyLayout);
+ {
+ wgpu::Buffer uploadBuffer = utils::CreateBufferFromData(
+ device, textureArrayData.data(), copyLayout.byteLength, wgpu::BufferUsage::CopySrc);
+ wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(
+ uploadBuffer, 0, copyLayout.bytesPerRow, bufferSpec.rowsPerImage);
+ wgpu::TextureCopyView textureCopyView =
+ utils::CreateTextureCopyView(texture, textureSpec.level, {0, 0, 0});
+ encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Layout.mipSize);
+ }
- // Create a buffer of `size` and populate it with empty data (0,0,0,0) Note:
- // Prepopulating the buffer with empty data ensures that there is not random data in the
- // expectation and helps ensure that the padding due to the bytes per row is not modified
- // by the copy.
- // TODO(jiawei.shao@intel.com): remove the initialization of the buffer after we support
- // buffer lazy-initialization.
- const uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(kTextureFormat);
- const std::vector<RGBA8> emptyData(bufferSpec.size / bytesPerTexel, RGBA8());
- wgpu::Buffer buffer =
- utils::CreateBufferFromData(device, emptyData.data(), bufferSpec.size,
- wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst);
+ // Create a buffer of `size` and populate it with empty data (0,0,0,0) Note:
+ // Prepopulating the buffer with empty data ensures that there is not random data in the
+ // expectation and helps ensure that the padding due to the bytes per row is not modified
+ // by the copy.
+ // TODO(jiawei.shao@intel.com): remove the initialization of the buffer after we support
+ // buffer lazy-initialization.
+ const uint32_t bytesPerTexel = utils::GetTexelBlockSizeInBytes(kTextureFormat);
+ const std::vector<RGBA8> emptyData(bufferSpec.size / bytesPerTexel, RGBA8());
+ wgpu::Buffer buffer =
+ utils::CreateBufferFromData(device, emptyData.data(), bufferSpec.size,
+ wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst);
- {
- wgpu::TextureCopyView textureCopyView =
- utils::CreateTextureCopyView(texture, textureSpec.level, textureSpec.copyOrigin);
- wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(
- buffer, bufferSpec.offset, bufferSpec.bytesPerRow, bufferSpec.rowsPerImage);
- encoder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size);
- }
+ {
+ wgpu::TextureCopyView textureCopyView =
+ utils::CreateTextureCopyView(texture, textureSpec.level, textureSpec.copyOrigin);
+ wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(
+ buffer, bufferSpec.offset, bufferSpec.bytesPerRow, bufferSpec.rowsPerImage);
+ encoder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size);
+ }
- wgpu::CommandBuffer commands = encoder.Finish();
- queue.Submit(1, &commands);
+ wgpu::CommandBuffer commands = encoder.Finish();
+ queue.Submit(1, &commands);
- uint64_t bufferOffset = bufferSpec.offset;
- const uint32_t texelCountInCopyRegion =
- bufferSpec.bytesPerRow / bytesPerTexel * (copySize.height - 1) + copySize.width;
- const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depth;
- std::vector<RGBA8> expected(texelCountInCopyRegion);
- for (uint32_t slice = textureSpec.copyOrigin.z; slice < maxArrayLayer; ++slice) {
- // Pack the data used to create the upload buffer in the specified copy region to have
- // the same format as the expected buffer data.
- std::fill(expected.begin(), expected.end(), RGBA8());
- const uint32_t texelIndexOffset = copyLayout.texelBlocksPerImage * slice;
- const uint32_t expectedTexelArrayDataStartIndex =
- texelIndexOffset + (textureSpec.copyOrigin.x +
- textureSpec.copyOrigin.y * copyLayout.texelBlocksPerRow);
+ uint64_t bufferOffset = bufferSpec.offset;
+ const uint32_t texelCountInCopyRegion =
+ bufferSpec.bytesPerRow / bytesPerTexel * (copySize.height - 1) + copySize.width;
+ const uint32_t maxArrayLayer = textureSpec.copyOrigin.z + copySize.depth;
+ std::vector<RGBA8> expected(texelCountInCopyRegion);
+ for (uint32_t slice = textureSpec.copyOrigin.z; slice < maxArrayLayer; ++slice) {
+ // Pack the data used to create the upload buffer in the specified copy region to have
+ // the same format as the expected buffer data.
+ std::fill(expected.begin(), expected.end(), RGBA8());
+ const uint32_t texelIndexOffset = copyLayout.texelBlocksPerImage * slice;
+ const uint32_t expectedTexelArrayDataStartIndex =
+ texelIndexOffset + (textureSpec.copyOrigin.x +
+ textureSpec.copyOrigin.y * copyLayout.texelBlocksPerRow);
- PackTextureData(&textureArrayData[expectedTexelArrayDataStartIndex], copySize.width,
- copySize.height, copyLayout.texelBlocksPerRow, expected.data(),
- bufferSpec.bytesPerRow / bytesPerTexel);
+ PackTextureData(&textureArrayData[expectedTexelArrayDataStartIndex], copySize.width,
+ copySize.height, copyLayout.texelBlocksPerRow, expected.data(),
+ bufferSpec.bytesPerRow / bytesPerTexel);
- EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<const uint32_t*>(expected.data()), buffer,
- bufferOffset, static_cast<uint32_t>(expected.size()))
- << "Texture to Buffer copy failed copying region [(" << textureSpec.copyOrigin.x
- << ", " << textureSpec.copyOrigin.y << "), ("
- << textureSpec.copyOrigin.x + copySize.width << ", "
- << textureSpec.copyOrigin.y + copySize.height << ")) from "
- << textureSpec.textureSize.width << " x " << textureSpec.textureSize.height
- << " texture at mip level " << textureSpec.level << " layer " << slice << " to "
- << bufferSpec.size << "-byte buffer with offset " << bufferOffset
- << " and bytes per row " << bufferSpec.bytesPerRow << std::endl;
+ EXPECT_BUFFER_U32_RANGE_EQ(reinterpret_cast<const uint32_t*>(expected.data()), buffer,
+ bufferOffset, static_cast<uint32_t>(expected.size()))
+ << "Texture to Buffer copy failed copying region [(" << textureSpec.copyOrigin.x
+ << ", " << textureSpec.copyOrigin.y << "), ("
+ << textureSpec.copyOrigin.x + copySize.width << ", "
+ << textureSpec.copyOrigin.y + copySize.height << ")) from "
+ << textureSpec.textureSize.width << " x " << textureSpec.textureSize.height
+ << " texture at mip level " << textureSpec.level << " layer " << slice << " to "
+ << bufferSpec.size << "-byte buffer with offset " << bufferOffset
+ << " and bytes per row " << bufferSpec.bytesPerRow << std::endl;
- bufferOffset += copyLayout.bytesPerImage;
- }
- }
+ bufferOffset += copyLayout.bytesPerImage;
+ }
+ }
};
class CopyTests_B2T : public CopyTests {
-protected:
+ protected:
static void FillBufferData(RGBA8* data, size_t count) {
for (size_t i = 0; i < count; ++i) {
- data[i] = RGBA8(
- static_cast<uint8_t>(i % 256),
- static_cast<uint8_t>((i / 256) % 256),
- static_cast<uint8_t>((i / 256 / 256) % 256),
- 255);
+ data[i] = RGBA8(static_cast<uint8_t>(i % 256), static_cast<uint8_t>((i / 256) % 256),
+ static_cast<uint8_t>((i / 256 / 256) % 256), 255);
}
}
@@ -510,7 +510,7 @@
constexpr uint32_t kWidth = 256;
constexpr uint32_t kHeight = 128;
for (unsigned int w : {64, 128, 256}) {
- for (unsigned int h : { 16, 32, 48 }) {
+ for (unsigned int h : {16, 32, 48}) {
TextureSpec textureSpec;
textureSpec.copyOrigin = {0, 0, 0};
textureSpec.level = 0;
@@ -531,7 +531,7 @@
defaultTextureSpec.textureSize = {kWidth, kHeight, 1};
for (unsigned int w : {13, 63, 65}) {
- for (unsigned int h : { 17, 19, 63 }) {
+ for (unsigned int h : {17, 19, 63}) {
TextureSpec textureSpec = defaultTextureSpec;
DoTest(textureSpec, MinimumBufferSpec(w, h), {w, h, 1});
}
@@ -746,7 +746,11 @@
DoTest(textureSpec, bufferSpec, {kWidth, kHeight, kCopyLayers});
}
-DAWN_INSTANTIATE_TEST(CopyTests_T2B, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(CopyTests_T2B,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
// Test that copying an entire texture with 256-byte aligned dimensions works
TEST_P(CopyTests_B2T, FullTextureAligned) {
@@ -877,7 +881,7 @@
constexpr uint32_t kWidth = 256;
constexpr uint32_t kHeight = 128;
for (unsigned int w : {64, 128, 256}) {
- for (unsigned int h : { 16, 32, 48 }) {
+ for (unsigned int h : {16, 32, 48}) {
TextureSpec textureSpec;
textureSpec.copyOrigin = {0, 0, 0};
textureSpec.level = 0;
@@ -1090,7 +1094,11 @@
DoTest(textureSpec, bufferSpec, {kWidth, kHeight, kCopyLayers});
}
-DAWN_INSTANTIATE_TEST(CopyTests_B2T, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(CopyTests_B2T,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
TEST_P(CopyTests_T2T, Texture) {
constexpr uint32_t kWidth = 256;
@@ -1310,7 +1318,11 @@
}
}
-DAWN_INSTANTIATE_TEST(CopyTests_T2T, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(CopyTests_T2T,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
static constexpr uint64_t kSmallBufferSize = 4;
static constexpr uint64_t kLargeBufferSize = 1 << 16;
diff --git a/src/tests/end2end/CullingTests.cpp b/src/tests/end2end/CullingTests.cpp
index 79a2303..726df13 100644
--- a/src/tests/end2end/CullingTests.cpp
+++ b/src/tests/end2end/CullingTests.cpp
@@ -127,4 +127,8 @@
DoTest(wgpu::FrontFace::CW, wgpu::CullMode::Back, true, false);
}
-DAWN_INSTANTIATE_TEST(CullingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(CullingTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/D3D12ResourceWrappingTests.cpp b/src/tests/end2end/D3D12ResourceWrappingTests.cpp
index 2907a87..364f48f 100644
--- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp
+++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp
@@ -130,8 +130,7 @@
// A small fixture used to initialize default data for the D3D12Resource validation tests.
// These tests are skipped if the harness is using the wire.
-class D3D12SharedHandleValidation : public D3D12ResourceTestBase {
-};
+class D3D12SharedHandleValidation : public D3D12ResourceTestBase {};
// Test a successful wrapping of an D3D12Resource in a texture
TEST_P(D3D12SharedHandleValidation, Success) {
diff --git a/src/tests/end2end/DebugMarkerTests.cpp b/src/tests/end2end/DebugMarkerTests.cpp
index f9fab77..d368a17 100644
--- a/src/tests/end2end/DebugMarkerTests.cpp
+++ b/src/tests/end2end/DebugMarkerTests.cpp
@@ -42,4 +42,8 @@
queue.Submit(1, &commands);
}
-DAWN_INSTANTIATE_TEST(DebugMarkerTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(DebugMarkerTests,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/DepthSamplingTests.cpp b/src/tests/end2end/DepthSamplingTests.cpp
index 7c24a69..06dcce6e 100644
--- a/src/tests/end2end/DepthSamplingTests.cpp
+++ b/src/tests/end2end/DepthSamplingTests.cpp
@@ -20,14 +20,10 @@
namespace {
constexpr wgpu::CompareFunction kCompareFunctions[] = {
- wgpu::CompareFunction::Never,
- wgpu::CompareFunction::Less,
- wgpu::CompareFunction::LessEqual,
- wgpu::CompareFunction::Greater,
- wgpu::CompareFunction::GreaterEqual,
- wgpu::CompareFunction::Equal,
- wgpu::CompareFunction::NotEqual,
- wgpu::CompareFunction::Always,
+ wgpu::CompareFunction::Never, wgpu::CompareFunction::Less,
+ wgpu::CompareFunction::LessEqual, wgpu::CompareFunction::Greater,
+ wgpu::CompareFunction::GreaterEqual, wgpu::CompareFunction::Equal,
+ wgpu::CompareFunction::NotEqual, wgpu::CompareFunction::Always,
};
// Test a "normal" ref value between 0 and 1; as well as negative and > 1 refs.
@@ -225,12 +221,11 @@
wgpu::SamplerDescriptor samplerDesc;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
- wgpu::BindGroup bindGroup =
- utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
- {
- {0, sampler},
- {1, mInputTexture.CreateView()},
- });
+ wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
+ {
+ {0, sampler},
+ {1, mInputTexture.CreateView()},
+ });
for (float textureValue : textureValues) {
// Set the input depth texture to the provided texture value
@@ -258,12 +253,9 @@
wgpu::SamplerDescriptor samplerDesc;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
- wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
- {
- {0, sampler},
- {1, mInputTexture.CreateView()},
- {2, mOutputBuffer}
- });
+ wgpu::BindGroup bindGroup = utils::MakeBindGroup(
+ device, pipeline.GetBindGroupLayout(0),
+ {{0, sampler}, {1, mInputTexture.CreateView()}, {2, mOutputBuffer}});
for (float textureValue : textureValues) {
// Set the input depth texture to the provided texture value
@@ -321,13 +313,12 @@
samplerDesc.compare = compare;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
- wgpu::BindGroup bindGroup =
- utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
- {
- {0, sampler},
- {1, mInputTexture.CreateView()},
- {2, mUniformBuffer},
- });
+ wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
+ {
+ {0, sampler},
+ {1, mInputTexture.CreateView()},
+ {2, mUniformBuffer},
+ });
for (float textureValue : textureValues) {
// Set the input depth texture to the provided texture value
@@ -364,12 +355,10 @@
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
- {
- {0, sampler},
- {1, mInputTexture.CreateView()},
- {2, mUniformBuffer},
- {3, mOutputBuffer}
- });
+ {{0, sampler},
+ {1, mInputTexture.CreateView()},
+ {2, mUniformBuffer},
+ {3, mOutputBuffer}});
for (float textureValue : textureValues) {
// Set the input depth texture to the provided texture value
diff --git a/src/tests/end2end/DepthStencilStateTests.cpp b/src/tests/end2end/DepthStencilStateTests.cpp
index 4881437..4788094 100644
--- a/src/tests/end2end/DepthStencilStateTests.cpp
+++ b/src/tests/end2end/DepthStencilStateTests.cpp
@@ -21,38 +21,38 @@
constexpr static unsigned int kRTSize = 64;
class DepthStencilStateTest : public DawnTest {
- protected:
- void SetUp() override {
- DawnTest::SetUp();
+ protected:
+ void SetUp() override {
+ DawnTest::SetUp();
- wgpu::TextureDescriptor renderTargetDescriptor;
- renderTargetDescriptor.dimension = wgpu::TextureDimension::e2D;
- renderTargetDescriptor.size.width = kRTSize;
- renderTargetDescriptor.size.height = kRTSize;
- renderTargetDescriptor.size.depth = 1;
- renderTargetDescriptor.sampleCount = 1;
- renderTargetDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
- renderTargetDescriptor.mipLevelCount = 1;
- renderTargetDescriptor.usage =
- wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
- renderTarget = device.CreateTexture(&renderTargetDescriptor);
+ wgpu::TextureDescriptor renderTargetDescriptor;
+ renderTargetDescriptor.dimension = wgpu::TextureDimension::e2D;
+ renderTargetDescriptor.size.width = kRTSize;
+ renderTargetDescriptor.size.height = kRTSize;
+ renderTargetDescriptor.size.depth = 1;
+ renderTargetDescriptor.sampleCount = 1;
+ renderTargetDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
+ renderTargetDescriptor.mipLevelCount = 1;
+ renderTargetDescriptor.usage =
+ wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
+ renderTarget = device.CreateTexture(&renderTargetDescriptor);
- renderTargetView = renderTarget.CreateView();
+ renderTargetView = renderTarget.CreateView();
- wgpu::TextureDescriptor depthDescriptor;
- depthDescriptor.dimension = wgpu::TextureDimension::e2D;
- depthDescriptor.size.width = kRTSize;
- depthDescriptor.size.height = kRTSize;
- depthDescriptor.size.depth = 1;
- depthDescriptor.sampleCount = 1;
- depthDescriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
- depthDescriptor.mipLevelCount = 1;
- depthDescriptor.usage = wgpu::TextureUsage::OutputAttachment;
- depthTexture = device.CreateTexture(&depthDescriptor);
+ wgpu::TextureDescriptor depthDescriptor;
+ depthDescriptor.dimension = wgpu::TextureDimension::e2D;
+ depthDescriptor.size.width = kRTSize;
+ depthDescriptor.size.height = kRTSize;
+ depthDescriptor.size.depth = 1;
+ depthDescriptor.sampleCount = 1;
+ depthDescriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
+ depthDescriptor.mipLevelCount = 1;
+ depthDescriptor.usage = wgpu::TextureUsage::OutputAttachment;
+ depthTexture = device.CreateTexture(&depthDescriptor);
- depthTextureView = depthTexture.CreateView();
+ depthTextureView = depthTexture.CreateView();
- vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
+ vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec3 color;
@@ -67,7 +67,7 @@
}
)");
- fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
+ fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450
layout(set = 0, binding = 0) uniform myBlock {
vec3 color;
@@ -78,235 +78,251 @@
fragColor = vec4(myUbo.color, 1.f);
}
)");
- }
+ }
- struct TestSpec {
- const wgpu::DepthStencilStateDescriptor& depthStencilState;
- RGBA8 color;
- float depth;
- uint32_t stencil;
- };
+ struct TestSpec {
+ const wgpu::DepthStencilStateDescriptor& depthStencilState;
+ RGBA8 color;
+ float depth;
+ uint32_t stencil;
+ };
- // Check whether a depth comparison function works as expected
- // The less, equal, greater booleans denote wether the respective triangle should be visible based on the comparison function
- void CheckDepthCompareFunction(wgpu::CompareFunction compareFunction,
- bool less,
- bool equal,
- bool greater) {
- wgpu::StencilStateFaceDescriptor stencilFace;
- stencilFace.compare = wgpu::CompareFunction::Always;
- stencilFace.failOp = wgpu::StencilOperation::Keep;
- stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
- stencilFace.passOp = wgpu::StencilOperation::Keep;
+ // Check whether a depth comparison function works as expected
+ // The less, equal, greater booleans denote wether the respective triangle should be visible
+ // based on the comparison function
+ void CheckDepthCompareFunction(wgpu::CompareFunction compareFunction,
+ bool less,
+ bool equal,
+ bool greater) {
+ wgpu::StencilStateFaceDescriptor stencilFace;
+ stencilFace.compare = wgpu::CompareFunction::Always;
+ stencilFace.failOp = wgpu::StencilOperation::Keep;
+ stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
+ stencilFace.passOp = wgpu::StencilOperation::Keep;
- wgpu::DepthStencilStateDescriptor baseState;
- baseState.depthWriteEnabled = true;
- baseState.depthCompare = wgpu::CompareFunction::Always;
- baseState.stencilBack = stencilFace;
- baseState.stencilFront = stencilFace;
- baseState.stencilReadMask = 0xff;
- baseState.stencilWriteMask = 0xff;
+ wgpu::DepthStencilStateDescriptor baseState;
+ baseState.depthWriteEnabled = true;
+ baseState.depthCompare = wgpu::CompareFunction::Always;
+ baseState.stencilBack = stencilFace;
+ baseState.stencilFront = stencilFace;
+ baseState.stencilReadMask = 0xff;
+ baseState.stencilWriteMask = 0xff;
- wgpu::DepthStencilStateDescriptor state;
- state.depthWriteEnabled = true;
- state.depthCompare = compareFunction;
- state.stencilBack = stencilFace;
- state.stencilFront = stencilFace;
- state.stencilReadMask = 0xff;
- state.stencilWriteMask = 0xff;
+ wgpu::DepthStencilStateDescriptor state;
+ state.depthWriteEnabled = true;
+ state.depthCompare = compareFunction;
+ state.stencilBack = stencilFace;
+ state.stencilFront = stencilFace;
+ state.stencilReadMask = 0xff;
+ state.stencilWriteMask = 0xff;
- RGBA8 baseColor = RGBA8(255, 255, 255, 255);
- RGBA8 lessColor = RGBA8(255, 0, 0, 255);
- RGBA8 equalColor = RGBA8(0, 255, 0, 255);
- RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
+ RGBA8 baseColor = RGBA8(255, 255, 255, 255);
+ RGBA8 lessColor = RGBA8(255, 0, 0, 255);
+ RGBA8 equalColor = RGBA8(0, 255, 0, 255);
+ RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
- // Base triangle at depth 0.5, depth always, depth write enabled
- TestSpec base = { baseState, baseColor, 0.5f, 0u };
+ // Base triangle at depth 0.5, depth always, depth write enabled
+ TestSpec base = {baseState, baseColor, 0.5f, 0u};
- // Draw the base triangle, then a triangle in stencilFront of the base triangle with the
- // given depth comparison function
- DoTest({ base, { state, lessColor, 0.f, 0u } }, less ? lessColor : baseColor);
+ // Draw the base triangle, then a triangle in stencilFront of the base triangle with the
+ // given depth comparison function
+ DoTest({base, {state, lessColor, 0.f, 0u}}, less ? lessColor : baseColor);
- // Draw the base triangle, then a triangle in at the same depth as the base triangle with the given depth comparison function
- DoTest({ base, { state, equalColor, 0.5f, 0u } }, equal ? equalColor : baseColor);
+ // Draw the base triangle, then a triangle in at the same depth as the base triangle with
+ // the given depth comparison function
+ DoTest({base, {state, equalColor, 0.5f, 0u}}, equal ? equalColor : baseColor);
- // Draw the base triangle, then a triangle behind the base triangle with the given depth comparison function
- DoTest({ base, { state, greaterColor, 1.0f, 0u } }, greater ? greaterColor : baseColor);
- }
+ // Draw the base triangle, then a triangle behind the base triangle with the given depth
+ // comparison function
+ DoTest({base, {state, greaterColor, 1.0f, 0u}}, greater ? greaterColor : baseColor);
+ }
- // Check whether a stencil comparison function works as expected
- // The less, equal, greater booleans denote wether the respective triangle should be visible based on the comparison function
- void CheckStencilCompareFunction(wgpu::CompareFunction compareFunction,
- bool less,
- bool equal,
- bool greater) {
- wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor;
- baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
- baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
- baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
- baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
- wgpu::DepthStencilStateDescriptor baseState;
- baseState.depthWriteEnabled = false;
- baseState.depthCompare = wgpu::CompareFunction::Always;
- baseState.stencilBack = baseStencilFaceDescriptor;
- baseState.stencilFront = baseStencilFaceDescriptor;
- baseState.stencilReadMask = 0xff;
- baseState.stencilWriteMask = 0xff;
+ // Check whether a stencil comparison function works as expected
+ // The less, equal, greater booleans denote wether the respective triangle should be visible
+ // based on the comparison function
+ void CheckStencilCompareFunction(wgpu::CompareFunction compareFunction,
+ bool less,
+ bool equal,
+ bool greater) {
+ wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor;
+ baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
+ baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
+ baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
+ baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
+ wgpu::DepthStencilStateDescriptor baseState;
+ baseState.depthWriteEnabled = false;
+ baseState.depthCompare = wgpu::CompareFunction::Always;
+ baseState.stencilBack = baseStencilFaceDescriptor;
+ baseState.stencilFront = baseStencilFaceDescriptor;
+ baseState.stencilReadMask = 0xff;
+ baseState.stencilWriteMask = 0xff;
- wgpu::StencilStateFaceDescriptor stencilFaceDescriptor;
- stencilFaceDescriptor.compare = compareFunction;
- stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
- stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
- stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
- wgpu::DepthStencilStateDescriptor state;
- state.depthWriteEnabled = false;
- state.depthCompare = wgpu::CompareFunction::Always;
- state.stencilBack = stencilFaceDescriptor;
- state.stencilFront = stencilFaceDescriptor;
- state.stencilReadMask = 0xff;
- state.stencilWriteMask = 0xff;
+ wgpu::StencilStateFaceDescriptor stencilFaceDescriptor;
+ stencilFaceDescriptor.compare = compareFunction;
+ stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
+ stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
+ stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
+ wgpu::DepthStencilStateDescriptor state;
+ state.depthWriteEnabled = false;
+ state.depthCompare = wgpu::CompareFunction::Always;
+ state.stencilBack = stencilFaceDescriptor;
+ state.stencilFront = stencilFaceDescriptor;
+ state.stencilReadMask = 0xff;
+ state.stencilWriteMask = 0xff;
- RGBA8 baseColor = RGBA8(255, 255, 255, 255);
- RGBA8 lessColor = RGBA8(255, 0, 0, 255);
- RGBA8 equalColor = RGBA8(0, 255, 0, 255);
- RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
+ RGBA8 baseColor = RGBA8(255, 255, 255, 255);
+ RGBA8 lessColor = RGBA8(255, 0, 0, 255);
+ RGBA8 equalColor = RGBA8(0, 255, 0, 255);
+ RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
- // Base triangle with stencil reference 1
- TestSpec base = { baseState, baseColor, 0.0f, 1u };
+ // Base triangle with stencil reference 1
+ TestSpec base = {baseState, baseColor, 0.0f, 1u};
- // Draw the base triangle, then a triangle with stencil reference 0 with the given stencil comparison function
- DoTest({ base, { state, lessColor, 0.f, 0u } }, less ? lessColor : baseColor);
+ // Draw the base triangle, then a triangle with stencil reference 0 with the given stencil
+ // comparison function
+ DoTest({base, {state, lessColor, 0.f, 0u}}, less ? lessColor : baseColor);
- // Draw the base triangle, then a triangle with stencil reference 1 with the given stencil comparison function
- DoTest({ base, { state, equalColor, 0.f, 1u } }, equal ? equalColor : baseColor);
+ // Draw the base triangle, then a triangle with stencil reference 1 with the given stencil
+ // comparison function
+ DoTest({base, {state, equalColor, 0.f, 1u}}, equal ? equalColor : baseColor);
- // Draw the base triangle, then a triangle with stencil reference 2 with the given stencil comparison function
- DoTest({ base, { state, greaterColor, 0.f, 2u } }, greater ? greaterColor : baseColor);
- }
+ // Draw the base triangle, then a triangle with stencil reference 2 with the given stencil
+ // comparison function
+ DoTest({base, {state, greaterColor, 0.f, 2u}}, greater ? greaterColor : baseColor);
+ }
- // Given the provided `initialStencil` and `reference`, check that applying the `stencilOperation` produces the `expectedStencil`
- void CheckStencilOperation(wgpu::StencilOperation stencilOperation,
- uint32_t initialStencil,
- uint32_t reference,
- uint32_t expectedStencil) {
- wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor;
- baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
- baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
- baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
- baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
- wgpu::DepthStencilStateDescriptor baseState;
- baseState.depthWriteEnabled = false;
- baseState.depthCompare = wgpu::CompareFunction::Always;
- baseState.stencilBack = baseStencilFaceDescriptor;
- baseState.stencilFront = baseStencilFaceDescriptor;
- baseState.stencilReadMask = 0xff;
- baseState.stencilWriteMask = 0xff;
+ // Given the provided `initialStencil` and `reference`, check that applying the
+ // `stencilOperation` produces the `expectedStencil`
+ void CheckStencilOperation(wgpu::StencilOperation stencilOperation,
+ uint32_t initialStencil,
+ uint32_t reference,
+ uint32_t expectedStencil) {
+ wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor;
+ baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
+ baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
+ baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
+ baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
+ wgpu::DepthStencilStateDescriptor baseState;
+ baseState.depthWriteEnabled = false;
+ baseState.depthCompare = wgpu::CompareFunction::Always;
+ baseState.stencilBack = baseStencilFaceDescriptor;
+ baseState.stencilFront = baseStencilFaceDescriptor;
+ baseState.stencilReadMask = 0xff;
+ baseState.stencilWriteMask = 0xff;
- wgpu::StencilStateFaceDescriptor stencilFaceDescriptor;
- stencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
- stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
- stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
- stencilFaceDescriptor.passOp = stencilOperation;
- wgpu::DepthStencilStateDescriptor state;
- state.depthWriteEnabled = false;
- state.depthCompare = wgpu::CompareFunction::Always;
- state.stencilBack = stencilFaceDescriptor;
- state.stencilFront = stencilFaceDescriptor;
- state.stencilReadMask = 0xff;
- state.stencilWriteMask = 0xff;
+ wgpu::StencilStateFaceDescriptor stencilFaceDescriptor;
+ stencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
+ stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
+ stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
+ stencilFaceDescriptor.passOp = stencilOperation;
+ wgpu::DepthStencilStateDescriptor state;
+ state.depthWriteEnabled = false;
+ state.depthCompare = wgpu::CompareFunction::Always;
+ state.stencilBack = stencilFaceDescriptor;
+ state.stencilFront = stencilFaceDescriptor;
+ state.stencilReadMask = 0xff;
+ state.stencilWriteMask = 0xff;
- CheckStencil({
+ CheckStencil(
+ {
// Wipe the stencil buffer with the initialStencil value
- { baseState, RGBA8(255, 255, 255, 255), 0.f, initialStencil },
+ {baseState, RGBA8(255, 255, 255, 255), 0.f, initialStencil},
// Draw a triangle with the provided stencil operation and reference
- { state, RGBA8(255, 0, 0, 255), 0.f, reference },
- }, expectedStencil);
- }
+ {state, RGBA8(255, 0, 0, 255), 0.f, reference},
+ },
+ expectedStencil);
+ }
- // Draw a list of test specs, and check if the stencil value is equal to the expected value
- void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) {
- wgpu::StencilStateFaceDescriptor stencilFaceDescriptor;
- stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal;
- stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
- stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
- stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
- wgpu::DepthStencilStateDescriptor state;
- state.depthWriteEnabled = false;
- state.depthCompare = wgpu::CompareFunction::Always;
- state.stencilBack = stencilFaceDescriptor;
- state.stencilFront = stencilFaceDescriptor;
- state.stencilReadMask = 0xff;
- state.stencilWriteMask = 0xff;
+ // Draw a list of test specs, and check if the stencil value is equal to the expected value
+ void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) {
+ wgpu::StencilStateFaceDescriptor stencilFaceDescriptor;
+ stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal;
+ stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
+ stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
+ stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
+ wgpu::DepthStencilStateDescriptor state;
+ state.depthWriteEnabled = false;
+ state.depthCompare = wgpu::CompareFunction::Always;
+ state.stencilBack = stencilFaceDescriptor;
+ state.stencilFront = stencilFaceDescriptor;
+ state.stencilReadMask = 0xff;
+ state.stencilWriteMask = 0xff;
- testParams.push_back({ state, RGBA8(0, 255, 0, 255), 0, expectedStencil });
- DoTest(testParams, RGBA8(0, 255, 0, 255));
- }
+ testParams.push_back({state, RGBA8(0, 255, 0, 255), 0, expectedStencil});
+ DoTest(testParams, RGBA8(0, 255, 0, 255));
+ }
- // Each test param represents a pair of triangles with a color, depth, stencil value, and depthStencil state, one frontfacing, one backfacing
- // Draw the triangles in order and check the expected colors for the frontfaces and backfaces
- void DoTest(const std::vector<TestSpec> &testParams, const RGBA8& expectedFront, const RGBA8& expectedBack) {
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ // Each test param represents a pair of triangles with a color, depth, stencil value, and
+ // depthStencil state, one frontfacing, one backfacing Draw the triangles in order and check the
+ // expected colors for the frontfaces and backfaces
+ void DoTest(const std::vector<TestSpec>& testParams,
+ const RGBA8& expectedFront,
+ const RGBA8& expectedBack) {
+ wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
- struct TriangleData {
- float color[3];
- float depth;
+ struct TriangleData {
+ float color[3];
+ float depth;
+ };
+
+ utils::ComboRenderPassDescriptor renderPass({renderTargetView}, depthTextureView);
+ wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
+
+ for (size_t i = 0; i < testParams.size(); ++i) {
+ const TestSpec& test = testParams[i];
+
+ TriangleData data = {
+ {static_cast<float>(test.color.r) / 255.f, static_cast<float>(test.color.g) / 255.f,
+ static_cast<float>(test.color.b) / 255.f},
+ test.depth,
};
+ // Upload a buffer for each triangle's depth and color data
+ wgpu::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData),
+ wgpu::BufferUsage::Uniform);
- utils::ComboRenderPassDescriptor renderPass({renderTargetView}, depthTextureView);
- wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
+ // Create a pipeline for the triangles with the test spec's depth stencil state
- for (size_t i = 0; i < testParams.size(); ++i) {
- const TestSpec& test = testParams[i];
+ utils::ComboRenderPipelineDescriptor descriptor(device);
+ descriptor.vertexStage.module = vsModule;
+ descriptor.cFragmentStage.module = fsModule;
+ descriptor.cDepthStencilState = test.depthStencilState;
+ descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
+ descriptor.depthStencilState = &descriptor.cDepthStencilState;
- TriangleData data = {
- { static_cast<float>(test.color.r) / 255.f, static_cast<float>(test.color.g) / 255.f, static_cast<float>(test.color.b) / 255.f },
- test.depth,
- };
- // Upload a buffer for each triangle's depth and color data
- wgpu::Buffer buffer = utils::CreateBufferFromData(
- device, &data, sizeof(TriangleData), wgpu::BufferUsage::Uniform);
+ wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
- // Create a pipeline for the triangles with the test spec's depth stencil state
+ // Create a bind group for the data
+ wgpu::BindGroup bindGroup = utils::MakeBindGroup(
+ device, pipeline.GetBindGroupLayout(0), {{0, buffer, 0, sizeof(TriangleData)}});
- utils::ComboRenderPipelineDescriptor descriptor(device);
- descriptor.vertexStage.module = vsModule;
- descriptor.cFragmentStage.module = fsModule;
- descriptor.cDepthStencilState = test.depthStencilState;
- descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
- descriptor.depthStencilState = &descriptor.cDepthStencilState;
-
- wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
-
- // Create a bind group for the data
- wgpu::BindGroup bindGroup = utils::MakeBindGroup(
- device, pipeline.GetBindGroupLayout(0), {{0, buffer, 0, sizeof(TriangleData)}});
-
- pass.SetPipeline(pipeline);
- pass.SetStencilReference(test.stencil); // Set the stencil reference
- pass.SetBindGroup(
- 0, bindGroup); // Set the bind group which contains color and depth data
- pass.Draw(6);
- }
- pass.EndPass();
-
- wgpu::CommandBuffer commands = encoder.Finish();
- queue.Submit(1, &commands);
-
- EXPECT_PIXEL_RGBA8_EQ(expectedFront, renderTarget, kRTSize / 4, kRTSize / 2) << "Front face check failed";
- EXPECT_PIXEL_RGBA8_EQ(expectedBack, renderTarget, 3 * kRTSize / 4, kRTSize / 2) << "Back face check failed";
+ pass.SetPipeline(pipeline);
+ pass.SetStencilReference(test.stencil); // Set the stencil reference
+ pass.SetBindGroup(0,
+ bindGroup); // Set the bind group which contains color and depth data
+ pass.Draw(6);
}
+ pass.EndPass();
- void DoTest(const std::vector<TestSpec> &testParams, const RGBA8& expected) {
- DoTest(testParams, expected, expected);
- }
+ wgpu::CommandBuffer commands = encoder.Finish();
+ queue.Submit(1, &commands);
- wgpu::Texture renderTarget;
- wgpu::Texture depthTexture;
- wgpu::TextureView renderTargetView;
- wgpu::TextureView depthTextureView;
- wgpu::ShaderModule vsModule;
- wgpu::ShaderModule fsModule;
+ EXPECT_PIXEL_RGBA8_EQ(expectedFront, renderTarget, kRTSize / 4, kRTSize / 2)
+ << "Front face check failed";
+ EXPECT_PIXEL_RGBA8_EQ(expectedBack, renderTarget, 3 * kRTSize / 4, kRTSize / 2)
+ << "Back face check failed";
+ }
+
+ void DoTest(const std::vector<TestSpec>& testParams, const RGBA8& expected) {
+ DoTest(testParams, expected, expected);
+ }
+
+ wgpu::Texture renderTarget;
+ wgpu::Texture depthTexture;
+ wgpu::TextureView renderTargetView;
+ wgpu::TextureView depthTextureView;
+ wgpu::ShaderModule vsModule;
+ wgpu::ShaderModule fsModule;
};
// Test compilation and usage of the fixture
@@ -325,9 +341,11 @@
state.stencilReadMask = 0xff;
state.stencilWriteMask = 0xff;
- DoTest({
- { state, RGBA8(0, 255, 0, 255), 0.5f, 0u },
- }, RGBA8(0, 255, 0, 255));
+ DoTest(
+ {
+ {state, RGBA8(0, 255, 0, 255), 0.5f, 0u},
+ },
+ RGBA8(0, 255, 0, 255));
}
// Test defaults: depth and stencil tests disabled
@@ -347,9 +365,9 @@
state.stencilWriteMask = 0xff;
TestSpec specs[3] = {
- { state, RGBA8(255, 0, 0, 255), 0.0f, 0u },
- { state, RGBA8(0, 255, 0, 255), 0.5f, 0u },
- { state, RGBA8(0, 0, 255, 255), 1.0f, 0u },
+ {state, RGBA8(255, 0, 0, 255), 0.0f, 0u},
+ {state, RGBA8(0, 255, 0, 255), 0.5f, 0u},
+ {state, RGBA8(0, 0, 255, 255), 1.0f, 0u},
};
// Test that for all combinations, the last triangle drawn is the one visible
@@ -357,8 +375,8 @@
for (uint32_t last = 0; last < 3; ++last) {
uint32_t i = (last + 1) % 3;
uint32_t j = (last + 2) % 3;
- DoTest({ specs[i], specs[j], specs[last] }, specs[last].color);
- DoTest({ specs[j], specs[i], specs[last] }, specs[last].color);
+ DoTest({specs[i], specs[j], specs[last]}, specs[last].color);
+ DoTest({specs[j], specs[i], specs[last]}, specs[last].color);
}
}
@@ -427,11 +445,17 @@
checkState.stencilReadMask = 0xff;
checkState.stencilWriteMask = 0xff;
- DoTest({
- { baseState, RGBA8(255, 255, 255, 255), 1.f, 0u }, // Draw a base triangle with depth enabled
- { noDepthWrite, RGBA8(0, 0, 0, 255), 0.f, 0u }, // Draw a second triangle without depth enabled
- { checkState, RGBA8(0, 255, 0, 255), 1.f, 0u }, // Draw a third triangle which should occlude the second even though it is behind it
- }, RGBA8(0, 255, 0, 255));
+ DoTest(
+ {
+ {baseState, RGBA8(255, 255, 255, 255), 1.f,
+ 0u}, // Draw a base triangle with depth enabled
+ {noDepthWrite, RGBA8(0, 0, 0, 255), 0.f,
+ 0u}, // Draw a second triangle without depth enabled
+ {checkState, RGBA8(0, 255, 0, 255), 1.f,
+ 0u}, // Draw a third triangle which should occlude the second even though it is behind
+ // it
+ },
+ RGBA8(0, 255, 0, 255));
}
// The following tests check that each stencil comparison function works
@@ -536,9 +560,11 @@
RGBA8 red = RGBA8(255, 0, 0, 255);
RGBA8 green = RGBA8(0, 255, 0, 255);
- TestSpec base = { baseState, baseColor, 0.5f, 3u }; // Base triangle to set the stencil to 3
- DoTest({ base, { state, red, 0.f, 1u } }, baseColor); // Triangle with stencil reference 1 and read mask 2 does not draw because (3 & 2 != 1)
- DoTest({ base, { state, green, 0.f, 2u } }, green); // Triangle with stencil reference 2 and read mask 2 draws because (3 & 2 == 2)
+ TestSpec base = {baseState, baseColor, 0.5f, 3u}; // Base triangle to set the stencil to 3
+ DoTest({base, {state, red, 0.f, 1u}}, baseColor); // Triangle with stencil reference 1 and read
+ // mask 2 does not draw because (3 & 2 != 1)
+ DoTest({base, {state, green, 0.f, 2u}},
+ green); // Triangle with stencil reference 2 and read mask 2 draws because (3 & 2 == 2)
}
// Check that setting a stencil write mask works
@@ -572,9 +598,12 @@
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
RGBA8 green = RGBA8(0, 255, 0, 255);
- TestSpec base = { baseState, baseColor, 0.5f, 3u }; // Base triangle with stencil reference 3 and mask 1 to set the stencil 1
- DoTest({ base, { state, green, 0.f, 2u } }, baseColor); // Triangle with stencil reference 2 does not draw because 2 != (3 & 1)
- DoTest({ base, { state, green, 0.f, 1u } }, green); // Triangle with stencil reference 1 draws because 1 == (3 & 1)
+ TestSpec base = {baseState, baseColor, 0.5f,
+ 3u}; // Base triangle with stencil reference 3 and mask 1 to set the stencil 1
+ DoTest({base, {state, green, 0.f, 2u}},
+ baseColor); // Triangle with stencil reference 2 does not draw because 2 != (3 & 1)
+ DoTest({base, {state, green, 0.f, 1u}},
+ green); // Triangle with stencil reference 1 draws because 1 == (3 & 1)
}
// Test that the stencil operation is executed on stencil fail
@@ -605,10 +634,13 @@
state.stencilReadMask = 0xff;
state.stencilWriteMask = 0xff;
- CheckStencil({
- { baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1
- { state, RGBA8(0, 0, 0, 255), 0.f, 2 } // Triangle with stencil reference 2 fails the Less comparison function
- }, 2); // Replace the stencil on failure, so it should be 2
+ CheckStencil(
+ {
+ {baseState, RGBA8(255, 255, 255, 255), 1.f, 1}, // Triangle to set stencil value to 1
+ {state, RGBA8(0, 0, 0, 255), 0.f,
+ 2} // Triangle with stencil reference 2 fails the Less comparison function
+ },
+ 2); // Replace the stencil on failure, so it should be 2
}
// Test that the stencil operation is executed on stencil pass, depth fail
@@ -639,10 +671,12 @@
state.stencilReadMask = 0xff;
state.stencilWriteMask = 0xff;
- CheckStencil({
- { baseState, RGBA8(255, 255, 255, 255), 0.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
- { state, RGBA8(0, 0, 0, 255), 1.f, 2 } }, // Triangle with stencil reference 2 passes the Greater comparison function. At depth 1, it fails the Less depth test
- 2); // Replace the stencil on stencil pass, depth failure, so it should be 2
+ CheckStencil({{baseState, RGBA8(255, 255, 255, 255), 0.f,
+ 1}, // Triangle to set stencil value to 1. Depth is 0
+ {state, RGBA8(0, 0, 0, 255), 1.f,
+ 2}}, // Triangle with stencil reference 2 passes the Greater comparison
+ // function. At depth 1, it fails the Less depth test
+ 2); // Replace the stencil on stencil pass, depth failure, so it should be 2
}
// Test that the stencil operation is executed on stencil pass, depth pass
@@ -673,10 +707,12 @@
state.stencilReadMask = 0xff;
state.stencilWriteMask = 0xff;
- CheckStencil({
- { baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
- { state, RGBA8(0, 0, 0, 255), 0.f, 2 } }, // Triangle with stencil reference 2 passes the Greater comparison function. At depth 0, it pass the Less depth test
-2); // Replace the stencil on stencil pass, depth pass, so it should be 2
+ CheckStencil({{baseState, RGBA8(255, 255, 255, 255), 1.f,
+ 1}, // Triangle to set stencil value to 1. Depth is 0
+ {state, RGBA8(0, 0, 0, 255), 0.f,
+ 2}}, // Triangle with stencil reference 2 passes the Greater comparison
+ // function. At depth 0, it pass the Less depth test
+ 2); // Replace the stencil on stencil pass, depth pass, so it should be 2
}
// Test that creating a render pipeline works with for all depth and combined formats
diff --git a/src/tests/end2end/DestroyTests.cpp b/src/tests/end2end/DestroyTests.cpp
index 82c43a6..4122001 100644
--- a/src/tests/end2end/DestroyTests.cpp
+++ b/src/tests/end2end/DestroyTests.cpp
@@ -157,4 +157,8 @@
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
}
-DAWN_INSTANTIATE_TEST(DestroyTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(DestroyTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/DrawIndexedTests.cpp b/src/tests/end2end/DrawIndexedTests.cpp
index 48abdad..f980af3 100644
--- a/src/tests/end2end/DrawIndexedTests.cpp
+++ b/src/tests/end2end/DrawIndexedTests.cpp
@@ -20,90 +20,89 @@
constexpr uint32_t kRTSize = 4;
class DrawIndexedTest : public DawnTest {
- protected:
- void SetUp() override {
- DawnTest::SetUp();
+ protected:
+ void SetUp() override {
+ DawnTest::SetUp();
- renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
+ renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
- wgpu::ShaderModule vsModule =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
+ wgpu::ShaderModule vsModule =
+ utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
gl_Position = pos;
})");
- wgpu::ShaderModule fsModule =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
+ wgpu::ShaderModule fsModule =
+ utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
- utils::ComboRenderPipelineDescriptor descriptor(device);
- descriptor.vertexStage.module = vsModule;
- descriptor.cFragmentStage.module = fsModule;
- descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
- descriptor.cVertexState.vertexBufferCount = 1;
- descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
- descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
- descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
- descriptor.cColorStates[0].format = renderPass.colorFormat;
+ utils::ComboRenderPipelineDescriptor descriptor(device);
+ descriptor.vertexStage.module = vsModule;
+ descriptor.cFragmentStage.module = fsModule;
+ descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
+ descriptor.cVertexState.vertexBufferCount = 1;
+ descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
+ descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
+ descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
+ descriptor.cColorStates[0].format = renderPass.colorFormat;
- pipeline = device.CreateRenderPipeline(&descriptor);
+ pipeline = device.CreateRenderPipeline(&descriptor);
- vertexBuffer = utils::CreateBufferFromData<float>(
- device, wgpu::BufferUsage::Vertex,
- {// First quad: the first 3 vertices represent the bottom left triangle
- -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f,
- 1.0f, 0.0f, 1.0f,
+ vertexBuffer = utils::CreateBufferFromData<float>(
+ device, wgpu::BufferUsage::Vertex,
+ {// First quad: the first 3 vertices represent the bottom left triangle
+ -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f,
+ 0.0f, 1.0f,
- // Second quad: the first 3 vertices represent the top right triangle
- -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f,
- -1.0f, 0.0f, 1.0f});
- indexBuffer = utils::CreateBufferFromData<uint32_t>(
- device, wgpu::BufferUsage::Index,
- {0, 1, 2, 0, 3, 1,
- // The indices below are added to test negatve baseVertex
- 0 + 4, 1 + 4, 2 + 4, 0 + 4, 3 + 4, 1 + 4});
+ // Second quad: the first 3 vertices represent the top right triangle
+ -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f,
+ 0.0f, 1.0f});
+ indexBuffer = utils::CreateBufferFromData<uint32_t>(
+ device, wgpu::BufferUsage::Index,
+ {0, 1, 2, 0, 3, 1,
+ // The indices below are added to test negatve baseVertex
+ 0 + 4, 1 + 4, 2 + 4, 0 + 4, 3 + 4, 1 + 4});
+ }
+
+ utils::BasicRenderPass renderPass;
+ wgpu::RenderPipeline pipeline;
+ wgpu::Buffer vertexBuffer;
+ wgpu::Buffer indexBuffer;
+
+ void Test(uint32_t indexCount,
+ uint32_t instanceCount,
+ uint32_t firstIndex,
+ int32_t baseVertex,
+ uint32_t firstInstance,
+ uint64_t bufferOffset,
+ RGBA8 bottomLeftExpected,
+ RGBA8 topRightExpected) {
+ wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ {
+ wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
+ pass.SetPipeline(pipeline);
+ pass.SetVertexBuffer(0, vertexBuffer);
+ pass.SetIndexBuffer(indexBuffer, bufferOffset);
+ pass.DrawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
+ pass.EndPass();
}
- utils::BasicRenderPass renderPass;
- wgpu::RenderPipeline pipeline;
- wgpu::Buffer vertexBuffer;
- wgpu::Buffer indexBuffer;
+ wgpu::CommandBuffer commands = encoder.Finish();
+ queue.Submit(1, &commands);
- void Test(uint32_t indexCount,
- uint32_t instanceCount,
- uint32_t firstIndex,
- int32_t baseVertex,
- uint32_t firstInstance,
- uint64_t bufferOffset,
- RGBA8 bottomLeftExpected,
- RGBA8 topRightExpected) {
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
- {
- wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
- pass.SetPipeline(pipeline);
- pass.SetVertexBuffer(0, vertexBuffer);
- pass.SetIndexBuffer(indexBuffer, bufferOffset);
- pass.DrawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
- pass.EndPass();
- }
-
- wgpu::CommandBuffer commands = encoder.Finish();
- queue.Submit(1, &commands);
-
- EXPECT_PIXEL_RGBA8_EQ(bottomLeftExpected, renderPass.color, 1, 3);
- EXPECT_PIXEL_RGBA8_EQ(topRightExpected, renderPass.color, 3, 1);
- }
+ EXPECT_PIXEL_RGBA8_EQ(bottomLeftExpected, renderPass.color, 1, 3);
+ EXPECT_PIXEL_RGBA8_EQ(topRightExpected, renderPass.color, 3, 1);
+ }
};
// The most basic DrawIndexed triangle draw.
TEST_P(DrawIndexedTest, Uint32) {
-
RGBA8 filled(0, 255, 0, 255);
RGBA8 notFilled(0, 0, 0, 0);
@@ -134,4 +133,8 @@
Test(3, 1, 3, -4, 0, 6 * sizeof(uint32_t), notFilled, filled);
}
-DAWN_INSTANTIATE_TEST(DrawIndexedTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(DrawIndexedTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/DrawIndirectTests.cpp b/src/tests/end2end/DrawIndirectTests.cpp
index 3f14375..56b55ec 100644
--- a/src/tests/end2end/DrawIndirectTests.cpp
+++ b/src/tests/end2end/DrawIndirectTests.cpp
@@ -124,4 +124,8 @@
Test({3, 1, 0, 0, 3, 1, 3, 0}, 4 * sizeof(uint32_t), notFilled, filled);
}
-DAWN_INSTANTIATE_TEST(DrawIndirectTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(DrawIndirectTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/GpuMemorySynchronizationTests.cpp b/src/tests/end2end/GpuMemorySynchronizationTests.cpp
index 3b4dcd1..4cf64d0 100644
--- a/src/tests/end2end/GpuMemorySynchronizationTests.cpp
+++ b/src/tests/end2end/GpuMemorySynchronizationTests.cpp
@@ -231,7 +231,11 @@
EXPECT_PIXEL_RGBA8_EQ(RGBA8(2, 0, 0, 255), renderPass.color, 0, 0);
}
-DAWN_INSTANTIATE_TEST(GpuMemorySyncTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(GpuMemorySyncTests,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
class StorageToUniformSyncTests : public DawnTest {
protected:
diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp
index af40c1b..9e44cb7 100644
--- a/src/tests/end2end/IOSurfaceWrappingTests.cpp
+++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp
@@ -369,7 +369,8 @@
// Test sampling from a R8 IOSurface
TEST_P(IOSurfaceUsageTests, SampleFromR8IOSurface) {
DAWN_SKIP_TEST_IF(UsesWire());
- ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_OneComponent8, 1);
+ ScopedIOSurfaceRef ioSurface =
+ CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_OneComponent8, 1);
uint8_t data = 0x01;
DoSampleTest(ioSurface.get(), wgpu::TextureFormat::R8Unorm, &data, sizeof(data),
@@ -379,7 +380,8 @@
// Test clearing a R8 IOSurface
TEST_P(IOSurfaceUsageTests, ClearR8IOSurface) {
DAWN_SKIP_TEST_IF(UsesWire());
- ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_OneComponent8, 1);
+ ScopedIOSurfaceRef ioSurface =
+ CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_OneComponent8, 1);
uint8_t data = 0x01;
DoClearTest(ioSurface.get(), wgpu::TextureFormat::R8Unorm, &data, sizeof(data));
@@ -388,7 +390,8 @@
// Test sampling from a RG8 IOSurface
TEST_P(IOSurfaceUsageTests, SampleFromRG8IOSurface) {
DAWN_SKIP_TEST_IF(UsesWire());
- ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_TwoComponent8, 2);
+ ScopedIOSurfaceRef ioSurface =
+ CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_TwoComponent8, 2);
uint16_t data = 0x0102; // Stored as (G, R)
DoSampleTest(ioSurface.get(), wgpu::TextureFormat::RG8Unorm, &data, sizeof(data),
@@ -398,7 +401,8 @@
// Test clearing a RG8 IOSurface
TEST_P(IOSurfaceUsageTests, ClearRG8IOSurface) {
DAWN_SKIP_TEST_IF(UsesWire());
- ScopedIOSurfaceRef ioSurface = CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_TwoComponent8, 2);
+ ScopedIOSurfaceRef ioSurface =
+ CreateSinglePlaneIOSurface(1, 1, kCVPixelFormatType_TwoComponent8, 2);
uint16_t data = 0x0201;
DoClearTest(ioSurface.get(), wgpu::TextureFormat::RG8Unorm, &data, sizeof(data));
diff --git a/src/tests/end2end/IndexFormatTests.cpp b/src/tests/end2end/IndexFormatTests.cpp
index ea83e91..554c674 100644
--- a/src/tests/end2end/IndexFormatTests.cpp
+++ b/src/tests/end2end/IndexFormatTests.cpp
@@ -21,45 +21,45 @@
constexpr uint32_t kRTSize = 400;
class IndexFormatTest : public DawnTest {
- protected:
- void SetUp() override {
- DawnTest::SetUp();
+ protected:
+ void SetUp() override {
+ DawnTest::SetUp();
- renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
- }
+ renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
+ }
- utils::BasicRenderPass renderPass;
+ utils::BasicRenderPass renderPass;
- wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format) {
- wgpu::ShaderModule vsModule =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
+ wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format) {
+ wgpu::ShaderModule vsModule =
+ utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
gl_Position = pos;
})");
- wgpu::ShaderModule fsModule =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
+ wgpu::ShaderModule fsModule =
+ utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
- utils::ComboRenderPipelineDescriptor descriptor(device);
- descriptor.vertexStage.module = vsModule;
- descriptor.cFragmentStage.module = fsModule;
- descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
- descriptor.cVertexState.indexFormat = format;
- descriptor.cVertexState.vertexBufferCount = 1;
- descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
- descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
- descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
- descriptor.cColorStates[0].format = renderPass.colorFormat;
+ utils::ComboRenderPipelineDescriptor descriptor(device);
+ descriptor.vertexStage.module = vsModule;
+ descriptor.cFragmentStage.module = fsModule;
+ descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip;
+ descriptor.cVertexState.indexFormat = format;
+ descriptor.cVertexState.vertexBufferCount = 1;
+ descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
+ descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
+ descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
+ descriptor.cColorStates[0].format = renderPass.colorFormat;
- return device.CreateRenderPipeline(&descriptor);
- }
+ return device.CreateRenderPipeline(&descriptor);
+ }
};
// Test that the Uint32 index format is correctly interpreted
@@ -275,4 +275,8 @@
EXPECT_PIXEL_RGBA8_EQ(RGBA8(0, 255, 0, 255), renderPass.color, 100, 300);
}
-DAWN_INSTANTIATE_TEST(IndexFormatTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(IndexFormatTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp
index ef03bf2..0605594 100644
--- a/src/tests/end2end/MultisampledRenderingTests.cpp
+++ b/src/tests/end2end/MultisampledRenderingTests.cpp
@@ -61,7 +61,6 @@
const char* fs = testDepth ? kFsOneOutputWithDepth : kFsOneOutputWithoutDepth;
-
return CreateRenderPipelineForTest(fs, 1, testDepth);
}
@@ -285,8 +284,8 @@
utils::ComboRenderPassDescriptor renderPass =
CreateComboRenderPassDescriptorForTest({mMultisampledColorView}, {mResolveView},
wgpu::LoadOp::Clear, wgpu::LoadOp::Clear, true);
- std::array<float, 5> kUniformData = {kGreen.r, kGreen.g, kGreen.b, kGreen.a, // Color
- 0.2f}; // depth
+ std::array<float, 5> kUniformData = {kGreen.r, kGreen.g, kGreen.b, kGreen.a, // Color
+ 0.2f}; // depth
constexpr uint32_t kSize = sizeof(kUniformData);
EncodeRenderPassForTest(commandEncoder, renderPass, pipeline, kUniformData.data(), kSize);
}
@@ -299,8 +298,8 @@
{mMultisampledColorView}, {mResolveView}, wgpu::LoadOp::Load, wgpu::LoadOp::Load,
kTestDepth);
- std::array<float, 8> kUniformData = {kRed.r, kRed.g, kRed.b, kRed.a, // color
- 0.5f}; // depth
+ std::array<float, 8> kUniformData = {kRed.r, kRed.g, kRed.b, kRed.a, // color
+ 0.5f}; // depth
constexpr uint32_t kSize = sizeof(kUniformData);
EncodeRenderPassForTest(commandEncoder, renderPass, pipeline, kUniformData.data(), kSize);
}
@@ -369,8 +368,8 @@
{mMultisampledColorView, multisampledColorView2}, {mResolveView, resolveView2},
wgpu::LoadOp::Clear, wgpu::LoadOp::Clear, kTestDepth);
- std::array<float, 8> kUniformData = {kRed.r, kRed.g, kRed.b, kRed.a, // color1
- kGreen.r, kGreen.g, kGreen.b, kGreen.a}; // color2
+ std::array<float, 8> kUniformData = {kRed.r, kRed.g, kRed.b, kRed.a, // color1
+ kGreen.r, kGreen.g, kGreen.b, kGreen.a}; // color2
constexpr uint32_t kSize = sizeof(kUniformData);
EncodeRenderPassForTest(commandEncoder, renderPass, pipeline, kUniformData.data(), kSize);
}
@@ -503,8 +502,8 @@
{mMultisampledColorView, multisampledColorView2}, {resolveView1, resolveView2},
wgpu::LoadOp::Clear, wgpu::LoadOp::Clear, kTestDepth);
- std::array<float, 8> kUniformData = {kRed.r, kRed.g, kRed.b, kRed.a, // color1
- kGreen.r, kGreen.g, kGreen.b, kGreen.a}; // color2
+ std::array<float, 8> kUniformData = {kRed.r, kRed.g, kRed.b, kRed.a, // color1
+ kGreen.r, kGreen.g, kGreen.b, kGreen.a}; // color2
constexpr uint32_t kSize = sizeof(kUniformData);
EncodeRenderPassForTest(commandEncoder, renderPass, pipeline, kUniformData.data(), kSize);
}
diff --git a/src/tests/end2end/NonzeroTextureCreationTests.cpp b/src/tests/end2end/NonzeroTextureCreationTests.cpp
index 9ee9e80..97759af 100644
--- a/src/tests/end2end/NonzeroTextureCreationTests.cpp
+++ b/src/tests/end2end/NonzeroTextureCreationTests.cpp
@@ -292,6 +292,6 @@
MetalBackend({"nonzero_clear_resources_on_creation_for_testing"},
{"lazy_clear_resource_on_first_use"}),
OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"},
- {"lazy_clear_resource_on_first_use"}),
+ {"lazy_clear_resource_on_first_use"}),
VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"},
- {"lazy_clear_resource_on_first_use"}));
+ {"lazy_clear_resource_on_first_use"}));
diff --git a/src/tests/end2end/ObjectCachingTests.cpp b/src/tests/end2end/ObjectCachingTests.cpp
index d27a3f5..20705a9 100644
--- a/src/tests/end2end/ObjectCachingTests.cpp
+++ b/src/tests/end2end/ObjectCachingTests.cpp
@@ -400,4 +400,8 @@
EXPECT_EQ(sampler.Get() == sameSampler.Get(), !UsesWire());
}
-DAWN_INSTANTIATE_TEST(ObjectCachingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(ObjectCachingTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/OpArrayLengthTests.cpp b/src/tests/end2end/OpArrayLengthTests.cpp
index 3e6a043..2d8e465 100644
--- a/src/tests/end2end/OpArrayLengthTests.cpp
+++ b/src/tests/end2end/OpArrayLengthTests.cpp
@@ -262,4 +262,8 @@
EXPECT_PIXEL_RGBA8_EQ(expectedColor, renderPass.color, 0, 0);
}
-DAWN_INSTANTIATE_TEST(OpArrayLengthTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(OpArrayLengthTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/PipelineLayoutTests.cpp b/src/tests/end2end/PipelineLayoutTests.cpp
index 6e71234..a4a02e9 100644
--- a/src/tests/end2end/PipelineLayoutTests.cpp
+++ b/src/tests/end2end/PipelineLayoutTests.cpp
@@ -62,4 +62,4 @@
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
- VulkanBackend());
\ No newline at end of file
+ VulkanBackend());
diff --git a/src/tests/end2end/PrimitiveTopologyTests.cpp b/src/tests/end2end/PrimitiveTopologyTests.cpp
index 822bfee..0c0c285 100644
--- a/src/tests/end2end/PrimitiveTopologyTests.cpp
+++ b/src/tests/end2end/PrimitiveTopologyTests.cpp
@@ -18,7 +18,8 @@
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/WGPUHelpers.h"
-// Primitive topology tests work by drawing the following vertices with all the different primitive topology states:
+// Primitive topology tests work by drawing the following vertices with all the different primitive
+// topology states:
// -------------------------------------
// | |
// | 1 2 5 |
@@ -81,8 +82,8 @@
// -------------------------------------
//
// Each of these different states is a superset of some of the previous states,
-// so for every state, we check any new added test locations that are not contained in previous states
-// We also check that the test locations of subsequent states are untouched
+// so for every state, we check any new added test locations that are not contained in previous
+// states We also check that the test locations of subsequent states are untouched
constexpr static unsigned int kRTSize = 32;
@@ -91,11 +92,13 @@
};
constexpr TestLocation GetMidpoint(const TestLocation& a, const TestLocation& b) noexcept {
- return { (a.x + b.x) / 2, (a.y + b.y) / 2 };
+ return {(a.x + b.x) / 2, (a.y + b.y) / 2};
}
-constexpr TestLocation GetCentroid(const TestLocation& a, const TestLocation& b, const TestLocation& c) noexcept {
- return { (a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3 };
+constexpr TestLocation GetCentroid(const TestLocation& a,
+ const TestLocation& b,
+ const TestLocation& c) noexcept {
+ return {(a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3};
}
// clang-format off
@@ -144,13 +147,13 @@
// clang-format on
class PrimitiveTopologyTest : public DawnTest {
- protected:
- void SetUp() override {
- DawnTest::SetUp();
+ protected:
+ void SetUp() override {
+ DawnTest::SetUp();
- renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
+ renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
- vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
+ vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450
layout(location = 0) in vec4 pos;
void main() {
@@ -158,69 +161,73 @@
gl_PointSize = 1.0;
})");
- fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
+ fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
- vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
- wgpu::BufferUsage::Vertex);
+ vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),
+ wgpu::BufferUsage::Vertex);
+ }
+
+ struct LocationSpec {
+ const TestLocation* locations;
+ size_t count;
+ bool include;
+ };
+
+ template <std::size_t N>
+ constexpr LocationSpec TestPoints(TestLocation const (&points)[N], bool include) noexcept {
+ return {points, N, include};
+ }
+
+ // Draw the vertices with the given primitive topology and check the pixel values of the test
+ // locations
+ void DoTest(wgpu::PrimitiveTopology primitiveTopology,
+ const std::vector<LocationSpec>& locationSpecs) {
+ utils::ComboRenderPipelineDescriptor descriptor(device);
+ descriptor.vertexStage.module = vsModule;
+ descriptor.cFragmentStage.module = fsModule;
+ descriptor.primitiveTopology = primitiveTopology;
+ descriptor.cVertexState.vertexBufferCount = 1;
+ descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
+ descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
+ descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
+ descriptor.cColorStates[0].format = renderPass.colorFormat;
+
+ wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
+
+ wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ {
+ wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
+ pass.SetPipeline(pipeline);
+ pass.SetVertexBuffer(0, vertexBuffer);
+ pass.Draw(6);
+ pass.EndPass();
}
- struct LocationSpec {
- const TestLocation* locations;
- size_t count;
- bool include;
- };
+ wgpu::CommandBuffer commands = encoder.Finish();
+ queue.Submit(1, &commands);
- template <std::size_t N>
- constexpr LocationSpec TestPoints(TestLocation const (&points)[N], bool include) noexcept {
- return { points, N, include };
- }
-
- // Draw the vertices with the given primitive topology and check the pixel values of the test locations
- void DoTest(wgpu::PrimitiveTopology primitiveTopology,
- const std::vector<LocationSpec>& locationSpecs) {
- utils::ComboRenderPipelineDescriptor descriptor(device);
- descriptor.vertexStage.module = vsModule;
- descriptor.cFragmentStage.module = fsModule;
- descriptor.primitiveTopology = primitiveTopology;
- descriptor.cVertexState.vertexBufferCount = 1;
- descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
- descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
- descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
- descriptor.cColorStates[0].format = renderPass.colorFormat;
-
- wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
-
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
- {
- wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
- pass.SetPipeline(pipeline);
- pass.SetVertexBuffer(0, vertexBuffer);
- pass.Draw(6);
- pass.EndPass();
- }
-
- wgpu::CommandBuffer commands = encoder.Finish();
- queue.Submit(1, &commands);
-
- for (auto& locationSpec : locationSpecs) {
- for (size_t i = 0; i < locationSpec.count; ++i) {
- // If this pixel is included, check that it is green. Otherwise, check that it is black
- RGBA8 color = locationSpec.include ? RGBA8::kGreen : RGBA8::kZero;
- EXPECT_PIXEL_RGBA8_EQ(color, renderPass.color, locationSpec.locations[i].x, locationSpec.locations[i].y)
- << "Expected (" << locationSpec.locations[i].x << ", " << locationSpec.locations[i].y << ") to be " << color;
- }
+ for (auto& locationSpec : locationSpecs) {
+ for (size_t i = 0; i < locationSpec.count; ++i) {
+ // If this pixel is included, check that it is green. Otherwise, check that it is
+ // black
+ RGBA8 color = locationSpec.include ? RGBA8::kGreen : RGBA8::kZero;
+ EXPECT_PIXEL_RGBA8_EQ(color, renderPass.color, locationSpec.locations[i].x,
+ locationSpec.locations[i].y)
+ << "Expected (" << locationSpec.locations[i].x << ", "
+ << locationSpec.locations[i].y << ") to be " << color;
}
}
+ }
- utils::BasicRenderPass renderPass;
- wgpu::ShaderModule vsModule;
- wgpu::ShaderModule fsModule;
- wgpu::Buffer vertexBuffer;
+ utils::BasicRenderPass renderPass;
+ wgpu::ShaderModule vsModule;
+ wgpu::ShaderModule fsModule;
+ wgpu::Buffer vertexBuffer;
};
// Test Point primitive topology
@@ -286,4 +293,8 @@
});
}
-DAWN_INSTANTIATE_TEST(PrimitiveTopologyTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(PrimitiveTopologyTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/RenderBundleTests.cpp b/src/tests/end2end/RenderBundleTests.cpp
index 0df87c3..c58eb8c 100644
--- a/src/tests/end2end/RenderBundleTests.cpp
+++ b/src/tests/end2end/RenderBundleTests.cpp
@@ -196,4 +196,8 @@
EXPECT_PIXEL_RGBA8_EQ(kColors[1], renderPass.color, 3, 1);
}
-DAWN_INSTANTIATE_TEST(RenderBundleTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(RenderBundleTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/RenderPassLoadOpTests.cpp b/src/tests/end2end/RenderPassLoadOpTests.cpp
index db7b6a9..011c6e0 100644
--- a/src/tests/end2end/RenderPassLoadOpTests.cpp
+++ b/src/tests/end2end/RenderPassLoadOpTests.cpp
@@ -22,62 +22,61 @@
constexpr static unsigned int kRTSize = 16;
class DrawQuad {
- public:
- DrawQuad() {}
- DrawQuad(wgpu::Device device, const char* vsSource, const char* fsSource) : device(device) {
- vsModule =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vsSource);
- fsModule =
- utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fsSource);
+ public:
+ DrawQuad() {
+ }
+ DrawQuad(wgpu::Device device, const char* vsSource, const char* fsSource) : device(device) {
+ vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vsSource);
+ fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fsSource);
- pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
- }
+ pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
+ }
- void Draw(wgpu::RenderPassEncoder* pass) {
- utils::ComboRenderPipelineDescriptor descriptor(device);
- descriptor.layout = pipelineLayout;
- descriptor.vertexStage.module = vsModule;
- descriptor.cFragmentStage.module = fsModule;
+ void Draw(wgpu::RenderPassEncoder* pass) {
+ utils::ComboRenderPipelineDescriptor descriptor(device);
+ descriptor.layout = pipelineLayout;
+ descriptor.vertexStage.module = vsModule;
+ descriptor.cFragmentStage.module = fsModule;
- auto renderPipeline = device.CreateRenderPipeline(&descriptor);
+ auto renderPipeline = device.CreateRenderPipeline(&descriptor);
- pass->SetPipeline(renderPipeline);
- pass->Draw(6, 1, 0, 0);
- }
+ pass->SetPipeline(renderPipeline);
+ pass->Draw(6, 1, 0, 0);
+ }
- private:
- wgpu::Device device;
- wgpu::ShaderModule vsModule = {};
- wgpu::ShaderModule fsModule = {};
- wgpu::PipelineLayout pipelineLayout = {};
+ private:
+ wgpu::Device device;
+ wgpu::ShaderModule vsModule = {};
+ wgpu::ShaderModule fsModule = {};
+ wgpu::PipelineLayout pipelineLayout = {};
};
class RenderPassLoadOpTests : public DawnTest {
- protected:
- void SetUp() override {
- DawnTest::SetUp();
+ protected:
+ void SetUp() override {
+ DawnTest::SetUp();
- wgpu::TextureDescriptor descriptor;
- descriptor.dimension = wgpu::TextureDimension::e2D;
- descriptor.size.width = kRTSize;
- descriptor.size.height = kRTSize;
- descriptor.size.depth = 1;
- descriptor.sampleCount = 1;
- descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
- descriptor.mipLevelCount = 1;
- descriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
- renderTarget = device.CreateTexture(&descriptor);
+ wgpu::TextureDescriptor descriptor;
+ descriptor.dimension = wgpu::TextureDimension::e2D;
+ descriptor.size.width = kRTSize;
+ descriptor.size.height = kRTSize;
+ descriptor.size.depth = 1;
+ descriptor.sampleCount = 1;
+ descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
+ descriptor.mipLevelCount = 1;
+ descriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
+ renderTarget = device.CreateTexture(&descriptor);
- renderTargetView = renderTarget.CreateView();
+ renderTargetView = renderTarget.CreateView();
- std::fill(expectZero.begin(), expectZero.end(), RGBA8::kZero);
+ std::fill(expectZero.begin(), expectZero.end(), RGBA8::kZero);
- std::fill(expectGreen.begin(), expectGreen.end(), RGBA8::kGreen);
+ std::fill(expectGreen.begin(), expectGreen.end(), RGBA8::kGreen);
- std::fill(expectBlue.begin(), expectBlue.end(), RGBA8::kBlue);
+ std::fill(expectBlue.begin(), expectBlue.end(), RGBA8::kBlue);
- // draws a blue quad on the right half of the screen
- const char* vsSource = R"(
+ // draws a blue quad on the right half of the screen
+ const char* vsSource = R"(
#version 450
void main() {
const vec2 pos[6] = vec2[6](
@@ -86,24 +85,24 @@
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
}
)";
- const char* fsSource = R"(
+ const char* fsSource = R"(
#version 450
layout(location = 0) out vec4 color;
void main() {
color = vec4(0.f, 0.f, 1.f, 1.f);
}
)";
- blueQuad = DrawQuad(device, vsSource, fsSource);
- }
+ blueQuad = DrawQuad(device, vsSource, fsSource);
+ }
- wgpu::Texture renderTarget;
- wgpu::TextureView renderTargetView;
+ wgpu::Texture renderTarget;
+ wgpu::TextureView renderTargetView;
- std::array<RGBA8, kRTSize * kRTSize> expectZero;
- std::array<RGBA8, kRTSize * kRTSize> expectGreen;
- std::array<RGBA8, kRTSize * kRTSize> expectBlue;
+ std::array<RGBA8, kRTSize * kRTSize> expectZero;
+ std::array<RGBA8, kRTSize * kRTSize> expectGreen;
+ std::array<RGBA8, kRTSize * kRTSize> expectBlue;
- DrawQuad blueQuad = {};
+ DrawQuad blueQuad = {};
};
// Tests clearing, loading, and drawing into color attachments
@@ -144,7 +143,12 @@
// Left half should still be green
EXPECT_TEXTURE_RGBA8_EQ(expectGreen.data(), renderTarget, 0, 0, kRTSize / 2, kRTSize, 0, 0);
// Right half should now be blue
- EXPECT_TEXTURE_RGBA8_EQ(expectBlue.data(), renderTarget, kRTSize / 2, 0, kRTSize / 2, kRTSize, 0, 0);
+ EXPECT_TEXTURE_RGBA8_EQ(expectBlue.data(), renderTarget, kRTSize / 2, 0, kRTSize / 2, kRTSize,
+ 0, 0);
}
-DAWN_INSTANTIATE_TEST(RenderPassLoadOpTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(RenderPassLoadOpTests,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/RenderPassTests.cpp b/src/tests/end2end/RenderPassTests.cpp
index ead9bee..74069ff 100644
--- a/src/tests/end2end/RenderPassTests.cpp
+++ b/src/tests/end2end/RenderPassTests.cpp
@@ -21,7 +21,7 @@
constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm;
class RenderPassTest : public DawnTest {
-protected:
+ protected:
void SetUp() override {
DawnTest::SetUp();
@@ -71,9 +71,9 @@
// Test using two different render passes in one commandBuffer works correctly.
TEST_P(RenderPassTest, TwoRenderPassesInOneCommandBuffer) {
if (IsOpenGL() || IsMetal()) {
- // crbug.com/950768
- // This test is consistently failing on OpenGL and flaky on Metal.
- return;
+ // crbug.com/950768
+ // This test is consistently failing on OpenGL and flaky on Metal.
+ return;
}
wgpu::Texture renderTarget1 = CreateDefault2DTexture();
diff --git a/src/tests/end2end/SamplerTests.cpp b/src/tests/end2end/SamplerTests.cpp
index d40f099..ad5ed92 100644
--- a/src/tests/end2end/SamplerTests.cpp
+++ b/src/tests/end2end/SamplerTests.cpp
@@ -46,10 +46,10 @@
255,
},
};
-}
+} // namespace
class SamplerTest : public DawnTest {
-protected:
+ protected:
void SetUp() override {
DawnTest::SetUp();
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
@@ -177,4 +177,8 @@
}
}
-DAWN_INSTANTIATE_TEST(SamplerTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(SamplerTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/ScissorTests.cpp b/src/tests/end2end/ScissorTests.cpp
index f674303..98722d0 100644
--- a/src/tests/end2end/ScissorTests.cpp
+++ b/src/tests/end2end/ScissorTests.cpp
@@ -17,7 +17,7 @@
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/WGPUHelpers.h"
-class ScissorTest: public DawnTest {
+class ScissorTest : public DawnTest {
protected:
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
wgpu::ShaderModule vsModule =
@@ -152,4 +152,8 @@
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 99, 99);
}
-DAWN_INSTANTIATE_TEST(ScissorTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(ScissorTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/TextureFormatTests.cpp b/src/tests/end2end/TextureFormatTests.cpp
index 06f70a5..cad7b31 100644
--- a/src/tests/end2end/TextureFormatTests.cpp
+++ b/src/tests/end2end/TextureFormatTests.cpp
@@ -404,7 +404,7 @@
ASSERT(sizeof(float) * formatInfo.componentCount == formatInfo.texelByteSize);
ASSERT(formatInfo.type == wgpu::TextureComponentType::Float);
- std::vector<float> textureData = {+0.0f, -0.0f, 1.0f, 1.0e-29f,
+ std::vector<float> textureData = {+0.0f, -0.0f, 1.0f, 1.0e-29f,
1.0e29f, NAN, INFINITY, -INFINITY};
DoFloatFormatSamplingTest(formatInfo, textureData, textureData);
@@ -733,4 +733,8 @@
// TODO(cwallez@chromium.org): Add tests for depth-stencil formats when we know if they are copyable
// in WebGPU.
-DAWN_INSTANTIATE_TEST(TextureFormatTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(TextureFormatTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/TextureViewTests.cpp b/src/tests/end2end/TextureViewTests.cpp
index acab158..4697169 100644
--- a/src/tests/end2end/TextureViewTests.cpp
+++ b/src/tests/end2end/TextureViewTests.cpp
@@ -70,7 +70,7 @@
} // anonymous namespace
class TextureViewSamplingTest : public DawnTest {
-protected:
+ protected:
// Generates an arbitrary pixel value per-layer-per-level, used for the "actual" uploaded
// textures and the "expected" results.
static int GenerateTestPixelValue(uint32_t layer, uint32_t level) {
@@ -104,8 +104,8 @@
const uint32_t textureHeightLevel0 = 1 << mipLevelCount;
constexpr wgpu::TextureUsage kUsage =
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
- mTexture = Create2DTexture(
- device, textureWidthLevel0, textureHeightLevel0, arrayLayerCount, mipLevelCount, kUsage);
+ mTexture = Create2DTexture(device, textureWidthLevel0, textureHeightLevel0, arrayLayerCount,
+ mipLevelCount, kUsage);
mDefaultTextureViewDescriptor.dimension = wgpu::TextureViewDimension::e2DArray;
mDefaultTextureViewDescriptor.format = kDefaultFormat;
@@ -145,10 +145,7 @@
queue.Submit(1, ©);
}
- void Verify(const wgpu::TextureView& textureView,
- const char* fragmentShader,
- int expected) {
-
+ void Verify(const wgpu::TextureView& textureView, const char* fragmentShader, int expected) {
wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fragmentShader);
@@ -176,8 +173,8 @@
RGBA8 expectedPixel(0, 0, 0, expected);
EXPECT_PIXEL_RGBA8_EQ(expectedPixel, mRenderPass.color, 0, 0);
- EXPECT_PIXEL_RGBA8_EQ(
- expectedPixel, mRenderPass.color, mRenderPass.width - 1, mRenderPass.height - 1);
+ EXPECT_PIXEL_RGBA8_EQ(expectedPixel, mRenderPass.color, mRenderPass.width - 1,
+ mRenderPass.height - 1);
// TODO(jiawei.shao@intel.com): add tests for 3D textures once Dawn supports 3D textures
}
@@ -262,13 +259,13 @@
std::string CreateFragmentShaderForCubeMapFace(uint32_t layer, bool isCubeMapArray) {
// Reference: https://en.wikipedia.org/wiki/Cube_mapping
const std::array<std::string, 6> kCoordsToCubeMapFace = {{
- " 1.f, tc, -sc", // Positive X
- "-1.f, tc, sc", // Negative X
- " sc, 1.f, -tc", // Positive Y
- " sc, -1.f, tc", // Negative Y
- " sc, tc, 1.f", // Positive Z
- " -sc, tc, -1.f", // Negative Z
- }};
+ " 1.f, tc, -sc", // Positive X
+ "-1.f, tc, sc", // Negative X
+ " sc, 1.f, -tc", // Positive Y
+ " sc, -1.f, tc", // Negative Y
+ " sc, tc, 1.f", // Positive Z
+ " -sc, tc, -1.f", // Negative Z
+ }};
const std::string textureType = isCubeMapArray ? "textureCubeArray" : "textureCube";
const std::string samplerType = isCubeMapArray ? "samplerCubeArray" : "samplerCube";
@@ -279,13 +276,15 @@
stream << R"(
#version 450
layout(set = 0, binding = 0) uniform sampler sampler0;
- layout(set = 0, binding = 1) uniform )" << textureType << R"( texture0;
+ layout(set = 0, binding = 1) uniform )"
+ << textureType << R"( texture0;
layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
void main() {
float sc = 2.f * texCoord.x - 1.f;
float tc = 2.f * texCoord.y - 1.f;
- fragColor = texture()" << samplerType << "(texture0, sampler0), ";
+ fragColor = texture()"
+ << samplerType << "(texture0, sampler0), ";
if (isCubeMapArray) {
stream << "vec4(" << coordToCubeMapFace << ", " << cubeMapArrayIndex;
@@ -321,7 +320,7 @@
// Check the data in the every face of the cube map (array) texture view.
for (uint32_t layer = 0; layer < textureViewLayerCount; ++layer) {
- const std::string &fragmentShader =
+ const std::string& fragmentShader =
CreateFragmentShaderForCubeMapFace(layer, isCubeMapArray);
int expected = GenerateTestPixelValue(textureViewBaseLayer + layer, 0);
@@ -362,8 +361,8 @@
}
)";
- const int expected = GenerateTestPixelValue(0, 0) + GenerateTestPixelValue(1, 0) +
- GenerateTestPixelValue(2, 0);
+ const int expected =
+ GenerateTestPixelValue(0, 0) + GenerateTestPixelValue(1, 0) + GenerateTestPixelValue(2, 0);
Verify(textureView, fragmentShader, expected);
}
@@ -427,7 +426,8 @@
TextureCubeMapTest(20, 3, 12, true);
}
-// Test sampling from a cube map texture array view that covers the last layer of a 2D array texture.
+// Test sampling from a cube map texture array view that covers the last layer of a 2D array
+// texture.
TEST_P(TextureViewSamplingTest, TextureCubeMapArrayViewCoveringLastLayer) {
// Test failing on the GPU FYI Mac Pro (AMD), see
// https://bugs.chromium.org/p/dawn/issues/detail?id=58
@@ -519,9 +519,8 @@
bytesPerRow / kBytesPerTexel * (textureWidthLevel0 - 1) + textureHeightLevel0;
constexpr RGBA8 kExpectedPixel(0, 255, 0, 255);
std::vector<RGBA8> expected(expectedDataSize, kExpectedPixel);
- EXPECT_TEXTURE_RGBA8_EQ(
- expected.data(), texture, 0, 0, textureViewWidth, textureViewHeight,
- textureViewBaseLevel, textureViewBaseLayer);
+ EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, textureViewWidth, textureViewHeight,
+ textureViewBaseLevel, textureViewBaseLayer);
}
};
@@ -565,7 +564,6 @@
TextureLayerAsColorAttachmentTest(wgpu::TextureViewDimension::e2D, kLayers, kMipLevels,
kBaseLayer, kBaseLevel);
}
-
}
// Test rendering into a 1-layer 2D array texture view created on a mipmap level of a 2D texture.
@@ -610,9 +608,17 @@
}
}
-DAWN_INSTANTIATE_TEST(TextureViewSamplingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(TextureViewSamplingTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
-DAWN_INSTANTIATE_TEST(TextureViewRenderingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(TextureViewRenderingTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
class TextureViewTest : public DawnTest {};
diff --git a/src/tests/end2end/TextureZeroInitTests.cpp b/src/tests/end2end/TextureZeroInitTests.cpp
index 3333007..dbd2e76 100644
--- a/src/tests/end2end/TextureZeroInitTests.cpp
+++ b/src/tests/end2end/TextureZeroInitTests.cpp
@@ -1144,11 +1144,10 @@
EXPECT_EQ(true, dawn_native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1));
}
-DAWN_INSTANTIATE_TEST(
- TextureZeroInitTest,
- D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
- D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"},
- {"use_d3d12_render_pass"}),
- OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"}),
- MetalBackend({"nonzero_clear_resources_on_creation_for_testing"}),
- VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"}));
+DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
+ D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
+ D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"},
+ {"use_d3d12_render_pass"}),
+ OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"}),
+ MetalBackend({"nonzero_clear_resources_on_creation_for_testing"}),
+ VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"}));
diff --git a/src/tests/end2end/VertexFormatTests.cpp b/src/tests/end2end/VertexFormatTests.cpp
index 6030adc..a4e773a 100644
--- a/src/tests/end2end/VertexFormatTests.cpp
+++ b/src/tests/end2end/VertexFormatTests.cpp
@@ -915,4 +915,8 @@
DoVertexFormatTest(wgpu::VertexFormat::Int4, vertexData, vertexData);
}
-DAWN_INSTANTIATE_TEST(VertexFormatTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(VertexFormatTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/VertexStateTests.cpp b/src/tests/end2end/VertexStateTests.cpp
index e65fefa..1c92f34 100644
--- a/src/tests/end2end/VertexStateTests.cpp
+++ b/src/tests/end2end/VertexStateTests.cpp
@@ -543,7 +543,7 @@
uint16_t halfs[2];
};
static_assert(sizeof(Data) == 16, "");
- Data data {1.f, {2u, 3u}, {Float32ToFloat16(4.f), Float32ToFloat16(5.f)}};
+ Data data{1.f, {2u, 3u}, {Float32ToFloat16(4.f), Float32ToFloat16(5.f)}};
wgpu::Buffer vertexBuffer =
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Vertex);
@@ -599,7 +599,11 @@
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 1, 1);
}
-DAWN_INSTANTIATE_TEST(VertexStateTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(VertexStateTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
// TODO for the input state:
// - Add more vertex formats
diff --git a/src/tests/end2end/ViewportOrientationTests.cpp b/src/tests/end2end/ViewportOrientationTests.cpp
index b592c21..7c2a04a 100644
--- a/src/tests/end2end/ViewportOrientationTests.cpp
+++ b/src/tests/end2end/ViewportOrientationTests.cpp
@@ -64,4 +64,8 @@
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kZero, renderPass.color, 1, 1);
}
-DAWN_INSTANTIATE_TEST(ViewportOrientationTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(ViewportOrientationTests,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());
diff --git a/src/tests/end2end/ViewportTests.cpp b/src/tests/end2end/ViewportTests.cpp
index 56dac87..2145ab4 100644
--- a/src/tests/end2end/ViewportTests.cpp
+++ b/src/tests/end2end/ViewportTests.cpp
@@ -404,4 +404,8 @@
DoTest(info);
}
-DAWN_INSTANTIATE_TEST(ViewportTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
+DAWN_INSTANTIATE_TEST(ViewportTest,
+ D3D12Backend(),
+ MetalBackend(),
+ OpenGLBackend(),
+ VulkanBackend());