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>
This commit is contained in:
Kai Ninomiya 2020-07-10 20:33:08 +00:00 committed by Commit Bot service account
parent 3d80b5c378
commit 2afea0c671
83 changed files with 3604 additions and 3481 deletions

View File

@ -18,8 +18,8 @@
#include "utils/SystemUtils.h"
#include "utils/WGPUHelpers.h"
#include <cstdlib>
#include <cstdio>
#include <cstdlib>
#include <vector>
wgpu::Device device;
@ -138,8 +138,7 @@ void init() {
bufferDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
ubo = device.CreateBuffer(&bufferDesc);
bindGroup =
utils::MakeBindGroup(device, bgl, {{0, ubo, 0, sizeof(ShaderData)}});
bindGroup = utils::MakeBindGroup(device, bgl, {{0, ubo, 0, sizeof(ShaderData)}});
}
void frame() {

View File

@ -49,9 +49,7 @@ static_library("dawn_sample_utils") {
# Template for samples to avoid listing dawn_sample_utils as a dep every time
template("dawn_sample") {
executable(target_name) {
deps = [
":dawn_sample_utils",
]
deps = [ ":dawn_sample_utils" ]
forward_variables_from(invoker, "*", [ "deps" ])
if (defined(invoker.deps)) {
@ -61,43 +59,27 @@ template("dawn_sample") {
}
dawn_sample("CppHelloTriangle") {
sources = [
"CppHelloTriangle.cpp",
]
sources = [ "CppHelloTriangle.cpp" ]
}
dawn_sample("CHelloTriangle") {
sources = [
"CHelloTriangle.cpp",
]
sources = [ "CHelloTriangle.cpp" ]
}
dawn_sample("ComputeBoids") {
sources = [
"ComputeBoids.cpp",
]
deps = [
"${dawn_root}/third_party/gn/glm",
]
sources = [ "ComputeBoids.cpp" ]
deps = [ "${dawn_root}/third_party/gn/glm" ]
}
dawn_sample("Animometer") {
sources = [
"Animometer.cpp",
]
sources = [ "Animometer.cpp" ]
}
dawn_sample("CubeReflection") {
sources = [
"CubeReflection.cpp",
]
deps = [
"${dawn_root}/third_party/gn/glm",
]
sources = [ "CubeReflection.cpp" ]
deps = [ "${dawn_root}/third_party/gn/glm" ]
}
dawn_sample("ManualSwapChainTest") {
sources = [
"ManualSwapChainTest.cpp",
]
sources = [ "ManualSwapChainTest.cpp" ]
}

View File

@ -75,8 +75,7 @@ void initBuffers() {
{
std::mt19937 generator;
std::uniform_real_distribution<float> dist(-1.0f, 1.0f);
for (auto& p : initialParticles)
{
for (auto& p : initialParticles) {
p.pos = glm::vec2(dist(generator), dist(generator));
p.vel = glm::vec2(dist(generator), dist(generator)) * 0.1f;
}
@ -253,7 +252,9 @@ void initSim() {
updatePipeline = device.CreateComputePipeline(&csDesc);
for (uint32_t i = 0; i < 2; ++i) {
updateBGs[i] = utils::MakeBindGroup(device, bgl, {
updateBGs[i] = utils::MakeBindGroup(
device, bgl,
{
{0, updateParams, 0, sizeof(SimParams)},
{1, particleBuffers[i], 0, kNumParticles * sizeof(Particle)},
{2, particleBuffers[(i + 1) % 2], 0, kNumParticles * sizeof(Particle)},

View File

@ -36,15 +36,15 @@ wgpu::BindGroup bindGroup;
void initBuffers() {
static const uint32_t indexData[3] = {
0, 1, 2,
0,
1,
2,
};
indexBuffer =
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
static const float vertexData[12] = {
0.0f, 0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.0f, 1.0f,
0.5f, -0.5f, 0.0f, 1.0f,
0.0f, 0.5f, 0.0f, 1.0f, -0.5f, -0.5f, 0.0f, 1.0f, 0.5f, -0.5f, 0.0f, 1.0f,
};
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
wgpu::BufferUsage::Vertex);
@ -141,17 +141,19 @@ void init() {
wgpu::TextureView view = texture.CreateView();
bindGroup = utils::MakeBindGroup(device, bgl, {
{0, sampler},
{1, view}
});
bindGroup = utils::MakeBindGroup(device, bgl, {{0, sampler}, {1, view}});
}
struct {uint32_t a; float b;} s;
struct {
uint32_t a;
float b;
} s;
void frame() {
s.a = (s.a + 1) % 256;
s.b += 0.02f;
if (s.b >= 1.0f) {s.b = 0.0f;}
if (s.b >= 1.0f) {
s.b = 0.0f;
}
wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView();
utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView);

View File

@ -18,10 +18,10 @@
#include "utils/SystemUtils.h"
#include "utils/WGPUHelpers.h"
#include <vector>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <vector>
wgpu::Device device;
@ -43,67 +43,44 @@ wgpu::RenderPipeline planePipeline;
wgpu::RenderPipeline reflectionPipeline;
void initBuffers() {
static const uint32_t indexData[6*6] = {
0, 1, 2,
0, 2, 3,
static const uint32_t indexData[6 * 6] = {0, 1, 2, 0, 2, 3,
4, 5, 6,
4, 6, 7,
4, 5, 6, 4, 6, 7,
8, 9, 10,
8, 10, 11,
8, 9, 10, 8, 10, 11,
12, 13, 14,
12, 14, 15,
12, 13, 14, 12, 14, 15,
16, 17, 18,
16, 18, 19,
16, 17, 18, 16, 18, 19,
20, 21, 22,
20, 22, 23
};
20, 21, 22, 20, 22, 23};
indexBuffer =
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
static const float vertexData[6 * 4 * 6] = {
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
-1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
1.0, 1.0, 1.0, 1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
-1.0, -1.0, -1.0, 1.0, 1.0, 0.0,
-1.0, 1.0, -1.0, 1.0, 1.0, 0.0,
1.0, 1.0, -1.0, 1.0, 1.0, 0.0,
1.0, -1.0, -1.0, 1.0, 1.0, 0.0,
-1.0, -1.0, -1.0, 1.0, 1.0, 0.0, -1.0, 1.0, -1.0, 1.0, 1.0, 0.0,
1.0, 1.0, -1.0, 1.0, 1.0, 0.0, 1.0, -1.0, -1.0, 1.0, 1.0, 0.0,
-1.0, 1.0, -1.0, 1.0, 0.0, 1.0,
-1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
1.0, 1.0, -1.0, 1.0, 0.0, 1.0,
-1.0, 1.0, -1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0,
-1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
1.0, -1.0, 1.0, 0.0, 1.0, 0.0,
-1.0, -1.0, 1.0, 0.0, 1.0, 0.0,
-1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
1.0, -1.0, 1.0, 0.0, 1.0, 0.0, -1.0, -1.0, 1.0, 0.0, 1.0, 0.0,
1.0, -1.0, -1.0, 0.0, 1.0, 1.0,
1.0, 1.0, -1.0, 0.0, 1.0, 1.0,
1.0, 1.0, 1.0, 0.0, 1.0, 1.0,
1.0, -1.0, 1.0, 0.0, 1.0, 1.0,
1.0, -1.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0,
1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 1.0,
-1.0, -1.0, -1.0, 1.0, 1.0, 1.0,
-1.0, -1.0, 1.0, 1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
-1.0, 1.0, -1.0, 1.0, 1.0, 1.0
};
-1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0,
-1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0};
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
wgpu::BufferUsage::Vertex);
static const float planeData[6 * 4] = {
-2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
-2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
-2.0, -1.0, -2.0, 0.5, 0.5, 0.5, 2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
2.0, -1.0, 2.0, 0.5, 0.5, 0.5, -2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
};
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData),
wgpu::BufferUsage::Vertex);
@ -191,15 +168,13 @@ void init() {
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
wgpu::BufferUsage::Uniform);
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
{0, cameraBuffer, 0, sizeof(CameraData)},
{1, transformBuffer[0], 0, sizeof(glm::mat4)}
});
bindGroup[0] = utils::MakeBindGroup(
device, bgl,
{{0, cameraBuffer, 0, sizeof(CameraData)}, {1, transformBuffer[0], 0, sizeof(glm::mat4)}});
bindGroup[1] = utils::MakeBindGroup(device, bgl, {
{0, cameraBuffer, 0, sizeof(CameraData)},
{1, transformBuffer[1], 0, sizeof(glm::mat4)}
});
bindGroup[1] = utils::MakeBindGroup(
device, bgl,
{{0, cameraBuffer, 0, sizeof(CameraData)}, {1, transformBuffer[1], 0, sizeof(glm::mat4)}});
depthStencilView = CreateDefaultDepthStencilView(device);
@ -250,17 +225,20 @@ void init() {
cameraData.proj = glm::perspective(glm::radians(45.0f), 1.f, 1.0f, 100.0f);
}
struct {uint32_t a; float b;} s;
struct {
uint32_t a;
float b;
} s;
void frame() {
s.a = (s.a + 1) % 256;
s.b += 0.01f;
if (s.b >= 1.0f) {s.b = 0.0f;}
if (s.b >= 1.0f) {
s.b = 0.0f;
}
cameraData.view = glm::lookAt(
glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f, 8.f * std::cos(glm::radians(s.b * 360.f))),
glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(0.0f, 1.0f, 0.0f)
);
cameraData.view = glm::lookAt(glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f,
8.f * std::cos(glm::radians(s.b * 360.f))),
glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
queue.WriteBuffer(cameraBuffer, 0, &cameraData, sizeof(CameraData));

View File

@ -150,7 +150,8 @@ void DoRender(WindowData* data) {
utils::ComboRenderPassDescriptor desc({view});
desc.cColorAttachments[0].loadOp = wgpu::LoadOp::Clear;
desc.cColorAttachments[0].clearColor = {data->clearCycle, 1.0f - data->clearCycle, 0.0f, 1.0f};
desc.cColorAttachments[0].clearColor = {data->clearCycle, 1.0f - data->clearCycle, 0.0f,
1.0f};
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&desc);
pass.EndPass();

View File

@ -60,7 +60,7 @@ void PrintGLFWError(int code, const char* message) {
enum class CmdBufType {
None,
Terrible,
//TODO(cwallez@chromium.org) double terrible cmdbuf
// TODO(cwallez@chromium.org): double terrible cmdbuf
};
// Default to D3D12, Metal, Vulkan, OpenGL in that order as D3D12 and Metal are the preferred on
@ -136,8 +136,7 @@ wgpu::Device CreateCppDawnDevice() {
cDevice = backendDevice;
break;
case CmdBufType::Terrible:
{
case CmdBufType::Terrible: {
c2sBuf = new utils::TerribleCommandBuffer();
s2cBuf = new utils::TerribleCommandBuffer();
@ -159,8 +158,7 @@ wgpu::Device CreateCppDawnDevice() {
procs = clientProcs;
cDevice = clientDevice;
}
break;
} break;
}
dawnProcSetProcs(&procs);
@ -221,7 +219,8 @@ bool InitSample(int argc, const char** argv) {
backendType = wgpu::BackendType::Vulkan;
continue;
}
fprintf(stderr, "--backend expects a backend name (opengl, metal, d3d12, null, vulkan)\n");
fprintf(stderr,
"--backend expects a backend name (opengl, metal, d3d12, null, vulkan)\n");
return false;
}
if (std::string("-c") == argv[i] || std::string("--command-buffer") == argv[i]) {

View File

@ -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) {

View File

@ -65,15 +65,15 @@ protected:
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"( {
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"( {
fs << "layout (std430, set = " << i << ", binding = 0) buffer StorageBuffer"
<< i << R"( {
vec4 color;
} buffer)"
<< i << ";\n";
@ -225,9 +225,9 @@ TEST_P(BindGroupTests, ReusedUBO) {
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);
@ -1091,4 +1091,8 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
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());

View File

@ -145,7 +145,11 @@ TEST_P(BufferMapReadTests, GetMappedRangeZeroSized) {
UnmapBuffer(buffer);
}
DAWN_INSTANTIATE_TEST(BufferMapReadTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(BufferMapReadTests,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());
class BufferMapWriteTests : public DawnTest {
protected:
@ -307,7 +311,11 @@ TEST_P(BufferMapWriteTests, GetMappedRangeZeroSized) {
UnmapBuffer(buffer);
}
DAWN_INSTANTIATE_TEST(BufferMapWriteTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(BufferMapWriteTests,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());
class CreateBufferMappedTests : public DawnTest {
protected:

View File

@ -97,4 +97,8 @@ TEST_P(ClipSpaceTest, ClipSpace) {
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());

View File

@ -758,8 +758,8 @@ TEST_P(ColorStateTest, IndependentColorState) {
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 @@ TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
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());

View File

@ -37,8 +37,7 @@ class CopyTests : public DawnTest {
uint32_t rowsPerImage;
};
static std::vector<RGBA8> GetExpectedTextureData(
const utils::BufferTextureCopyLayout& layout) {
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;
@ -67,7 +66,12 @@ class CopyTests : public DawnTest {
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) {
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;
@ -103,9 +107,8 @@ class CopyTests_T2B : public CopyTests {
// Initialize the source texture
std::vector<RGBA8> textureArrayData = GetExpectedTextureData(copyLayout);
{
wgpu::Buffer uploadBuffer =
utils::CreateBufferFromData(device, textureArrayData.data(),
copyLayout.byteLength, wgpu::BufferUsage::CopySrc);
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 =
@ -174,11 +177,8 @@ class CopyTests_B2T : public CopyTests {
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);
}
}
@ -746,7 +746,11 @@ TEST_P(CopyTests_T2B, Texture2DArrayRegionNonzeroRowsPerImage) {
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) {
@ -1090,7 +1094,11 @@ TEST_P(CopyTests_B2T, Texture2DArrayRegionNonzeroRowsPerImage) {
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 @@ TEST_P(CopyTests_T2T, MultipleMipSrcSingleMipDst) {
}
}
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;

View File

@ -127,4 +127,8 @@ TEST_P(CullingTest, CullBackFaceWhenCWIsFrontFace) {
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());

View File

@ -130,8 +130,7 @@ namespace {
// 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) {

View File

@ -42,4 +42,8 @@ TEST_P(DebugMarkerTests, NoFailureWithoutDebugToolAttached) {
queue.Submit(1, &commands);
}
DAWN_INSTANTIATE_TEST(DebugMarkerTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(DebugMarkerTests,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -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,8 +221,7 @@ class DepthSamplingTest : public DawnTest {
wgpu::SamplerDescriptor samplerDesc;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
{
{0, sampler},
{1, mInputTexture.CreateView()},
@ -258,12 +253,9 @@ class DepthSamplingTest : public DawnTest {
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,8 +313,7 @@ class DepthSamplingTest : public DawnTest {
samplerDesc.compare = compare;
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
{
{0, sampler},
{1, mInputTexture.CreateView()},
@ -364,12 +355,10 @@ class DepthSamplingTest : public DawnTest {
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
{
{0, sampler},
{{0, sampler},
{1, mInputTexture.CreateView()},
{2, mUniformBuffer},
{3, mOutputBuffer}
});
{3, mOutputBuffer}});
for (float textureValue : textureValues) {
// Set the input depth texture to the provided texture value

View File

@ -88,7 +88,8 @@ class DepthStencilStateTest : public DawnTest {
};
// 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
// 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,
@ -127,15 +128,18 @@ class DepthStencilStateTest : public DawnTest {
// 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
// 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
// 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
// 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,
@ -174,17 +178,21 @@ class DepthStencilStateTest : public DawnTest {
// 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
// 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
// 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
// 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`
// 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,
@ -215,13 +223,15 @@ class DepthStencilStateTest : public DawnTest {
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},
// Draw a triangle with the provided stencil operation and reference
{state, RGBA8(255, 0, 0, 255), 0.f, reference},
}, expectedStencil);
},
expectedStencil);
}
// Draw a list of test specs, and check if the stencil value is equal to the expected value
@ -243,9 +253,12 @@ class DepthStencilStateTest : public DawnTest {
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) {
// 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 {
@ -260,12 +273,13 @@ class DepthStencilStateTest : public DawnTest {
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 },
{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::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData),
wgpu::BufferUsage::Uniform);
// Create a pipeline for the triangles with the test spec's depth stencil state
@ -284,8 +298,8 @@ class DepthStencilStateTest : public DawnTest {
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.SetBindGroup(0,
bindGroup); // Set the bind group which contains color and depth data
pass.Draw(6);
}
pass.EndPass();
@ -293,8 +307,10 @@ class DepthStencilStateTest : public DawnTest {
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";
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) {
@ -325,9 +341,11 @@ TEST_P(DepthStencilStateTest, Basic) {
state.stencilReadMask = 0xff;
state.stencilWriteMask = 0xff;
DoTest({
DoTest(
{
{state, RGBA8(0, 255, 0, 255), 0.5f, 0u},
}, RGBA8(0, 255, 0, 255));
},
RGBA8(0, 255, 0, 255));
}
// Test defaults: depth and stencil tests disabled
@ -427,11 +445,17 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) {
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
@ -537,8 +561,10 @@ TEST_P(DepthStencilStateTest, StencilReadMask) {
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)
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 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) {
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 @@ TEST_P(DepthStencilStateTest, StencilFail) {
state.stencilReadMask = 0xff;
state.stencilWriteMask = 0xff;
CheckStencil({
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
{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,9 +671,11 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) {
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
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
}
@ -673,9 +707,11 @@ TEST_P(DepthStencilStateTest, StencilDepthPass) {
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
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
}

View File

@ -157,4 +157,8 @@ TEST_P(DestroyTest, TextureSubmitDestroySubmit) {
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
}
DAWN_INSTANTIATE_TEST(DestroyTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(DestroyTest,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -57,12 +57,12 @@ class DrawIndexedTest : public DawnTest {
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,
-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});
-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,
@ -103,7 +103,6 @@ class DrawIndexedTest : public DawnTest {
// 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_P(DrawIndexedTest, BaseVertex) {
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());

View File

@ -124,4 +124,8 @@ TEST_P(DrawIndirectTest, IndirectOffset) {
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());

View File

@ -231,7 +231,11 @@ TEST_P(GpuMemorySyncTests, ComputePassToRenderPass) {
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:

View File

@ -369,7 +369,8 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
// 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_P(IOSurfaceUsageTests, SampleFromR8IOSurface) {
// 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_P(IOSurfaceUsageTests, ClearR8IOSurface) {
// 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_P(IOSurfaceUsageTests, SampleFromRG8IOSurface) {
// 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));

View File

@ -275,4 +275,8 @@ TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
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());

View File

@ -61,7 +61,6 @@ class MultisampledRenderingTest : public DawnTest {
const char* fs = testDepth ? kFsOneOutputWithDepth : kFsOneOutputWithoutDepth;
return CreateRenderPipelineForTest(fs, 1, testDepth);
}

View File

@ -400,4 +400,8 @@ TEST_P(ObjectCachingTest, SamplerDeduplication) {
EXPECT_EQ(sampler.Get() == sameSampler.Get(), !UsesWire());
}
DAWN_INSTANTIATE_TEST(ObjectCachingTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(ObjectCachingTest,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -262,4 +262,8 @@ TEST_P(OpArrayLengthTest, Vertex) {
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());

View File

@ -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;
@ -94,7 +95,9 @@ constexpr TestLocation GetMidpoint(const TestLocation& a, const TestLocation& b)
return {(a.x + b.x) / 2, (a.y + b.y) / 2};
}
constexpr TestLocation GetCentroid(const TestLocation& a, const TestLocation& b, const TestLocation& c) noexcept {
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};
}
@ -180,7 +183,8 @@ class PrimitiveTopologyTest : public DawnTest {
return {points, N, include};
}
// Draw the vertices with the given primitive topology and check the pixel values of the test locations
// 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);
@ -209,10 +213,13 @@ class PrimitiveTopologyTest : public DawnTest {
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
// 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;
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;
}
}
}
@ -286,4 +293,8 @@ TEST_P(PrimitiveTopologyTest, TriangleStrip) {
});
}
DAWN_INSTANTIATE_TEST(PrimitiveTopologyTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(PrimitiveTopologyTest,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -196,4 +196,8 @@ TEST_P(RenderBundleTest, BundleAndRenderPassCommands) {
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());

View File

@ -23,12 +23,11 @@ constexpr static unsigned int kRTSize = 16;
class DrawQuad {
public:
DrawQuad() {}
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);
vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vsSource);
fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fsSource);
pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
}
@ -144,7 +143,12 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
// 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());

View File

@ -46,7 +46,7 @@ namespace {
255,
},
};
}
} // namespace
class SamplerTest : public DawnTest {
protected:
@ -177,4 +177,8 @@ TEST_P(SamplerTest, AddressMode) {
}
}
DAWN_INSTANTIATE_TEST(SamplerTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(SamplerTest,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -152,4 +152,8 @@ TEST_P(ScissorTest, NoInheritanceBetweenRenderPass) {
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());

View File

@ -733,4 +733,8 @@ TEST_P(TextureFormatTest, RG11B10Float) {
// 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());

View File

@ -104,8 +104,8 @@ protected:
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 @@ protected:
queue.Submit(1, &copy);
}
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 @@ protected:
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
}
@ -279,13 +276,15 @@ protected:
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;
@ -362,8 +361,8 @@ TEST_P(TextureViewSamplingTest, Default2DArrayTexture) {
}
)";
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 @@ TEST_P(TextureViewSamplingTest, TextureCubeMapArrayViewOnPartOfTexture) {
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,8 +519,7 @@ class TextureViewRenderingTest : public DawnTest {
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,
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, textureViewWidth, textureViewHeight,
textureViewBaseLevel, textureViewBaseLayer);
}
};
@ -565,7 +564,6 @@ TEST_P(TextureViewRenderingTest, Texture2DViewOnALayerOf2DArrayTextureAsColorAtt
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 @@ TEST_P(TextureViewRenderingTest, Texture2DArrayViewOnALayerOf2DArrayTextureAsCol
}
}
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 {};

View File

@ -1144,8 +1144,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferNonRenderableUnaligned) {
EXPECT_EQ(true, dawn_native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1));
}
DAWN_INSTANTIATE_TEST(
TextureZeroInitTest,
DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"},
{"use_d3d12_render_pass"}),

View File

@ -915,4 +915,8 @@ TEST_P(VertexFormatTest, Int4) {
DoVertexFormatTest(wgpu::VertexFormat::Int4, vertexData, vertexData);
}
DAWN_INSTANTIATE_TEST(VertexFormatTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(VertexFormatTest,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -599,7 +599,11 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
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

View File

@ -64,4 +64,8 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
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());

View File

@ -404,4 +404,8 @@ TEST_P(ViewportTest, DoNotTruncateWidthAndHeight2) {
DoTest(info);
}
DAWN_INSTANTIATE_TEST(ViewportTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
DAWN_INSTANTIATE_TEST(ViewportTest,
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
VulkanBackend());

View File

@ -121,7 +121,8 @@ TEST(CommandAllocator, BasicWithData) {
uint32_t myValues[5] = {6, 42, 0xFFFFFFFF, 0, 54};
{
CommandPushConstants* pushConstants = allocator.Allocate<CommandPushConstants>(CommandType::PushConstants);
CommandPushConstants* pushConstants =
allocator.Allocate<CommandPushConstants>(CommandType::PushConstants);
pushConstants->size = mySize;
pushConstants->offset = myOffset;

View File

@ -26,9 +26,7 @@ const char* dummyErrorMessage = "I am an error message :3";
// Check returning a success MaybeError with {};
TEST(ErrorTests, Error_Success) {
auto ReturnSuccess = []() -> MaybeError {
return {};
};
auto ReturnSuccess = []() -> MaybeError { return {}; };
MaybeError result = ReturnSuccess();
ASSERT_TRUE(result.IsSuccess());
@ -36,9 +34,7 @@ TEST(ErrorTests, Error_Success) {
// Check returning an error MaybeError with "return DAWN_VALIDATION_ERROR"
TEST(ErrorTests, Error_Error) {
auto ReturnError = []() -> MaybeError {
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
};
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
MaybeError result = ReturnError();
ASSERT_TRUE(result.IsError());
@ -49,9 +45,7 @@ TEST(ErrorTests, Error_Error) {
// Check returning a success ResultOrError with an implicit conversion
TEST(ErrorTests, ResultOrError_Success) {
auto ReturnSuccess = []() -> ResultOrError<int*> {
return &dummySuccess;
};
auto ReturnSuccess = []() -> ResultOrError<int*> { return &dummySuccess; };
ResultOrError<int*> result = ReturnSuccess();
ASSERT_TRUE(result.IsSuccess());
@ -73,9 +67,7 @@ TEST(ErrorTests, ResultOrError_Error) {
// Check DAWN_TRY handles successes correctly.
TEST(ErrorTests, TRY_Success) {
auto ReturnSuccess = []() -> MaybeError {
return {};
};
auto ReturnSuccess = []() -> MaybeError { return {}; };
// We need to check that DAWN_TRY doesn't return on successes
bool tryReturned = true;
@ -93,9 +85,7 @@ TEST(ErrorTests, TRY_Success) {
// Check DAWN_TRY handles errors correctly.
TEST(ErrorTests, TRY_Error) {
auto ReturnError = []() -> MaybeError {
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
};
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
auto Try = [ReturnError]() -> MaybeError {
DAWN_TRY(ReturnError());
@ -113,9 +103,7 @@ TEST(ErrorTests, TRY_Error) {
// Check DAWN_TRY adds to the backtrace.
TEST(ErrorTests, TRY_AddsToBacktrace) {
auto ReturnError = []() -> MaybeError {
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
};
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
auto SingleTry = [ReturnError]() -> MaybeError {
DAWN_TRY(ReturnError());
@ -141,9 +129,7 @@ TEST(ErrorTests, TRY_AddsToBacktrace) {
// Check DAWN_TRY_ASSIGN handles successes correctly.
TEST(ErrorTests, TRY_RESULT_Success) {
auto ReturnSuccess = []() -> ResultOrError<int*> {
return &dummySuccess;
};
auto ReturnSuccess = []() -> ResultOrError<int*> { return &dummySuccess; };
// We need to check that DAWN_TRY doesn't return on successes
bool tryReturned = true;
@ -260,9 +246,7 @@ TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
// Check a MaybeError can be DAWN_TRIED in a function that returns an ResultOrError
// Check DAWN_TRY handles errors correctly.
TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
auto ReturnError = []() -> MaybeError {
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
};
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
auto Try = [ReturnError]() -> ResultOrError<int*> {
DAWN_TRY(ReturnError());
@ -279,9 +263,7 @@ TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
// Check a MaybeError can be DAWN_TRIED in a function that returns an ResultOrError
// Check DAWN_TRY handles errors correctly. Version without Result<E*, T*>
TEST(ErrorTests, TRY_ConversionToErrorOrResultNonPointer) {
auto ReturnError = []() -> MaybeError {
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
};
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
auto Try = [ReturnError]() -> ResultOrError<int> {
DAWN_TRY(ReturnError());

View File

@ -194,4 +194,3 @@ TEST(ObjectBase, AssignNullptr) {
obj = nullptr;
ASSERT_EQ(refcount, 1);
}

View File

@ -96,7 +96,9 @@ TEST(ResultOnlyPointerError, MovingError) {
// Test returning an error Result<void, E>
TEST(ResultOnlyPointerError, ReturningError) {
auto CreateError = []() -> Result<void, int> { return {std::make_unique<int>(dummyError)}; };
auto CreateError = []() -> Result<void, int> {
return {std::make_unique<int>(dummyError)};
};
Result<void, int> result = CreateError();
TestError(&result, dummyError);
@ -143,7 +145,9 @@ TEST(ResultBothPointer, MovingError) {
// Test returning an error Result<T*, E>
TEST(ResultBothPointer, ReturningError) {
auto CreateError = []() -> Result<float*, int> { return {std::make_unique<int>(dummyError)}; };
auto CreateError = []() -> Result<float*, int> {
return {std::make_unique<int>(dummyError)};
};
Result<float*, int> result = CreateError();
TestError(&result, dummyError);
@ -164,9 +168,7 @@ TEST(ResultBothPointer, MovingSuccess) {
// Test returning a success Result<T*, E>
TEST(ResultBothPointer, ReturningSuccess) {
auto CreateSuccess = []() -> Result<float*, int*> {
return {&dummySuccess};
};
auto CreateSuccess = []() -> Result<float*, int*> { return {&dummySuccess}; };
Result<float*, int*> result = CreateSuccess();
TestSuccess(&result, &dummySuccess);
@ -290,7 +292,9 @@ TEST(ResultRefT, MovingSuccess) {
// Test returning a success Result<Ref<T>, E>
TEST(ResultRefT, ReturningSuccess) {
AClass success;
auto CreateSuccess = [&success]() -> Result<Ref<AClass>, int> { return Ref<AClass>(&success); };
auto CreateSuccess = [&success]() -> Result<Ref<AClass>, int> {
return Ref<AClass>(&success);
};
Result<Ref<AClass>, int> result = CreateSuccess();
TestSuccess(&result, &success);

View File

@ -21,14 +21,12 @@
// Make our own Base - Backend object pair, reusing the CommandBuffer name
namespace dawn_native {
class CommandBufferBase : public RefCounted {
};
}
class CommandBufferBase : public RefCounted {};
} // namespace dawn_native
using namespace dawn_native;
class MyCommandBuffer : public CommandBufferBase {
};
class MyCommandBuffer : public CommandBufferBase {};
struct MyBackendTraits {
using CommandBufferType = MyCommandBuffer;
@ -71,7 +69,8 @@ TEST(ToBackend, Ref) {
const Ref<CommandBufferBase> base(cmdBuf);
const auto& backendCmdBuf = ToBackend(base);
static_assert(std::is_same<decltype(ToBackend(base)), const Ref<MyCommandBuffer>&>::value, "");
static_assert(std::is_same<decltype(ToBackend(base)), const Ref<MyCommandBuffer>&>::value,
"");
ASSERT_EQ(cmdBuf, backendCmdBuf.Get());
cmdBuf->Release();

View File

@ -55,7 +55,8 @@ namespace {
// Check that the offset is aligned
void ValidateOffset(const TextureCopySplit& copySplit) {
ASSERT_TRUE(Align(copySplit.offset, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT) == copySplit.offset);
ASSERT_TRUE(Align(copySplit.offset, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT) ==
copySplit.offset);
}
bool RangesOverlap(uint32_t minA, uint32_t maxA, uint32_t minB, uint32_t maxB) {
@ -68,9 +69,15 @@ namespace {
const auto& a = copySplit.copies[i];
for (uint32_t j = i + 1; j < copySplit.count; ++j) {
const auto& b = copySplit.copies[j];
bool overlapX = RangesOverlap(a.textureOffset.x, a.textureOffset.x + a.copySize.width, b.textureOffset.x, b.textureOffset.x + b.copySize.width);
bool overlapY = RangesOverlap(a.textureOffset.y, a.textureOffset.y + a.copySize.height, b.textureOffset.y, b.textureOffset.y + b.copySize.height);
bool overlapZ = RangesOverlap(a.textureOffset.z, a.textureOffset.z + a.copySize.depth, b.textureOffset.z, b.textureOffset.z + b.copySize.depth);
bool overlapX =
RangesOverlap(a.textureOffset.x, a.textureOffset.x + a.copySize.width,
b.textureOffset.x, b.textureOffset.x + b.copySize.width);
bool overlapY =
RangesOverlap(a.textureOffset.y, a.textureOffset.y + a.copySize.height,
b.textureOffset.y, b.textureOffset.y + b.copySize.height);
bool overlapZ =
RangesOverlap(a.textureOffset.z, a.textureOffset.z + a.copySize.depth,
b.textureOffset.z, b.textureOffset.z + b.copySize.depth);
ASSERT_TRUE(!overlapX || !overlapY || !overlapZ);
}
}
@ -105,7 +112,8 @@ namespace {
ASSERT_EQ(maxZ, textureSpec.z + textureSpec.depth);
}
// Validate that the number of pixels copied is exactly equal to the number of pixels in the texture region
// Validate that the number of pixels copied is exactly equal to the number of pixels in the
// texture region
void ValidatePixelCount(const TextureSpec& textureSpec, const TextureCopySplit& copySplit) {
uint32_t count = 0;
for (uint32_t i = 0; i < copySplit.count; ++i) {
@ -116,7 +124,9 @@ namespace {
}
// Check that every buffer offset is at the correct pixel location
void ValidateBufferOffset(const TextureSpec& textureSpec, const BufferSpec& bufferSpec, const TextureCopySplit& copySplit) {
void ValidateBufferOffset(const TextureSpec& textureSpec,
const BufferSpec& bufferSpec,
const TextureCopySplit& copySplit) {
ASSERT_TRUE(copySplit.count > 0);
uint32_t texelsPerBlock = textureSpec.blockWidth * textureSpec.blockHeight;
@ -149,7 +159,9 @@ namespace {
}
}
void ValidateCopySplit(const TextureSpec& textureSpec, const BufferSpec& bufferSpec, const TextureCopySplit& copySplit) {
void ValidateCopySplit(const TextureSpec& textureSpec,
const BufferSpec& bufferSpec,
const TextureCopySplit& copySplit) {
ValidateFootprints(copySplit);
ValidateOffset(copySplit);
ValidateDisjoint(copySplit);
@ -176,8 +188,13 @@ namespace {
os << "CopySplit" << std::endl;
for (uint32_t i = 0; i < copySplit.count; ++i) {
const auto& copy = copySplit.copies[i];
os << " " << i << ": Texture at (" << copy.textureOffset.x << ", " << copy.textureOffset.y << ", " << copy.textureOffset.z << "), size (" << copy.copySize.width << ", " << copy.copySize.height << ", " << copy.copySize.depth << ")" << std::endl;
os << " " << i << ": Buffer at (" << copy.bufferOffset.x << ", " << copy.bufferOffset.y << ", " << copy.bufferOffset.z << "), footprint (" << copy.bufferSize.width << ", " << copy.bufferSize.height << ", " << copy.bufferSize.depth << ")" << std::endl;
os << " " << i << ": Texture at (" << copy.textureOffset.x << ", "
<< copy.textureOffset.y << ", " << copy.textureOffset.z << "), size ("
<< copy.copySize.width << ", " << copy.copySize.height << ", " << copy.copySize.depth
<< ")" << std::endl;
os << " " << i << ": Buffer at (" << copy.bufferOffset.x << ", " << copy.bufferOffset.y
<< ", " << copy.bufferOffset.z << "), footprint (" << copy.bufferSize.width << ", "
<< copy.bufferSize.height << ", " << copy.bufferSize.depth << ")" << std::endl;
}
return os;
}
@ -260,14 +277,12 @@ namespace {
}
// Define a list of values to set properties in the spec structs
constexpr uint32_t kCheckValues[] = {
1, 2, 3, 4, 5, 6, 7, 8, // small values
constexpr uint32_t kCheckValues[] = {1, 2, 3, 4, 5, 6, 7, 8, // small values
16, 32, 64, 128, 256, 512, 1024, 2048, // powers of 2
15, 31, 63, 127, 257, 511, 1023, 2047, // misalignments
17, 33, 65, 129, 257, 513, 1025, 2049
};
17, 33, 65, 129, 257, 513, 1025, 2049};
}
} // namespace
class CopySplitTest : public testing::Test {
protected:
@ -290,11 +305,11 @@ class CopySplitTest : public testing::Test {
TEST_F(CopySplitTest, General) {
for (TextureSpec textureSpec : kBaseTextureSpecs) {
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}
@ -310,11 +325,11 @@ TEST_F(CopySplitTest, TextureWidth) {
}
textureSpec.width = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}
@ -331,11 +346,11 @@ TEST_F(CopySplitTest, TextureHeight) {
}
textureSpec.height = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}
@ -349,11 +364,11 @@ TEST_F(CopySplitTest, TextureX) {
for (uint32_t val : kCheckValues) {
textureSpec.x = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}
@ -367,11 +382,11 @@ TEST_F(CopySplitTest, TextureY) {
for (uint32_t val : kCheckValues) {
textureSpec.y = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}
@ -385,11 +400,11 @@ TEST_F(CopySplitTest, TexelSize) {
for (uint32_t texelSize : {4, 8, 16, 32, 64}) {
textureSpec.texelBlockSizeInBytes = texelSize;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}
@ -407,7 +422,8 @@ TEST_F(CopySplitTest, BufferOffset) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}
@ -426,7 +442,8 @@ TEST_F(CopySplitTest, RowPitch) {
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) {
std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
<< std::endl
<< copySplit << std::endl;
FAIL() << message.str();
}

View File

@ -121,16 +121,10 @@ TEST_F(BindGroupValidationTest, BindingSetTwice) {
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
// Control case: check that different bindings work
utils::MakeBindGroup(device, layout, {
{0, mSampler},
{1, mSampler}
});
utils::MakeBindGroup(device, layout, {{0, mSampler}, {1, mSampler}});
// Check that setting the same binding twice is invalid
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {
{0, mSampler},
{0, mSampler}
}));
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, mSampler}, {0, mSampler}}));
}
// Check that a sampler binding must contain exactly one sampler
@ -428,7 +422,8 @@ TEST_F(BindGroupValidationTest, BufferBindingOOB) {
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 256}}));
// Error case, offset+size overflows to be 0
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256, uint32_t(0) - uint32_t(256)}}));
ASSERT_DEVICE_ERROR(
utils::MakeBindGroup(device, layout, {{0, buffer, 256, uint32_t(0) - uint32_t(256)}}));
}
// Tests constraints to be sure the uniform buffer binding isn't too large
@ -1191,8 +1186,8 @@ TEST_F(SetBindGroupValidationTest, DynamicOffsetOrder) {
// Create buffers which are 3x, 2x, and 1x the size of the minimum buffer offset, plus 4 bytes
// to spare (to avoid zero-sized bindings). We will offset the bindings so they reach the very
// end of the buffer. Any mismatch applying too-large of an offset to a smaller buffer will hit the
// out-of-bounds condition during validation.
// end of the buffer. Any mismatch applying too-large of an offset to a smaller buffer will hit
// the out-of-bounds condition during validation.
wgpu::Buffer buffer3x =
CreateBuffer(3 * kMinDynamicBufferOffsetAlignment + 4, wgpu::BufferUsage::Storage);
wgpu::Buffer buffer2x =
@ -1487,7 +1482,6 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
wgpu::RenderPipeline CreateFSRenderPipeline(
const char* fsShader,
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
wgpu::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450

View File

@ -416,7 +416,8 @@ TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
WaitForAllOperations(device);
}
// Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the callback
// Test that the MapReadCallback isn't fired twice the buffer external refcount reaches 0 in the
// callback
TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
wgpu::Buffer buf = CreateMapReadBuffer(4);
@ -429,7 +430,8 @@ TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
WaitForAllOperations(device);
}
// Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the callback
// Test that the MapWriteCallback isn't fired twice the buffer external refcount reaches 0 in the
// callback
TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
wgpu::Buffer buf = CreateMapWriteBuffer(4);

View File

@ -16,8 +16,7 @@
#include "utils/WGPUHelpers.h"
class CommandBufferValidationTest : public ValidationTest {
};
class CommandBufferValidationTest : public ValidationTest {};
// Test for an empty command buffer
TEST_F(CommandBufferValidationTest, Empty) {

View File

@ -14,7 +14,7 @@
#include "tests/unittests/validation/ValidationTest.h"
class ComputeValidationTest : public ValidationTest {
};
class ComputeValidationTest : public ValidationTest {};
//TODO(cwallez@chromium.org): Add a regression test for Disptach validation trying to acces the input state.
// TODO(cwallez@chromium.org): Add a regression test for Disptach validation trying to acces the
// input state.

View File

@ -1168,8 +1168,8 @@ TEST_F(CopyCommandTest_T2T, 2DTextureDepthStencil) {
TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {
{
wgpu::Texture source = Create2DTexture(16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureUsage::CopySrc);
wgpu::Texture source = Create2DTexture(
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopySrc);
wgpu::Texture destination = Create2DTexture(
16, 16, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
@ -1179,8 +1179,8 @@ TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {
}
{
wgpu::Texture source = Create2DTexture(16, 16, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureUsage::CopySrc);
wgpu::Texture source = Create2DTexture(
16, 16, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopySrc);
wgpu::Texture destination = Create2DTexture(
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
@ -1190,8 +1190,8 @@ TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {
}
{
wgpu::Texture source = Create2DTexture(16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureUsage::CopySrc);
wgpu::Texture source = Create2DTexture(
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopySrc);
wgpu::Texture destination = Create2DTexture(
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);

View File

@ -223,8 +223,7 @@ TEST_F(SetViewportTest, MinDepthEqualOrGreaterThanMaxDepth) {
}
}
class SetScissorRectTest : public ValidationTest {
};
class SetScissorRectTest : public ValidationTest {};
// Test to check basic use of SetScissor
TEST_F(SetScissorRectTest, Success) {
@ -284,8 +283,7 @@ TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) {
encoder.Finish();
}
class SetBlendColorTest : public ValidationTest {
};
class SetBlendColorTest : public ValidationTest {};
// Test to check basic use of SetBlendColor
TEST_F(SetBlendColorTest, Success) {
@ -315,8 +313,7 @@ TEST_F(SetBlendColorTest, AnyValueAllowed) {
encoder.Finish();
}
class SetStencilReferenceTest : public ValidationTest {
};
class SetStencilReferenceTest : public ValidationTest {};
// Test to check basic use of SetStencilReferenceTest
TEST_F(SetStencilReferenceTest, Success) {

View File

@ -18,8 +18,7 @@
namespace {
class QueueSubmitValidationTest : public ValidationTest {
};
class QueueSubmitValidationTest : public ValidationTest {};
// Test submitting with a mapped buffer is disallowed
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {

View File

@ -83,7 +83,8 @@ TEST_F(RenderPassDescriptorValidationTest, Empty) {
TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
// One color attachment
{
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
utils::ComboRenderPassDescriptor renderPass({color});
AssertBeginRenderPassSuccess(&renderPass);
@ -100,10 +101,14 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
// Test OOB color attachment indices are handled
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
wgpu::TextureView color0 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color1 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color2 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color3 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color0 =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color1 =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color2 =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color3 =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
// For setting the color attachment, control case
{
utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3});
@ -143,9 +148,12 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
// Attachments must have the same size
TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
wgpu::TextureView color1x1A = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color1x1B = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color2x2 = Create2DAttachment(device, 2, 2, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color1x1A =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color1x1B =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView color2x2 =
Create2DAttachment(device, 2, 2, wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView depthStencil1x1 =
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
@ -196,10 +204,12 @@ TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
constexpr uint32_t kLevelCount = 1;
constexpr uint32_t kSize = 32;
constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
constexpr wgpu::TextureFormat kDepthStencilFormat =
wgpu::TextureFormat::Depth24PlusStencil8;
wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize, kSize, kArrayLayers, kLevelCount);
wgpu::Texture colorTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount);
wgpu::Texture depthStencilTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kArrayLayers, kLevelCount);
@ -238,18 +248,20 @@ TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
}
}
// Currently only texture views with arrayLayerCount == 1 are allowed to be color and depth stencil
// attachments
// Currently only texture views with arrayLayerCount == 1 are allowed to be color and depth
// stencil attachments
TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepthStencil) {
constexpr uint32_t kLevelCount = 1;
constexpr uint32_t kSize = 32;
constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
constexpr wgpu::TextureFormat kDepthStencilFormat =
wgpu::TextureFormat::Depth24PlusStencil8;
constexpr uint32_t kArrayLayers = 10;
wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize, kSize, kArrayLayers, kLevelCount);
wgpu::Texture colorTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount);
wgpu::Texture depthStencilTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kArrayLayers, kLevelCount);
@ -337,12 +349,14 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
constexpr uint32_t kArrayLayers = 1;
constexpr uint32_t kSize = 32;
constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
constexpr wgpu::TextureFormat kDepthStencilFormat =
wgpu::TextureFormat::Depth24PlusStencil8;
constexpr uint32_t kLevelCount = 4;
wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize, kSize, kArrayLayers, kLevelCount);
wgpu::Texture colorTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount);
wgpu::Texture depthStencilTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kArrayLayers, kLevelCount);
@ -434,11 +448,11 @@ TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget
static constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
wgpu::Texture colorTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
kLevelCount, kSampleCount);
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount, kSampleCount);
wgpu::Texture resolveTargetTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
kLevelCount, kSampleCount);
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount, kSampleCount);
wgpu::TextureView colorTextureView = colorTexture.CreateView();
wgpu::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView();
@ -447,7 +461,8 @@ TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget
AssertBeginRenderPassError(&renderPass);
}
class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescriptorValidationTest {
class MultisampledRenderPassDescriptorValidationTest
: public RenderPassDescriptorValidationTest {
public:
utils::ComboRenderPassDescriptor CreateMultisampledRenderPass() {
return utils::ComboRenderPassDescriptor({CreateMultisampledColorTextureView()});
@ -509,8 +524,9 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget
// It is not allowed to use a resolve target with array layer count > 1.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMoreThanOne) {
constexpr uint32_t kArrayLayers2 = 2;
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize, kSize, kArrayLayers2, kLevelCount);
wgpu::Texture resolveTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers2, kLevelCount);
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
@ -521,8 +537,9 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMo
// It is not allowed to use a resolve target with mipmap level count > 1.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelMoreThanOne) {
constexpr uint32_t kLevelCount2 = 2;
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize, kSize, kArrayLayers, kLevelCount2);
wgpu::Texture resolveTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount2);
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
@ -530,14 +547,16 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelM
AssertBeginRenderPassError(&renderPass);
}
// It is not allowed to use a resolve target which is created from a texture whose usage does not
// include wgpu::TextureUsage::OutputAttachment.
// It is not allowed to use a resolve target which is created from a texture whose usage does
// not include wgpu::TextureUsage::OutputAttachment.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) {
constexpr wgpu::TextureUsage kUsage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
constexpr wgpu::TextureUsage kUsage =
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
wgpu::Texture nonColorUsageResolveTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
kLevelCount, 1, kUsage);
wgpu::TextureView nonColorUsageResolveTextureView = nonColorUsageResolveTexture.CreateView();
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount, 1, kUsage);
wgpu::TextureView nonColorUsageResolveTextureView =
nonColorUsageResolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = nonColorUsageResolveTextureView;
@ -546,8 +565,9 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutpu
// It is not allowed to use a resolve target which is in error state.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState) {
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize, kSize, kArrayLayers, kLevelCount);
wgpu::Texture resolveTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
kArrayLayers, kLevelCount);
wgpu::TextureViewDescriptor errorTextureView;
errorTextureView.dimension = wgpu::TextureViewDimension::e2D;
errorTextureView.format = kColorFormat;
@ -572,8 +592,9 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithReso
// It is not allowed to use a resolve target in a format different from the color attachment.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFormat) {
constexpr wgpu::TextureFormat kColorFormat2 = wgpu::TextureFormat::BGRA8Unorm;
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat2,
kSize, kSize, kArrayLayers, kLevelCount);
wgpu::Texture resolveTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat2, kSize, kSize,
kArrayLayers, kLevelCount);
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
@ -582,10 +603,12 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFor
}
// Tests on the size of the resolve target.
TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTargetCompatibility) {
TEST_F(MultisampledRenderPassDescriptorValidationTest,
ColorAttachmentResolveTargetCompatibility) {
constexpr uint32_t kSize2 = kSize * 2;
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
kSize2, kSize2, kArrayLayers, kLevelCount + 1);
wgpu::Texture resolveTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize2, kSize2,
kArrayLayers, kLevelCount + 1);
wgpu::TextureViewDescriptor textureViewDescriptor;
textureViewDescriptor.nextInChain = nullptr;
@ -599,7 +622,8 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
wgpu::TextureViewDescriptor firstMipLevelDescriptor = textureViewDescriptor;
firstMipLevelDescriptor.baseMipLevel = 0;
wgpu::TextureView resolveTextureView = resolveTexture.CreateView(&firstMipLevelDescriptor);
wgpu::TextureView resolveTextureView =
resolveTexture.CreateView(&firstMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
@ -610,7 +634,8 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
wgpu::TextureViewDescriptor secondMipLevelDescriptor = textureViewDescriptor;
secondMipLevelDescriptor.baseMipLevel = 1;
wgpu::TextureView resolveTextureView = resolveTexture.CreateView(&secondMipLevelDescriptor);
wgpu::TextureView resolveTextureView =
resolveTexture.CreateView(&secondMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
@ -620,37 +645,38 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
// Tests on the sample count of depth stencil attachment.
TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSampleCount) {
constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
constexpr wgpu::TextureFormat kDepthStencilFormat =
wgpu::TextureFormat::Depth24PlusStencil8;
wgpu::Texture multisampledDepthStencilTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kArrayLayers, kLevelCount, kSampleCount);
wgpu::TextureView multisampledDepthStencilTextureView =
multisampledDepthStencilTexture.CreateView();
// It is not allowed to use a depth stencil attachment whose sample count is different from the
// one of the color attachment.
{
wgpu::Texture depthStencilTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
kArrayLayers, kLevelCount);
wgpu::TextureView depthStencilTextureView = depthStencilTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass(
{CreateMultisampledColorTextureView()}, depthStencilTextureView);
AssertBeginRenderPassError(&renderPass);
}
{
utils::ComboRenderPassDescriptor renderPass(
{CreateNonMultisampledColorTextureView()}, multisampledDepthStencilTextureView);
AssertBeginRenderPassError(&renderPass);
}
// It is allowed to use a multisampled depth stencil attachment whose sample count is equal to
// It is not allowed to use a depth stencil attachment whose sample count is different from
// the one of the color attachment.
{
utils::ComboRenderPassDescriptor renderPass(
{CreateMultisampledColorTextureView()}, multisampledDepthStencilTextureView);
wgpu::Texture depthStencilTexture =
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize,
kSize, kArrayLayers, kLevelCount);
wgpu::TextureView depthStencilTextureView = depthStencilTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass({CreateMultisampledColorTextureView()},
depthStencilTextureView);
AssertBeginRenderPassError(&renderPass);
}
{
utils::ComboRenderPassDescriptor renderPass({CreateNonMultisampledColorTextureView()},
multisampledDepthStencilTextureView);
AssertBeginRenderPassError(&renderPass);
}
// It is allowed to use a multisampled depth stencil attachment whose sample count is equal
// to the one of the color attachment.
{
utils::ComboRenderPassDescriptor renderPass({CreateMultisampledColorTextureView()},
multisampledDepthStencilTextureView);
AssertBeginRenderPassSuccess(&renderPass);
}
@ -662,8 +688,8 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSam
}
}
// Tests that NaN cannot be accepted as a valid color or depth clear value and INFINITY is valid in
// both color and depth clear values.
// Tests that NaN cannot be accepted as a valid color or depth clear value and INFINITY is valid
// in both color and depth clear values.
TEST_F(RenderPassDescriptorValidationTest, UseNaNOrINFINITYAsColorOrDepthClearValue) {
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);

View File

@ -20,8 +20,7 @@
#include <sstream>
class ShaderModuleValidationTest : public ValidationTest {
};
class ShaderModuleValidationTest : public ValidationTest {};
// Test case with a simpler shader that should successfully be created
TEST_F(ShaderModuleValidationTest, CreationSuccess) {

View File

@ -49,7 +49,8 @@ class TextureValidationTest : public ValidationTest {
static constexpr uint32_t kDefaultMipLevels = 1;
static constexpr uint32_t kDefaultSampleCount = 1;
static constexpr wgpu::TextureFormat kDefaultTextureFormat = wgpu::TextureFormat::RGBA8Unorm;
static constexpr wgpu::TextureFormat kDefaultTextureFormat =
wgpu::TextureFormat::RGBA8Unorm;
};
// Test the validation of sample count
@ -378,8 +379,8 @@ class CompressedTextureFormatsValidationTests : public TextureValidationTest {
wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
wgpu::TextureDescriptor descriptor =
TextureValidationTest::CreateDefaultTextureDescriptor();
descriptor.usage =
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
descriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst |
wgpu::TextureUsage::Sampled;
return descriptor;
}
@ -429,8 +430,8 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
}
}
// Test the creation of a texture with BC format will fail when the extension textureCompressionBC
// is not enabled.
// Test the creation of a texture with BC format will fail when the extension
// textureCompressionBC is not enabled.
TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtension) {
const std::vector<const char*> kEmptyVector;
wgpu::Device deviceWithoutExtension = CreateDeviceFromAdapter(adapter, kEmptyVector);
@ -471,7 +472,8 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
// Test the validation of sample count when creating textures in compressed texture formats.
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
// Test that it is invalid to specify SampleCount > 1 when we create a texture in BC formats.
// Test that it is invalid to specify SampleCount > 1 when we create a texture in BC
// formats.
for (wgpu::TextureFormat format : kBCFormats) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = format;

View File

@ -16,8 +16,7 @@
namespace {
class TextureViewValidationTest : public ValidationTest {
};
class TextureViewValidationTest : public ValidationTest {};
constexpr uint32_t kWidth = 32u;
constexpr uint32_t kHeight = 32u;

View File

@ -16,8 +16,7 @@
namespace {
class ToggleValidationTest : public ValidationTest {
};
class ToggleValidationTest : public ValidationTest {};
// Tests querying the detail of a toggle from dawn_native::InstanceBase works correctly.
TEST_F(ToggleValidationTest, QueryToggleInfo) {

View File

@ -185,7 +185,6 @@ TEST_F(WireArgumentTests, CStringArgument) {
FlushClient();
}
// Test that the wire is able to send objects as value arguments
TEST_F(WireArgumentTests, ObjectAsValueArgument) {
WGPUCommandEncoder cmdBufEncoder = wgpuDeviceCreateCommandEncoder(device, nullptr);

View File

@ -613,4 +613,3 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
FlushClient();
}

View File

@ -64,7 +64,8 @@ class WireErrorCallbackTests : public WireTest {
WireTest::SetUp();
mockDeviceErrorCallback = std::make_unique<StrictMock<MockDeviceErrorCallback>>();
mockDevicePopErrorScopeCallback = std::make_unique<StrictMock<MockDevicePopErrorScopeCallback>>();
mockDevicePopErrorScopeCallback =
std::make_unique<StrictMock<MockDevicePopErrorScopeCallback>>();
mockDeviceLostCallback = std::make_unique<StrictMock<MockDeviceLostCallback>>();
}
@ -206,8 +207,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeDeviceDestroyed) {
EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
.WillOnce(Return(true));
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)).WillOnce(Return(true));
FlushClient();
// Incomplete callback called in Device destructor.

View File

@ -40,7 +40,8 @@ TEST_F(WireExtensionTests, ChainedStruct) {
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
EXPECT_STREQ(serverDesc->label, clientDesc.label);
const auto* ext = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
const auto* ext =
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
serverDesc->nextInChain);
EXPECT_EQ(ext->chain.sType, clientExt.chain.sType);
EXPECT_EQ(ext->maxAnisotropy, clientExt.maxAnisotropy);
@ -73,12 +74,14 @@ TEST_F(WireExtensionTests, MutlipleChainedStructs) {
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
EXPECT_STREQ(serverDesc->label, clientDesc.label);
const auto* ext1 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
const auto* ext1 =
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
serverDesc->nextInChain);
EXPECT_EQ(ext1->chain.sType, clientExt1.chain.sType);
EXPECT_EQ(ext1->maxAnisotropy, clientExt1.maxAnisotropy);
const auto* ext2 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
const auto* ext2 =
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
ext1->chain.next);
EXPECT_EQ(ext2->chain.sType, clientExt2.chain.sType);
EXPECT_EQ(ext2->maxAnisotropy, clientExt2.maxAnisotropy);
@ -99,12 +102,14 @@ TEST_F(WireExtensionTests, MutlipleChainedStructs) {
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
EXPECT_STREQ(serverDesc->label, clientDesc.label);
const auto* ext2 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
const auto* ext2 =
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
serverDesc->nextInChain);
EXPECT_EQ(ext2->chain.sType, clientExt2.chain.sType);
EXPECT_EQ(ext2->maxAnisotropy, clientExt2.maxAnisotropy);
const auto* ext1 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
const auto* ext1 =
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
ext2->chain.next);
EXPECT_EQ(ext1->chain.sType, clientExt1.chain.sType);
EXPECT_EQ(ext1->maxAnisotropy, clientExt1.maxAnisotropy);

View File

@ -180,9 +180,7 @@ class WireMemoryTransferServiceTests : public WireTest {
ClientReadHandle* handle = clientMemoryTransferService.NewReadHandle();
EXPECT_CALL(clientMemoryTransferService, OnCreateReadHandle(sizeof(mBufferContent)))
.WillOnce(InvokeWithoutArgs([=]() {
return handle;
}));
.WillOnce(InvokeWithoutArgs([=]() { return handle; }));
return handle;
}
@ -259,9 +257,7 @@ class WireMemoryTransferServiceTests : public WireTest {
ClientWriteHandle* handle = clientMemoryTransferService.NewWriteHandle();
EXPECT_CALL(clientMemoryTransferService, OnCreateWriteHandle(sizeof(mBufferContent)))
.WillOnce(InvokeWithoutArgs([=]() {
return handle;
}));
.WillOnce(InvokeWithoutArgs([=]() { return handle; }));
return handle;
}
@ -300,22 +296,18 @@ class WireMemoryTransferServiceTests : public WireTest {
EXPECT_CALL(serverMemoryTransferService,
OnDeserializeWriteHandle(Pointee(Eq(mSerializeCreateInfo)),
sizeof(mSerializeCreateInfo), _))
.WillOnce(InvokeWithoutArgs([&]() {
return false;
}));
.WillOnce(InvokeWithoutArgs([&]() { return false; }));
}
void ExpectClientWriteHandleOpen(ClientWriteHandle* handle, uint32_t* mappedData) {
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleOpen(handle))
.WillOnce(InvokeWithoutArgs([=]() {
return std::make_pair(mappedData, sizeof(*mappedData));
}));
.WillOnce(InvokeWithoutArgs(
[=]() { return std::make_pair(mappedData, sizeof(*mappedData)); }));
}
void MockClientWriteHandleOpenFailure(ClientWriteHandle* handle) {
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleOpen(handle))
.WillOnce(InvokeWithoutArgs(
[&]() { return std::make_pair(nullptr, 0); }));
.WillOnce(InvokeWithoutArgs([&]() { return std::make_pair(nullptr, 0); }));
}
void ExpectClientWriteHandleSerializeFlush(ClientWriteHandle* handle) {
@ -348,8 +340,8 @@ class WireMemoryTransferServiceTests : public WireTest {
// Arbitrary values used within tests to check if serialized data is correctly passed
// between the client and server. The static data changes between runs of the tests and
// test expectations will check that serialized values are passed to the respective deserialization
// function.
// test expectations will check that serialized values are passed to the respective
// deserialization function.
static uint32_t mSerializeCreateInfo;
static uint32_t mSerializeInitialDataInfo;
static uint32_t mSerializeFlushInfo;
@ -360,8 +352,9 @@ class WireMemoryTransferServiceTests : public WireTest {
// The client's zero-initialized buffer for writing.
uint32_t mMappedBufferContent = 0;
// |mMappedBufferContent| should be set equal to |mUpdatedBufferContent| when the client performs a write.
// Test expectations should check that |mBufferContent == mUpdatedBufferContent| after all writes are flushed.
// |mMappedBufferContent| should be set equal to |mUpdatedBufferContent| when the client
// performs a write. Test expectations should check that |mBufferContent ==
// mUpdatedBufferContent| after all writes are flushed.
static uint32_t mUpdatedBufferContent;
testing::StrictMock<dawn_wire::server::MockMemoryTransferService> serverMemoryTransferService;

View File

@ -68,9 +68,11 @@ inline testing::Matcher<MatcherLambdaArgument<Lambda>> MatchesLambda(Lambda lamb
class StringMessageMatcher : public testing::MatcherInterface<const char*> {
public:
explicit StringMessageMatcher() {}
explicit StringMessageMatcher() {
}
bool MatchAndExplain(const char* message, testing::MatchResultListener* listener) const override {
bool MatchAndExplain(const char* message,
testing::MatchResultListener* listener) const override {
if (message == nullptr) {
*listener << "missing error message";
return false;