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:
parent
3d80b5c378
commit
2afea0c671
|
@ -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() {
|
||||
|
|
|
@ -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" ]
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ void frame() {
|
|||
{
|
||||
colorAttachment.attachment = backbufferView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
colorAttachment.loadOp = WGPULoadOp_Clear;
|
||||
colorAttachment.storeOp = WGPUStoreOp_Store;
|
||||
renderpassInfo.colorAttachmentCount = 1;
|
||||
|
|
|
@ -67,7 +67,7 @@ void initBuffers() {
|
|||
modelBuffer =
|
||||
utils::CreateBufferFromData(device, model, sizeof(model), wgpu::BufferUsage::Vertex);
|
||||
|
||||
SimParams params = { 0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles };
|
||||
SimParams params = {0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles};
|
||||
updateParams =
|
||||
utils::CreateBufferFromData(device, ¶ms, sizeof(params), wgpu::BufferUsage::Uniform);
|
||||
|
||||
|
@ -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)},
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
@ -74,7 +74,7 @@ static wgpu::BackendType backendType = wgpu::BackendType::Vulkan;
|
|||
#elif defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||
static wgpu::BackendType backendType = wgpu::BackendType::OpenGL;
|
||||
#else
|
||||
#error
|
||||
# error
|
||||
#endif
|
||||
|
||||
static CmdBufType cmdBufType = CmdBufType::Terrible;
|
||||
|
@ -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]) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
constexpr static uint32_t kRTSize = 8;
|
||||
|
||||
class BindGroupTests : public DawnTest {
|
||||
protected:
|
||||
protected:
|
||||
wgpu::CommandBuffer CreateSimpleComputeCommandBuffer(const wgpu::ComputePipeline& pipeline,
|
||||
const wgpu::BindGroup& bindGroup) {
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
@ -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";
|
||||
|
@ -195,10 +195,10 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
|||
};
|
||||
ASSERT(offsetof(Data, color) == 256);
|
||||
constexpr float dummy = 0.0f;
|
||||
Data data {
|
||||
{ 1.f, 0.f, dummy, dummy, 0.f, 1.0f, dummy, dummy },
|
||||
{ 0 },
|
||||
{ 0.f, 1.f, 0.f, 1.f },
|
||||
Data data{
|
||||
{1.f, 0.f, dummy, dummy, 0.f, 1.0f, dummy, dummy},
|
||||
{0},
|
||||
{0.f, 1.f, 0.f, 1.f},
|
||||
};
|
||||
wgpu::Buffer buffer =
|
||||
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Uniform);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -260,7 +260,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
|
||||
|
||||
constexpr float dummy = 0.0f;
|
||||
constexpr float transform[] = { 1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy };
|
||||
constexpr float transform[] = {1.f, 0.f, dummy, dummy, 0.f, 1.f, dummy, dummy};
|
||||
wgpu::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform),
|
||||
wgpu::BufferUsage::Uniform);
|
||||
|
||||
|
@ -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());
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 =
|
||||
|
@ -171,14 +174,11 @@ class CopyTests_T2B : public CopyTests {
|
|||
};
|
||||
|
||||
class CopyTests_B2T : public CopyTests {
|
||||
protected:
|
||||
protected:
|
||||
static void FillBufferData(RGBA8* data, size_t count) {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
data[i] = RGBA8(
|
||||
static_cast<uint8_t>(i % 256),
|
||||
static_cast<uint8_t>((i / 256) % 256),
|
||||
static_cast<uint8_t>((i / 256 / 256) % 256),
|
||||
255);
|
||||
data[i] = RGBA8(static_cast<uint8_t>(i % 256), static_cast<uint8_t>((i / 256) % 256),
|
||||
static_cast<uint8_t>((i / 256 / 256) % 256), 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -510,7 +510,7 @@ TEST_P(CopyTests_T2B, TextureRegionAligned) {
|
|||
constexpr uint32_t kWidth = 256;
|
||||
constexpr uint32_t kHeight = 128;
|
||||
for (unsigned int w : {64, 128, 256}) {
|
||||
for (unsigned int h : { 16, 32, 48 }) {
|
||||
for (unsigned int h : {16, 32, 48}) {
|
||||
TextureSpec textureSpec;
|
||||
textureSpec.copyOrigin = {0, 0, 0};
|
||||
textureSpec.level = 0;
|
||||
|
@ -531,7 +531,7 @@ TEST_P(CopyTests_T2B, TextureRegionUnaligned) {
|
|||
defaultTextureSpec.textureSize = {kWidth, kHeight, 1};
|
||||
|
||||
for (unsigned int w : {13, 63, 65}) {
|
||||
for (unsigned int h : { 17, 19, 63 }) {
|
||||
for (unsigned int h : {17, 19, 63}) {
|
||||
TextureSpec textureSpec = defaultTextureSpec;
|
||||
DoTest(textureSpec, MinimumBufferSpec(w, h), {w, h, 1});
|
||||
}
|
||||
|
@ -746,7 +746,11 @@ 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) {
|
||||
|
@ -877,7 +881,7 @@ TEST_P(CopyTests_B2T, TextureRegionAligned) {
|
|||
constexpr uint32_t kWidth = 256;
|
||||
constexpr uint32_t kHeight = 128;
|
||||
for (unsigned int w : {64, 128, 256}) {
|
||||
for (unsigned int h : { 16, 32, 48 }) {
|
||||
for (unsigned int h : {16, 32, 48}) {
|
||||
TextureSpec textureSpec;
|
||||
textureSpec.copyOrigin = {0, 0, 0};
|
||||
textureSpec.level = 0;
|
||||
|
@ -1090,7 +1094,11 @@ 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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
@ -121,21 +122,24 @@ class DepthStencilStateTest : public DawnTest {
|
|||
RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
|
||||
|
||||
// Base triangle at depth 0.5, depth always, depth write enabled
|
||||
TestSpec base = { baseState, baseColor, 0.5f, 0u };
|
||||
TestSpec base = {baseState, baseColor, 0.5f, 0u};
|
||||
|
||||
// Draw the base triangle, then a triangle in stencilFront of the base triangle with the
|
||||
// given depth comparison function
|
||||
DoTest({ base, { state, lessColor, 0.f, 0u } }, less ? lessColor : baseColor);
|
||||
DoTest({base, {state, lessColor, 0.f, 0u}}, less ? lessColor : baseColor);
|
||||
|
||||
// Draw the base triangle, then a triangle in at the same depth as the base triangle with the given depth comparison function
|
||||
DoTest({ base, { state, equalColor, 0.5f, 0u } }, equal ? equalColor : baseColor);
|
||||
// Draw the base triangle, then a triangle in at the same depth as the base triangle with
|
||||
// the given depth comparison function
|
||||
DoTest({base, {state, equalColor, 0.5f, 0u}}, equal ? equalColor : baseColor);
|
||||
|
||||
// Draw the base triangle, then a triangle behind the base triangle with the given depth comparison function
|
||||
DoTest({ base, { state, greaterColor, 1.0f, 0u } }, greater ? greaterColor : baseColor);
|
||||
// Draw the base triangle, then a triangle behind the base triangle with the given depth
|
||||
// comparison function
|
||||
DoTest({base, {state, greaterColor, 1.0f, 0u}}, greater ? greaterColor : baseColor);
|
||||
}
|
||||
|
||||
// Check whether a stencil comparison function works as expected
|
||||
// The less, equal, greater booleans denote wether the respective triangle should be visible based on the comparison function
|
||||
// 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,
|
||||
|
@ -172,19 +176,23 @@ class DepthStencilStateTest : public DawnTest {
|
|||
RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
|
||||
|
||||
// Base triangle with stencil reference 1
|
||||
TestSpec base = { baseState, baseColor, 0.0f, 1u };
|
||||
TestSpec base = {baseState, baseColor, 0.0f, 1u};
|
||||
|
||||
// Draw the base triangle, then a triangle with stencil reference 0 with the given stencil comparison function
|
||||
DoTest({ base, { state, lessColor, 0.f, 0u } }, less ? lessColor : baseColor);
|
||||
// Draw the base triangle, then a triangle with stencil reference 0 with the given stencil
|
||||
// comparison function
|
||||
DoTest({base, {state, lessColor, 0.f, 0u}}, less ? lessColor : baseColor);
|
||||
|
||||
// Draw the base triangle, then a triangle with stencil reference 1 with the given stencil comparison function
|
||||
DoTest({ base, { state, equalColor, 0.f, 1u } }, equal ? equalColor : baseColor);
|
||||
// Draw the base triangle, then a triangle with stencil reference 1 with the given stencil
|
||||
// comparison function
|
||||
DoTest({base, {state, equalColor, 0.f, 1u}}, equal ? equalColor : baseColor);
|
||||
|
||||
// Draw the base triangle, then a triangle with stencil reference 2 with the given stencil comparison function
|
||||
DoTest({ base, { state, greaterColor, 0.f, 2u } }, greater ? greaterColor : baseColor);
|
||||
// Draw the base triangle, then a triangle with stencil reference 2 with the given stencil
|
||||
// comparison function
|
||||
DoTest({base, {state, greaterColor, 0.f, 2u}}, greater ? greaterColor : baseColor);
|
||||
}
|
||||
|
||||
// Given the provided `initialStencil` and `reference`, check that applying the `stencilOperation` produces the `expectedStencil`
|
||||
// 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 },
|
||||
{baseState, RGBA8(255, 255, 255, 255), 0.f, initialStencil},
|
||||
|
||||
// Draw a triangle with the provided stencil operation and reference
|
||||
{ state, RGBA8(255, 0, 0, 255), 0.f, reference },
|
||||
}, expectedStencil);
|
||||
{state, RGBA8(255, 0, 0, 255), 0.f, reference},
|
||||
},
|
||||
expectedStencil);
|
||||
}
|
||||
|
||||
// Draw a list of test specs, and check if the stencil value is equal to the expected value
|
||||
|
@ -239,13 +249,16 @@ class DepthStencilStateTest : public DawnTest {
|
|||
state.stencilReadMask = 0xff;
|
||||
state.stencilWriteMask = 0xff;
|
||||
|
||||
testParams.push_back({ state, RGBA8(0, 255, 0, 255), 0, expectedStencil });
|
||||
testParams.push_back({state, RGBA8(0, 255, 0, 255), 0, expectedStencil});
|
||||
DoTest(testParams, RGBA8(0, 255, 0, 255));
|
||||
}
|
||||
|
||||
// Each test param represents a pair of triangles with a color, depth, stencil value, and depthStencil state, one frontfacing, one backfacing
|
||||
// Draw the triangles in order and check the expected colors for the frontfaces and backfaces
|
||||
void DoTest(const std::vector<TestSpec> &testParams, const RGBA8& expectedFront, const RGBA8& expectedBack) {
|
||||
// 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,11 +307,13 @@ 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) {
|
||||
void DoTest(const std::vector<TestSpec>& testParams, const RGBA8& expected) {
|
||||
DoTest(testParams, expected, expected);
|
||||
}
|
||||
|
||||
|
@ -325,9 +341,11 @@ TEST_P(DepthStencilStateTest, Basic) {
|
|||
state.stencilReadMask = 0xff;
|
||||
state.stencilWriteMask = 0xff;
|
||||
|
||||
DoTest({
|
||||
{ state, RGBA8(0, 255, 0, 255), 0.5f, 0u },
|
||||
}, RGBA8(0, 255, 0, 255));
|
||||
DoTest(
|
||||
{
|
||||
{state, RGBA8(0, 255, 0, 255), 0.5f, 0u},
|
||||
},
|
||||
RGBA8(0, 255, 0, 255));
|
||||
}
|
||||
|
||||
// Test defaults: depth and stencil tests disabled
|
||||
|
@ -347,9 +365,9 @@ TEST_P(DepthStencilStateTest, DepthStencilDisabled) {
|
|||
state.stencilWriteMask = 0xff;
|
||||
|
||||
TestSpec specs[3] = {
|
||||
{ state, RGBA8(255, 0, 0, 255), 0.0f, 0u },
|
||||
{ state, RGBA8(0, 255, 0, 255), 0.5f, 0u },
|
||||
{ state, RGBA8(0, 0, 255, 255), 1.0f, 0u },
|
||||
{state, RGBA8(255, 0, 0, 255), 0.0f, 0u},
|
||||
{state, RGBA8(0, 255, 0, 255), 0.5f, 0u},
|
||||
{state, RGBA8(0, 0, 255, 255), 1.0f, 0u},
|
||||
};
|
||||
|
||||
// Test that for all combinations, the last triangle drawn is the one visible
|
||||
|
@ -357,8 +375,8 @@ TEST_P(DepthStencilStateTest, DepthStencilDisabled) {
|
|||
for (uint32_t last = 0; last < 3; ++last) {
|
||||
uint32_t i = (last + 1) % 3;
|
||||
uint32_t j = (last + 2) % 3;
|
||||
DoTest({ specs[i], specs[j], specs[last] }, specs[last].color);
|
||||
DoTest({ specs[j], specs[i], specs[last] }, specs[last].color);
|
||||
DoTest({specs[i], specs[j], specs[last]}, specs[last].color);
|
||||
DoTest({specs[j], specs[i], specs[last]}, specs[last].color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,11 +445,17 @@ 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
|
||||
|
@ -536,9 +560,11 @@ TEST_P(DepthStencilStateTest, StencilReadMask) {
|
|||
RGBA8 red = RGBA8(255, 0, 0, 255);
|
||||
RGBA8 green = RGBA8(0, 255, 0, 255);
|
||||
|
||||
TestSpec base = { baseState, baseColor, 0.5f, 3u }; // Base triangle to set the stencil to 3
|
||||
DoTest({ base, { state, red, 0.f, 1u } }, baseColor); // Triangle with stencil reference 1 and read mask 2 does not draw because (3 & 2 != 1)
|
||||
DoTest({ base, { state, green, 0.f, 2u } }, green); // Triangle with stencil reference 2 and read mask 2 draws because (3 & 2 == 2)
|
||||
TestSpec base = {baseState, baseColor, 0.5f, 3u}; // Base triangle to set the stencil to 3
|
||||
DoTest({base, {state, red, 0.f, 1u}}, baseColor); // Triangle with stencil reference 1 and read
|
||||
// mask 2 does not draw because (3 & 2 != 1)
|
||||
DoTest({base, {state, green, 0.f, 2u}},
|
||||
green); // Triangle with stencil reference 2 and read mask 2 draws because (3 & 2 == 2)
|
||||
}
|
||||
|
||||
// Check that setting a stencil write mask works
|
||||
|
@ -572,9 +598,12 @@ 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({
|
||||
{ baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1
|
||||
{ state, RGBA8(0, 0, 0, 255), 0.f, 2 } // Triangle with stencil reference 2 fails the Less comparison function
|
||||
}, 2); // Replace the stencil on failure, so it should be 2
|
||||
CheckStencil(
|
||||
{
|
||||
{baseState, RGBA8(255, 255, 255, 255), 1.f, 1}, // Triangle to set stencil value to 1
|
||||
{state, RGBA8(0, 0, 0, 255), 0.f,
|
||||
2} // Triangle with stencil reference 2 fails the Less comparison function
|
||||
},
|
||||
2); // Replace the stencil on failure, so it should be 2
|
||||
}
|
||||
|
||||
// Test that the stencil operation is executed on stencil pass, depth fail
|
||||
|
@ -639,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,10 +707,12 @@ 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
|
||||
2); // Replace the stencil on stencil pass, depth pass, so it should be 2
|
||||
CheckStencil({{baseState, RGBA8(255, 255, 255, 255), 1.f,
|
||||
1}, // Triangle to set stencil value to 1. Depth is 0
|
||||
{state, RGBA8(0, 0, 0, 255), 0.f,
|
||||
2}}, // Triangle with stencil reference 2 passes the Greater comparison
|
||||
// function. At depth 0, it pass the Less depth test
|
||||
2); // Replace the stencil on stencil pass, depth pass, so it should be 2
|
||||
}
|
||||
|
||||
// Test that creating a render pipeline works with for all depth and combined formats
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -61,7 +61,6 @@ class MultisampledRenderingTest : public DawnTest {
|
|||
|
||||
const char* fs = testDepth ? kFsOneOutputWithDepth : kFsOneOutputWithoutDepth;
|
||||
|
||||
|
||||
return CreateRenderPipelineForTest(fs, 1, testDepth);
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
// Primitive topology tests work by drawing the following vertices with all the different primitive topology states:
|
||||
// Primitive topology tests work by drawing the following vertices with all the different primitive
|
||||
// topology states:
|
||||
// -------------------------------------
|
||||
// | |
|
||||
// | 1 2 5 |
|
||||
|
@ -81,8 +82,8 @@
|
|||
// -------------------------------------
|
||||
//
|
||||
// Each of these different states is a superset of some of the previous states,
|
||||
// so for every state, we check any new added test locations that are not contained in previous states
|
||||
// We also check that the test locations of subsequent states are untouched
|
||||
// so for every state, we check any new added test locations that are not contained in previous
|
||||
// states We also check that the test locations of subsequent states are untouched
|
||||
|
||||
constexpr static unsigned int kRTSize = 32;
|
||||
|
||||
|
@ -91,11 +92,13 @@ struct TestLocation {
|
|||
};
|
||||
|
||||
constexpr TestLocation GetMidpoint(const TestLocation& a, const TestLocation& b) noexcept {
|
||||
return { (a.x + b.x) / 2, (a.y + b.y) / 2 };
|
||||
return {(a.x + b.x) / 2, (a.y + b.y) / 2};
|
||||
}
|
||||
|
||||
constexpr TestLocation GetCentroid(const TestLocation& a, const TestLocation& b, const TestLocation& c) noexcept {
|
||||
return { (a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3 };
|
||||
constexpr TestLocation GetCentroid(const TestLocation& a,
|
||||
const TestLocation& b,
|
||||
const TestLocation& c) noexcept {
|
||||
return {(a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3};
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
@ -177,10 +180,11 @@ class PrimitiveTopologyTest : public DawnTest {
|
|||
|
||||
template <std::size_t N>
|
||||
constexpr LocationSpec TestPoints(TestLocation const (&points)[N], bool include) noexcept {
|
||||
return { points, N, include };
|
||||
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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -21,7 +21,7 @@ constexpr uint32_t kRTSize = 16;
|
|||
constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||
|
||||
class RenderPassTest : public DawnTest {
|
||||
protected:
|
||||
protected:
|
||||
void SetUp() override {
|
||||
DawnTest::SetUp();
|
||||
|
||||
|
|
|
@ -46,10 +46,10 @@ namespace {
|
|||
255,
|
||||
},
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class SamplerTest : public DawnTest {
|
||||
protected:
|
||||
protected:
|
||||
void SetUp() override {
|
||||
DawnTest::SetUp();
|
||||
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
@ -177,4 +177,8 @@ TEST_P(SamplerTest, AddressMode) {
|
|||
}
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(SamplerTest, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|
||||
DAWN_INSTANTIATE_TEST(SamplerTest,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
OpenGLBackend(),
|
||||
VulkanBackend());
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class ScissorTest: public DawnTest {
|
||||
class ScissorTest : public DawnTest {
|
||||
protected:
|
||||
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
|
||||
wgpu::ShaderModule vsModule =
|
||||
|
@ -152,4 +152,8 @@ 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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace {
|
|||
} // anonymous namespace
|
||||
|
||||
class TextureViewSamplingTest : public DawnTest {
|
||||
protected:
|
||||
protected:
|
||||
// Generates an arbitrary pixel value per-layer-per-level, used for the "actual" uploaded
|
||||
// textures and the "expected" results.
|
||||
static int GenerateTestPixelValue(uint32_t layer, uint32_t level) {
|
||||
|
@ -104,8 +104,8 @@ 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, ©);
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -321,7 +320,7 @@ protected:
|
|||
|
||||
// Check the data in the every face of the cube map (array) texture view.
|
||||
for (uint32_t layer = 0; layer < textureViewLayerCount; ++layer) {
|
||||
const std::string &fragmentShader =
|
||||
const std::string& fragmentShader =
|
||||
CreateFragmentShaderForCubeMapFace(layer, isCubeMapArray);
|
||||
|
||||
int expected = GenerateTestPixelValue(textureViewBaseLayer + layer, 0);
|
||||
|
@ -362,8 +361,8 @@ 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 {};
|
||||
|
||||
|
|
|
@ -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"}),
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -543,7 +543,7 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
|
|||
uint16_t halfs[2];
|
||||
};
|
||||
static_assert(sizeof(Data) == 16, "");
|
||||
Data data {1.f, {2u, 3u}, {Float32ToFloat16(4.f), Float32ToFloat16(5.f)}};
|
||||
Data data{1.f, {2u, 3u}, {Float32ToFloat16(4.f), Float32ToFloat16(5.f)}};
|
||||
|
||||
wgpu::Buffer vertexBuffer =
|
||||
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Vertex);
|
||||
|
@ -599,7 +599,11 @@ 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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -209,7 +210,7 @@ TEST(CommandAllocator, LargeCommands) {
|
|||
for (int i = 0; i < kCommandCount; i++) {
|
||||
CommandBig* big = allocator.Allocate<CommandBig>(CommandType::Big);
|
||||
for (int j = 0; j < kBigBufferSize; j++) {
|
||||
big->buffer[j] = count ++;
|
||||
big->buffer[j] = count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,9 +224,9 @@ TEST(CommandAllocator, LargeCommands) {
|
|||
CommandBig* big = iterator.NextCommand<CommandBig>();
|
||||
for (int i = 0; i < kBigBufferSize; i++) {
|
||||
ASSERT_EQ(big->buffer[i], count);
|
||||
count ++;
|
||||
count++;
|
||||
}
|
||||
numCommands ++;
|
||||
numCommands++;
|
||||
}
|
||||
ASSERT_EQ(numCommands, kCommandCount);
|
||||
|
||||
|
@ -242,7 +243,7 @@ TEST(CommandAllocator, ManySmallCommands) {
|
|||
uint16_t count = 0;
|
||||
for (int i = 0; i < kCommandCount; i++) {
|
||||
CommandSmall* small = allocator.Allocate<CommandSmall>(CommandType::Small);
|
||||
small->data = count ++;
|
||||
small->data = count++;
|
||||
}
|
||||
|
||||
CommandIterator iterator(std::move(allocator));
|
||||
|
@ -254,8 +255,8 @@ TEST(CommandAllocator, ManySmallCommands) {
|
|||
|
||||
CommandSmall* small = iterator.NextCommand<CommandSmall>();
|
||||
ASSERT_EQ(small->data, count);
|
||||
count ++;
|
||||
numCommands ++;
|
||||
count++;
|
||||
numCommands++;
|
||||
}
|
||||
ASSERT_EQ(numCommands, kCommandCount);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace wgpu {
|
|||
A = 8,
|
||||
};
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct IsDawnBitmask<Color> {
|
||||
static constexpr bool enable = true;
|
||||
};
|
||||
|
|
|
@ -21,45 +21,39 @@ using namespace dawn_native;
|
|||
|
||||
namespace {
|
||||
|
||||
int dummySuccess = 0xbeef;
|
||||
const char* dummyErrorMessage = "I am an error message :3";
|
||||
int dummySuccess = 0xbeef;
|
||||
const char* dummyErrorMessage = "I am an error message :3";
|
||||
|
||||
// Check returning a success MaybeError with {};
|
||||
TEST(ErrorTests, Error_Success) {
|
||||
auto ReturnSuccess = []() -> MaybeError {
|
||||
return {};
|
||||
};
|
||||
// Check returning a success MaybeError with {};
|
||||
TEST(ErrorTests, Error_Success) {
|
||||
auto ReturnSuccess = []() -> MaybeError { return {}; };
|
||||
|
||||
MaybeError result = ReturnSuccess();
|
||||
ASSERT_TRUE(result.IsSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
// Check returning an error MaybeError with "return DAWN_VALIDATION_ERROR"
|
||||
TEST(ErrorTests, Error_Error) {
|
||||
auto ReturnError = []() -> MaybeError {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
// Check returning an error MaybeError with "return DAWN_VALIDATION_ERROR"
|
||||
TEST(ErrorTests, Error_Error) {
|
||||
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||
|
||||
MaybeError result = ReturnError();
|
||||
ASSERT_TRUE(result.IsError());
|
||||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Check returning a success ResultOrError with an implicit conversion
|
||||
TEST(ErrorTests, ResultOrError_Success) {
|
||||
auto ReturnSuccess = []() -> ResultOrError<int*> {
|
||||
return &dummySuccess;
|
||||
};
|
||||
// Check returning a success ResultOrError with an implicit conversion
|
||||
TEST(ErrorTests, ResultOrError_Success) {
|
||||
auto ReturnSuccess = []() -> ResultOrError<int*> { return &dummySuccess; };
|
||||
|
||||
ResultOrError<int*> result = ReturnSuccess();
|
||||
ASSERT_TRUE(result.IsSuccess());
|
||||
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Check returning an error ResultOrError with "return DAWN_VALIDATION_ERROR"
|
||||
TEST(ErrorTests, ResultOrError_Error) {
|
||||
// Check returning an error ResultOrError with "return DAWN_VALIDATION_ERROR"
|
||||
TEST(ErrorTests, ResultOrError_Error) {
|
||||
auto ReturnError = []() -> ResultOrError<int*> {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
|
@ -69,13 +63,11 @@ TEST(ErrorTests, ResultOrError_Error) {
|
|||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Check DAWN_TRY handles successes correctly.
|
||||
TEST(ErrorTests, TRY_Success) {
|
||||
auto ReturnSuccess = []() -> MaybeError {
|
||||
return {};
|
||||
};
|
||||
// Check DAWN_TRY handles successes correctly.
|
||||
TEST(ErrorTests, TRY_Success) {
|
||||
auto ReturnSuccess = []() -> MaybeError { return {}; };
|
||||
|
||||
// We need to check that DAWN_TRY doesn't return on successes
|
||||
bool tryReturned = true;
|
||||
|
@ -89,13 +81,11 @@ TEST(ErrorTests, TRY_Success) {
|
|||
MaybeError result = Try();
|
||||
ASSERT_TRUE(result.IsSuccess());
|
||||
ASSERT_FALSE(tryReturned);
|
||||
}
|
||||
}
|
||||
|
||||
// Check DAWN_TRY handles errors correctly.
|
||||
TEST(ErrorTests, TRY_Error) {
|
||||
auto ReturnError = []() -> MaybeError {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
// Check DAWN_TRY handles errors correctly.
|
||||
TEST(ErrorTests, TRY_Error) {
|
||||
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||
|
||||
auto Try = [ReturnError]() -> MaybeError {
|
||||
DAWN_TRY(ReturnError());
|
||||
|
@ -109,13 +99,11 @@ TEST(ErrorTests, TRY_Error) {
|
|||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Check DAWN_TRY adds to the backtrace.
|
||||
TEST(ErrorTests, TRY_AddsToBacktrace) {
|
||||
auto ReturnError = []() -> MaybeError {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
// Check DAWN_TRY adds to the backtrace.
|
||||
TEST(ErrorTests, TRY_AddsToBacktrace) {
|
||||
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||
|
||||
auto SingleTry = [ReturnError]() -> MaybeError {
|
||||
DAWN_TRY(ReturnError());
|
||||
|
@ -137,13 +125,11 @@ TEST(ErrorTests, TRY_AddsToBacktrace) {
|
|||
std::unique_ptr<ErrorData> doubleData = doubleResult.AcquireError();
|
||||
|
||||
ASSERT_EQ(singleData->GetBacktrace().size() + 1, doubleData->GetBacktrace().size());
|
||||
}
|
||||
}
|
||||
|
||||
// Check DAWN_TRY_ASSIGN handles successes correctly.
|
||||
TEST(ErrorTests, TRY_RESULT_Success) {
|
||||
auto ReturnSuccess = []() -> ResultOrError<int*> {
|
||||
return &dummySuccess;
|
||||
};
|
||||
// Check DAWN_TRY_ASSIGN handles successes correctly.
|
||||
TEST(ErrorTests, TRY_RESULT_Success) {
|
||||
auto ReturnSuccess = []() -> ResultOrError<int*> { return &dummySuccess; };
|
||||
|
||||
// We need to check that DAWN_TRY doesn't return on successes
|
||||
bool tryReturned = true;
|
||||
|
@ -161,10 +147,10 @@ TEST(ErrorTests, TRY_RESULT_Success) {
|
|||
ASSERT_TRUE(result.IsSuccess());
|
||||
ASSERT_FALSE(tryReturned);
|
||||
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Check DAWN_TRY_ASSIGN handles errors correctly.
|
||||
TEST(ErrorTests, TRY_RESULT_Error) {
|
||||
// Check DAWN_TRY_ASSIGN handles errors correctly.
|
||||
TEST(ErrorTests, TRY_RESULT_Error) {
|
||||
auto ReturnError = []() -> ResultOrError<int*> {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
|
@ -184,10 +170,10 @@ TEST(ErrorTests, TRY_RESULT_Error) {
|
|||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Check DAWN_TRY_ASSIGN adds to the backtrace.
|
||||
TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
|
||||
// Check DAWN_TRY_ASSIGN adds to the backtrace.
|
||||
TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
|
||||
auto ReturnError = []() -> ResultOrError<int*> {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
|
@ -212,10 +198,10 @@ TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
|
|||
std::unique_ptr<ErrorData> doubleData = doubleResult.AcquireError();
|
||||
|
||||
ASSERT_EQ(singleData->GetBacktrace().size() + 1, doubleData->GetBacktrace().size());
|
||||
}
|
||||
}
|
||||
|
||||
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
||||
TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
||||
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
||||
TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
||||
auto ReturnError = []() -> ResultOrError<int*> {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
|
@ -233,11 +219,11 @@ TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
|||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
||||
// Version without Result<E*, T*>
|
||||
TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
|
||||
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
||||
// Version without Result<E*, T*>
|
||||
TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
|
||||
auto ReturnError = []() -> ResultOrError<int> {
|
||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||
};
|
||||
|
@ -255,16 +241,14 @@ TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
|
|||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
};
|
||||
// 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 Try = [ReturnError]() -> ResultOrError<int*>{
|
||||
auto Try = [ReturnError]() -> ResultOrError<int*> {
|
||||
DAWN_TRY(ReturnError());
|
||||
return &dummySuccess;
|
||||
};
|
||||
|
@ -274,16 +258,14 @@ TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
|
|||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
};
|
||||
// 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 Try = [ReturnError]() -> ResultOrError<int>{
|
||||
auto Try = [ReturnError]() -> ResultOrError<int> {
|
||||
DAWN_TRY(ReturnError());
|
||||
return 42;
|
||||
};
|
||||
|
@ -293,6 +275,6 @@ TEST(ErrorTests, TRY_ConversionToErrorOrResultNonPointer) {
|
|||
|
||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -194,4 +194,3 @@ TEST(ObjectBase, AssignNullptr) {
|
|||
obj = nullptr;
|
||||
ASSERT_EQ(refcount, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ TEST(PerStage, IterateAllStages) {
|
|||
counts[SingleShaderStage::Compute] = 0;
|
||||
|
||||
for (auto stage : IterateStages(kAllStages)) {
|
||||
counts[stage] ++;
|
||||
counts[stage]++;
|
||||
}
|
||||
|
||||
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 1);
|
||||
|
@ -64,7 +64,7 @@ TEST(PerStage, IterateOneStage) {
|
|||
counts[SingleShaderStage::Compute] = 0;
|
||||
|
||||
for (auto stage : IterateStages(wgpu::ShaderStage::Fragment)) {
|
||||
counts[stage] ++;
|
||||
counts[stage]++;
|
||||
}
|
||||
|
||||
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 0);
|
||||
|
@ -80,7 +80,7 @@ TEST(PerStage, IterateNoStages) {
|
|||
counts[SingleShaderStage::Compute] = 0;
|
||||
|
||||
for (auto stage : IterateStages(wgpu::ShaderStage::Fragment & wgpu::ShaderStage::Vertex)) {
|
||||
counts[stage] ++;
|
||||
counts[stage]++;
|
||||
}
|
||||
|
||||
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 0);
|
||||
|
|
|
@ -19,17 +19,17 @@
|
|||
|
||||
namespace {
|
||||
|
||||
template<typename T, typename E>
|
||||
void TestError(Result<T, E>* result, E expectedError) {
|
||||
template <typename T, typename E>
|
||||
void TestError(Result<T, E>* result, E expectedError) {
|
||||
EXPECT_TRUE(result->IsError());
|
||||
EXPECT_FALSE(result->IsSuccess());
|
||||
|
||||
std::unique_ptr<E> storedError = result->AcquireError();
|
||||
EXPECT_EQ(*storedError, expectedError);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename E>
|
||||
void TestSuccess(Result<T, E>* result, T expectedSuccess) {
|
||||
template <typename T, typename E>
|
||||
void TestSuccess(Result<T, E>* result, T expectedSuccess) {
|
||||
EXPECT_FALSE(result->IsError());
|
||||
EXPECT_TRUE(result->IsSuccess());
|
||||
|
||||
|
@ -40,23 +40,23 @@ void TestSuccess(Result<T, E>* result, T expectedSuccess) {
|
|||
// payload and is neither in the success nor error state.
|
||||
EXPECT_FALSE(result->IsError());
|
||||
EXPECT_FALSE(result->IsSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
static int dummyError = 0xbeef;
|
||||
static float dummySuccess = 42.0f;
|
||||
static const float dummyConstSuccess = 42.0f;
|
||||
static int dummyError = 0xbeef;
|
||||
static float dummySuccess = 42.0f;
|
||||
static const float dummyConstSuccess = 42.0f;
|
||||
|
||||
class AClass : public RefCounted {
|
||||
class AClass : public RefCounted {
|
||||
public:
|
||||
int a = 0;
|
||||
};
|
||||
};
|
||||
|
||||
// Tests using the following overload of TestSuccess make
|
||||
// local Ref instances to dummySuccessObj. Tests should
|
||||
// ensure any local Ref objects made along the way continue
|
||||
// to point to dummySuccessObj.
|
||||
template <typename T, typename E>
|
||||
void TestSuccess(Result<Ref<T>, E>* result, T* expectedSuccess) {
|
||||
// Tests using the following overload of TestSuccess make
|
||||
// local Ref instances to dummySuccessObj. Tests should
|
||||
// ensure any local Ref objects made along the way continue
|
||||
// to point to dummySuccessObj.
|
||||
template <typename T, typename E>
|
||||
void TestSuccess(Result<Ref<T>, E>* result, T* expectedSuccess) {
|
||||
EXPECT_FALSE(result->IsError());
|
||||
EXPECT_TRUE(result->IsSuccess());
|
||||
|
||||
|
@ -77,103 +77,105 @@ void TestSuccess(Result<Ref<T>, E>* result, T* expectedSuccess) {
|
|||
// the object. storedSuccess should contain the only other
|
||||
// reference to the object.
|
||||
EXPECT_EQ(storedSuccess->GetRefCountForTesting(), 2u);
|
||||
}
|
||||
}
|
||||
|
||||
// Result<void, E*>
|
||||
// Result<void, E*>
|
||||
|
||||
// Test constructing an error Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ConstructingError) {
|
||||
// Test constructing an error Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ConstructingError) {
|
||||
Result<void, int> result(std::make_unique<int>(dummyError));
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving an error Result<void, E>
|
||||
TEST(ResultOnlyPointerError, MovingError) {
|
||||
// Test moving an error Result<void, E>
|
||||
TEST(ResultOnlyPointerError, MovingError) {
|
||||
Result<void, int> result(std::make_unique<int>(dummyError));
|
||||
Result<void, int> movedResult(std::move(result));
|
||||
TestError(&movedResult, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning an error Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ReturningError) {
|
||||
auto CreateError = []() -> Result<void, int> { return {std::make_unique<int>(dummyError)}; };
|
||||
// Test returning an error Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ReturningError) {
|
||||
auto CreateError = []() -> Result<void, int> {
|
||||
return {std::make_unique<int>(dummyError)};
|
||||
};
|
||||
|
||||
Result<void, int> result = CreateError();
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test constructing a success Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ConstructingSuccess) {
|
||||
// Test constructing a success Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ConstructingSuccess) {
|
||||
Result<void, int> result;
|
||||
EXPECT_TRUE(result.IsSuccess());
|
||||
EXPECT_FALSE(result.IsError());
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving a success Result<void, E>
|
||||
TEST(ResultOnlyPointerError, MovingSuccess) {
|
||||
// Test moving a success Result<void, E>
|
||||
TEST(ResultOnlyPointerError, MovingSuccess) {
|
||||
Result<void, int> result;
|
||||
Result<void, int> movedResult(std::move(result));
|
||||
EXPECT_TRUE(movedResult.IsSuccess());
|
||||
EXPECT_FALSE(movedResult.IsError());
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning a success Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ReturningSuccess) {
|
||||
// Test returning a success Result<void, E>
|
||||
TEST(ResultOnlyPointerError, ReturningSuccess) {
|
||||
auto CreateError = []() -> Result<void, int> { return {}; };
|
||||
|
||||
Result<void, int> result = CreateError();
|
||||
EXPECT_TRUE(result.IsSuccess());
|
||||
EXPECT_FALSE(result.IsError());
|
||||
}
|
||||
}
|
||||
|
||||
// Result<T*, E*>
|
||||
// Result<T*, E*>
|
||||
|
||||
// Test constructing an error Result<T*, E>
|
||||
TEST(ResultBothPointer, ConstructingError) {
|
||||
// Test constructing an error Result<T*, E>
|
||||
TEST(ResultBothPointer, ConstructingError) {
|
||||
Result<float*, int> result(std::make_unique<int>(dummyError));
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving an error Result<T*, E>
|
||||
TEST(ResultBothPointer, MovingError) {
|
||||
// Test moving an error Result<T*, E>
|
||||
TEST(ResultBothPointer, MovingError) {
|
||||
Result<float*, int> result(std::make_unique<int>(dummyError));
|
||||
Result<float*, int> movedResult(std::move(result));
|
||||
TestError(&movedResult, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning an error Result<T*, E>
|
||||
TEST(ResultBothPointer, ReturningError) {
|
||||
auto CreateError = []() -> Result<float*, int> { return {std::make_unique<int>(dummyError)}; };
|
||||
// Test returning an error Result<T*, E>
|
||||
TEST(ResultBothPointer, ReturningError) {
|
||||
auto CreateError = []() -> Result<float*, int> {
|
||||
return {std::make_unique<int>(dummyError)};
|
||||
};
|
||||
|
||||
Result<float*, int> result = CreateError();
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test constructing a success Result<T*, E>
|
||||
TEST(ResultBothPointer, ConstructingSuccess) {
|
||||
// Test constructing a success Result<T*, E>
|
||||
TEST(ResultBothPointer, ConstructingSuccess) {
|
||||
Result<float*, int> result(&dummySuccess);
|
||||
TestSuccess(&result, &dummySuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving a success Result<T*, E>
|
||||
TEST(ResultBothPointer, MovingSuccess) {
|
||||
// Test moving a success Result<T*, E>
|
||||
TEST(ResultBothPointer, MovingSuccess) {
|
||||
Result<float*, int> result(&dummySuccess);
|
||||
Result<float*, int> movedResult(std::move(result));
|
||||
TestSuccess(&movedResult, &dummySuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning a success Result<T*, E>
|
||||
TEST(ResultBothPointer, ReturningSuccess) {
|
||||
auto CreateSuccess = []() -> Result<float*, int*> {
|
||||
return {&dummySuccess};
|
||||
};
|
||||
// Test returning a success Result<T*, E>
|
||||
TEST(ResultBothPointer, ReturningSuccess) {
|
||||
auto CreateSuccess = []() -> Result<float*, int*> { return {&dummySuccess}; };
|
||||
|
||||
Result<float*, int*> result = CreateSuccess();
|
||||
TestSuccess(&result, &dummySuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Tests converting from a Result<TChild*, E>
|
||||
TEST(ResultBothPointer, ConversionFromChildClass) {
|
||||
// Tests converting from a Result<TChild*, E>
|
||||
TEST(ResultBothPointer, ConversionFromChildClass) {
|
||||
struct T {
|
||||
int a;
|
||||
};
|
||||
|
@ -195,187 +197,189 @@ TEST(ResultBothPointer, ConversionFromChildClass) {
|
|||
Result<T*, int> result = std::move(resultChild);
|
||||
TestSuccess(&result, childAsT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Result<const T*, E>
|
||||
// Result<const T*, E>
|
||||
|
||||
// Test constructing an error Result<const T*, E>
|
||||
TEST(ResultBothPointerWithConstResult, ConstructingError) {
|
||||
// Test constructing an error Result<const T*, E>
|
||||
TEST(ResultBothPointerWithConstResult, ConstructingError) {
|
||||
Result<const float*, int> result(std::make_unique<int>(dummyError));
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving an error Result<const T*, E>
|
||||
TEST(ResultBothPointerWithConstResult, MovingError) {
|
||||
// Test moving an error Result<const T*, E>
|
||||
TEST(ResultBothPointerWithConstResult, MovingError) {
|
||||
Result<const float*, int> result(std::make_unique<int>(dummyError));
|
||||
Result<const float*, int> movedResult(std::move(result));
|
||||
TestError(&movedResult, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning an error Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, ReturningError) {
|
||||
// Test returning an error Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, ReturningError) {
|
||||
auto CreateError = []() -> Result<const float*, int> {
|
||||
return {std::make_unique<int>(dummyError)};
|
||||
};
|
||||
|
||||
Result<const float*, int> result = CreateError();
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test constructing a success Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, ConstructingSuccess) {
|
||||
// Test constructing a success Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, ConstructingSuccess) {
|
||||
Result<const float*, int> result(&dummyConstSuccess);
|
||||
TestSuccess(&result, &dummyConstSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving a success Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, MovingSuccess) {
|
||||
// Test moving a success Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, MovingSuccess) {
|
||||
Result<const float*, int> result(&dummyConstSuccess);
|
||||
Result<const float*, int> movedResult(std::move(result));
|
||||
TestSuccess(&movedResult, &dummyConstSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning a success Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, ReturningSuccess) {
|
||||
// Test returning a success Result<const T*, E*>
|
||||
TEST(ResultBothPointerWithConstResult, ReturningSuccess) {
|
||||
auto CreateSuccess = []() -> Result<const float*, int> { return {&dummyConstSuccess}; };
|
||||
|
||||
Result<const float*, int> result = CreateSuccess();
|
||||
TestSuccess(&result, &dummyConstSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
// Result<Ref<T>, E>
|
||||
// Result<Ref<T>, E>
|
||||
|
||||
// Test constructing an error Result<Ref<T>, E>
|
||||
TEST(ResultRefT, ConstructingError) {
|
||||
// Test constructing an error Result<Ref<T>, E>
|
||||
TEST(ResultRefT, ConstructingError) {
|
||||
Result<Ref<AClass>, int> result(std::make_unique<int>(dummyError));
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving an error Result<Ref<T>, E>
|
||||
TEST(ResultRefT, MovingError) {
|
||||
// Test moving an error Result<Ref<T>, E>
|
||||
TEST(ResultRefT, MovingError) {
|
||||
Result<Ref<AClass>, int> result(std::make_unique<int>(dummyError));
|
||||
Result<Ref<AClass>, int> movedResult(std::move(result));
|
||||
TestError(&movedResult, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning an error Result<Ref<T>, E>
|
||||
TEST(ResultRefT, ReturningError) {
|
||||
// Test returning an error Result<Ref<T>, E>
|
||||
TEST(ResultRefT, ReturningError) {
|
||||
auto CreateError = []() -> Result<Ref<AClass>, int> {
|
||||
return {std::make_unique<int>(dummyError)};
|
||||
};
|
||||
|
||||
Result<Ref<AClass>, int> result = CreateError();
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test constructing a success Result<Ref<T>, E>
|
||||
TEST(ResultRefT, ConstructingSuccess) {
|
||||
// Test constructing a success Result<Ref<T>, E>
|
||||
TEST(ResultRefT, ConstructingSuccess) {
|
||||
AClass success;
|
||||
|
||||
Ref<AClass> refObj(&success);
|
||||
Result<Ref<AClass>, int> result(std::move(refObj));
|
||||
TestSuccess(&result, &success);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving a success Result<Ref<T>, E>
|
||||
TEST(ResultRefT, MovingSuccess) {
|
||||
// Test moving a success Result<Ref<T>, E>
|
||||
TEST(ResultRefT, MovingSuccess) {
|
||||
AClass success;
|
||||
|
||||
Ref<AClass> refObj(&success);
|
||||
Result<Ref<AClass>, int> result(std::move(refObj));
|
||||
Result<Ref<AClass>, int> movedResult(std::move(result));
|
||||
TestSuccess(&movedResult, &success);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning a success Result<Ref<T>, E>
|
||||
TEST(ResultRefT, ReturningSuccess) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
class OtherClass {
|
||||
class OtherClass {
|
||||
public:
|
||||
int a = 0;
|
||||
};
|
||||
class Base : public RefCounted {};
|
||||
class Child : public OtherClass, public Base {};
|
||||
};
|
||||
class Base : public RefCounted {};
|
||||
class Child : public OtherClass, public Base {};
|
||||
|
||||
// Test constructing a Result<Ref<TChild>, E>
|
||||
TEST(ResultRefT, ConversionFromChildConstructor) {
|
||||
// Test constructing a Result<Ref<TChild>, E>
|
||||
TEST(ResultRefT, ConversionFromChildConstructor) {
|
||||
Child child;
|
||||
Ref<Child> refChild(&child);
|
||||
|
||||
Result<Ref<Base>, int> result(std::move(refChild));
|
||||
TestSuccess<Base>(&result, &child);
|
||||
}
|
||||
}
|
||||
|
||||
// Test copy constructing Result<Ref<TChild>, E>
|
||||
TEST(ResultRefT, ConversionFromChildCopyConstructor) {
|
||||
// Test copy constructing Result<Ref<TChild>, E>
|
||||
TEST(ResultRefT, ConversionFromChildCopyConstructor) {
|
||||
Child child;
|
||||
Ref<Child> refChild(&child);
|
||||
|
||||
Result<Ref<Child>, int> resultChild(std::move(refChild));
|
||||
Result<Ref<Base>, int> result(std::move(resultChild));
|
||||
TestSuccess<Base>(&result, &child);
|
||||
}
|
||||
}
|
||||
|
||||
// Test assignment operator for Result<Ref<TChild>, E>
|
||||
TEST(ResultRefT, ConversionFromChildAssignmentOperator) {
|
||||
// Test assignment operator for Result<Ref<TChild>, E>
|
||||
TEST(ResultRefT, ConversionFromChildAssignmentOperator) {
|
||||
Child child;
|
||||
Ref<Child> refChild(&child);
|
||||
|
||||
Result<Ref<Child>, int> resultChild(std::move(refChild));
|
||||
Result<Ref<Base>, int> result = std::move(resultChild);
|
||||
TestSuccess<Base>(&result, &child);
|
||||
}
|
||||
}
|
||||
|
||||
// Result<T, E>
|
||||
// Result<T, E>
|
||||
|
||||
// Test constructing an error Result<T, E>
|
||||
TEST(ResultGeneric, ConstructingError) {
|
||||
// Test constructing an error Result<T, E>
|
||||
TEST(ResultGeneric, ConstructingError) {
|
||||
Result<std::vector<float>, int> result(std::make_unique<int>(dummyError));
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving an error Result<T, E>
|
||||
TEST(ResultGeneric, MovingError) {
|
||||
// Test moving an error Result<T, E>
|
||||
TEST(ResultGeneric, MovingError) {
|
||||
Result<std::vector<float>, int> result(std::make_unique<int>(dummyError));
|
||||
Result<std::vector<float>, int> movedResult(std::move(result));
|
||||
TestError(&movedResult, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning an error Result<T, E>
|
||||
TEST(ResultGeneric, ReturningError) {
|
||||
// Test returning an error Result<T, E>
|
||||
TEST(ResultGeneric, ReturningError) {
|
||||
auto CreateError = []() -> Result<std::vector<float>, int> {
|
||||
return {std::make_unique<int>(dummyError)};
|
||||
};
|
||||
|
||||
Result<std::vector<float>, int> result = CreateError();
|
||||
TestError(&result, dummyError);
|
||||
}
|
||||
}
|
||||
|
||||
// Test constructing a success Result<T, E>
|
||||
TEST(ResultGeneric, ConstructingSuccess) {
|
||||
// Test constructing a success Result<T, E>
|
||||
TEST(ResultGeneric, ConstructingSuccess) {
|
||||
Result<std::vector<float>, int> result({1.0f});
|
||||
TestSuccess(&result, {1.0f});
|
||||
}
|
||||
}
|
||||
|
||||
// Test moving a success Result<T, E>
|
||||
TEST(ResultGeneric, MovingSuccess) {
|
||||
// Test moving a success Result<T, E>
|
||||
TEST(ResultGeneric, MovingSuccess) {
|
||||
Result<std::vector<float>, int> result({1.0f});
|
||||
Result<std::vector<float>, int> movedResult(std::move(result));
|
||||
TestSuccess(&movedResult, {1.0f});
|
||||
}
|
||||
}
|
||||
|
||||
// Test returning a success Result<T, E>
|
||||
TEST(ResultGeneric, ReturningSuccess) {
|
||||
// Test returning a success Result<T, E>
|
||||
TEST(ResultGeneric, ReturningSuccess) {
|
||||
auto CreateSuccess = []() -> Result<std::vector<float>, int> { return {{1.0f}}; };
|
||||
|
||||
Result<std::vector<float>, int> result = CreateSuccess();
|
||||
TestSuccess(&result, {1.0f});
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -21,21 +21,19 @@
|
|||
|
||||
// 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;
|
||||
};
|
||||
|
||||
// Instanciate ToBackend for our "backend"
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
auto ToBackend(T&& common) -> decltype(ToBackendBase<MyBackendTraits>(common)) {
|
||||
return ToBackendBase<MyBackendTraits>(common);
|
||||
}
|
||||
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -406,7 +400,7 @@ TEST_F(BindGroupValidationTest, BufferBindingOOB) {
|
|||
utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256}});
|
||||
|
||||
// Success case, touching the end of the buffer works
|
||||
utils::MakeBindGroup(device, layout, {{0, buffer, 3*256, 256}});
|
||||
utils::MakeBindGroup(device, layout, {{0, buffer, 3 * 256, 256}});
|
||||
|
||||
// Error case, zero size is invalid.
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 0}}));
|
||||
|
@ -419,16 +413,17 @@ TEST_F(BindGroupValidationTest, BufferBindingOOB) {
|
|||
utils::MakeBindGroup(device, layout, {{0, buffer, 256, wgpu::kWholeSize}});
|
||||
|
||||
// Error case, offset is OOB
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256*5, 0}}));
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 256 * 5, 0}}));
|
||||
|
||||
// Error case, size is OOB
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256*5}}));
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256 * 5}}));
|
||||
|
||||
// Error case, offset+size is OOB
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
|
||||
namespace {
|
||||
|
||||
class QueueSubmitValidationTest : public ValidationTest {
|
||||
};
|
||||
class QueueSubmitValidationTest : public ValidationTest {};
|
||||
|
||||
// Test submitting with a mapped buffer is disallowed
|
||||
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
||||
// Test submitting with a mapped buffer is disallowed
|
||||
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
||||
// Create a map-write buffer.
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
|
||||
|
@ -60,9 +59,9 @@ TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
|||
// Unmap the buffer, queue submit should succeed
|
||||
buffer.Unmap();
|
||||
queue.Submit(1, &commands);
|
||||
}
|
||||
}
|
||||
|
||||
class QueueWriteBufferValidationTest : public ValidationTest {
|
||||
class QueueWriteBufferValidationTest : public ValidationTest {
|
||||
private:
|
||||
void SetUp() override {
|
||||
ValidationTest::SetUp();
|
||||
|
@ -78,26 +77,26 @@ class QueueWriteBufferValidationTest : public ValidationTest {
|
|||
}
|
||||
|
||||
wgpu::Queue queue;
|
||||
};
|
||||
};
|
||||
|
||||
// Test the success case for WriteBuffer
|
||||
TEST_F(QueueWriteBufferValidationTest, Success) {
|
||||
// Test the success case for WriteBuffer
|
||||
TEST_F(QueueWriteBufferValidationTest, Success) {
|
||||
wgpu::Buffer buf = CreateBuffer(4);
|
||||
|
||||
uint32_t foo = 0x01020304;
|
||||
queue.WriteBuffer(buf, 0, &foo, sizeof(foo));
|
||||
}
|
||||
}
|
||||
|
||||
// Test error case for WriteBuffer out of bounds
|
||||
TEST_F(QueueWriteBufferValidationTest, OutOfBounds) {
|
||||
// Test error case for WriteBuffer out of bounds
|
||||
TEST_F(QueueWriteBufferValidationTest, OutOfBounds) {
|
||||
wgpu::Buffer buf = CreateBuffer(4);
|
||||
|
||||
uint32_t foo[2] = {0, 0};
|
||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, foo, 8));
|
||||
}
|
||||
}
|
||||
|
||||
// Test error case for WriteBuffer out of bounds with an overflow
|
||||
TEST_F(QueueWriteBufferValidationTest, OutOfBoundsOverflow) {
|
||||
// Test error case for WriteBuffer out of bounds with an overflow
|
||||
TEST_F(QueueWriteBufferValidationTest, OutOfBoundsOverflow) {
|
||||
wgpu::Buffer buf = CreateBuffer(1024);
|
||||
|
||||
uint32_t foo[2] = {0, 0};
|
||||
|
@ -107,10 +106,10 @@ TEST_F(QueueWriteBufferValidationTest, OutOfBoundsOverflow) {
|
|||
uint64_t offset = uint64_t(int64_t(0) - int64_t(4));
|
||||
|
||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, offset, foo, 4));
|
||||
}
|
||||
}
|
||||
|
||||
// Test error case for WriteBuffer with the wrong usage
|
||||
TEST_F(QueueWriteBufferValidationTest, WrongUsage) {
|
||||
// Test error case for WriteBuffer with the wrong usage
|
||||
TEST_F(QueueWriteBufferValidationTest, WrongUsage) {
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
descriptor.size = 4;
|
||||
descriptor.usage = wgpu::BufferUsage::Vertex;
|
||||
|
@ -118,35 +117,35 @@ TEST_F(QueueWriteBufferValidationTest, WrongUsage) {
|
|||
|
||||
uint32_t foo = 0;
|
||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &foo, sizeof(foo)));
|
||||
}
|
||||
}
|
||||
|
||||
// Test WriteBuffer with unaligned size
|
||||
TEST_F(QueueWriteBufferValidationTest, UnalignedSize) {
|
||||
// Test WriteBuffer with unaligned size
|
||||
TEST_F(QueueWriteBufferValidationTest, UnalignedSize) {
|
||||
wgpu::Buffer buf = CreateBuffer(4);
|
||||
|
||||
uint16_t value = 123;
|
||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
||||
}
|
||||
}
|
||||
|
||||
// Test WriteBuffer with unaligned offset
|
||||
TEST_F(QueueWriteBufferValidationTest, UnalignedOffset) {
|
||||
// Test WriteBuffer with unaligned offset
|
||||
TEST_F(QueueWriteBufferValidationTest, UnalignedOffset) {
|
||||
wgpu::Buffer buf = CreateBuffer(8);
|
||||
|
||||
uint32_t value = 0x01020304;
|
||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 2, &value, sizeof(value)));
|
||||
}
|
||||
}
|
||||
|
||||
// Test WriteBuffer with destroyed buffer
|
||||
TEST_F(QueueWriteBufferValidationTest, DestroyedBuffer) {
|
||||
// Test WriteBuffer with destroyed buffer
|
||||
TEST_F(QueueWriteBufferValidationTest, DestroyedBuffer) {
|
||||
wgpu::Buffer buf = CreateBuffer(4);
|
||||
buf.Destroy();
|
||||
|
||||
uint32_t value = 0;
|
||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
||||
}
|
||||
}
|
||||
|
||||
// Test WriteBuffer with mapped buffer
|
||||
TEST_F(QueueWriteBufferValidationTest, MappedBuffer) {
|
||||
// Test WriteBuffer with mapped buffer
|
||||
TEST_F(QueueWriteBufferValidationTest, MappedBuffer) {
|
||||
// CreateBufferMapped
|
||||
{
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
|
@ -193,6 +192,6 @@ TEST_F(QueueWriteBufferValidationTest, MappedBuffer) {
|
|||
uint32_t value = 0;
|
||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
namespace {
|
||||
|
||||
class RenderPassDescriptorValidationTest : public ValidationTest {
|
||||
class RenderPassDescriptorValidationTest : public ValidationTest {
|
||||
public:
|
||||
void AssertBeginRenderPassSuccess(const wgpu::RenderPassDescriptor* descriptor) {
|
||||
wgpu::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor);
|
||||
|
@ -40,9 +40,9 @@ class RenderPassDescriptorValidationTest : public ValidationTest {
|
|||
renderPassEncoder.EndPass();
|
||||
return commandEncoder;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
wgpu::Texture CreateTexture(wgpu::Device& device,
|
||||
wgpu::Texture CreateTexture(wgpu::Device& device,
|
||||
wgpu::TextureDimension dimension,
|
||||
wgpu::TextureFormat format,
|
||||
uint32_t width,
|
||||
|
@ -62,28 +62,29 @@ wgpu::Texture CreateTexture(wgpu::Device& device,
|
|||
descriptor.usage = usage;
|
||||
|
||||
return device.CreateTexture(&descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
wgpu::TextureView Create2DAttachment(wgpu::Device& device,
|
||||
wgpu::TextureView Create2DAttachment(wgpu::Device& device,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
wgpu::TextureFormat format) {
|
||||
wgpu::Texture texture =
|
||||
CreateTexture(device, wgpu::TextureDimension::e2D, format, width, height, 1, 1);
|
||||
return texture.CreateView();
|
||||
}
|
||||
}
|
||||
|
||||
// Using BeginRenderPass with no attachments isn't valid
|
||||
TEST_F(RenderPassDescriptorValidationTest, Empty) {
|
||||
// Using BeginRenderPass with no attachments isn't valid
|
||||
TEST_F(RenderPassDescriptorValidationTest, Empty) {
|
||||
utils::ComboRenderPassDescriptor renderPass({}, nullptr);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// A render pass with only one color or one depth attachment is ok
|
||||
TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
||||
// A render pass with only one color or one depth attachment is ok
|
||||
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);
|
||||
|
@ -96,14 +97,18 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
|||
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
// For setting the color attachment, control case
|
||||
{
|
||||
utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3});
|
||||
|
@ -139,13 +144,16 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
|
|||
renderPass.depthStencilAttachment = nullptr;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
// 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 depthStencil1x1 =
|
||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
|
||||
|
@ -169,10 +177,10 @@ TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
|
|||
utils::ComboRenderPassDescriptor renderPass({color1x1A, color1x1B}, depthStencil2x2);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attachments formats must match whether they are used for color or depth-stencil
|
||||
TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
||||
// Attachments formats must match whether they are used for color or depth-stencil
|
||||
TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
||||
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
||||
wgpu::TextureView depthStencil =
|
||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
|
||||
|
@ -188,18 +196,20 @@ TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
|||
utils::ComboRenderPassDescriptor renderPass({}, color);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Depth and stencil storeOps must match
|
||||
TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
|
||||
// Depth and stencil storeOps must match
|
||||
TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
|
||||
constexpr uint32_t kArrayLayers = 1;
|
||||
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);
|
||||
|
@ -236,20 +246,22 @@ TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
|
|||
renderPass.cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Clear;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Currently only texture views with arrayLayerCount == 1 are allowed to be color and depth stencil
|
||||
// attachments
|
||||
TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepthStencil) {
|
||||
// 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);
|
||||
|
@ -330,19 +342,21 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
|||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only 2D texture views with mipLevelCount == 1 are allowed to be color attachments
|
||||
TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepthStencil) {
|
||||
// Only 2D texture views with mipLevelCount == 1 are allowed to be color attachments
|
||||
TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepthStencil) {
|
||||
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);
|
||||
|
@ -423,10 +437,10 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
|||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// It is not allowed to set resolve target when the color attachment is non-multisampled.
|
||||
TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget) {
|
||||
// It is not allowed to set resolve target when the color attachment is non-multisampled.
|
||||
TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget) {
|
||||
static constexpr uint32_t kArrayLayers = 1;
|
||||
static constexpr uint32_t kLevelCount = 1;
|
||||
static constexpr uint32_t kSize = 32;
|
||||
|
@ -434,20 +448,21 @@ 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();
|
||||
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescriptorValidationTest {
|
||||
class MultisampledRenderPassDescriptorValidationTest
|
||||
: public RenderPassDescriptorValidationTest {
|
||||
public:
|
||||
utils::ComboRenderPassDescriptor CreateMultisampledRenderPass() {
|
||||
return utils::ComboRenderPassDescriptor({CreateMultisampledColorTextureView()});
|
||||
|
@ -475,10 +490,10 @@ class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescript
|
|||
|
||||
return colorTexture.CreateView();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Tests on the use of multisampled textures as color attachments
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachments) {
|
||||
// Tests on the use of multisampled textures as color attachments
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachments) {
|
||||
wgpu::TextureView colorTextureView = CreateNonMultisampledColorTextureView();
|
||||
wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
|
||||
wgpu::TextureView multisampledColorTextureView = CreateMultisampledColorTextureView();
|
||||
|
@ -495,59 +510,64 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachme
|
|||
{multisampledColorTextureView, colorTextureView});
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// It is not allowed to use a multisampled resolve target.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget) {
|
||||
// It is not allowed to use a multisampled resolve target.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget) {
|
||||
wgpu::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView();
|
||||
|
||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||
renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// It is not allowed to use a resolve target with array layer count > 1.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMoreThanOne) {
|
||||
// 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();
|
||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// It is not allowed to use a resolve target with mipmap level count > 1.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelMoreThanOne) {
|
||||
// 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();
|
||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||
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.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) {
|
||||
constexpr wgpu::TextureUsage kUsage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
|
||||
// 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;
|
||||
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;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
// 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::TextureViewDescriptor errorTextureView;
|
||||
errorTextureView.dimension = wgpu::TextureViewDimension::e2D;
|
||||
errorTextureView.format = kColorFormat;
|
||||
|
@ -558,34 +578,37 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState
|
|||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||
renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// It is allowed to use a multisampled color attachment and a non-multisampled resolve target.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithResolveTarget) {
|
||||
// It is allowed to use a multisampled color attachment and a non-multisampled resolve target.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithResolveTarget) {
|
||||
wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
|
||||
|
||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// It is not allowed to use a resolve target in a format different from the color attachment.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFormat) {
|
||||
// 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();
|
||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// Tests on the size of the resolve target.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTargetCompatibility) {
|
||||
// Tests on the size of the resolve target.
|
||||
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,47 +634,49 @@ 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;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tests on the sample count of depth stencil attachment.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSampleCount) {
|
||||
constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||
// Tests on the sample count of depth stencil attachment.
|
||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSampleCount) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -660,11 +686,11 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSam
|
|||
utils::ComboRenderPassDescriptor renderPass({}, multisampledDepthStencilTextureView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// 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);
|
||||
|
||||
// Tests that NaN cannot be used in clearColor.
|
||||
|
@ -734,8 +760,8 @@ TEST_F(RenderPassDescriptorValidationTest, UseNaNOrINFINITYAsColorOrDepthClearVa
|
|||
renderPass.cDepthStencilAttachmentInfo.clearDepth = INFINITY;
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(cwallez@chromium.org): Constraints on attachment aliasing?
|
||||
// TODO(cwallez@chromium.org): Constraints on attachment aliasing?
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
namespace {
|
||||
|
||||
class TextureValidationTest : public ValidationTest {
|
||||
class TextureValidationTest : public ValidationTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
queue = device.GetDefaultQueue();
|
||||
|
@ -49,11 +49,12 @@ 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
|
||||
TEST_F(TextureValidationTest, SampleCount) {
|
||||
// Test the validation of sample count
|
||||
TEST_F(TextureValidationTest, SampleCount) {
|
||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||
|
||||
// sampleCount == 1 is allowed.
|
||||
|
@ -106,10 +107,10 @@ TEST_F(TextureValidationTest, SampleCount) {
|
|||
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test the validation of the mip level count
|
||||
TEST_F(TextureValidationTest, MipLevelCount) {
|
||||
// Test the validation of the mip level count
|
||||
TEST_F(TextureValidationTest, MipLevelCount) {
|
||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||
|
||||
// mipLevelCount == 1 is allowed
|
||||
|
@ -195,9 +196,9 @@ TEST_F(TextureValidationTest, MipLevelCount) {
|
|||
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
// Test the validation of array layer count
|
||||
TEST_F(TextureValidationTest, ArrayLayerCount) {
|
||||
}
|
||||
// Test the validation of array layer count
|
||||
TEST_F(TextureValidationTest, ArrayLayerCount) {
|
||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||
|
||||
// Array layer count exceeding kMaxTexture2DArrayLayers is not allowed
|
||||
|
@ -223,10 +224,10 @@ TEST_F(TextureValidationTest, ArrayLayerCount) {
|
|||
|
||||
device.CreateTexture(&descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test the validation of texture size
|
||||
TEST_F(TextureValidationTest, TextureSize) {
|
||||
// Test the validation of texture size
|
||||
TEST_F(TextureValidationTest, TextureSize) {
|
||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||
|
||||
// Texture size exceeding kMaxTextureSize is not allowed
|
||||
|
@ -255,26 +256,26 @@ TEST_F(TextureValidationTest, TextureSize) {
|
|||
|
||||
device.CreateTexture(&descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test that it is valid to destroy a texture
|
||||
TEST_F(TextureValidationTest, DestroyTexture) {
|
||||
// Test that it is valid to destroy a texture
|
||||
TEST_F(TextureValidationTest, DestroyTexture) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||
texture.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// Test that it's valid to destroy a destroyed texture
|
||||
TEST_F(TextureValidationTest, DestroyDestroyedTexture) {
|
||||
// Test that it's valid to destroy a destroyed texture
|
||||
TEST_F(TextureValidationTest, DestroyDestroyedTexture) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||
texture.Destroy();
|
||||
texture.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// Test that it's invalid to submit a destroyed texture in a queue
|
||||
// in the case of destroy, encode, submit
|
||||
TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
|
||||
// Test that it's invalid to submit a destroyed texture in a queue
|
||||
// in the case of destroy, encode, submit
|
||||
TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||
wgpu::TextureView textureView = texture.CreateView();
|
||||
|
@ -293,11 +294,11 @@ TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
|
|||
|
||||
// Submit should fail due to destroyed texture
|
||||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||
}
|
||||
}
|
||||
|
||||
// Test that it's invalid to submit a destroyed texture in a queue
|
||||
// in the case of encode, destroy, submit
|
||||
TEST_F(TextureValidationTest, EncodeDestroySubmit) {
|
||||
// Test that it's invalid to submit a destroyed texture in a queue
|
||||
// in the case of encode, destroy, submit
|
||||
TEST_F(TextureValidationTest, EncodeDestroySubmit) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||
wgpu::TextureView textureView = texture.CreateView();
|
||||
|
@ -316,10 +317,10 @@ TEST_F(TextureValidationTest, EncodeDestroySubmit) {
|
|||
|
||||
// Submit should fail due to destroyed texture
|
||||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||
}
|
||||
}
|
||||
|
||||
// Test it is an error to create an OutputAttachment texture with a non-renderable format.
|
||||
TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
|
||||
// Test it is an error to create an OutputAttachment texture with a non-renderable format.
|
||||
TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
descriptor.size = {1, 1, 1};
|
||||
descriptor.usage = wgpu::TextureUsage::OutputAttachment;
|
||||
|
@ -340,11 +341,11 @@ TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
|
|||
descriptor.format = format;
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test it is an error to create a Storage texture with any format that doesn't support
|
||||
// TextureUsage::Storage texture usages.
|
||||
TEST_F(TextureValidationTest, TextureFormatNotSupportTextureUsageStorage) {
|
||||
// Test it is an error to create a Storage texture with any format that doesn't support
|
||||
// TextureUsage::Storage texture usages.
|
||||
TEST_F(TextureValidationTest, TextureFormatNotSupportTextureUsageStorage) {
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
descriptor.size = {1, 1, 1};
|
||||
descriptor.usage = wgpu::TextureUsage::Storage;
|
||||
|
@ -357,18 +358,18 @@ TEST_F(TextureValidationTest, TextureFormatNotSupportTextureUsageStorage) {
|
|||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test it is an error to create a texture with format "Undefined".
|
||||
TEST_F(TextureValidationTest, TextureFormatUndefined) {
|
||||
// Test it is an error to create a texture with format "Undefined".
|
||||
TEST_F(TextureValidationTest, TextureFormatUndefined) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
descriptor.format = wgpu::TextureFormat::Undefined;
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with
|
||||
// compressed texture formats.
|
||||
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||
// TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with
|
||||
// compressed texture formats.
|
||||
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||
public:
|
||||
CompressedTextureFormatsValidationTests() : TextureValidationTest() {
|
||||
device = CreateDeviceFromAdapter(adapter, {"texture_compression_bc"});
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -391,10 +392,10 @@ class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
|||
wgpu::TextureFormat::BC5RGUnorm, wgpu::TextureFormat::BC5RGSnorm,
|
||||
wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBSfloat,
|
||||
wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb};
|
||||
};
|
||||
};
|
||||
|
||||
// Test the validation of texture size when creating textures in compressed texture formats.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
||||
// Test the validation of texture size when creating textures in compressed texture formats.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
||||
// Test that it is invalid to use a number that is not a multiple of 4 (the compressed block
|
||||
// width and height of all BC formats) as the width or height of textures in BC formats.
|
||||
for (wgpu::TextureFormat format : kBCFormats) {
|
||||
|
@ -427,11 +428,11 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
|||
device.CreateTexture(&descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test the creation of a texture with BC format will fail when the extension textureCompressionBC
|
||||
// is not enabled.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtension) {
|
||||
// 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);
|
||||
for (wgpu::TextureFormat format : kBCFormats) {
|
||||
|
@ -439,10 +440,10 @@ TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtens
|
|||
descriptor.format = format;
|
||||
ASSERT_DEVICE_ERROR(deviceWithoutExtension.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test the validation of texture usages when creating textures in compressed texture formats.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
||||
// Test the validation of texture usages when creating textures in compressed texture formats.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
||||
// Test that only CopySrc, CopyDst and Sampled are accepted as the texture usage of the
|
||||
// textures in BC formats.
|
||||
for (wgpu::TextureFormat format : kBCFormats) {
|
||||
|
@ -467,21 +468,22 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
|||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 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.
|
||||
for (wgpu::TextureFormat format : kBCFormats) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
descriptor.format = format;
|
||||
descriptor.sampleCount = 4;
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test the validation of creating 2D array textures in compressed texture formats.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {
|
||||
// Test the validation of creating 2D array textures in compressed texture formats.
|
||||
TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {
|
||||
// Test that it is allowed to create a 2D array texture in BC formats.
|
||||
for (wgpu::TextureFormat format : kBCFormats) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
|
@ -489,6 +491,6 @@ TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {
|
|||
descriptor.size.depth = 6;
|
||||
device.CreateTexture(&descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -16,16 +16,15 @@
|
|||
|
||||
namespace {
|
||||
|
||||
class TextureViewValidationTest : public ValidationTest {
|
||||
};
|
||||
class TextureViewValidationTest : public ValidationTest {};
|
||||
|
||||
constexpr uint32_t kWidth = 32u;
|
||||
constexpr uint32_t kHeight = 32u;
|
||||
constexpr uint32_t kDefaultMipLevels = 6u;
|
||||
constexpr uint32_t kWidth = 32u;
|
||||
constexpr uint32_t kHeight = 32u;
|
||||
constexpr uint32_t kDefaultMipLevels = 6u;
|
||||
|
||||
constexpr wgpu::TextureFormat kDefaultTextureFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||
constexpr wgpu::TextureFormat kDefaultTextureFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||
|
||||
wgpu::Texture Create2DArrayTexture(wgpu::Device& device,
|
||||
wgpu::Texture Create2DArrayTexture(wgpu::Device& device,
|
||||
uint32_t arrayLayerCount,
|
||||
uint32_t width = kWidth,
|
||||
uint32_t height = kHeight,
|
||||
|
@ -41,9 +40,9 @@ wgpu::Texture Create2DArrayTexture(wgpu::Device& device,
|
|||
descriptor.mipLevelCount = mipLevelCount;
|
||||
descriptor.usage = wgpu::TextureUsage::Sampled;
|
||||
return device.CreateTexture(&descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) {
|
||||
wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) {
|
||||
wgpu::TextureViewDescriptor descriptor;
|
||||
descriptor.format = kDefaultTextureFormat;
|
||||
descriptor.dimension = dimension;
|
||||
|
@ -52,10 +51,10 @@ wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimensi
|
|||
descriptor.baseArrayLayer = 0;
|
||||
descriptor.arrayLayerCount = 1;
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
// Test creating texture view on a 2D non-array texture
|
||||
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
|
||||
// Test creating texture view on a 2D non-array texture
|
||||
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
|
||||
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
||||
|
||||
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
||||
|
@ -114,10 +113,10 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
|
|||
descriptor.mipLevelCount = 1;
|
||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test creating texture view on a 2D array texture
|
||||
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
|
||||
// Test creating texture view on a 2D array texture
|
||||
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
|
||||
constexpr uint32_t kDefaultArrayLayers = 6;
|
||||
|
||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||
|
@ -171,12 +170,12 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
|
|||
descriptor.arrayLayerCount = 1;
|
||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Using the "none" ("default") values validates the same as explicitly
|
||||
// specifying the values they're supposed to default to.
|
||||
// Variant for a texture with more than 1 array layer.
|
||||
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
|
||||
// Using the "none" ("default") values validates the same as explicitly
|
||||
// specifying the values they're supposed to default to.
|
||||
// Variant for a texture with more than 1 array layer.
|
||||
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
|
||||
constexpr uint32_t kDefaultArrayLayers = 6;
|
||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||
|
||||
|
@ -212,12 +211,12 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
|
|||
descriptor.mipLevelCount = kDefaultMipLevels;
|
||||
texture.CreateView(&descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Using the "none" ("default") values validates the same as explicitly
|
||||
// specifying the values they're supposed to default to.
|
||||
// Variant for a texture with only 1 array layer.
|
||||
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
|
||||
// Using the "none" ("default") values validates the same as explicitly
|
||||
// specifying the values they're supposed to default to.
|
||||
// Variant for a texture with only 1 array layer.
|
||||
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
|
||||
constexpr uint32_t kDefaultArrayLayers = 1;
|
||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||
|
||||
|
@ -256,10 +255,10 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
|
|||
descriptor.arrayLayerCount = kDefaultArrayLayers;
|
||||
texture.CreateView(&descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test creating cube map texture view
|
||||
TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
||||
// Test creating cube map texture view
|
||||
TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
||||
constexpr uint32_t kDefaultArrayLayers = 16;
|
||||
|
||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||
|
@ -318,11 +317,11 @@ TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
|||
descriptor.arrayLayerCount = 12;
|
||||
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateView(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test the format compatibility rules when creating a texture view.
|
||||
// TODO(jiawei.shao@intel.com): add more tests when the rules are fully implemented.
|
||||
TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
|
||||
// Test the format compatibility rules when creating a texture view.
|
||||
// TODO(jiawei.shao@intel.com): add more tests when the rules are fully implemented.
|
||||
TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
|
||||
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
||||
|
||||
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
||||
|
@ -334,19 +333,19 @@ TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
|
|||
descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test that it's invalid to create a texture view from a destroyed texture
|
||||
TEST_F(TextureViewValidationTest, DestroyCreateTextureView) {
|
||||
// Test that it's invalid to create a texture view from a destroyed texture
|
||||
TEST_F(TextureViewValidationTest, DestroyCreateTextureView) {
|
||||
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
||||
wgpu::TextureViewDescriptor descriptor =
|
||||
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
|
||||
texture.Destroy();
|
||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
// Test that only TextureAspect::All is supported
|
||||
TEST_F(TextureViewValidationTest, AspectMustBeAll) {
|
||||
// Test that only TextureAspect::All is supported
|
||||
TEST_F(TextureViewValidationTest, AspectMustBeAll) {
|
||||
wgpu::TextureDescriptor descriptor = {};
|
||||
descriptor.size = {1, 1, 1};
|
||||
descriptor.format = wgpu::TextureFormat::Depth32Float;
|
||||
|
@ -359,6 +358,6 @@ TEST_F(TextureViewValidationTest, AspectMustBeAll) {
|
|||
|
||||
viewDescriptor.aspect = wgpu::TextureAspect::DepthOnly;
|
||||
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDescriptor));
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -16,11 +16,10 @@
|
|||
|
||||
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) {
|
||||
// Tests querying the detail of a toggle from dawn_native::InstanceBase works correctly.
|
||||
TEST_F(ToggleValidationTest, QueryToggleInfo) {
|
||||
// Query with a valid toggle name
|
||||
{
|
||||
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
||||
|
@ -37,10 +36,10 @@ TEST_F(ToggleValidationTest, QueryToggleInfo) {
|
|||
const dawn_native::ToggleInfo* toggleInfo = instance->GetToggleInfo(kInvalidToggleName);
|
||||
ASSERT_EQ(nullptr, toggleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tests overriding toggles when creating a device works correctly.
|
||||
TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||
// Tests overriding toggles when creating a device works correctly.
|
||||
TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||
// Create device with a valid name of a toggle
|
||||
{
|
||||
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
||||
|
@ -74,9 +73,9 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
|||
}
|
||||
ASSERT_EQ(InvalidToggleExists, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
||||
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
||||
const char* kValidToggleName = "turn_off_vsync";
|
||||
dawn_native::DeviceDescriptor descriptor;
|
||||
descriptor.forceEnabledToggles.push_back(kValidToggleName);
|
||||
|
@ -90,5 +89,5 @@ TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
|||
}
|
||||
}
|
||||
ASSERT_EQ(validToggleExists, true);
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -27,7 +27,7 @@ ValidationTest::ValidationTest() {
|
|||
|
||||
// Validation tests run against the null backend, find the corresponding adapter
|
||||
bool foundNullAdapter = false;
|
||||
for (auto ¤tAdapter : adapters) {
|
||||
for (auto& currentAdapter : adapters) {
|
||||
wgpu::AdapterProperties adapterProperties;
|
||||
currentAdapter.GetProperties(&adapterProperties);
|
||||
|
||||
|
@ -129,7 +129,7 @@ ValidationTest::DummyRenderPass::DummyRenderPass(const wgpu::Device& device)
|
|||
wgpu::TextureView view = attachment.CreateView();
|
||||
mColorAttachment.attachment = view;
|
||||
mColorAttachment.resolveTarget = nullptr;
|
||||
mColorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mColorAttachment.clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
mColorAttachment.loadOp = wgpu::LoadOp::Clear;
|
||||
mColorAttachment.storeOp = wgpu::StoreOp::Store;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -613,4 +613,3 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
|
|||
|
||||
FlushClient();
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue