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/SystemUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
wgpu::Device device;
|
wgpu::Device device;
|
||||||
|
@ -138,8 +138,7 @@ void init() {
|
||||||
bufferDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
bufferDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
||||||
ubo = device.CreateBuffer(&bufferDesc);
|
ubo = device.CreateBuffer(&bufferDesc);
|
||||||
|
|
||||||
bindGroup =
|
bindGroup = utils::MakeBindGroup(device, bgl, {{0, ubo, 0, sizeof(ShaderData)}});
|
||||||
utils::MakeBindGroup(device, bgl, {{0, ubo, 0, sizeof(ShaderData)}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame() {
|
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 for samples to avoid listing dawn_sample_utils as a dep every time
|
||||||
template("dawn_sample") {
|
template("dawn_sample") {
|
||||||
executable(target_name) {
|
executable(target_name) {
|
||||||
deps = [
|
deps = [ ":dawn_sample_utils" ]
|
||||||
":dawn_sample_utils",
|
|
||||||
]
|
|
||||||
forward_variables_from(invoker, "*", [ "deps" ])
|
forward_variables_from(invoker, "*", [ "deps" ])
|
||||||
|
|
||||||
if (defined(invoker.deps)) {
|
if (defined(invoker.deps)) {
|
||||||
|
@ -61,43 +59,27 @@ template("dawn_sample") {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_sample("CppHelloTriangle") {
|
dawn_sample("CppHelloTriangle") {
|
||||||
sources = [
|
sources = [ "CppHelloTriangle.cpp" ]
|
||||||
"CppHelloTriangle.cpp",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_sample("CHelloTriangle") {
|
dawn_sample("CHelloTriangle") {
|
||||||
sources = [
|
sources = [ "CHelloTriangle.cpp" ]
|
||||||
"CHelloTriangle.cpp",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_sample("ComputeBoids") {
|
dawn_sample("ComputeBoids") {
|
||||||
sources = [
|
sources = [ "ComputeBoids.cpp" ]
|
||||||
"ComputeBoids.cpp",
|
deps = [ "${dawn_root}/third_party/gn/glm" ]
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
"${dawn_root}/third_party/gn/glm",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_sample("Animometer") {
|
dawn_sample("Animometer") {
|
||||||
sources = [
|
sources = [ "Animometer.cpp" ]
|
||||||
"Animometer.cpp",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_sample("CubeReflection") {
|
dawn_sample("CubeReflection") {
|
||||||
sources = [
|
sources = [ "CubeReflection.cpp" ]
|
||||||
"CubeReflection.cpp",
|
deps = [ "${dawn_root}/third_party/gn/glm" ]
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
"${dawn_root}/third_party/gn/glm",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn_sample("ManualSwapChainTest") {
|
dawn_sample("ManualSwapChainTest") {
|
||||||
sources = [
|
sources = [ "ManualSwapChainTest.cpp" ]
|
||||||
"ManualSwapChainTest.cpp",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ void frame() {
|
||||||
{
|
{
|
||||||
colorAttachment.attachment = backbufferView;
|
colorAttachment.attachment = backbufferView;
|
||||||
colorAttachment.resolveTarget = nullptr;
|
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.loadOp = WGPULoadOp_Clear;
|
||||||
colorAttachment.storeOp = WGPUStoreOp_Store;
|
colorAttachment.storeOp = WGPUStoreOp_Store;
|
||||||
renderpassInfo.colorAttachmentCount = 1;
|
renderpassInfo.colorAttachmentCount = 1;
|
||||||
|
|
|
@ -67,7 +67,7 @@ void initBuffers() {
|
||||||
modelBuffer =
|
modelBuffer =
|
||||||
utils::CreateBufferFromData(device, model, sizeof(model), wgpu::BufferUsage::Vertex);
|
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 =
|
updateParams =
|
||||||
utils::CreateBufferFromData(device, ¶ms, sizeof(params), wgpu::BufferUsage::Uniform);
|
utils::CreateBufferFromData(device, ¶ms, sizeof(params), wgpu::BufferUsage::Uniform);
|
||||||
|
|
||||||
|
@ -75,8 +75,7 @@ void initBuffers() {
|
||||||
{
|
{
|
||||||
std::mt19937 generator;
|
std::mt19937 generator;
|
||||||
std::uniform_real_distribution<float> dist(-1.0f, 1.0f);
|
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.pos = glm::vec2(dist(generator), dist(generator));
|
||||||
p.vel = glm::vec2(dist(generator), dist(generator)) * 0.1f;
|
p.vel = glm::vec2(dist(generator), dist(generator)) * 0.1f;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +252,9 @@ void initSim() {
|
||||||
updatePipeline = device.CreateComputePipeline(&csDesc);
|
updatePipeline = device.CreateComputePipeline(&csDesc);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 2; ++i) {
|
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)},
|
{0, updateParams, 0, sizeof(SimParams)},
|
||||||
{1, particleBuffers[i], 0, kNumParticles * sizeof(Particle)},
|
{1, particleBuffers[i], 0, kNumParticles * sizeof(Particle)},
|
||||||
{2, particleBuffers[(i + 1) % 2], 0, kNumParticles * sizeof(Particle)},
|
{2, particleBuffers[(i + 1) % 2], 0, kNumParticles * sizeof(Particle)},
|
||||||
|
|
|
@ -36,15 +36,15 @@ wgpu::BindGroup bindGroup;
|
||||||
|
|
||||||
void initBuffers() {
|
void initBuffers() {
|
||||||
static const uint32_t indexData[3] = {
|
static const uint32_t indexData[3] = {
|
||||||
0, 1, 2,
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
};
|
};
|
||||||
indexBuffer =
|
indexBuffer =
|
||||||
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
|
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
|
||||||
|
|
||||||
static const float vertexData[12] = {
|
static const float vertexData[12] = {
|
||||||
0.0f, 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,
|
||||||
-0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
0.5f, -0.5f, 0.0f, 1.0f,
|
|
||||||
};
|
};
|
||||||
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
||||||
wgpu::BufferUsage::Vertex);
|
wgpu::BufferUsage::Vertex);
|
||||||
|
@ -141,17 +141,19 @@ void init() {
|
||||||
|
|
||||||
wgpu::TextureView view = texture.CreateView();
|
wgpu::TextureView view = texture.CreateView();
|
||||||
|
|
||||||
bindGroup = utils::MakeBindGroup(device, bgl, {
|
bindGroup = utils::MakeBindGroup(device, bgl, {{0, sampler}, {1, view}});
|
||||||
{0, sampler},
|
|
||||||
{1, view}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct {uint32_t a; float b;} s;
|
struct {
|
||||||
|
uint32_t a;
|
||||||
|
float b;
|
||||||
|
} s;
|
||||||
void frame() {
|
void frame() {
|
||||||
s.a = (s.a + 1) % 256;
|
s.a = (s.a + 1) % 256;
|
||||||
s.b += 0.02f;
|
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();
|
wgpu::TextureView backbufferView = swapchain.GetCurrentTextureView();
|
||||||
utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView);
|
utils::ComboRenderPassDescriptor renderPass({backbufferView}, depthStencilView);
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
wgpu::Device device;
|
wgpu::Device device;
|
||||||
|
|
||||||
|
@ -43,67 +43,44 @@ wgpu::RenderPipeline planePipeline;
|
||||||
wgpu::RenderPipeline reflectionPipeline;
|
wgpu::RenderPipeline reflectionPipeline;
|
||||||
|
|
||||||
void initBuffers() {
|
void initBuffers() {
|
||||||
static const uint32_t indexData[6*6] = {
|
static const uint32_t indexData[6 * 6] = {0, 1, 2, 0, 2, 3,
|
||||||
0, 1, 2,
|
|
||||||
0, 2, 3,
|
|
||||||
|
|
||||||
4, 5, 6,
|
4, 5, 6, 4, 6, 7,
|
||||||
4, 6, 7,
|
|
||||||
|
|
||||||
8, 9, 10,
|
8, 9, 10, 8, 10, 11,
|
||||||
8, 10, 11,
|
|
||||||
|
|
||||||
12, 13, 14,
|
12, 13, 14, 12, 14, 15,
|
||||||
12, 14, 15,
|
|
||||||
|
|
||||||
16, 17, 18,
|
16, 17, 18, 16, 18, 19,
|
||||||
16, 18, 19,
|
|
||||||
|
|
||||||
20, 21, 22,
|
20, 21, 22, 20, 22, 23};
|
||||||
20, 22, 23
|
|
||||||
};
|
|
||||||
indexBuffer =
|
indexBuffer =
|
||||||
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
|
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
|
||||||
|
|
||||||
static const float vertexData[6 * 4 * 6] = {
|
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),
|
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
||||||
wgpu::BufferUsage::Vertex);
|
wgpu::BufferUsage::Vertex);
|
||||||
|
|
||||||
static const float planeData[6 * 4] = {
|
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),
|
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData),
|
||||||
wgpu::BufferUsage::Vertex);
|
wgpu::BufferUsage::Vertex);
|
||||||
|
@ -191,15 +168,13 @@ void init() {
|
||||||
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
||||||
wgpu::BufferUsage::Uniform);
|
wgpu::BufferUsage::Uniform);
|
||||||
|
|
||||||
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
bindGroup[0] = utils::MakeBindGroup(
|
||||||
{0, cameraBuffer, 0, sizeof(CameraData)},
|
device, bgl,
|
||||||
{1, transformBuffer[0], 0, sizeof(glm::mat4)}
|
{{0, cameraBuffer, 0, sizeof(CameraData)}, {1, transformBuffer[0], 0, sizeof(glm::mat4)}});
|
||||||
});
|
|
||||||
|
|
||||||
bindGroup[1] = utils::MakeBindGroup(device, bgl, {
|
bindGroup[1] = utils::MakeBindGroup(
|
||||||
{0, cameraBuffer, 0, sizeof(CameraData)},
|
device, bgl,
|
||||||
{1, transformBuffer[1], 0, sizeof(glm::mat4)}
|
{{0, cameraBuffer, 0, sizeof(CameraData)}, {1, transformBuffer[1], 0, sizeof(glm::mat4)}});
|
||||||
});
|
|
||||||
|
|
||||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||||
|
|
||||||
|
@ -250,17 +225,20 @@ void init() {
|
||||||
cameraData.proj = glm::perspective(glm::radians(45.0f), 1.f, 1.0f, 100.0f);
|
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() {
|
void frame() {
|
||||||
s.a = (s.a + 1) % 256;
|
s.a = (s.a + 1) % 256;
|
||||||
s.b += 0.01f;
|
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(
|
cameraData.view = glm::lookAt(glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f,
|
||||||
glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f, 8.f * std::cos(glm::radians(s.b * 360.f))),
|
8.f * std::cos(glm::radians(s.b * 360.f))),
|
||||||
glm::vec3(0.0f, 0.0f, 0.0f),
|
glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
glm::vec3(0.0f, 1.0f, 0.0f)
|
|
||||||
);
|
|
||||||
|
|
||||||
queue.WriteBuffer(cameraBuffer, 0, &cameraData, sizeof(CameraData));
|
queue.WriteBuffer(cameraBuffer, 0, &cameraData, sizeof(CameraData));
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,8 @@ void DoRender(WindowData* data) {
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor desc({view});
|
utils::ComboRenderPassDescriptor desc({view});
|
||||||
desc.cColorAttachments[0].loadOp = wgpu::LoadOp::Clear;
|
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);
|
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&desc);
|
||||||
pass.EndPass();
|
pass.EndPass();
|
||||||
|
|
|
@ -60,7 +60,7 @@ void PrintGLFWError(int code, const char* message) {
|
||||||
enum class CmdBufType {
|
enum class CmdBufType {
|
||||||
None,
|
None,
|
||||||
Terrible,
|
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
|
// 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)
|
#elif defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
static wgpu::BackendType backendType = wgpu::BackendType::OpenGL;
|
static wgpu::BackendType backendType = wgpu::BackendType::OpenGL;
|
||||||
#else
|
#else
|
||||||
#error
|
# error
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static CmdBufType cmdBufType = CmdBufType::Terrible;
|
static CmdBufType cmdBufType = CmdBufType::Terrible;
|
||||||
|
@ -136,8 +136,7 @@ wgpu::Device CreateCppDawnDevice() {
|
||||||
cDevice = backendDevice;
|
cDevice = backendDevice;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CmdBufType::Terrible:
|
case CmdBufType::Terrible: {
|
||||||
{
|
|
||||||
c2sBuf = new utils::TerribleCommandBuffer();
|
c2sBuf = new utils::TerribleCommandBuffer();
|
||||||
s2cBuf = new utils::TerribleCommandBuffer();
|
s2cBuf = new utils::TerribleCommandBuffer();
|
||||||
|
|
||||||
|
@ -159,8 +158,7 @@ wgpu::Device CreateCppDawnDevice() {
|
||||||
|
|
||||||
procs = clientProcs;
|
procs = clientProcs;
|
||||||
cDevice = clientDevice;
|
cDevice = clientDevice;
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnProcSetProcs(&procs);
|
dawnProcSetProcs(&procs);
|
||||||
|
@ -221,7 +219,8 @@ bool InitSample(int argc, const char** argv) {
|
||||||
backendType = wgpu::BackendType::Vulkan;
|
backendType = wgpu::BackendType::Vulkan;
|
||||||
continue;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (std::string("-c") == argv[i] || std::string("--command-buffer") == argv[i]) {
|
if (std::string("-c") == argv[i] || std::string("--command-buffer") == argv[i]) {
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class BasicTests : public DawnTest {
|
class BasicTests : public DawnTest {};
|
||||||
};
|
|
||||||
|
|
||||||
// Test adapter filter by vendor id.
|
// Test adapter filter by vendor id.
|
||||||
TEST_P(BasicTests, VendorIdFilter) {
|
TEST_P(BasicTests, VendorIdFilter) {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
constexpr static uint32_t kRTSize = 8;
|
constexpr static uint32_t kRTSize = 8;
|
||||||
|
|
||||||
class BindGroupTests : public DawnTest {
|
class BindGroupTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
wgpu::CommandBuffer CreateSimpleComputeCommandBuffer(const wgpu::ComputePipeline& pipeline,
|
wgpu::CommandBuffer CreateSimpleComputeCommandBuffer(const wgpu::ComputePipeline& pipeline,
|
||||||
const wgpu::BindGroup& bindGroup) {
|
const wgpu::BindGroup& bindGroup) {
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
@ -65,15 +65,15 @@ protected:
|
||||||
for (size_t i = 0; i < bindingTypes.size(); ++i) {
|
for (size_t i = 0; i < bindingTypes.size(); ++i) {
|
||||||
switch (bindingTypes[i]) {
|
switch (bindingTypes[i]) {
|
||||||
case wgpu::BindingType::UniformBuffer:
|
case wgpu::BindingType::UniformBuffer:
|
||||||
fs << "layout (std140, set = " << i << ", binding = 0) uniform UniformBuffer" << i
|
fs << "layout (std140, set = " << i << ", binding = 0) uniform UniformBuffer"
|
||||||
<< R"( {
|
<< i << R"( {
|
||||||
vec4 color;
|
vec4 color;
|
||||||
} buffer)"
|
} buffer)"
|
||||||
<< i << ";\n";
|
<< i << ";\n";
|
||||||
break;
|
break;
|
||||||
case wgpu::BindingType::StorageBuffer:
|
case wgpu::BindingType::StorageBuffer:
|
||||||
fs << "layout (std430, set = " << i << ", binding = 0) buffer StorageBuffer" << i
|
fs << "layout (std430, set = " << i << ", binding = 0) buffer StorageBuffer"
|
||||||
<< R"( {
|
<< i << R"( {
|
||||||
vec4 color;
|
vec4 color;
|
||||||
} buffer)"
|
} buffer)"
|
||||||
<< i << ";\n";
|
<< i << ";\n";
|
||||||
|
@ -195,10 +195,10 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
||||||
};
|
};
|
||||||
ASSERT(offsetof(Data, color) == 256);
|
ASSERT(offsetof(Data, color) == 256);
|
||||||
constexpr float dummy = 0.0f;
|
constexpr float dummy = 0.0f;
|
||||||
Data data {
|
Data data{
|
||||||
{ 1.f, 0.f, dummy, dummy, 0.f, 1.0f, dummy, dummy },
|
{1.f, 0.f, dummy, dummy, 0.f, 1.0f, dummy, dummy},
|
||||||
{ 0 },
|
{0},
|
||||||
{ 0.f, 1.f, 0.f, 1.f },
|
{0.f, 1.f, 0.f, 1.f},
|
||||||
};
|
};
|
||||||
wgpu::Buffer buffer =
|
wgpu::Buffer buffer =
|
||||||
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Uniform);
|
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);
|
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.
|
// Test a bindgroup containing a UBO in the vertex shader and a sampler and texture in the fragment
|
||||||
// In D3D12 for example, these different types of bindings end up in different namespaces, but the register
|
// shader. In D3D12 for example, these different types of bindings end up in different namespaces,
|
||||||
// offsets used must match between the shader module and descriptor range.
|
// but the register offsets used must match between the shader module and descriptor range.
|
||||||
TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
||||||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
||||||
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
|
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
|
||||||
|
|
||||||
constexpr float dummy = 0.0f;
|
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::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform),
|
||||||
wgpu::BufferUsage::Uniform);
|
wgpu::BufferUsage::Uniform);
|
||||||
|
|
||||||
|
@ -1091,4 +1091,8 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
|
||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 0, 0);
|
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);
|
UnmapBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(BufferMapReadTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|
DAWN_INSTANTIATE_TEST(BufferMapReadTests,
|
||||||
|
D3D12Backend(),
|
||||||
|
MetalBackend(),
|
||||||
|
OpenGLBackend(),
|
||||||
|
VulkanBackend());
|
||||||
|
|
||||||
class BufferMapWriteTests : public DawnTest {
|
class BufferMapWriteTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
@ -307,7 +311,11 @@ TEST_P(BufferMapWriteTests, GetMappedRangeZeroSized) {
|
||||||
UnmapBuffer(buffer);
|
UnmapBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(BufferMapWriteTests, D3D12Backend(), MetalBackend(), OpenGLBackend(), VulkanBackend());
|
DAWN_INSTANTIATE_TEST(BufferMapWriteTests,
|
||||||
|
D3D12Backend(),
|
||||||
|
MetalBackend(),
|
||||||
|
OpenGLBackend(),
|
||||||
|
VulkanBackend());
|
||||||
|
|
||||||
class CreateBufferMappedTests : public DawnTest {
|
class CreateBufferMappedTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -97,4 +97,8 @@ TEST_P(ClipSpaceTest, ClipSpace) {
|
||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, colorTexture, 0, 0);
|
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();
|
renderTargetViews[i] = renderTargets[i].CreateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass({renderTargetViews[0], renderTargetViews[1],
|
utils::ComboRenderPassDescriptor renderPass(
|
||||||
renderTargetViews[2], renderTargetViews[3]});
|
{renderTargetViews[0], renderTargetViews[1], renderTargetViews[2], renderTargetViews[3]});
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
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);
|
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;
|
uint32_t rowsPerImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<RGBA8> GetExpectedTextureData(
|
static std::vector<RGBA8> GetExpectedTextureData(const utils::BufferTextureCopyLayout& layout) {
|
||||||
const utils::BufferTextureCopyLayout& layout) {
|
|
||||||
std::vector<RGBA8> textureData(layout.texelBlockCount);
|
std::vector<RGBA8> textureData(layout.texelBlockCount);
|
||||||
for (uint32_t layer = 0; layer < layout.mipSize.depth; ++layer) {
|
for (uint32_t layer = 0; layer < layout.mipSize.depth; ++layer) {
|
||||||
const uint32_t texelIndexOffsetPerSlice = layout.texelBlocksPerImage * layer;
|
const uint32_t texelIndexOffsetPerSlice = layout.texelBlocksPerImage * layer;
|
||||||
|
@ -67,7 +66,12 @@ class CopyTests : public DawnTest {
|
||||||
return {totalBufferSize, 0, bytesPerRow, appliedRowsPerImage};
|
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 y = 0; y < height; ++y) {
|
||||||
for (unsigned int x = 0; x < width; ++x) {
|
for (unsigned int x = 0; x < width; ++x) {
|
||||||
unsigned int src = x + y * srcTexelsPerRow;
|
unsigned int src = x + y * srcTexelsPerRow;
|
||||||
|
@ -103,9 +107,8 @@ class CopyTests_T2B : public CopyTests {
|
||||||
// Initialize the source texture
|
// Initialize the source texture
|
||||||
std::vector<RGBA8> textureArrayData = GetExpectedTextureData(copyLayout);
|
std::vector<RGBA8> textureArrayData = GetExpectedTextureData(copyLayout);
|
||||||
{
|
{
|
||||||
wgpu::Buffer uploadBuffer =
|
wgpu::Buffer uploadBuffer = utils::CreateBufferFromData(
|
||||||
utils::CreateBufferFromData(device, textureArrayData.data(),
|
device, textureArrayData.data(), copyLayout.byteLength, wgpu::BufferUsage::CopySrc);
|
||||||
copyLayout.byteLength, wgpu::BufferUsage::CopySrc);
|
|
||||||
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(
|
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(
|
||||||
uploadBuffer, 0, copyLayout.bytesPerRow, bufferSpec.rowsPerImage);
|
uploadBuffer, 0, copyLayout.bytesPerRow, bufferSpec.rowsPerImage);
|
||||||
wgpu::TextureCopyView textureCopyView =
|
wgpu::TextureCopyView textureCopyView =
|
||||||
|
@ -171,14 +174,11 @@ class CopyTests_T2B : public CopyTests {
|
||||||
};
|
};
|
||||||
|
|
||||||
class CopyTests_B2T : public CopyTests {
|
class CopyTests_B2T : public CopyTests {
|
||||||
protected:
|
protected:
|
||||||
static void FillBufferData(RGBA8* data, size_t count) {
|
static void FillBufferData(RGBA8* data, size_t count) {
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
data[i] = RGBA8(
|
data[i] = RGBA8(static_cast<uint8_t>(i % 256), static_cast<uint8_t>((i / 256) % 256),
|
||||||
static_cast<uint8_t>(i % 256),
|
static_cast<uint8_t>((i / 256 / 256) % 256), 255);
|
||||||
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 kWidth = 256;
|
||||||
constexpr uint32_t kHeight = 128;
|
constexpr uint32_t kHeight = 128;
|
||||||
for (unsigned int w : {64, 128, 256}) {
|
for (unsigned int w : {64, 128, 256}) {
|
||||||
for (unsigned int h : { 16, 32, 48 }) {
|
for (unsigned int h : {16, 32, 48}) {
|
||||||
TextureSpec textureSpec;
|
TextureSpec textureSpec;
|
||||||
textureSpec.copyOrigin = {0, 0, 0};
|
textureSpec.copyOrigin = {0, 0, 0};
|
||||||
textureSpec.level = 0;
|
textureSpec.level = 0;
|
||||||
|
@ -531,7 +531,7 @@ TEST_P(CopyTests_T2B, TextureRegionUnaligned) {
|
||||||
defaultTextureSpec.textureSize = {kWidth, kHeight, 1};
|
defaultTextureSpec.textureSize = {kWidth, kHeight, 1};
|
||||||
|
|
||||||
for (unsigned int w : {13, 63, 65}) {
|
for (unsigned int w : {13, 63, 65}) {
|
||||||
for (unsigned int h : { 17, 19, 63 }) {
|
for (unsigned int h : {17, 19, 63}) {
|
||||||
TextureSpec textureSpec = defaultTextureSpec;
|
TextureSpec textureSpec = defaultTextureSpec;
|
||||||
DoTest(textureSpec, MinimumBufferSpec(w, h), {w, h, 1});
|
DoTest(textureSpec, MinimumBufferSpec(w, h), {w, h, 1});
|
||||||
}
|
}
|
||||||
|
@ -746,7 +746,11 @@ TEST_P(CopyTests_T2B, Texture2DArrayRegionNonzeroRowsPerImage) {
|
||||||
DoTest(textureSpec, bufferSpec, {kWidth, kHeight, kCopyLayers});
|
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 that copying an entire texture with 256-byte aligned dimensions works
|
||||||
TEST_P(CopyTests_B2T, FullTextureAligned) {
|
TEST_P(CopyTests_B2T, FullTextureAligned) {
|
||||||
|
@ -877,7 +881,7 @@ TEST_P(CopyTests_B2T, TextureRegionAligned) {
|
||||||
constexpr uint32_t kWidth = 256;
|
constexpr uint32_t kWidth = 256;
|
||||||
constexpr uint32_t kHeight = 128;
|
constexpr uint32_t kHeight = 128;
|
||||||
for (unsigned int w : {64, 128, 256}) {
|
for (unsigned int w : {64, 128, 256}) {
|
||||||
for (unsigned int h : { 16, 32, 48 }) {
|
for (unsigned int h : {16, 32, 48}) {
|
||||||
TextureSpec textureSpec;
|
TextureSpec textureSpec;
|
||||||
textureSpec.copyOrigin = {0, 0, 0};
|
textureSpec.copyOrigin = {0, 0, 0};
|
||||||
textureSpec.level = 0;
|
textureSpec.level = 0;
|
||||||
|
@ -1090,7 +1094,11 @@ TEST_P(CopyTests_B2T, Texture2DArrayRegionNonzeroRowsPerImage) {
|
||||||
DoTest(textureSpec, bufferSpec, {kWidth, kHeight, kCopyLayers});
|
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) {
|
TEST_P(CopyTests_T2T, Texture) {
|
||||||
constexpr uint32_t kWidth = 256;
|
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 kSmallBufferSize = 4;
|
||||||
static constexpr uint64_t kLargeBufferSize = 1 << 16;
|
static constexpr uint64_t kLargeBufferSize = 1 << 16;
|
||||||
|
|
|
@ -127,4 +127,8 @@ TEST_P(CullingTest, CullBackFaceWhenCWIsFrontFace) {
|
||||||
DoTest(wgpu::FrontFace::CW, wgpu::CullMode::Back, true, false);
|
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.
|
// A small fixture used to initialize default data for the D3D12Resource validation tests.
|
||||||
// These tests are skipped if the harness is using the wire.
|
// 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 a successful wrapping of an D3D12Resource in a texture
|
||||||
TEST_P(D3D12SharedHandleValidation, Success) {
|
TEST_P(D3D12SharedHandleValidation, Success) {
|
||||||
|
|
|
@ -42,4 +42,8 @@ TEST_P(DebugMarkerTests, NoFailureWithoutDebugToolAttached) {
|
||||||
queue.Submit(1, &commands);
|
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 {
|
namespace {
|
||||||
|
|
||||||
constexpr wgpu::CompareFunction kCompareFunctions[] = {
|
constexpr wgpu::CompareFunction kCompareFunctions[] = {
|
||||||
wgpu::CompareFunction::Never,
|
wgpu::CompareFunction::Never, wgpu::CompareFunction::Less,
|
||||||
wgpu::CompareFunction::Less,
|
wgpu::CompareFunction::LessEqual, wgpu::CompareFunction::Greater,
|
||||||
wgpu::CompareFunction::LessEqual,
|
wgpu::CompareFunction::GreaterEqual, wgpu::CompareFunction::Equal,
|
||||||
wgpu::CompareFunction::Greater,
|
wgpu::CompareFunction::NotEqual, wgpu::CompareFunction::Always,
|
||||||
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.
|
// 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::SamplerDescriptor samplerDesc;
|
||||||
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
||||||
|
|
||||||
wgpu::BindGroup bindGroup =
|
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
|
||||||
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
|
|
||||||
{
|
{
|
||||||
{0, sampler},
|
{0, sampler},
|
||||||
{1, mInputTexture.CreateView()},
|
{1, mInputTexture.CreateView()},
|
||||||
|
@ -258,12 +253,9 @@ class DepthSamplingTest : public DawnTest {
|
||||||
wgpu::SamplerDescriptor samplerDesc;
|
wgpu::SamplerDescriptor samplerDesc;
|
||||||
wgpu::Sampler sampler = device.CreateSampler(&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},
|
{{0, sampler}, {1, mInputTexture.CreateView()}, {2, mOutputBuffer}});
|
||||||
{1, mInputTexture.CreateView()},
|
|
||||||
{2, mOutputBuffer}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (float textureValue : textureValues) {
|
for (float textureValue : textureValues) {
|
||||||
// Set the input depth texture to the provided texture value
|
// Set the input depth texture to the provided texture value
|
||||||
|
@ -321,8 +313,7 @@ class DepthSamplingTest : public DawnTest {
|
||||||
samplerDesc.compare = compare;
|
samplerDesc.compare = compare;
|
||||||
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
wgpu::Sampler sampler = device.CreateSampler(&samplerDesc);
|
||||||
|
|
||||||
wgpu::BindGroup bindGroup =
|
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
|
||||||
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
|
|
||||||
{
|
{
|
||||||
{0, sampler},
|
{0, sampler},
|
||||||
{1, mInputTexture.CreateView()},
|
{1, mInputTexture.CreateView()},
|
||||||
|
@ -364,12 +355,10 @@ class DepthSamplingTest : public DawnTest {
|
||||||
wgpu::Sampler sampler = device.CreateSampler(&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},
|
||||||
{0, sampler},
|
|
||||||
{1, mInputTexture.CreateView()},
|
{1, mInputTexture.CreateView()},
|
||||||
{2, mUniformBuffer},
|
{2, mUniformBuffer},
|
||||||
{3, mOutputBuffer}
|
{3, mOutputBuffer}});
|
||||||
});
|
|
||||||
|
|
||||||
for (float textureValue : textureValues) {
|
for (float textureValue : textureValues) {
|
||||||
// Set the input depth texture to the provided texture value
|
// 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
|
// 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,
|
void CheckDepthCompareFunction(wgpu::CompareFunction compareFunction,
|
||||||
bool less,
|
bool less,
|
||||||
bool equal,
|
bool equal,
|
||||||
|
@ -121,21 +122,24 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
|
RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
|
||||||
|
|
||||||
// Base triangle at depth 0.5, depth always, depth write enabled
|
// 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
|
// Draw the base triangle, then a triangle in stencilFront of the base triangle with the
|
||||||
// given depth comparison function
|
// 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
|
// Draw the base triangle, then a triangle in at the same depth as the base triangle with
|
||||||
DoTest({ base, { state, equalColor, 0.5f, 0u } }, equal ? equalColor : baseColor);
|
// the given depth comparison function
|
||||||
|
DoTest({base, {state, equalColor, 0.5f, 0u}}, equal ? equalColor : baseColor);
|
||||||
|
|
||||||
// Draw the base triangle, then a triangle behind the base triangle with the given depth comparison function
|
// Draw the base triangle, then a triangle behind the base triangle with the given depth
|
||||||
DoTest({ base, { state, greaterColor, 1.0f, 0u } }, greater ? greaterColor : baseColor);
|
// comparison function
|
||||||
|
DoTest({base, {state, greaterColor, 1.0f, 0u}}, greater ? greaterColor : baseColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether a stencil comparison function works as expected
|
// 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,
|
void CheckStencilCompareFunction(wgpu::CompareFunction compareFunction,
|
||||||
bool less,
|
bool less,
|
||||||
bool equal,
|
bool equal,
|
||||||
|
@ -172,19 +176,23 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
|
RGBA8 greaterColor = RGBA8(0, 0, 255, 255);
|
||||||
|
|
||||||
// Base triangle with stencil reference 1
|
// 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
|
// Draw the base triangle, then a triangle with stencil reference 0 with the given stencil
|
||||||
DoTest({ base, { state, lessColor, 0.f, 0u } }, less ? lessColor : baseColor);
|
// comparison function
|
||||||
|
DoTest({base, {state, lessColor, 0.f, 0u}}, less ? lessColor : baseColor);
|
||||||
|
|
||||||
// Draw the base triangle, then a triangle with stencil reference 1 with the given stencil comparison function
|
// Draw the base triangle, then a triangle with stencil reference 1 with the given stencil
|
||||||
DoTest({ base, { state, equalColor, 0.f, 1u } }, equal ? equalColor : baseColor);
|
// comparison function
|
||||||
|
DoTest({base, {state, equalColor, 0.f, 1u}}, equal ? equalColor : baseColor);
|
||||||
|
|
||||||
// Draw the base triangle, then a triangle with stencil reference 2 with the given stencil comparison function
|
// Draw the base triangle, then a triangle with stencil reference 2 with the given stencil
|
||||||
DoTest({ base, { state, greaterColor, 0.f, 2u } }, greater ? greaterColor : baseColor);
|
// 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,
|
void CheckStencilOperation(wgpu::StencilOperation stencilOperation,
|
||||||
uint32_t initialStencil,
|
uint32_t initialStencil,
|
||||||
uint32_t reference,
|
uint32_t reference,
|
||||||
|
@ -215,13 +223,15 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
state.stencilReadMask = 0xff;
|
state.stencilReadMask = 0xff;
|
||||||
state.stencilWriteMask = 0xff;
|
state.stencilWriteMask = 0xff;
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil(
|
||||||
|
{
|
||||||
// Wipe the stencil buffer with the initialStencil value
|
// 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
|
// Draw a triangle with the provided stencil operation and reference
|
||||||
{ state, RGBA8(255, 0, 0, 255), 0.f, reference },
|
{state, RGBA8(255, 0, 0, 255), 0.f, reference},
|
||||||
}, expectedStencil);
|
},
|
||||||
|
expectedStencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a list of test specs, and check if the stencil value is equal to the expected value
|
// 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.stencilReadMask = 0xff;
|
||||||
state.stencilWriteMask = 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));
|
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
|
// Each test param represents a pair of triangles with a color, depth, stencil value, and
|
||||||
// Draw the triangles in order and check the expected colors for the frontfaces and backfaces
|
// depthStencil state, one frontfacing, one backfacing Draw the triangles in order and check the
|
||||||
void DoTest(const std::vector<TestSpec> &testParams, const RGBA8& expectedFront, const RGBA8& expectedBack) {
|
// 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();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
||||||
struct TriangleData {
|
struct TriangleData {
|
||||||
|
@ -260,12 +273,13 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
const TestSpec& test = testParams[i];
|
const TestSpec& test = testParams[i];
|
||||||
|
|
||||||
TriangleData data = {
|
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,
|
test.depth,
|
||||||
};
|
};
|
||||||
// Upload a buffer for each triangle's depth and color data
|
// Upload a buffer for each triangle's depth and color data
|
||||||
wgpu::Buffer buffer = utils::CreateBufferFromData(
|
wgpu::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData),
|
||||||
device, &data, sizeof(TriangleData), wgpu::BufferUsage::Uniform);
|
wgpu::BufferUsage::Uniform);
|
||||||
|
|
||||||
// Create a pipeline for the triangles with the test spec's depth stencil state
|
// 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.SetPipeline(pipeline);
|
||||||
pass.SetStencilReference(test.stencil); // Set the stencil reference
|
pass.SetStencilReference(test.stencil); // Set the stencil reference
|
||||||
pass.SetBindGroup(
|
pass.SetBindGroup(0,
|
||||||
0, bindGroup); // Set the bind group which contains color and depth data
|
bindGroup); // Set the bind group which contains color and depth data
|
||||||
pass.Draw(6);
|
pass.Draw(6);
|
||||||
}
|
}
|
||||||
pass.EndPass();
|
pass.EndPass();
|
||||||
|
@ -293,11 +307,13 @@ class DepthStencilStateTest : public DawnTest {
|
||||||
wgpu::CommandBuffer commands = encoder.Finish();
|
wgpu::CommandBuffer commands = encoder.Finish();
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
|
|
||||||
EXPECT_PIXEL_RGBA8_EQ(expectedFront, renderTarget, kRTSize / 4, kRTSize / 2) << "Front face check failed";
|
EXPECT_PIXEL_RGBA8_EQ(expectedFront, renderTarget, kRTSize / 4, kRTSize / 2)
|
||||||
EXPECT_PIXEL_RGBA8_EQ(expectedBack, renderTarget, 3 * kRTSize / 4, kRTSize / 2) << "Back face check failed";
|
<< "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);
|
DoTest(testParams, expected, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,9 +341,11 @@ TEST_P(DepthStencilStateTest, Basic) {
|
||||||
state.stencilReadMask = 0xff;
|
state.stencilReadMask = 0xff;
|
||||||
state.stencilWriteMask = 0xff;
|
state.stencilWriteMask = 0xff;
|
||||||
|
|
||||||
DoTest({
|
DoTest(
|
||||||
{ state, RGBA8(0, 255, 0, 255), 0.5f, 0u },
|
{
|
||||||
}, RGBA8(0, 255, 0, 255));
|
{state, RGBA8(0, 255, 0, 255), 0.5f, 0u},
|
||||||
|
},
|
||||||
|
RGBA8(0, 255, 0, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test defaults: depth and stencil tests disabled
|
// Test defaults: depth and stencil tests disabled
|
||||||
|
@ -347,9 +365,9 @@ TEST_P(DepthStencilStateTest, DepthStencilDisabled) {
|
||||||
state.stencilWriteMask = 0xff;
|
state.stencilWriteMask = 0xff;
|
||||||
|
|
||||||
TestSpec specs[3] = {
|
TestSpec specs[3] = {
|
||||||
{ state, RGBA8(255, 0, 0, 255), 0.0f, 0u },
|
{state, RGBA8(255, 0, 0, 255), 0.0f, 0u},
|
||||||
{ state, RGBA8(0, 255, 0, 255), 0.5f, 0u },
|
{state, RGBA8(0, 255, 0, 255), 0.5f, 0u},
|
||||||
{ state, RGBA8(0, 0, 255, 255), 1.0f, 0u },
|
{state, RGBA8(0, 0, 255, 255), 1.0f, 0u},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test that for all combinations, the last triangle drawn is the one visible
|
// 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) {
|
for (uint32_t last = 0; last < 3; ++last) {
|
||||||
uint32_t i = (last + 1) % 3;
|
uint32_t i = (last + 1) % 3;
|
||||||
uint32_t j = (last + 2) % 3;
|
uint32_t j = (last + 2) % 3;
|
||||||
DoTest({ specs[i], specs[j], 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);
|
DoTest({specs[j], specs[i], specs[last]}, specs[last].color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,11 +445,17 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) {
|
||||||
checkState.stencilReadMask = 0xff;
|
checkState.stencilReadMask = 0xff;
|
||||||
checkState.stencilWriteMask = 0xff;
|
checkState.stencilWriteMask = 0xff;
|
||||||
|
|
||||||
DoTest({
|
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
|
{baseState, RGBA8(255, 255, 255, 255), 1.f,
|
||||||
{ checkState, RGBA8(0, 255, 0, 255), 1.f, 0u }, // Draw a third triangle which should occlude the second even though it is behind it
|
0u}, // Draw a base triangle with depth enabled
|
||||||
}, RGBA8(0, 255, 0, 255));
|
{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
|
// 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 red = RGBA8(255, 0, 0, 255);
|
||||||
RGBA8 green = RGBA8(0, 255, 0, 255);
|
RGBA8 green = RGBA8(0, 255, 0, 255);
|
||||||
|
|
||||||
TestSpec base = { baseState, baseColor, 0.5f, 3u }; // Base triangle to set the stencil to 3
|
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, red, 0.f, 1u}}, baseColor); // Triangle with stencil reference 1 and read
|
||||||
DoTest({ base, { state, green, 0.f, 2u } }, green); // Triangle with stencil reference 2 and read mask 2 draws because (3 & 2 == 2)
|
// 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
|
// Check that setting a stencil write mask works
|
||||||
|
@ -572,9 +598,12 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) {
|
||||||
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
RGBA8 baseColor = RGBA8(255, 255, 255, 255);
|
||||||
RGBA8 green = RGBA8(0, 255, 0, 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
|
TestSpec base = {baseState, baseColor, 0.5f,
|
||||||
DoTest({ base, { state, green, 0.f, 2u } }, baseColor); // Triangle with stencil reference 2 does not draw because 2 != (3 & 1)
|
3u}; // Base triangle with stencil reference 3 and mask 1 to set the stencil 1
|
||||||
DoTest({ base, { state, green, 0.f, 1u } }, green); // Triangle with stencil reference 1 draws because 1 == (3 & 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
|
// Test that the stencil operation is executed on stencil fail
|
||||||
|
@ -605,10 +634,13 @@ TEST_P(DepthStencilStateTest, StencilFail) {
|
||||||
state.stencilReadMask = 0xff;
|
state.stencilReadMask = 0xff;
|
||||||
state.stencilWriteMask = 0xff;
|
state.stencilWriteMask = 0xff;
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil(
|
||||||
{ baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1
|
{
|
||||||
{ state, RGBA8(0, 0, 0, 255), 0.f, 2 } // Triangle with stencil reference 2 fails the Less comparison function
|
{baseState, RGBA8(255, 255, 255, 255), 1.f, 1}, // Triangle to set stencil value to 1
|
||||||
}, 2); // Replace the stencil on failure, so it should be 2
|
{state, RGBA8(0, 0, 0, 255), 0.f,
|
||||||
|
2} // Triangle with stencil reference 2 fails the Less comparison function
|
||||||
|
},
|
||||||
|
2); // Replace the stencil on failure, so it should be 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that the stencil operation is executed on stencil pass, depth fail
|
// Test that the stencil operation is executed on stencil pass, depth fail
|
||||||
|
@ -639,9 +671,11 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) {
|
||||||
state.stencilReadMask = 0xff;
|
state.stencilReadMask = 0xff;
|
||||||
state.stencilWriteMask = 0xff;
|
state.stencilWriteMask = 0xff;
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil({{baseState, RGBA8(255, 255, 255, 255), 0.f,
|
||||||
{ baseState, RGBA8(255, 255, 255, 255), 0.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
|
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
|
{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
|
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.stencilReadMask = 0xff;
|
||||||
state.stencilWriteMask = 0xff;
|
state.stencilWriteMask = 0xff;
|
||||||
|
|
||||||
CheckStencil({
|
CheckStencil({{baseState, RGBA8(255, 255, 255, 255), 1.f,
|
||||||
{ baseState, RGBA8(255, 255, 255, 255), 1.f, 1 }, // Triangle to set stencil value to 1. Depth is 0
|
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
|
{state, RGBA8(0, 0, 0, 255), 0.f,
|
||||||
2); // Replace the stencil on stencil pass, depth pass, so it should be 2
|
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
|
// 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));
|
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>(
|
vertexBuffer = utils::CreateBufferFromData<float>(
|
||||||
device, wgpu::BufferUsage::Vertex,
|
device, wgpu::BufferUsage::Vertex,
|
||||||
{// First quad: the first 3 vertices represent the bottom left triangle
|
{// 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, 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,
|
||||||
1.0f, 0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
|
|
||||||
// Second quad: the first 3 vertices represent the top right triangle
|
// 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, 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,
|
||||||
-1.0f, 0.0f, 1.0f});
|
0.0f, 1.0f});
|
||||||
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
indexBuffer = utils::CreateBufferFromData<uint32_t>(
|
||||||
device, wgpu::BufferUsage::Index,
|
device, wgpu::BufferUsage::Index,
|
||||||
{0, 1, 2, 0, 3, 1,
|
{0, 1, 2, 0, 3, 1,
|
||||||
|
@ -103,7 +103,6 @@ class DrawIndexedTest : public DawnTest {
|
||||||
|
|
||||||
// The most basic DrawIndexed triangle draw.
|
// The most basic DrawIndexed triangle draw.
|
||||||
TEST_P(DrawIndexedTest, Uint32) {
|
TEST_P(DrawIndexedTest, Uint32) {
|
||||||
|
|
||||||
RGBA8 filled(0, 255, 0, 255);
|
RGBA8 filled(0, 255, 0, 255);
|
||||||
RGBA8 notFilled(0, 0, 0, 0);
|
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);
|
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);
|
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);
|
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 {
|
class StorageToUniformSyncTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -369,7 +369,8 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
|
||||||
// Test sampling from a R8 IOSurface
|
// Test sampling from a R8 IOSurface
|
||||||
TEST_P(IOSurfaceUsageTests, SampleFromR8IOSurface) {
|
TEST_P(IOSurfaceUsageTests, SampleFromR8IOSurface) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
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;
|
uint8_t data = 0x01;
|
||||||
DoSampleTest(ioSurface.get(), wgpu::TextureFormat::R8Unorm, &data, sizeof(data),
|
DoSampleTest(ioSurface.get(), wgpu::TextureFormat::R8Unorm, &data, sizeof(data),
|
||||||
|
@ -379,7 +380,8 @@ TEST_P(IOSurfaceUsageTests, SampleFromR8IOSurface) {
|
||||||
// Test clearing a R8 IOSurface
|
// Test clearing a R8 IOSurface
|
||||||
TEST_P(IOSurfaceUsageTests, ClearR8IOSurface) {
|
TEST_P(IOSurfaceUsageTests, ClearR8IOSurface) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
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;
|
uint8_t data = 0x01;
|
||||||
DoClearTest(ioSurface.get(), wgpu::TextureFormat::R8Unorm, &data, sizeof(data));
|
DoClearTest(ioSurface.get(), wgpu::TextureFormat::R8Unorm, &data, sizeof(data));
|
||||||
|
@ -388,7 +390,8 @@ TEST_P(IOSurfaceUsageTests, ClearR8IOSurface) {
|
||||||
// Test sampling from a RG8 IOSurface
|
// Test sampling from a RG8 IOSurface
|
||||||
TEST_P(IOSurfaceUsageTests, SampleFromRG8IOSurface) {
|
TEST_P(IOSurfaceUsageTests, SampleFromRG8IOSurface) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
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)
|
uint16_t data = 0x0102; // Stored as (G, R)
|
||||||
DoSampleTest(ioSurface.get(), wgpu::TextureFormat::RG8Unorm, &data, sizeof(data),
|
DoSampleTest(ioSurface.get(), wgpu::TextureFormat::RG8Unorm, &data, sizeof(data),
|
||||||
|
@ -398,7 +401,8 @@ TEST_P(IOSurfaceUsageTests, SampleFromRG8IOSurface) {
|
||||||
// Test clearing a RG8 IOSurface
|
// Test clearing a RG8 IOSurface
|
||||||
TEST_P(IOSurfaceUsageTests, ClearRG8IOSurface) {
|
TEST_P(IOSurfaceUsageTests, ClearRG8IOSurface) {
|
||||||
DAWN_SKIP_TEST_IF(UsesWire());
|
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;
|
uint16_t data = 0x0201;
|
||||||
DoClearTest(ioSurface.get(), wgpu::TextureFormat::RG8Unorm, &data, sizeof(data));
|
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);
|
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;
|
const char* fs = testDepth ? kFsOneOutputWithDepth : kFsOneOutputWithoutDepth;
|
||||||
|
|
||||||
|
|
||||||
return CreateRenderPipelineForTest(fs, 1, testDepth);
|
return CreateRenderPipelineForTest(fs, 1, testDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -400,4 +400,8 @@ TEST_P(ObjectCachingTest, SamplerDeduplication) {
|
||||||
EXPECT_EQ(sampler.Get() == sameSampler.Get(), !UsesWire());
|
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);
|
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/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/WGPUHelpers.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 |
|
// | 1 2 5 |
|
||||||
|
@ -81,8 +82,8 @@
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
//
|
//
|
||||||
// Each of these different states is a superset of some of the previous states,
|
// 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
|
// so for every state, we check any new added test locations that are not contained in previous
|
||||||
// We also check that the test locations of subsequent states are untouched
|
// states We also check that the test locations of subsequent states are untouched
|
||||||
|
|
||||||
constexpr static unsigned int kRTSize = 32;
|
constexpr static unsigned int kRTSize = 32;
|
||||||
|
|
||||||
|
@ -91,11 +92,13 @@ struct TestLocation {
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr TestLocation GetMidpoint(const TestLocation& a, const TestLocation& b) noexcept {
|
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 {
|
constexpr TestLocation GetCentroid(const TestLocation& a,
|
||||||
return { (a.x + b.x + c.x) / 3, (a.y + b.y + c.y) / 3 };
|
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
|
// clang-format off
|
||||||
|
@ -177,10 +180,11 @@ class PrimitiveTopologyTest : public DawnTest {
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
constexpr LocationSpec TestPoints(TestLocation const (&points)[N], bool include) noexcept {
|
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,
|
void DoTest(wgpu::PrimitiveTopology primitiveTopology,
|
||||||
const std::vector<LocationSpec>& locationSpecs) {
|
const std::vector<LocationSpec>& locationSpecs) {
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
|
@ -209,10 +213,13 @@ class PrimitiveTopologyTest : public DawnTest {
|
||||||
|
|
||||||
for (auto& locationSpec : locationSpecs) {
|
for (auto& locationSpec : locationSpecs) {
|
||||||
for (size_t i = 0; i < locationSpec.count; ++i) {
|
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;
|
RGBA8 color = locationSpec.include ? RGBA8::kGreen : RGBA8::kZero;
|
||||||
EXPECT_PIXEL_RGBA8_EQ(color, renderPass.color, locationSpec.locations[i].x, locationSpec.locations[i].y)
|
EXPECT_PIXEL_RGBA8_EQ(color, renderPass.color, locationSpec.locations[i].x,
|
||||||
<< "Expected (" << locationSpec.locations[i].x << ", " << locationSpec.locations[i].y << ") to be " << color;
|
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);
|
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 {
|
class DrawQuad {
|
||||||
public:
|
public:
|
||||||
DrawQuad() {}
|
DrawQuad() {
|
||||||
|
}
|
||||||
DrawQuad(wgpu::Device device, const char* vsSource, const char* fsSource) : device(device) {
|
DrawQuad(wgpu::Device device, const char* vsSource, const char* fsSource) : device(device) {
|
||||||
vsModule =
|
vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vsSource);
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vsSource);
|
fsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fsSource);
|
||||||
fsModule =
|
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fsSource);
|
|
||||||
|
|
||||||
pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
|
pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +143,12 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
|
||||||
// Left half should still be green
|
// Left half should still be green
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(expectGreen.data(), renderTarget, 0, 0, kRTSize / 2, kRTSize, 0, 0);
|
EXPECT_TEXTURE_RGBA8_EQ(expectGreen.data(), renderTarget, 0, 0, kRTSize / 2, kRTSize, 0, 0);
|
||||||
// Right half should now be blue
|
// 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;
|
constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
|
|
||||||
class RenderPassTest : public DawnTest {
|
class RenderPassTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
DawnTest::SetUp();
|
DawnTest::SetUp();
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,10 @@ namespace {
|
||||||
255,
|
255,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
class SamplerTest : public DawnTest {
|
class SamplerTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
DawnTest::SetUp();
|
DawnTest::SetUp();
|
||||||
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
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/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ScissorTest: public DawnTest {
|
class ScissorTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
|
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule =
|
||||||
|
@ -152,4 +152,8 @@ TEST_P(ScissorTest, NoInheritanceBetweenRenderPass) {
|
||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kGreen, renderPass.color, 99, 99);
|
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
|
// TODO(cwallez@chromium.org): Add tests for depth-stencil formats when we know if they are copyable
|
||||||
// in WebGPU.
|
// 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
|
} // anonymous namespace
|
||||||
|
|
||||||
class TextureViewSamplingTest : public DawnTest {
|
class TextureViewSamplingTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
// Generates an arbitrary pixel value per-layer-per-level, used for the "actual" uploaded
|
// Generates an arbitrary pixel value per-layer-per-level, used for the "actual" uploaded
|
||||||
// textures and the "expected" results.
|
// textures and the "expected" results.
|
||||||
static int GenerateTestPixelValue(uint32_t layer, uint32_t level) {
|
static int GenerateTestPixelValue(uint32_t layer, uint32_t level) {
|
||||||
|
@ -104,8 +104,8 @@ protected:
|
||||||
const uint32_t textureHeightLevel0 = 1 << mipLevelCount;
|
const uint32_t textureHeightLevel0 = 1 << mipLevelCount;
|
||||||
constexpr wgpu::TextureUsage kUsage =
|
constexpr wgpu::TextureUsage kUsage =
|
||||||
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
|
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
|
||||||
mTexture = Create2DTexture(
|
mTexture = Create2DTexture(device, textureWidthLevel0, textureHeightLevel0, arrayLayerCount,
|
||||||
device, textureWidthLevel0, textureHeightLevel0, arrayLayerCount, mipLevelCount, kUsage);
|
mipLevelCount, kUsage);
|
||||||
|
|
||||||
mDefaultTextureViewDescriptor.dimension = wgpu::TextureViewDimension::e2DArray;
|
mDefaultTextureViewDescriptor.dimension = wgpu::TextureViewDimension::e2DArray;
|
||||||
mDefaultTextureViewDescriptor.format = kDefaultFormat;
|
mDefaultTextureViewDescriptor.format = kDefaultFormat;
|
||||||
|
@ -145,10 +145,7 @@ protected:
|
||||||
queue.Submit(1, ©);
|
queue.Submit(1, ©);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Verify(const wgpu::TextureView& textureView,
|
void Verify(const wgpu::TextureView& textureView, const char* fragmentShader, int expected) {
|
||||||
const char* fragmentShader,
|
|
||||||
int expected) {
|
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fragmentShader);
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fragmentShader);
|
||||||
|
|
||||||
|
@ -176,8 +173,8 @@ protected:
|
||||||
|
|
||||||
RGBA8 expectedPixel(0, 0, 0, expected);
|
RGBA8 expectedPixel(0, 0, 0, expected);
|
||||||
EXPECT_PIXEL_RGBA8_EQ(expectedPixel, mRenderPass.color, 0, 0);
|
EXPECT_PIXEL_RGBA8_EQ(expectedPixel, mRenderPass.color, 0, 0);
|
||||||
EXPECT_PIXEL_RGBA8_EQ(
|
EXPECT_PIXEL_RGBA8_EQ(expectedPixel, mRenderPass.color, mRenderPass.width - 1,
|
||||||
expectedPixel, mRenderPass.color, mRenderPass.width - 1, mRenderPass.height - 1);
|
mRenderPass.height - 1);
|
||||||
// TODO(jiawei.shao@intel.com): add tests for 3D textures once Dawn supports 3D textures
|
// TODO(jiawei.shao@intel.com): add tests for 3D textures once Dawn supports 3D textures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,13 +276,15 @@ protected:
|
||||||
stream << R"(
|
stream << R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(set = 0, binding = 0) uniform sampler sampler0;
|
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) in vec2 texCoord;
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
void main() {
|
void main() {
|
||||||
float sc = 2.f * texCoord.x - 1.f;
|
float sc = 2.f * texCoord.x - 1.f;
|
||||||
float tc = 2.f * texCoord.y - 1.f;
|
float tc = 2.f * texCoord.y - 1.f;
|
||||||
fragColor = texture()" << samplerType << "(texture0, sampler0), ";
|
fragColor = texture()"
|
||||||
|
<< samplerType << "(texture0, sampler0), ";
|
||||||
|
|
||||||
if (isCubeMapArray) {
|
if (isCubeMapArray) {
|
||||||
stream << "vec4(" << coordToCubeMapFace << ", " << cubeMapArrayIndex;
|
stream << "vec4(" << coordToCubeMapFace << ", " << cubeMapArrayIndex;
|
||||||
|
@ -321,7 +320,7 @@ protected:
|
||||||
|
|
||||||
// Check the data in the every face of the cube map (array) texture view.
|
// Check the data in the every face of the cube map (array) texture view.
|
||||||
for (uint32_t layer = 0; layer < textureViewLayerCount; ++layer) {
|
for (uint32_t layer = 0; layer < textureViewLayerCount; ++layer) {
|
||||||
const std::string &fragmentShader =
|
const std::string& fragmentShader =
|
||||||
CreateFragmentShaderForCubeMapFace(layer, isCubeMapArray);
|
CreateFragmentShaderForCubeMapFace(layer, isCubeMapArray);
|
||||||
|
|
||||||
int expected = GenerateTestPixelValue(textureViewBaseLayer + layer, 0);
|
int expected = GenerateTestPixelValue(textureViewBaseLayer + layer, 0);
|
||||||
|
@ -362,8 +361,8 @@ TEST_P(TextureViewSamplingTest, Default2DArrayTexture) {
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
const int expected = GenerateTestPixelValue(0, 0) + GenerateTestPixelValue(1, 0) +
|
const int expected =
|
||||||
GenerateTestPixelValue(2, 0);
|
GenerateTestPixelValue(0, 0) + GenerateTestPixelValue(1, 0) + GenerateTestPixelValue(2, 0);
|
||||||
Verify(textureView, fragmentShader, expected);
|
Verify(textureView, fragmentShader, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +426,8 @@ TEST_P(TextureViewSamplingTest, TextureCubeMapArrayViewOnPartOfTexture) {
|
||||||
TextureCubeMapTest(20, 3, 12, true);
|
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_P(TextureViewSamplingTest, TextureCubeMapArrayViewCoveringLastLayer) {
|
||||||
// Test failing on the GPU FYI Mac Pro (AMD), see
|
// Test failing on the GPU FYI Mac Pro (AMD), see
|
||||||
// https://bugs.chromium.org/p/dawn/issues/detail?id=58
|
// https://bugs.chromium.org/p/dawn/issues/detail?id=58
|
||||||
|
@ -519,8 +519,7 @@ class TextureViewRenderingTest : public DawnTest {
|
||||||
bytesPerRow / kBytesPerTexel * (textureWidthLevel0 - 1) + textureHeightLevel0;
|
bytesPerRow / kBytesPerTexel * (textureWidthLevel0 - 1) + textureHeightLevel0;
|
||||||
constexpr RGBA8 kExpectedPixel(0, 255, 0, 255);
|
constexpr RGBA8 kExpectedPixel(0, 255, 0, 255);
|
||||||
std::vector<RGBA8> expected(expectedDataSize, kExpectedPixel);
|
std::vector<RGBA8> expected(expectedDataSize, kExpectedPixel);
|
||||||
EXPECT_TEXTURE_RGBA8_EQ(
|
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), texture, 0, 0, textureViewWidth, textureViewHeight,
|
||||||
expected.data(), texture, 0, 0, textureViewWidth, textureViewHeight,
|
|
||||||
textureViewBaseLevel, textureViewBaseLayer);
|
textureViewBaseLevel, textureViewBaseLayer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -565,7 +564,6 @@ TEST_P(TextureViewRenderingTest, Texture2DViewOnALayerOf2DArrayTextureAsColorAtt
|
||||||
TextureLayerAsColorAttachmentTest(wgpu::TextureViewDimension::e2D, kLayers, kMipLevels,
|
TextureLayerAsColorAttachmentTest(wgpu::TextureViewDimension::e2D, kLayers, kMipLevels,
|
||||||
kBaseLayer, kBaseLevel);
|
kBaseLayer, kBaseLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test rendering into a 1-layer 2D array texture view created on a mipmap level of a 2D texture.
|
// 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 {};
|
class TextureViewTest : public DawnTest {};
|
||||||
|
|
||||||
|
|
|
@ -1144,8 +1144,7 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferNonRenderableUnaligned) {
|
||||||
EXPECT_EQ(true, dawn_native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1));
|
EXPECT_EQ(true, dawn_native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(
|
DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
|
||||||
TextureZeroInitTest,
|
|
||||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
|
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"},
|
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"},
|
||||||
{"use_d3d12_render_pass"}),
|
{"use_d3d12_render_pass"}),
|
||||||
|
|
|
@ -915,4 +915,8 @@ TEST_P(VertexFormatTest, Int4) {
|
||||||
DoVertexFormatTest(wgpu::VertexFormat::Int4, vertexData, vertexData);
|
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];
|
uint16_t halfs[2];
|
||||||
};
|
};
|
||||||
static_assert(sizeof(Data) == 16, "");
|
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 =
|
wgpu::Buffer vertexBuffer =
|
||||||
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Vertex);
|
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);
|
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:
|
// TODO for the input state:
|
||||||
// - Add more vertex formats
|
// - Add more vertex formats
|
||||||
|
|
|
@ -64,4 +64,8 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
|
||||||
EXPECT_PIXEL_RGBA8_EQ(RGBA8::kZero, renderPass.color, 1, 1);
|
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);
|
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};
|
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->size = mySize;
|
||||||
pushConstants->offset = myOffset;
|
pushConstants->offset = myOffset;
|
||||||
|
|
||||||
|
@ -209,7 +210,7 @@ TEST(CommandAllocator, LargeCommands) {
|
||||||
for (int i = 0; i < kCommandCount; i++) {
|
for (int i = 0; i < kCommandCount; i++) {
|
||||||
CommandBig* big = allocator.Allocate<CommandBig>(CommandType::Big);
|
CommandBig* big = allocator.Allocate<CommandBig>(CommandType::Big);
|
||||||
for (int j = 0; j < kBigBufferSize; j++) {
|
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>();
|
CommandBig* big = iterator.NextCommand<CommandBig>();
|
||||||
for (int i = 0; i < kBigBufferSize; i++) {
|
for (int i = 0; i < kBigBufferSize; i++) {
|
||||||
ASSERT_EQ(big->buffer[i], count);
|
ASSERT_EQ(big->buffer[i], count);
|
||||||
count ++;
|
count++;
|
||||||
}
|
}
|
||||||
numCommands ++;
|
numCommands++;
|
||||||
}
|
}
|
||||||
ASSERT_EQ(numCommands, kCommandCount);
|
ASSERT_EQ(numCommands, kCommandCount);
|
||||||
|
|
||||||
|
@ -242,7 +243,7 @@ TEST(CommandAllocator, ManySmallCommands) {
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
for (int i = 0; i < kCommandCount; i++) {
|
for (int i = 0; i < kCommandCount; i++) {
|
||||||
CommandSmall* small = allocator.Allocate<CommandSmall>(CommandType::Small);
|
CommandSmall* small = allocator.Allocate<CommandSmall>(CommandType::Small);
|
||||||
small->data = count ++;
|
small->data = count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandIterator iterator(std::move(allocator));
|
CommandIterator iterator(std::move(allocator));
|
||||||
|
@ -254,8 +255,8 @@ TEST(CommandAllocator, ManySmallCommands) {
|
||||||
|
|
||||||
CommandSmall* small = iterator.NextCommand<CommandSmall>();
|
CommandSmall* small = iterator.NextCommand<CommandSmall>();
|
||||||
ASSERT_EQ(small->data, count);
|
ASSERT_EQ(small->data, count);
|
||||||
count ++;
|
count++;
|
||||||
numCommands ++;
|
numCommands++;
|
||||||
}
|
}
|
||||||
ASSERT_EQ(numCommands, kCommandCount);
|
ASSERT_EQ(numCommands, kCommandCount);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace wgpu {
|
||||||
A = 8,
|
A = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template <>
|
||||||
struct IsDawnBitmask<Color> {
|
struct IsDawnBitmask<Color> {
|
||||||
static constexpr bool enable = true;
|
static constexpr bool enable = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,45 +21,39 @@ using namespace dawn_native;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int dummySuccess = 0xbeef;
|
int dummySuccess = 0xbeef;
|
||||||
const char* dummyErrorMessage = "I am an error message :3";
|
const char* dummyErrorMessage = "I am an error message :3";
|
||||||
|
|
||||||
// Check returning a success MaybeError with {};
|
// Check returning a success MaybeError with {};
|
||||||
TEST(ErrorTests, Error_Success) {
|
TEST(ErrorTests, Error_Success) {
|
||||||
auto ReturnSuccess = []() -> MaybeError {
|
auto ReturnSuccess = []() -> MaybeError { return {}; };
|
||||||
return {};
|
|
||||||
};
|
|
||||||
|
|
||||||
MaybeError result = ReturnSuccess();
|
MaybeError result = ReturnSuccess();
|
||||||
ASSERT_TRUE(result.IsSuccess());
|
ASSERT_TRUE(result.IsSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check returning an error MaybeError with "return DAWN_VALIDATION_ERROR"
|
// Check returning an error MaybeError with "return DAWN_VALIDATION_ERROR"
|
||||||
TEST(ErrorTests, Error_Error) {
|
TEST(ErrorTests, Error_Error) {
|
||||||
auto ReturnError = []() -> MaybeError {
|
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
|
||||||
};
|
|
||||||
|
|
||||||
MaybeError result = ReturnError();
|
MaybeError result = ReturnError();
|
||||||
ASSERT_TRUE(result.IsError());
|
ASSERT_TRUE(result.IsError());
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check returning a success ResultOrError with an implicit conversion
|
// Check returning a success ResultOrError with an implicit conversion
|
||||||
TEST(ErrorTests, ResultOrError_Success) {
|
TEST(ErrorTests, ResultOrError_Success) {
|
||||||
auto ReturnSuccess = []() -> ResultOrError<int*> {
|
auto ReturnSuccess = []() -> ResultOrError<int*> { return &dummySuccess; };
|
||||||
return &dummySuccess;
|
|
||||||
};
|
|
||||||
|
|
||||||
ResultOrError<int*> result = ReturnSuccess();
|
ResultOrError<int*> result = ReturnSuccess();
|
||||||
ASSERT_TRUE(result.IsSuccess());
|
ASSERT_TRUE(result.IsSuccess());
|
||||||
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
|
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check returning an error ResultOrError with "return DAWN_VALIDATION_ERROR"
|
// Check returning an error ResultOrError with "return DAWN_VALIDATION_ERROR"
|
||||||
TEST(ErrorTests, ResultOrError_Error) {
|
TEST(ErrorTests, ResultOrError_Error) {
|
||||||
auto ReturnError = []() -> ResultOrError<int*> {
|
auto ReturnError = []() -> ResultOrError<int*> {
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||||
};
|
};
|
||||||
|
@ -69,13 +63,11 @@ TEST(ErrorTests, ResultOrError_Error) {
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check DAWN_TRY handles successes correctly.
|
// Check DAWN_TRY handles successes correctly.
|
||||||
TEST(ErrorTests, TRY_Success) {
|
TEST(ErrorTests, TRY_Success) {
|
||||||
auto ReturnSuccess = []() -> MaybeError {
|
auto ReturnSuccess = []() -> MaybeError { return {}; };
|
||||||
return {};
|
|
||||||
};
|
|
||||||
|
|
||||||
// We need to check that DAWN_TRY doesn't return on successes
|
// We need to check that DAWN_TRY doesn't return on successes
|
||||||
bool tryReturned = true;
|
bool tryReturned = true;
|
||||||
|
@ -89,13 +81,11 @@ TEST(ErrorTests, TRY_Success) {
|
||||||
MaybeError result = Try();
|
MaybeError result = Try();
|
||||||
ASSERT_TRUE(result.IsSuccess());
|
ASSERT_TRUE(result.IsSuccess());
|
||||||
ASSERT_FALSE(tryReturned);
|
ASSERT_FALSE(tryReturned);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check DAWN_TRY handles errors correctly.
|
// Check DAWN_TRY handles errors correctly.
|
||||||
TEST(ErrorTests, TRY_Error) {
|
TEST(ErrorTests, TRY_Error) {
|
||||||
auto ReturnError = []() -> MaybeError {
|
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto Try = [ReturnError]() -> MaybeError {
|
auto Try = [ReturnError]() -> MaybeError {
|
||||||
DAWN_TRY(ReturnError());
|
DAWN_TRY(ReturnError());
|
||||||
|
@ -109,13 +99,11 @@ TEST(ErrorTests, TRY_Error) {
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check DAWN_TRY adds to the backtrace.
|
// Check DAWN_TRY adds to the backtrace.
|
||||||
TEST(ErrorTests, TRY_AddsToBacktrace) {
|
TEST(ErrorTests, TRY_AddsToBacktrace) {
|
||||||
auto ReturnError = []() -> MaybeError {
|
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto SingleTry = [ReturnError]() -> MaybeError {
|
auto SingleTry = [ReturnError]() -> MaybeError {
|
||||||
DAWN_TRY(ReturnError());
|
DAWN_TRY(ReturnError());
|
||||||
|
@ -137,13 +125,11 @@ TEST(ErrorTests, TRY_AddsToBacktrace) {
|
||||||
std::unique_ptr<ErrorData> doubleData = doubleResult.AcquireError();
|
std::unique_ptr<ErrorData> doubleData = doubleResult.AcquireError();
|
||||||
|
|
||||||
ASSERT_EQ(singleData->GetBacktrace().size() + 1, doubleData->GetBacktrace().size());
|
ASSERT_EQ(singleData->GetBacktrace().size() + 1, doubleData->GetBacktrace().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check DAWN_TRY_ASSIGN handles successes correctly.
|
// Check DAWN_TRY_ASSIGN handles successes correctly.
|
||||||
TEST(ErrorTests, TRY_RESULT_Success) {
|
TEST(ErrorTests, TRY_RESULT_Success) {
|
||||||
auto ReturnSuccess = []() -> ResultOrError<int*> {
|
auto ReturnSuccess = []() -> ResultOrError<int*> { return &dummySuccess; };
|
||||||
return &dummySuccess;
|
|
||||||
};
|
|
||||||
|
|
||||||
// We need to check that DAWN_TRY doesn't return on successes
|
// We need to check that DAWN_TRY doesn't return on successes
|
||||||
bool tryReturned = true;
|
bool tryReturned = true;
|
||||||
|
@ -161,10 +147,10 @@ TEST(ErrorTests, TRY_RESULT_Success) {
|
||||||
ASSERT_TRUE(result.IsSuccess());
|
ASSERT_TRUE(result.IsSuccess());
|
||||||
ASSERT_FALSE(tryReturned);
|
ASSERT_FALSE(tryReturned);
|
||||||
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
|
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check DAWN_TRY_ASSIGN handles errors correctly.
|
// Check DAWN_TRY_ASSIGN handles errors correctly.
|
||||||
TEST(ErrorTests, TRY_RESULT_Error) {
|
TEST(ErrorTests, TRY_RESULT_Error) {
|
||||||
auto ReturnError = []() -> ResultOrError<int*> {
|
auto ReturnError = []() -> ResultOrError<int*> {
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||||
};
|
};
|
||||||
|
@ -184,10 +170,10 @@ TEST(ErrorTests, TRY_RESULT_Error) {
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check DAWN_TRY_ASSIGN adds to the backtrace.
|
// Check DAWN_TRY_ASSIGN adds to the backtrace.
|
||||||
TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
|
TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
|
||||||
auto ReturnError = []() -> ResultOrError<int*> {
|
auto ReturnError = []() -> ResultOrError<int*> {
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||||
};
|
};
|
||||||
|
@ -212,10 +198,10 @@ TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
|
||||||
std::unique_ptr<ErrorData> doubleData = doubleResult.AcquireError();
|
std::unique_ptr<ErrorData> doubleData = doubleResult.AcquireError();
|
||||||
|
|
||||||
ASSERT_EQ(singleData->GetBacktrace().size() + 1, doubleData->GetBacktrace().size());
|
ASSERT_EQ(singleData->GetBacktrace().size() + 1, doubleData->GetBacktrace().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
||||||
TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
||||||
auto ReturnError = []() -> ResultOrError<int*> {
|
auto ReturnError = []() -> ResultOrError<int*> {
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||||
};
|
};
|
||||||
|
@ -233,11 +219,11 @@ TEST(ErrorTests, TRY_RESULT_ConversionToError) {
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
|
||||||
// Version without Result<E*, T*>
|
// Version without Result<E*, T*>
|
||||||
TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
|
TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
|
||||||
auto ReturnError = []() -> ResultOrError<int> {
|
auto ReturnError = []() -> ResultOrError<int> {
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
||||||
};
|
};
|
||||||
|
@ -255,16 +241,14 @@ TEST(ErrorTests, TRY_RESULT_ConversionToErrorNonPointer) {
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check a MaybeError can be DAWN_TRIED in a function that returns an ResultOrError
|
// Check a MaybeError can be DAWN_TRIED in a function that returns an ResultOrError
|
||||||
// Check DAWN_TRY handles errors correctly.
|
// Check DAWN_TRY handles errors correctly.
|
||||||
TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
|
TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
|
||||||
auto ReturnError = []() -> MaybeError {
|
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto Try = [ReturnError]() -> ResultOrError<int*>{
|
auto Try = [ReturnError]() -> ResultOrError<int*> {
|
||||||
DAWN_TRY(ReturnError());
|
DAWN_TRY(ReturnError());
|
||||||
return &dummySuccess;
|
return &dummySuccess;
|
||||||
};
|
};
|
||||||
|
@ -274,16 +258,14 @@ TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check a MaybeError can be DAWN_TRIED in a function that returns an ResultOrError
|
// 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*>
|
// Check DAWN_TRY handles errors correctly. Version without Result<E*, T*>
|
||||||
TEST(ErrorTests, TRY_ConversionToErrorOrResultNonPointer) {
|
TEST(ErrorTests, TRY_ConversionToErrorOrResultNonPointer) {
|
||||||
auto ReturnError = []() -> MaybeError {
|
auto ReturnError = []() -> MaybeError { return DAWN_VALIDATION_ERROR(dummyErrorMessage); };
|
||||||
return DAWN_VALIDATION_ERROR(dummyErrorMessage);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto Try = [ReturnError]() -> ResultOrError<int>{
|
auto Try = [ReturnError]() -> ResultOrError<int> {
|
||||||
DAWN_TRY(ReturnError());
|
DAWN_TRY(ReturnError());
|
||||||
return 42;
|
return 42;
|
||||||
};
|
};
|
||||||
|
@ -293,6 +275,6 @@ TEST(ErrorTests, TRY_ConversionToErrorOrResultNonPointer) {
|
||||||
|
|
||||||
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
std::unique_ptr<ErrorData> errorData = result.AcquireError();
|
||||||
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
ASSERT_EQ(errorData->GetMessage(), dummyErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -194,4 +194,3 @@ TEST(ObjectBase, AssignNullptr) {
|
||||||
obj = nullptr;
|
obj = nullptr;
|
||||||
ASSERT_EQ(refcount, 1);
|
ASSERT_EQ(refcount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ TEST(PerStage, IterateAllStages) {
|
||||||
counts[SingleShaderStage::Compute] = 0;
|
counts[SingleShaderStage::Compute] = 0;
|
||||||
|
|
||||||
for (auto stage : IterateStages(kAllStages)) {
|
for (auto stage : IterateStages(kAllStages)) {
|
||||||
counts[stage] ++;
|
counts[stage]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 1);
|
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 1);
|
||||||
|
@ -64,7 +64,7 @@ TEST(PerStage, IterateOneStage) {
|
||||||
counts[SingleShaderStage::Compute] = 0;
|
counts[SingleShaderStage::Compute] = 0;
|
||||||
|
|
||||||
for (auto stage : IterateStages(wgpu::ShaderStage::Fragment)) {
|
for (auto stage : IterateStages(wgpu::ShaderStage::Fragment)) {
|
||||||
counts[stage] ++;
|
counts[stage]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 0);
|
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 0);
|
||||||
|
@ -80,7 +80,7 @@ TEST(PerStage, IterateNoStages) {
|
||||||
counts[SingleShaderStage::Compute] = 0;
|
counts[SingleShaderStage::Compute] = 0;
|
||||||
|
|
||||||
for (auto stage : IterateStages(wgpu::ShaderStage::Fragment & wgpu::ShaderStage::Vertex)) {
|
for (auto stage : IterateStages(wgpu::ShaderStage::Fragment & wgpu::ShaderStage::Vertex)) {
|
||||||
counts[stage] ++;
|
counts[stage]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 0);
|
ASSERT_EQ(counts[wgpu::ShaderStage::Vertex], 0);
|
||||||
|
|
|
@ -19,17 +19,17 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template<typename T, typename E>
|
template <typename T, typename E>
|
||||||
void TestError(Result<T, E>* result, E expectedError) {
|
void TestError(Result<T, E>* result, E expectedError) {
|
||||||
EXPECT_TRUE(result->IsError());
|
EXPECT_TRUE(result->IsError());
|
||||||
EXPECT_FALSE(result->IsSuccess());
|
EXPECT_FALSE(result->IsSuccess());
|
||||||
|
|
||||||
std::unique_ptr<E> storedError = result->AcquireError();
|
std::unique_ptr<E> storedError = result->AcquireError();
|
||||||
EXPECT_EQ(*storedError, expectedError);
|
EXPECT_EQ(*storedError, expectedError);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename E>
|
template <typename T, typename E>
|
||||||
void TestSuccess(Result<T, E>* result, T expectedSuccess) {
|
void TestSuccess(Result<T, E>* result, T expectedSuccess) {
|
||||||
EXPECT_FALSE(result->IsError());
|
EXPECT_FALSE(result->IsError());
|
||||||
EXPECT_TRUE(result->IsSuccess());
|
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.
|
// payload and is neither in the success nor error state.
|
||||||
EXPECT_FALSE(result->IsError());
|
EXPECT_FALSE(result->IsError());
|
||||||
EXPECT_FALSE(result->IsSuccess());
|
EXPECT_FALSE(result->IsSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dummyError = 0xbeef;
|
static int dummyError = 0xbeef;
|
||||||
static float dummySuccess = 42.0f;
|
static float dummySuccess = 42.0f;
|
||||||
static const float dummyConstSuccess = 42.0f;
|
static const float dummyConstSuccess = 42.0f;
|
||||||
|
|
||||||
class AClass : public RefCounted {
|
class AClass : public RefCounted {
|
||||||
public:
|
public:
|
||||||
int a = 0;
|
int a = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tests using the following overload of TestSuccess make
|
// Tests using the following overload of TestSuccess make
|
||||||
// local Ref instances to dummySuccessObj. Tests should
|
// local Ref instances to dummySuccessObj. Tests should
|
||||||
// ensure any local Ref objects made along the way continue
|
// ensure any local Ref objects made along the way continue
|
||||||
// to point to dummySuccessObj.
|
// to point to dummySuccessObj.
|
||||||
template <typename T, typename E>
|
template <typename T, typename E>
|
||||||
void TestSuccess(Result<Ref<T>, E>* result, T* expectedSuccess) {
|
void TestSuccess(Result<Ref<T>, E>* result, T* expectedSuccess) {
|
||||||
EXPECT_FALSE(result->IsError());
|
EXPECT_FALSE(result->IsError());
|
||||||
EXPECT_TRUE(result->IsSuccess());
|
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
|
// the object. storedSuccess should contain the only other
|
||||||
// reference to the object.
|
// reference to the object.
|
||||||
EXPECT_EQ(storedSuccess->GetRefCountForTesting(), 2u);
|
EXPECT_EQ(storedSuccess->GetRefCountForTesting(), 2u);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result<void, E*>
|
// Result<void, E*>
|
||||||
|
|
||||||
// Test constructing an error Result<void, E>
|
// Test constructing an error Result<void, E>
|
||||||
TEST(ResultOnlyPointerError, ConstructingError) {
|
TEST(ResultOnlyPointerError, ConstructingError) {
|
||||||
Result<void, int> result(std::make_unique<int>(dummyError));
|
Result<void, int> result(std::make_unique<int>(dummyError));
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving an error Result<void, E>
|
// Test moving an error Result<void, E>
|
||||||
TEST(ResultOnlyPointerError, MovingError) {
|
TEST(ResultOnlyPointerError, MovingError) {
|
||||||
Result<void, int> result(std::make_unique<int>(dummyError));
|
Result<void, int> result(std::make_unique<int>(dummyError));
|
||||||
Result<void, int> movedResult(std::move(result));
|
Result<void, int> movedResult(std::move(result));
|
||||||
TestError(&movedResult, dummyError);
|
TestError(&movedResult, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning an error Result<void, E>
|
// Test returning an error Result<void, E>
|
||||||
TEST(ResultOnlyPointerError, ReturningError) {
|
TEST(ResultOnlyPointerError, ReturningError) {
|
||||||
auto CreateError = []() -> Result<void, int> { return {std::make_unique<int>(dummyError)}; };
|
auto CreateError = []() -> Result<void, int> {
|
||||||
|
return {std::make_unique<int>(dummyError)};
|
||||||
|
};
|
||||||
|
|
||||||
Result<void, int> result = CreateError();
|
Result<void, int> result = CreateError();
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test constructing a success Result<void, E>
|
// Test constructing a success Result<void, E>
|
||||||
TEST(ResultOnlyPointerError, ConstructingSuccess) {
|
TEST(ResultOnlyPointerError, ConstructingSuccess) {
|
||||||
Result<void, int> result;
|
Result<void, int> result;
|
||||||
EXPECT_TRUE(result.IsSuccess());
|
EXPECT_TRUE(result.IsSuccess());
|
||||||
EXPECT_FALSE(result.IsError());
|
EXPECT_FALSE(result.IsError());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving a success Result<void, E>
|
// Test moving a success Result<void, E>
|
||||||
TEST(ResultOnlyPointerError, MovingSuccess) {
|
TEST(ResultOnlyPointerError, MovingSuccess) {
|
||||||
Result<void, int> result;
|
Result<void, int> result;
|
||||||
Result<void, int> movedResult(std::move(result));
|
Result<void, int> movedResult(std::move(result));
|
||||||
EXPECT_TRUE(movedResult.IsSuccess());
|
EXPECT_TRUE(movedResult.IsSuccess());
|
||||||
EXPECT_FALSE(movedResult.IsError());
|
EXPECT_FALSE(movedResult.IsError());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning a success Result<void, E>
|
// Test returning a success Result<void, E>
|
||||||
TEST(ResultOnlyPointerError, ReturningSuccess) {
|
TEST(ResultOnlyPointerError, ReturningSuccess) {
|
||||||
auto CreateError = []() -> Result<void, int> { return {}; };
|
auto CreateError = []() -> Result<void, int> { return {}; };
|
||||||
|
|
||||||
Result<void, int> result = CreateError();
|
Result<void, int> result = CreateError();
|
||||||
EXPECT_TRUE(result.IsSuccess());
|
EXPECT_TRUE(result.IsSuccess());
|
||||||
EXPECT_FALSE(result.IsError());
|
EXPECT_FALSE(result.IsError());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result<T*, E*>
|
// Result<T*, E*>
|
||||||
|
|
||||||
// Test constructing an error Result<T*, E>
|
// Test constructing an error Result<T*, E>
|
||||||
TEST(ResultBothPointer, ConstructingError) {
|
TEST(ResultBothPointer, ConstructingError) {
|
||||||
Result<float*, int> result(std::make_unique<int>(dummyError));
|
Result<float*, int> result(std::make_unique<int>(dummyError));
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving an error Result<T*, E>
|
// Test moving an error Result<T*, E>
|
||||||
TEST(ResultBothPointer, MovingError) {
|
TEST(ResultBothPointer, MovingError) {
|
||||||
Result<float*, int> result(std::make_unique<int>(dummyError));
|
Result<float*, int> result(std::make_unique<int>(dummyError));
|
||||||
Result<float*, int> movedResult(std::move(result));
|
Result<float*, int> movedResult(std::move(result));
|
||||||
TestError(&movedResult, dummyError);
|
TestError(&movedResult, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning an error Result<T*, E>
|
// Test returning an error Result<T*, E>
|
||||||
TEST(ResultBothPointer, ReturningError) {
|
TEST(ResultBothPointer, ReturningError) {
|
||||||
auto CreateError = []() -> Result<float*, int> { return {std::make_unique<int>(dummyError)}; };
|
auto CreateError = []() -> Result<float*, int> {
|
||||||
|
return {std::make_unique<int>(dummyError)};
|
||||||
|
};
|
||||||
|
|
||||||
Result<float*, int> result = CreateError();
|
Result<float*, int> result = CreateError();
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test constructing a success Result<T*, E>
|
// Test constructing a success Result<T*, E>
|
||||||
TEST(ResultBothPointer, ConstructingSuccess) {
|
TEST(ResultBothPointer, ConstructingSuccess) {
|
||||||
Result<float*, int> result(&dummySuccess);
|
Result<float*, int> result(&dummySuccess);
|
||||||
TestSuccess(&result, &dummySuccess);
|
TestSuccess(&result, &dummySuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving a success Result<T*, E>
|
// Test moving a success Result<T*, E>
|
||||||
TEST(ResultBothPointer, MovingSuccess) {
|
TEST(ResultBothPointer, MovingSuccess) {
|
||||||
Result<float*, int> result(&dummySuccess);
|
Result<float*, int> result(&dummySuccess);
|
||||||
Result<float*, int> movedResult(std::move(result));
|
Result<float*, int> movedResult(std::move(result));
|
||||||
TestSuccess(&movedResult, &dummySuccess);
|
TestSuccess(&movedResult, &dummySuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning a success Result<T*, E>
|
// Test returning a success Result<T*, E>
|
||||||
TEST(ResultBothPointer, ReturningSuccess) {
|
TEST(ResultBothPointer, ReturningSuccess) {
|
||||||
auto CreateSuccess = []() -> Result<float*, int*> {
|
auto CreateSuccess = []() -> Result<float*, int*> { return {&dummySuccess}; };
|
||||||
return {&dummySuccess};
|
|
||||||
};
|
|
||||||
|
|
||||||
Result<float*, int*> result = CreateSuccess();
|
Result<float*, int*> result = CreateSuccess();
|
||||||
TestSuccess(&result, &dummySuccess);
|
TestSuccess(&result, &dummySuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests converting from a Result<TChild*, E>
|
// Tests converting from a Result<TChild*, E>
|
||||||
TEST(ResultBothPointer, ConversionFromChildClass) {
|
TEST(ResultBothPointer, ConversionFromChildClass) {
|
||||||
struct T {
|
struct T {
|
||||||
int a;
|
int a;
|
||||||
};
|
};
|
||||||
|
@ -195,187 +197,189 @@ TEST(ResultBothPointer, ConversionFromChildClass) {
|
||||||
Result<T*, int> result = std::move(resultChild);
|
Result<T*, int> result = std::move(resultChild);
|
||||||
TestSuccess(&result, childAsT);
|
TestSuccess(&result, childAsT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result<const T*, E>
|
// Result<const T*, E>
|
||||||
|
|
||||||
// Test constructing an error Result<const T*, E>
|
// Test constructing an error Result<const T*, E>
|
||||||
TEST(ResultBothPointerWithConstResult, ConstructingError) {
|
TEST(ResultBothPointerWithConstResult, ConstructingError) {
|
||||||
Result<const float*, int> result(std::make_unique<int>(dummyError));
|
Result<const float*, int> result(std::make_unique<int>(dummyError));
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving an error Result<const T*, E>
|
// Test moving an error Result<const T*, E>
|
||||||
TEST(ResultBothPointerWithConstResult, MovingError) {
|
TEST(ResultBothPointerWithConstResult, MovingError) {
|
||||||
Result<const float*, int> result(std::make_unique<int>(dummyError));
|
Result<const float*, int> result(std::make_unique<int>(dummyError));
|
||||||
Result<const float*, int> movedResult(std::move(result));
|
Result<const float*, int> movedResult(std::move(result));
|
||||||
TestError(&movedResult, dummyError);
|
TestError(&movedResult, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning an error Result<const T*, E*>
|
// Test returning an error Result<const T*, E*>
|
||||||
TEST(ResultBothPointerWithConstResult, ReturningError) {
|
TEST(ResultBothPointerWithConstResult, ReturningError) {
|
||||||
auto CreateError = []() -> Result<const float*, int> {
|
auto CreateError = []() -> Result<const float*, int> {
|
||||||
return {std::make_unique<int>(dummyError)};
|
return {std::make_unique<int>(dummyError)};
|
||||||
};
|
};
|
||||||
|
|
||||||
Result<const float*, int> result = CreateError();
|
Result<const float*, int> result = CreateError();
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test constructing a success Result<const T*, E*>
|
// Test constructing a success Result<const T*, E*>
|
||||||
TEST(ResultBothPointerWithConstResult, ConstructingSuccess) {
|
TEST(ResultBothPointerWithConstResult, ConstructingSuccess) {
|
||||||
Result<const float*, int> result(&dummyConstSuccess);
|
Result<const float*, int> result(&dummyConstSuccess);
|
||||||
TestSuccess(&result, &dummyConstSuccess);
|
TestSuccess(&result, &dummyConstSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving a success Result<const T*, E*>
|
// Test moving a success Result<const T*, E*>
|
||||||
TEST(ResultBothPointerWithConstResult, MovingSuccess) {
|
TEST(ResultBothPointerWithConstResult, MovingSuccess) {
|
||||||
Result<const float*, int> result(&dummyConstSuccess);
|
Result<const float*, int> result(&dummyConstSuccess);
|
||||||
Result<const float*, int> movedResult(std::move(result));
|
Result<const float*, int> movedResult(std::move(result));
|
||||||
TestSuccess(&movedResult, &dummyConstSuccess);
|
TestSuccess(&movedResult, &dummyConstSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning a success Result<const T*, E*>
|
// Test returning a success Result<const T*, E*>
|
||||||
TEST(ResultBothPointerWithConstResult, ReturningSuccess) {
|
TEST(ResultBothPointerWithConstResult, ReturningSuccess) {
|
||||||
auto CreateSuccess = []() -> Result<const float*, int> { return {&dummyConstSuccess}; };
|
auto CreateSuccess = []() -> Result<const float*, int> { return {&dummyConstSuccess}; };
|
||||||
|
|
||||||
Result<const float*, int> result = CreateSuccess();
|
Result<const float*, int> result = CreateSuccess();
|
||||||
TestSuccess(&result, &dummyConstSuccess);
|
TestSuccess(&result, &dummyConstSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result<Ref<T>, E>
|
// Result<Ref<T>, E>
|
||||||
|
|
||||||
// Test constructing an error Result<Ref<T>, E>
|
// Test constructing an error Result<Ref<T>, E>
|
||||||
TEST(ResultRefT, ConstructingError) {
|
TEST(ResultRefT, ConstructingError) {
|
||||||
Result<Ref<AClass>, int> result(std::make_unique<int>(dummyError));
|
Result<Ref<AClass>, int> result(std::make_unique<int>(dummyError));
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving an error Result<Ref<T>, E>
|
// Test moving an error Result<Ref<T>, E>
|
||||||
TEST(ResultRefT, MovingError) {
|
TEST(ResultRefT, MovingError) {
|
||||||
Result<Ref<AClass>, int> result(std::make_unique<int>(dummyError));
|
Result<Ref<AClass>, int> result(std::make_unique<int>(dummyError));
|
||||||
Result<Ref<AClass>, int> movedResult(std::move(result));
|
Result<Ref<AClass>, int> movedResult(std::move(result));
|
||||||
TestError(&movedResult, dummyError);
|
TestError(&movedResult, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning an error Result<Ref<T>, E>
|
// Test returning an error Result<Ref<T>, E>
|
||||||
TEST(ResultRefT, ReturningError) {
|
TEST(ResultRefT, ReturningError) {
|
||||||
auto CreateError = []() -> Result<Ref<AClass>, int> {
|
auto CreateError = []() -> Result<Ref<AClass>, int> {
|
||||||
return {std::make_unique<int>(dummyError)};
|
return {std::make_unique<int>(dummyError)};
|
||||||
};
|
};
|
||||||
|
|
||||||
Result<Ref<AClass>, int> result = CreateError();
|
Result<Ref<AClass>, int> result = CreateError();
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test constructing a success Result<Ref<T>, E>
|
// Test constructing a success Result<Ref<T>, E>
|
||||||
TEST(ResultRefT, ConstructingSuccess) {
|
TEST(ResultRefT, ConstructingSuccess) {
|
||||||
AClass success;
|
AClass success;
|
||||||
|
|
||||||
Ref<AClass> refObj(&success);
|
Ref<AClass> refObj(&success);
|
||||||
Result<Ref<AClass>, int> result(std::move(refObj));
|
Result<Ref<AClass>, int> result(std::move(refObj));
|
||||||
TestSuccess(&result, &success);
|
TestSuccess(&result, &success);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving a success Result<Ref<T>, E>
|
// Test moving a success Result<Ref<T>, E>
|
||||||
TEST(ResultRefT, MovingSuccess) {
|
TEST(ResultRefT, MovingSuccess) {
|
||||||
AClass success;
|
AClass success;
|
||||||
|
|
||||||
Ref<AClass> refObj(&success);
|
Ref<AClass> refObj(&success);
|
||||||
Result<Ref<AClass>, int> result(std::move(refObj));
|
Result<Ref<AClass>, int> result(std::move(refObj));
|
||||||
Result<Ref<AClass>, int> movedResult(std::move(result));
|
Result<Ref<AClass>, int> movedResult(std::move(result));
|
||||||
TestSuccess(&movedResult, &success);
|
TestSuccess(&movedResult, &success);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning a success Result<Ref<T>, E>
|
// Test returning a success Result<Ref<T>, E>
|
||||||
TEST(ResultRefT, ReturningSuccess) {
|
TEST(ResultRefT, ReturningSuccess) {
|
||||||
AClass success;
|
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();
|
Result<Ref<AClass>, int> result = CreateSuccess();
|
||||||
TestSuccess(&result, &success);
|
TestSuccess(&result, &success);
|
||||||
}
|
}
|
||||||
|
|
||||||
class OtherClass {
|
class OtherClass {
|
||||||
public:
|
public:
|
||||||
int a = 0;
|
int a = 0;
|
||||||
};
|
};
|
||||||
class Base : public RefCounted {};
|
class Base : public RefCounted {};
|
||||||
class Child : public OtherClass, public Base {};
|
class Child : public OtherClass, public Base {};
|
||||||
|
|
||||||
// Test constructing a Result<Ref<TChild>, E>
|
// Test constructing a Result<Ref<TChild>, E>
|
||||||
TEST(ResultRefT, ConversionFromChildConstructor) {
|
TEST(ResultRefT, ConversionFromChildConstructor) {
|
||||||
Child child;
|
Child child;
|
||||||
Ref<Child> refChild(&child);
|
Ref<Child> refChild(&child);
|
||||||
|
|
||||||
Result<Ref<Base>, int> result(std::move(refChild));
|
Result<Ref<Base>, int> result(std::move(refChild));
|
||||||
TestSuccess<Base>(&result, &child);
|
TestSuccess<Base>(&result, &child);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test copy constructing Result<Ref<TChild>, E>
|
// Test copy constructing Result<Ref<TChild>, E>
|
||||||
TEST(ResultRefT, ConversionFromChildCopyConstructor) {
|
TEST(ResultRefT, ConversionFromChildCopyConstructor) {
|
||||||
Child child;
|
Child child;
|
||||||
Ref<Child> refChild(&child);
|
Ref<Child> refChild(&child);
|
||||||
|
|
||||||
Result<Ref<Child>, int> resultChild(std::move(refChild));
|
Result<Ref<Child>, int> resultChild(std::move(refChild));
|
||||||
Result<Ref<Base>, int> result(std::move(resultChild));
|
Result<Ref<Base>, int> result(std::move(resultChild));
|
||||||
TestSuccess<Base>(&result, &child);
|
TestSuccess<Base>(&result, &child);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test assignment operator for Result<Ref<TChild>, E>
|
// Test assignment operator for Result<Ref<TChild>, E>
|
||||||
TEST(ResultRefT, ConversionFromChildAssignmentOperator) {
|
TEST(ResultRefT, ConversionFromChildAssignmentOperator) {
|
||||||
Child child;
|
Child child;
|
||||||
Ref<Child> refChild(&child);
|
Ref<Child> refChild(&child);
|
||||||
|
|
||||||
Result<Ref<Child>, int> resultChild(std::move(refChild));
|
Result<Ref<Child>, int> resultChild(std::move(refChild));
|
||||||
Result<Ref<Base>, int> result = std::move(resultChild);
|
Result<Ref<Base>, int> result = std::move(resultChild);
|
||||||
TestSuccess<Base>(&result, &child);
|
TestSuccess<Base>(&result, &child);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result<T, E>
|
// Result<T, E>
|
||||||
|
|
||||||
// Test constructing an error Result<T, E>
|
// Test constructing an error Result<T, E>
|
||||||
TEST(ResultGeneric, ConstructingError) {
|
TEST(ResultGeneric, ConstructingError) {
|
||||||
Result<std::vector<float>, int> result(std::make_unique<int>(dummyError));
|
Result<std::vector<float>, int> result(std::make_unique<int>(dummyError));
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving an error Result<T, E>
|
// Test moving an error Result<T, E>
|
||||||
TEST(ResultGeneric, MovingError) {
|
TEST(ResultGeneric, MovingError) {
|
||||||
Result<std::vector<float>, int> result(std::make_unique<int>(dummyError));
|
Result<std::vector<float>, int> result(std::make_unique<int>(dummyError));
|
||||||
Result<std::vector<float>, int> movedResult(std::move(result));
|
Result<std::vector<float>, int> movedResult(std::move(result));
|
||||||
TestError(&movedResult, dummyError);
|
TestError(&movedResult, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning an error Result<T, E>
|
// Test returning an error Result<T, E>
|
||||||
TEST(ResultGeneric, ReturningError) {
|
TEST(ResultGeneric, ReturningError) {
|
||||||
auto CreateError = []() -> Result<std::vector<float>, int> {
|
auto CreateError = []() -> Result<std::vector<float>, int> {
|
||||||
return {std::make_unique<int>(dummyError)};
|
return {std::make_unique<int>(dummyError)};
|
||||||
};
|
};
|
||||||
|
|
||||||
Result<std::vector<float>, int> result = CreateError();
|
Result<std::vector<float>, int> result = CreateError();
|
||||||
TestError(&result, dummyError);
|
TestError(&result, dummyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test constructing a success Result<T, E>
|
// Test constructing a success Result<T, E>
|
||||||
TEST(ResultGeneric, ConstructingSuccess) {
|
TEST(ResultGeneric, ConstructingSuccess) {
|
||||||
Result<std::vector<float>, int> result({1.0f});
|
Result<std::vector<float>, int> result({1.0f});
|
||||||
TestSuccess(&result, {1.0f});
|
TestSuccess(&result, {1.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test moving a success Result<T, E>
|
// Test moving a success Result<T, E>
|
||||||
TEST(ResultGeneric, MovingSuccess) {
|
TEST(ResultGeneric, MovingSuccess) {
|
||||||
Result<std::vector<float>, int> result({1.0f});
|
Result<std::vector<float>, int> result({1.0f});
|
||||||
Result<std::vector<float>, int> movedResult(std::move(result));
|
Result<std::vector<float>, int> movedResult(std::move(result));
|
||||||
TestSuccess(&movedResult, {1.0f});
|
TestSuccess(&movedResult, {1.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test returning a success Result<T, E>
|
// Test returning a success Result<T, E>
|
||||||
TEST(ResultGeneric, ReturningSuccess) {
|
TEST(ResultGeneric, ReturningSuccess) {
|
||||||
auto CreateSuccess = []() -> Result<std::vector<float>, int> { return {{1.0f}}; };
|
auto CreateSuccess = []() -> Result<std::vector<float>, int> { return {{1.0f}}; };
|
||||||
|
|
||||||
Result<std::vector<float>, int> result = CreateSuccess();
|
Result<std::vector<float>, int> result = CreateSuccess();
|
||||||
TestSuccess(&result, {1.0f});
|
TestSuccess(&result, {1.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -21,21 +21,19 @@
|
||||||
|
|
||||||
// Make our own Base - Backend object pair, reusing the CommandBuffer name
|
// Make our own Base - Backend object pair, reusing the CommandBuffer name
|
||||||
namespace dawn_native {
|
namespace dawn_native {
|
||||||
class CommandBufferBase : public RefCounted {
|
class CommandBufferBase : public RefCounted {};
|
||||||
};
|
} // namespace dawn_native
|
||||||
}
|
|
||||||
|
|
||||||
using namespace dawn_native;
|
using namespace dawn_native;
|
||||||
|
|
||||||
class MyCommandBuffer : public CommandBufferBase {
|
class MyCommandBuffer : public CommandBufferBase {};
|
||||||
};
|
|
||||||
|
|
||||||
struct MyBackendTraits {
|
struct MyBackendTraits {
|
||||||
using CommandBufferType = MyCommandBuffer;
|
using CommandBufferType = MyCommandBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Instanciate ToBackend for our "backend"
|
// Instanciate ToBackend for our "backend"
|
||||||
template<typename T>
|
template <typename T>
|
||||||
auto ToBackend(T&& common) -> decltype(ToBackendBase<MyBackendTraits>(common)) {
|
auto ToBackend(T&& common) -> decltype(ToBackendBase<MyBackendTraits>(common)) {
|
||||||
return ToBackendBase<MyBackendTraits>(common);
|
return ToBackendBase<MyBackendTraits>(common);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +69,8 @@ TEST(ToBackend, Ref) {
|
||||||
const Ref<CommandBufferBase> base(cmdBuf);
|
const Ref<CommandBufferBase> base(cmdBuf);
|
||||||
|
|
||||||
const auto& backendCmdBuf = ToBackend(base);
|
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());
|
ASSERT_EQ(cmdBuf, backendCmdBuf.Get());
|
||||||
|
|
||||||
cmdBuf->Release();
|
cmdBuf->Release();
|
||||||
|
|
|
@ -55,7 +55,8 @@ namespace {
|
||||||
|
|
||||||
// Check that the offset is aligned
|
// Check that the offset is aligned
|
||||||
void ValidateOffset(const TextureCopySplit& copySplit) {
|
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) {
|
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];
|
const auto& a = copySplit.copies[i];
|
||||||
for (uint32_t j = i + 1; j < copySplit.count; ++j) {
|
for (uint32_t j = i + 1; j < copySplit.count; ++j) {
|
||||||
const auto& b = copySplit.copies[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 overlapX =
|
||||||
bool overlapY = RangesOverlap(a.textureOffset.y, a.textureOffset.y + a.copySize.height, b.textureOffset.y, b.textureOffset.y + b.copySize.height);
|
RangesOverlap(a.textureOffset.x, a.textureOffset.x + a.copySize.width,
|
||||||
bool overlapZ = RangesOverlap(a.textureOffset.z, a.textureOffset.z + a.copySize.depth, b.textureOffset.z, b.textureOffset.z + b.copySize.depth);
|
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);
|
ASSERT_TRUE(!overlapX || !overlapY || !overlapZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +112,8 @@ namespace {
|
||||||
ASSERT_EQ(maxZ, textureSpec.z + textureSpec.depth);
|
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) {
|
void ValidatePixelCount(const TextureSpec& textureSpec, const TextureCopySplit& copySplit) {
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
for (uint32_t i = 0; i < copySplit.count; ++i) {
|
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
|
// 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);
|
ASSERT_TRUE(copySplit.count > 0);
|
||||||
|
|
||||||
uint32_t texelsPerBlock = textureSpec.blockWidth * textureSpec.blockHeight;
|
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);
|
ValidateFootprints(copySplit);
|
||||||
ValidateOffset(copySplit);
|
ValidateOffset(copySplit);
|
||||||
ValidateDisjoint(copySplit);
|
ValidateDisjoint(copySplit);
|
||||||
|
@ -176,8 +188,13 @@ namespace {
|
||||||
os << "CopySplit" << std::endl;
|
os << "CopySplit" << std::endl;
|
||||||
for (uint32_t i = 0; i < copySplit.count; ++i) {
|
for (uint32_t i = 0; i < copySplit.count; ++i) {
|
||||||
const auto& copy = copySplit.copies[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 << ": Texture at (" << copy.textureOffset.x << ", "
|
||||||
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;
|
<< 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;
|
return os;
|
||||||
}
|
}
|
||||||
|
@ -260,14 +277,12 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define a list of values to set properties in the spec structs
|
// Define a list of values to set properties in the spec structs
|
||||||
constexpr uint32_t kCheckValues[] = {
|
constexpr uint32_t kCheckValues[] = {1, 2, 3, 4, 5, 6, 7, 8, // small values
|
||||||
1, 2, 3, 4, 5, 6, 7, 8, // small values
|
|
||||||
16, 32, 64, 128, 256, 512, 1024, 2048, // powers of 2
|
16, 32, 64, 128, 256, 512, 1024, 2048, // powers of 2
|
||||||
15, 31, 63, 127, 257, 511, 1023, 2047, // misalignments
|
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 {
|
class CopySplitTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
@ -290,11 +305,11 @@ class CopySplitTest : public testing::Test {
|
||||||
TEST_F(CopySplitTest, General) {
|
TEST_F(CopySplitTest, General) {
|
||||||
for (TextureSpec textureSpec : kBaseTextureSpecs) {
|
for (TextureSpec textureSpec : kBaseTextureSpecs) {
|
||||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||||
|
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
@ -310,11 +325,11 @@ TEST_F(CopySplitTest, TextureWidth) {
|
||||||
}
|
}
|
||||||
textureSpec.width = val;
|
textureSpec.width = val;
|
||||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||||
|
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
@ -331,11 +346,11 @@ TEST_F(CopySplitTest, TextureHeight) {
|
||||||
}
|
}
|
||||||
textureSpec.height = val;
|
textureSpec.height = val;
|
||||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||||
|
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
@ -349,11 +364,11 @@ TEST_F(CopySplitTest, TextureX) {
|
||||||
for (uint32_t val : kCheckValues) {
|
for (uint32_t val : kCheckValues) {
|
||||||
textureSpec.x = val;
|
textureSpec.x = val;
|
||||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||||
|
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
@ -367,11 +382,11 @@ TEST_F(CopySplitTest, TextureY) {
|
||||||
for (uint32_t val : kCheckValues) {
|
for (uint32_t val : kCheckValues) {
|
||||||
textureSpec.y = val;
|
textureSpec.y = val;
|
||||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||||
|
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
@ -385,11 +400,11 @@ TEST_F(CopySplitTest, TexelSize) {
|
||||||
for (uint32_t texelSize : {4, 8, 16, 32, 64}) {
|
for (uint32_t texelSize : {4, 8, 16, 32, 64}) {
|
||||||
textureSpec.texelBlockSizeInBytes = texelSize;
|
textureSpec.texelBlockSizeInBytes = texelSize;
|
||||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||||
|
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
@ -407,7 +422,8 @@ TEST_F(CopySplitTest, BufferOffset) {
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
@ -426,7 +442,8 @@ TEST_F(CopySplitTest, RowPitch) {
|
||||||
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
TextureCopySplit copySplit = DoTest(textureSpec, bufferSpec);
|
||||||
if (HasFatalFailure()) {
|
if (HasFatalFailure()) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec << std::endl
|
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||||
|
<< std::endl
|
||||||
<< copySplit << std::endl;
|
<< copySplit << std::endl;
|
||||||
FAIL() << message.str();
|
FAIL() << message.str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,16 +121,10 @@ TEST_F(BindGroupValidationTest, BindingSetTwice) {
|
||||||
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
|
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}});
|
||||||
|
|
||||||
// Control case: check that different bindings work
|
// Control case: check that different bindings work
|
||||||
utils::MakeBindGroup(device, layout, {
|
utils::MakeBindGroup(device, layout, {{0, mSampler}, {1, mSampler}});
|
||||||
{0, mSampler},
|
|
||||||
{1, mSampler}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Check that setting the same binding twice is invalid
|
// Check that setting the same binding twice is invalid
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, mSampler}, {0, mSampler}}));
|
||||||
{0, mSampler},
|
|
||||||
{0, mSampler}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that a sampler binding must contain exactly one sampler
|
// 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}});
|
utils::MakeBindGroup(device, layout, {{0, buffer, 0, 256}});
|
||||||
|
|
||||||
// Success case, touching the end of the buffer works
|
// 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.
|
// Error case, zero size is invalid.
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 0}}));
|
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}});
|
utils::MakeBindGroup(device, layout, {{0, buffer, 256, wgpu::kWholeSize}});
|
||||||
|
|
||||||
// Error case, offset is OOB
|
// 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
|
// 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
|
// Error case, offset+size is OOB
|
||||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 256}}));
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, buffer, 1024, 256}}));
|
||||||
|
|
||||||
// Error case, offset+size overflows to be 0
|
// 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
|
// 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
|
// 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
|
// 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
|
// end of the buffer. Any mismatch applying too-large of an offset to a smaller buffer will hit
|
||||||
// out-of-bounds condition during validation.
|
// the out-of-bounds condition during validation.
|
||||||
wgpu::Buffer buffer3x =
|
wgpu::Buffer buffer3x =
|
||||||
CreateBuffer(3 * kMinDynamicBufferOffsetAlignment + 4, wgpu::BufferUsage::Storage);
|
CreateBuffer(3 * kMinDynamicBufferOffsetAlignment + 4, wgpu::BufferUsage::Storage);
|
||||||
wgpu::Buffer buffer2x =
|
wgpu::Buffer buffer2x =
|
||||||
|
@ -1487,7 +1482,6 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
|
||||||
wgpu::RenderPipeline CreateFSRenderPipeline(
|
wgpu::RenderPipeline CreateFSRenderPipeline(
|
||||||
const char* fsShader,
|
const char* fsShader,
|
||||||
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
|
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
|
||||||
|
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
|
|
|
@ -416,7 +416,8 @@ TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
|
||||||
WaitForAllOperations(device);
|
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) {
|
TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
|
||||||
wgpu::Buffer buf = CreateMapReadBuffer(4);
|
wgpu::Buffer buf = CreateMapReadBuffer(4);
|
||||||
|
|
||||||
|
@ -429,7 +430,8 @@ TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
|
||||||
WaitForAllOperations(device);
|
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) {
|
TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
|
||||||
wgpu::Buffer buf = CreateMapWriteBuffer(4);
|
wgpu::Buffer buf = CreateMapWriteBuffer(4);
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class CommandBufferValidationTest : public ValidationTest {
|
class CommandBufferValidationTest : public ValidationTest {};
|
||||||
};
|
|
||||||
|
|
||||||
// Test for an empty command buffer
|
// Test for an empty command buffer
|
||||||
TEST_F(CommandBufferValidationTest, Empty) {
|
TEST_F(CommandBufferValidationTest, Empty) {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#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) {
|
TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {
|
||||||
{
|
{
|
||||||
wgpu::Texture source = Create2DTexture(16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8,
|
wgpu::Texture source = Create2DTexture(
|
||||||
wgpu::TextureUsage::CopySrc);
|
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopySrc);
|
||||||
wgpu::Texture destination = Create2DTexture(
|
wgpu::Texture destination = Create2DTexture(
|
||||||
16, 16, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
|
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::Texture source = Create2DTexture(
|
||||||
wgpu::TextureUsage::CopySrc);
|
16, 16, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopySrc);
|
||||||
wgpu::Texture destination = Create2DTexture(
|
wgpu::Texture destination = Create2DTexture(
|
||||||
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
|
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::Texture source = Create2DTexture(
|
||||||
wgpu::TextureUsage::CopySrc);
|
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopySrc);
|
||||||
wgpu::Texture destination = Create2DTexture(
|
wgpu::Texture destination = Create2DTexture(
|
||||||
16, 16, 1, 3, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureUsage::CopyDst);
|
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 to check basic use of SetScissor
|
||||||
TEST_F(SetScissorRectTest, Success) {
|
TEST_F(SetScissorRectTest, Success) {
|
||||||
|
@ -284,8 +283,7 @@ TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) {
|
||||||
encoder.Finish();
|
encoder.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
class SetBlendColorTest : public ValidationTest {
|
class SetBlendColorTest : public ValidationTest {};
|
||||||
};
|
|
||||||
|
|
||||||
// Test to check basic use of SetBlendColor
|
// Test to check basic use of SetBlendColor
|
||||||
TEST_F(SetBlendColorTest, Success) {
|
TEST_F(SetBlendColorTest, Success) {
|
||||||
|
@ -315,8 +313,7 @@ TEST_F(SetBlendColorTest, AnyValueAllowed) {
|
||||||
encoder.Finish();
|
encoder.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
class SetStencilReferenceTest : public ValidationTest {
|
class SetStencilReferenceTest : public ValidationTest {};
|
||||||
};
|
|
||||||
|
|
||||||
// Test to check basic use of SetStencilReferenceTest
|
// Test to check basic use of SetStencilReferenceTest
|
||||||
TEST_F(SetStencilReferenceTest, Success) {
|
TEST_F(SetStencilReferenceTest, Success) {
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class QueueSubmitValidationTest : public ValidationTest {
|
class QueueSubmitValidationTest : public ValidationTest {};
|
||||||
};
|
|
||||||
|
|
||||||
// Test submitting with a mapped buffer is disallowed
|
// Test submitting with a mapped buffer is disallowed
|
||||||
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
||||||
// Create a map-write buffer.
|
// Create a map-write buffer.
|
||||||
wgpu::BufferDescriptor descriptor;
|
wgpu::BufferDescriptor descriptor;
|
||||||
descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
|
descriptor.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
|
||||||
|
@ -60,9 +59,9 @@ TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
||||||
// Unmap the buffer, queue submit should succeed
|
// Unmap the buffer, queue submit should succeed
|
||||||
buffer.Unmap();
|
buffer.Unmap();
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
class QueueWriteBufferValidationTest : public ValidationTest {
|
class QueueWriteBufferValidationTest : public ValidationTest {
|
||||||
private:
|
private:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
ValidationTest::SetUp();
|
ValidationTest::SetUp();
|
||||||
|
@ -78,26 +77,26 @@ class QueueWriteBufferValidationTest : public ValidationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::Queue queue;
|
wgpu::Queue queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test the success case for WriteBuffer
|
// Test the success case for WriteBuffer
|
||||||
TEST_F(QueueWriteBufferValidationTest, Success) {
|
TEST_F(QueueWriteBufferValidationTest, Success) {
|
||||||
wgpu::Buffer buf = CreateBuffer(4);
|
wgpu::Buffer buf = CreateBuffer(4);
|
||||||
|
|
||||||
uint32_t foo = 0x01020304;
|
uint32_t foo = 0x01020304;
|
||||||
queue.WriteBuffer(buf, 0, &foo, sizeof(foo));
|
queue.WriteBuffer(buf, 0, &foo, sizeof(foo));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test error case for WriteBuffer out of bounds
|
// Test error case for WriteBuffer out of bounds
|
||||||
TEST_F(QueueWriteBufferValidationTest, OutOfBounds) {
|
TEST_F(QueueWriteBufferValidationTest, OutOfBounds) {
|
||||||
wgpu::Buffer buf = CreateBuffer(4);
|
wgpu::Buffer buf = CreateBuffer(4);
|
||||||
|
|
||||||
uint32_t foo[2] = {0, 0};
|
uint32_t foo[2] = {0, 0};
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, foo, 8));
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, foo, 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test error case for WriteBuffer out of bounds with an overflow
|
// Test error case for WriteBuffer out of bounds with an overflow
|
||||||
TEST_F(QueueWriteBufferValidationTest, OutOfBoundsOverflow) {
|
TEST_F(QueueWriteBufferValidationTest, OutOfBoundsOverflow) {
|
||||||
wgpu::Buffer buf = CreateBuffer(1024);
|
wgpu::Buffer buf = CreateBuffer(1024);
|
||||||
|
|
||||||
uint32_t foo[2] = {0, 0};
|
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));
|
uint64_t offset = uint64_t(int64_t(0) - int64_t(4));
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, offset, foo, 4));
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, offset, foo, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test error case for WriteBuffer with the wrong usage
|
// Test error case for WriteBuffer with the wrong usage
|
||||||
TEST_F(QueueWriteBufferValidationTest, WrongUsage) {
|
TEST_F(QueueWriteBufferValidationTest, WrongUsage) {
|
||||||
wgpu::BufferDescriptor descriptor;
|
wgpu::BufferDescriptor descriptor;
|
||||||
descriptor.size = 4;
|
descriptor.size = 4;
|
||||||
descriptor.usage = wgpu::BufferUsage::Vertex;
|
descriptor.usage = wgpu::BufferUsage::Vertex;
|
||||||
|
@ -118,35 +117,35 @@ TEST_F(QueueWriteBufferValidationTest, WrongUsage) {
|
||||||
|
|
||||||
uint32_t foo = 0;
|
uint32_t foo = 0;
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &foo, sizeof(foo)));
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &foo, sizeof(foo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test WriteBuffer with unaligned size
|
// Test WriteBuffer with unaligned size
|
||||||
TEST_F(QueueWriteBufferValidationTest, UnalignedSize) {
|
TEST_F(QueueWriteBufferValidationTest, UnalignedSize) {
|
||||||
wgpu::Buffer buf = CreateBuffer(4);
|
wgpu::Buffer buf = CreateBuffer(4);
|
||||||
|
|
||||||
uint16_t value = 123;
|
uint16_t value = 123;
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test WriteBuffer with unaligned offset
|
// Test WriteBuffer with unaligned offset
|
||||||
TEST_F(QueueWriteBufferValidationTest, UnalignedOffset) {
|
TEST_F(QueueWriteBufferValidationTest, UnalignedOffset) {
|
||||||
wgpu::Buffer buf = CreateBuffer(8);
|
wgpu::Buffer buf = CreateBuffer(8);
|
||||||
|
|
||||||
uint32_t value = 0x01020304;
|
uint32_t value = 0x01020304;
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 2, &value, sizeof(value)));
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 2, &value, sizeof(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test WriteBuffer with destroyed buffer
|
// Test WriteBuffer with destroyed buffer
|
||||||
TEST_F(QueueWriteBufferValidationTest, DestroyedBuffer) {
|
TEST_F(QueueWriteBufferValidationTest, DestroyedBuffer) {
|
||||||
wgpu::Buffer buf = CreateBuffer(4);
|
wgpu::Buffer buf = CreateBuffer(4);
|
||||||
buf.Destroy();
|
buf.Destroy();
|
||||||
|
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test WriteBuffer with mapped buffer
|
// Test WriteBuffer with mapped buffer
|
||||||
TEST_F(QueueWriteBufferValidationTest, MappedBuffer) {
|
TEST_F(QueueWriteBufferValidationTest, MappedBuffer) {
|
||||||
// CreateBufferMapped
|
// CreateBufferMapped
|
||||||
{
|
{
|
||||||
wgpu::BufferDescriptor descriptor;
|
wgpu::BufferDescriptor descriptor;
|
||||||
|
@ -193,6 +192,6 @@ TEST_F(QueueWriteBufferValidationTest, MappedBuffer) {
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
ASSERT_DEVICE_ERROR(queue.WriteBuffer(buf, 0, &value, sizeof(value)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class RenderPassDescriptorValidationTest : public ValidationTest {
|
class RenderPassDescriptorValidationTest : public ValidationTest {
|
||||||
public:
|
public:
|
||||||
void AssertBeginRenderPassSuccess(const wgpu::RenderPassDescriptor* descriptor) {
|
void AssertBeginRenderPassSuccess(const wgpu::RenderPassDescriptor* descriptor) {
|
||||||
wgpu::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor);
|
wgpu::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor);
|
||||||
|
@ -40,9 +40,9 @@ class RenderPassDescriptorValidationTest : public ValidationTest {
|
||||||
renderPassEncoder.EndPass();
|
renderPassEncoder.EndPass();
|
||||||
return commandEncoder;
|
return commandEncoder;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
wgpu::Texture CreateTexture(wgpu::Device& device,
|
wgpu::Texture CreateTexture(wgpu::Device& device,
|
||||||
wgpu::TextureDimension dimension,
|
wgpu::TextureDimension dimension,
|
||||||
wgpu::TextureFormat format,
|
wgpu::TextureFormat format,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
|
@ -62,28 +62,29 @@ wgpu::Texture CreateTexture(wgpu::Device& device,
|
||||||
descriptor.usage = usage;
|
descriptor.usage = usage;
|
||||||
|
|
||||||
return device.CreateTexture(&descriptor);
|
return device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::TextureView Create2DAttachment(wgpu::Device& device,
|
wgpu::TextureView Create2DAttachment(wgpu::Device& device,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
wgpu::TextureFormat format) {
|
wgpu::TextureFormat format) {
|
||||||
wgpu::Texture texture =
|
wgpu::Texture texture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, format, width, height, 1, 1);
|
CreateTexture(device, wgpu::TextureDimension::e2D, format, width, height, 1, 1);
|
||||||
return texture.CreateView();
|
return texture.CreateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using BeginRenderPass with no attachments isn't valid
|
// Using BeginRenderPass with no attachments isn't valid
|
||||||
TEST_F(RenderPassDescriptorValidationTest, Empty) {
|
TEST_F(RenderPassDescriptorValidationTest, Empty) {
|
||||||
utils::ComboRenderPassDescriptor renderPass({}, nullptr);
|
utils::ComboRenderPassDescriptor renderPass({}, nullptr);
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// A render pass with only one color or one depth attachment is ok
|
// A render pass with only one color or one depth attachment is ok
|
||||||
TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
||||||
// One color attachment
|
// 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});
|
utils::ComboRenderPassDescriptor renderPass({color});
|
||||||
|
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
|
@ -96,14 +97,18 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
||||||
|
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test OOB color attachment indices are handled
|
// Test OOB color attachment indices are handled
|
||||||
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
|
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
|
||||||
wgpu::TextureView color0 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
wgpu::TextureView color0 =
|
||||||
wgpu::TextureView color1 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
||||||
wgpu::TextureView color2 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
wgpu::TextureView color1 =
|
||||||
wgpu::TextureView color3 = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
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
|
// For setting the color attachment, control case
|
||||||
{
|
{
|
||||||
utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3});
|
utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3});
|
||||||
|
@ -139,13 +144,16 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
|
||||||
renderPass.depthStencilAttachment = nullptr;
|
renderPass.depthStencilAttachment = nullptr;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attachments must have the same size
|
// Attachments must have the same size
|
||||||
TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
|
TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
|
||||||
wgpu::TextureView color1x1A = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
wgpu::TextureView color1x1A =
|
||||||
wgpu::TextureView color1x1B = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
||||||
wgpu::TextureView color2x2 = Create2DAttachment(device, 2, 2, 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 =
|
wgpu::TextureView depthStencil1x1 =
|
||||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
|
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
|
||||||
|
@ -169,10 +177,10 @@ TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
|
||||||
utils::ComboRenderPassDescriptor renderPass({color1x1A, color1x1B}, depthStencil2x2);
|
utils::ComboRenderPassDescriptor renderPass({color1x1A, color1x1B}, depthStencil2x2);
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attachments formats must match whether they are used for color or depth-stencil
|
// Attachments formats must match whether they are used for color or depth-stencil
|
||||||
TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
||||||
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
||||||
wgpu::TextureView depthStencil =
|
wgpu::TextureView depthStencil =
|
||||||
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
|
Create2DAttachment(device, 1, 1, wgpu::TextureFormat::Depth24PlusStencil8);
|
||||||
|
@ -188,18 +196,20 @@ TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
||||||
utils::ComboRenderPassDescriptor renderPass({}, color);
|
utils::ComboRenderPassDescriptor renderPass({}, color);
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Depth and stencil storeOps must match
|
// Depth and stencil storeOps must match
|
||||||
TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
|
TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
|
||||||
constexpr uint32_t kArrayLayers = 1;
|
constexpr uint32_t kArrayLayers = 1;
|
||||||
constexpr uint32_t kLevelCount = 1;
|
constexpr uint32_t kLevelCount = 1;
|
||||||
constexpr uint32_t kSize = 32;
|
constexpr uint32_t kSize = 32;
|
||||||
constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
|
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,
|
wgpu::Texture colorTexture =
|
||||||
kSize, kSize, kArrayLayers, kLevelCount);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
|
kArrayLayers, kLevelCount);
|
||||||
wgpu::Texture depthStencilTexture =
|
wgpu::Texture depthStencilTexture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
||||||
kArrayLayers, kLevelCount);
|
kArrayLayers, kLevelCount);
|
||||||
|
@ -236,20 +246,22 @@ TEST_F(RenderPassDescriptorValidationTest, DepthStencilStoreOpMismatch) {
|
||||||
renderPass.cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Clear;
|
renderPass.cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Clear;
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently only texture views with arrayLayerCount == 1 are allowed to be color and depth stencil
|
// Currently only texture views with arrayLayerCount == 1 are allowed to be color and depth
|
||||||
// attachments
|
// stencil attachments
|
||||||
TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepthStencil) {
|
TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepthStencil) {
|
||||||
constexpr uint32_t kLevelCount = 1;
|
constexpr uint32_t kLevelCount = 1;
|
||||||
constexpr uint32_t kSize = 32;
|
constexpr uint32_t kSize = 32;
|
||||||
constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
|
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;
|
constexpr uint32_t kArrayLayers = 10;
|
||||||
|
|
||||||
wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
|
wgpu::Texture colorTexture =
|
||||||
kSize, kSize, kArrayLayers, kLevelCount);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
|
kArrayLayers, kLevelCount);
|
||||||
wgpu::Texture depthStencilTexture =
|
wgpu::Texture depthStencilTexture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
||||||
kArrayLayers, kLevelCount);
|
kArrayLayers, kLevelCount);
|
||||||
|
@ -330,19 +342,21 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
||||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only 2D texture views with mipLevelCount == 1 are allowed to be color attachments
|
// Only 2D texture views with mipLevelCount == 1 are allowed to be color attachments
|
||||||
TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepthStencil) {
|
TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepthStencil) {
|
||||||
constexpr uint32_t kArrayLayers = 1;
|
constexpr uint32_t kArrayLayers = 1;
|
||||||
constexpr uint32_t kSize = 32;
|
constexpr uint32_t kSize = 32;
|
||||||
constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
|
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;
|
constexpr uint32_t kLevelCount = 4;
|
||||||
|
|
||||||
wgpu::Texture colorTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
|
wgpu::Texture colorTexture =
|
||||||
kSize, kSize, kArrayLayers, kLevelCount);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
|
kArrayLayers, kLevelCount);
|
||||||
wgpu::Texture depthStencilTexture =
|
wgpu::Texture depthStencilTexture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
||||||
kArrayLayers, kLevelCount);
|
kArrayLayers, kLevelCount);
|
||||||
|
@ -423,10 +437,10 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
||||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to set resolve target when the color attachment is non-multisampled.
|
// It is not allowed to set resolve target when the color attachment is non-multisampled.
|
||||||
TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget) {
|
TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget) {
|
||||||
static constexpr uint32_t kArrayLayers = 1;
|
static constexpr uint32_t kArrayLayers = 1;
|
||||||
static constexpr uint32_t kLevelCount = 1;
|
static constexpr uint32_t kLevelCount = 1;
|
||||||
static constexpr uint32_t kSize = 32;
|
static constexpr uint32_t kSize = 32;
|
||||||
|
@ -434,20 +448,21 @@ TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget
|
||||||
static constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
|
static constexpr wgpu::TextureFormat kColorFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
|
|
||||||
wgpu::Texture colorTexture =
|
wgpu::Texture colorTexture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
kLevelCount, kSampleCount);
|
kArrayLayers, kLevelCount, kSampleCount);
|
||||||
wgpu::Texture resolveTargetTexture =
|
wgpu::Texture resolveTargetTexture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
kLevelCount, kSampleCount);
|
kArrayLayers, kLevelCount, kSampleCount);
|
||||||
wgpu::TextureView colorTextureView = colorTexture.CreateView();
|
wgpu::TextureView colorTextureView = colorTexture.CreateView();
|
||||||
wgpu::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView();
|
wgpu::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView();
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||||
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescriptorValidationTest {
|
class MultisampledRenderPassDescriptorValidationTest
|
||||||
|
: public RenderPassDescriptorValidationTest {
|
||||||
public:
|
public:
|
||||||
utils::ComboRenderPassDescriptor CreateMultisampledRenderPass() {
|
utils::ComboRenderPassDescriptor CreateMultisampledRenderPass() {
|
||||||
return utils::ComboRenderPassDescriptor({CreateMultisampledColorTextureView()});
|
return utils::ComboRenderPassDescriptor({CreateMultisampledColorTextureView()});
|
||||||
|
@ -475,10 +490,10 @@ class MultisampledRenderPassDescriptorValidationTest : public RenderPassDescript
|
||||||
|
|
||||||
return colorTexture.CreateView();
|
return colorTexture.CreateView();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tests on the use of multisampled textures as color attachments
|
// Tests on the use of multisampled textures as color attachments
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachments) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachments) {
|
||||||
wgpu::TextureView colorTextureView = CreateNonMultisampledColorTextureView();
|
wgpu::TextureView colorTextureView = CreateNonMultisampledColorTextureView();
|
||||||
wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
|
wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
|
||||||
wgpu::TextureView multisampledColorTextureView = CreateMultisampledColorTextureView();
|
wgpu::TextureView multisampledColorTextureView = CreateMultisampledColorTextureView();
|
||||||
|
@ -495,59 +510,64 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorAttachme
|
||||||
{multisampledColorTextureView, colorTextureView});
|
{multisampledColorTextureView, colorTextureView});
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to use a multisampled resolve target.
|
// It is not allowed to use a multisampled resolve target.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget) {
|
||||||
wgpu::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView();
|
wgpu::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView();
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView;
|
renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to use a resolve target with array layer count > 1.
|
// It is not allowed to use a resolve target with array layer count > 1.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMoreThanOne) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMoreThanOne) {
|
||||||
constexpr uint32_t kArrayLayers2 = 2;
|
constexpr uint32_t kArrayLayers2 = 2;
|
||||||
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
|
wgpu::Texture resolveTexture =
|
||||||
kSize, kSize, kArrayLayers2, kLevelCount);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
|
kArrayLayers2, kLevelCount);
|
||||||
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
|
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to use a resolve target with mipmap level count > 1.
|
// It is not allowed to use a resolve target with mipmap level count > 1.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelMoreThanOne) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelMoreThanOne) {
|
||||||
constexpr uint32_t kLevelCount2 = 2;
|
constexpr uint32_t kLevelCount2 = 2;
|
||||||
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
|
wgpu::Texture resolveTexture =
|
||||||
kSize, kSize, kArrayLayers, kLevelCount2);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
|
kArrayLayers, kLevelCount2);
|
||||||
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
|
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to use a resolve target which is created from a texture whose usage does not
|
// It is not allowed to use a resolve target which is created from a texture whose usage does
|
||||||
// include wgpu::TextureUsage::OutputAttachment.
|
// not include wgpu::TextureUsage::OutputAttachment.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutputAttachment) {
|
||||||
constexpr wgpu::TextureUsage kUsage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
|
constexpr wgpu::TextureUsage kUsage =
|
||||||
|
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::CopySrc;
|
||||||
wgpu::Texture nonColorUsageResolveTexture =
|
wgpu::Texture nonColorUsageResolveTexture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers,
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
kLevelCount, 1, kUsage);
|
kArrayLayers, kLevelCount, 1, kUsage);
|
||||||
wgpu::TextureView nonColorUsageResolveTextureView = nonColorUsageResolveTexture.CreateView();
|
wgpu::TextureView nonColorUsageResolveTextureView =
|
||||||
|
nonColorUsageResolveTexture.CreateView();
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = nonColorUsageResolveTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = nonColorUsageResolveTextureView;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to use a resolve target which is in error state.
|
// It is not allowed to use a resolve target which is in error state.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState) {
|
||||||
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
|
wgpu::Texture resolveTexture =
|
||||||
kSize, kSize, kArrayLayers, kLevelCount);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize, kSize,
|
||||||
|
kArrayLayers, kLevelCount);
|
||||||
wgpu::TextureViewDescriptor errorTextureView;
|
wgpu::TextureViewDescriptor errorTextureView;
|
||||||
errorTextureView.dimension = wgpu::TextureViewDimension::e2D;
|
errorTextureView.dimension = wgpu::TextureViewDimension::e2D;
|
||||||
errorTextureView.format = kColorFormat;
|
errorTextureView.format = kColorFormat;
|
||||||
|
@ -558,34 +578,37 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget;
|
renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is allowed to use a multisampled color attachment and a non-multisampled resolve target.
|
// It is allowed to use a multisampled color attachment and a non-multisampled resolve target.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithResolveTarget) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithResolveTarget) {
|
||||||
wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
|
wgpu::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is not allowed to use a resolve target in a format different from the color attachment.
|
// It is not allowed to use a resolve target in a format different from the color attachment.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFormat) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFormat) {
|
||||||
constexpr wgpu::TextureFormat kColorFormat2 = wgpu::TextureFormat::BGRA8Unorm;
|
constexpr wgpu::TextureFormat kColorFormat2 = wgpu::TextureFormat::BGRA8Unorm;
|
||||||
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat2,
|
wgpu::Texture resolveTexture =
|
||||||
kSize, kSize, kArrayLayers, kLevelCount);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat2, kSize, kSize,
|
||||||
|
kArrayLayers, kLevelCount);
|
||||||
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
|
wgpu::TextureView resolveTextureView = resolveTexture.CreateView();
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||||
AssertBeginRenderPassError(&renderPass);
|
AssertBeginRenderPassError(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests on the size of the resolve target.
|
// Tests on the size of the resolve target.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTargetCompatibility) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest,
|
||||||
|
ColorAttachmentResolveTargetCompatibility) {
|
||||||
constexpr uint32_t kSize2 = kSize * 2;
|
constexpr uint32_t kSize2 = kSize * 2;
|
||||||
wgpu::Texture resolveTexture = CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat,
|
wgpu::Texture resolveTexture =
|
||||||
kSize2, kSize2, kArrayLayers, kLevelCount + 1);
|
CreateTexture(device, wgpu::TextureDimension::e2D, kColorFormat, kSize2, kSize2,
|
||||||
|
kArrayLayers, kLevelCount + 1);
|
||||||
|
|
||||||
wgpu::TextureViewDescriptor textureViewDescriptor;
|
wgpu::TextureViewDescriptor textureViewDescriptor;
|
||||||
textureViewDescriptor.nextInChain = nullptr;
|
textureViewDescriptor.nextInChain = nullptr;
|
||||||
|
@ -599,7 +622,8 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
|
||||||
wgpu::TextureViewDescriptor firstMipLevelDescriptor = textureViewDescriptor;
|
wgpu::TextureViewDescriptor firstMipLevelDescriptor = textureViewDescriptor;
|
||||||
firstMipLevelDescriptor.baseMipLevel = 0;
|
firstMipLevelDescriptor.baseMipLevel = 0;
|
||||||
|
|
||||||
wgpu::TextureView resolveTextureView = resolveTexture.CreateView(&firstMipLevelDescriptor);
|
wgpu::TextureView resolveTextureView =
|
||||||
|
resolveTexture.CreateView(&firstMipLevelDescriptor);
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||||
|
@ -610,47 +634,49 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
|
||||||
wgpu::TextureViewDescriptor secondMipLevelDescriptor = textureViewDescriptor;
|
wgpu::TextureViewDescriptor secondMipLevelDescriptor = textureViewDescriptor;
|
||||||
secondMipLevelDescriptor.baseMipLevel = 1;
|
secondMipLevelDescriptor.baseMipLevel = 1;
|
||||||
|
|
||||||
wgpu::TextureView resolveTextureView = resolveTexture.CreateView(&secondMipLevelDescriptor);
|
wgpu::TextureView resolveTextureView =
|
||||||
|
resolveTexture.CreateView(&secondMipLevelDescriptor);
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
|
||||||
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests on the sample count of depth stencil attachment.
|
// Tests on the sample count of depth stencil attachment.
|
||||||
TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSampleCount) {
|
TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSampleCount) {
|
||||||
constexpr wgpu::TextureFormat kDepthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
|
constexpr wgpu::TextureFormat kDepthStencilFormat =
|
||||||
|
wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
wgpu::Texture multisampledDepthStencilTexture =
|
wgpu::Texture multisampledDepthStencilTexture =
|
||||||
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
CreateTexture(device, wgpu::TextureDimension::e2D, kDepthStencilFormat, kSize, kSize,
|
||||||
kArrayLayers, kLevelCount, kSampleCount);
|
kArrayLayers, kLevelCount, kSampleCount);
|
||||||
wgpu::TextureView multisampledDepthStencilTextureView =
|
wgpu::TextureView multisampledDepthStencilTextureView =
|
||||||
multisampledDepthStencilTexture.CreateView();
|
multisampledDepthStencilTexture.CreateView();
|
||||||
|
|
||||||
// It is not allowed to use a depth stencil attachment whose sample count is different from the
|
// It is not allowed to use a depth stencil attachment whose sample count is different from
|
||||||
// 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
|
|
||||||
// the one of the color attachment.
|
// the one of the color attachment.
|
||||||
{
|
{
|
||||||
utils::ComboRenderPassDescriptor renderPass(
|
wgpu::Texture depthStencilTexture =
|
||||||
{CreateMultisampledColorTextureView()}, multisampledDepthStencilTextureView);
|
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);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,11 +686,11 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, DepthStencilAttachmentSam
|
||||||
utils::ComboRenderPassDescriptor renderPass({}, multisampledDepthStencilTextureView);
|
utils::ComboRenderPassDescriptor renderPass({}, multisampledDepthStencilTextureView);
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that NaN cannot be accepted as a valid color or depth clear value and INFINITY is valid in
|
// Tests that NaN cannot be accepted as a valid color or depth clear value and INFINITY is valid
|
||||||
// both color and depth clear values.
|
// in both color and depth clear values.
|
||||||
TEST_F(RenderPassDescriptorValidationTest, UseNaNOrINFINITYAsColorOrDepthClearValue) {
|
TEST_F(RenderPassDescriptorValidationTest, UseNaNOrINFINITYAsColorOrDepthClearValue) {
|
||||||
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
wgpu::TextureView color = Create2DAttachment(device, 1, 1, wgpu::TextureFormat::RGBA8Unorm);
|
||||||
|
|
||||||
// Tests that NaN cannot be used in clearColor.
|
// Tests that NaN cannot be used in clearColor.
|
||||||
|
@ -734,8 +760,8 @@ TEST_F(RenderPassDescriptorValidationTest, UseNaNOrINFINITYAsColorOrDepthClearVa
|
||||||
renderPass.cDepthStencilAttachmentInfo.clearDepth = INFINITY;
|
renderPass.cDepthStencilAttachmentInfo.clearDepth = INFINITY;
|
||||||
AssertBeginRenderPassSuccess(&renderPass);
|
AssertBeginRenderPassSuccess(&renderPass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(cwallez@chromium.org): Constraints on attachment aliasing?
|
// TODO(cwallez@chromium.org): Constraints on attachment aliasing?
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
class ShaderModuleValidationTest : public ValidationTest {
|
class ShaderModuleValidationTest : public ValidationTest {};
|
||||||
};
|
|
||||||
|
|
||||||
// Test case with a simpler shader that should successfully be created
|
// Test case with a simpler shader that should successfully be created
|
||||||
TEST_F(ShaderModuleValidationTest, CreationSuccess) {
|
TEST_F(ShaderModuleValidationTest, CreationSuccess) {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class TextureValidationTest : public ValidationTest {
|
class TextureValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
queue = device.GetDefaultQueue();
|
queue = device.GetDefaultQueue();
|
||||||
|
@ -49,11 +49,12 @@ class TextureValidationTest : public ValidationTest {
|
||||||
static constexpr uint32_t kDefaultMipLevels = 1;
|
static constexpr uint32_t kDefaultMipLevels = 1;
|
||||||
static constexpr uint32_t kDefaultSampleCount = 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 the validation of sample count
|
||||||
TEST_F(TextureValidationTest, SampleCount) {
|
TEST_F(TextureValidationTest, SampleCount) {
|
||||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
||||||
// sampleCount == 1 is allowed.
|
// sampleCount == 1 is allowed.
|
||||||
|
@ -106,10 +107,10 @@ TEST_F(TextureValidationTest, SampleCount) {
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the validation of the mip level count
|
// Test the validation of the mip level count
|
||||||
TEST_F(TextureValidationTest, MipLevelCount) {
|
TEST_F(TextureValidationTest, MipLevelCount) {
|
||||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
||||||
// mipLevelCount == 1 is allowed
|
// mipLevelCount == 1 is allowed
|
||||||
|
@ -195,9 +196,9 @@ TEST_F(TextureValidationTest, MipLevelCount) {
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Test the validation of array layer count
|
// Test the validation of array layer count
|
||||||
TEST_F(TextureValidationTest, ArrayLayerCount) {
|
TEST_F(TextureValidationTest, ArrayLayerCount) {
|
||||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
||||||
// Array layer count exceeding kMaxTexture2DArrayLayers is not allowed
|
// Array layer count exceeding kMaxTexture2DArrayLayers is not allowed
|
||||||
|
@ -223,10 +224,10 @@ TEST_F(TextureValidationTest, ArrayLayerCount) {
|
||||||
|
|
||||||
device.CreateTexture(&descriptor);
|
device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the validation of texture size
|
// Test the validation of texture size
|
||||||
TEST_F(TextureValidationTest, TextureSize) {
|
TEST_F(TextureValidationTest, TextureSize) {
|
||||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
||||||
// Texture size exceeding kMaxTextureSize is not allowed
|
// Texture size exceeding kMaxTextureSize is not allowed
|
||||||
|
@ -255,26 +256,26 @@ TEST_F(TextureValidationTest, TextureSize) {
|
||||||
|
|
||||||
device.CreateTexture(&descriptor);
|
device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that it is valid to destroy a texture
|
// Test that it is valid to destroy a texture
|
||||||
TEST_F(TextureValidationTest, DestroyTexture) {
|
TEST_F(TextureValidationTest, DestroyTexture) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||||
texture.Destroy();
|
texture.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that it's valid to destroy a destroyed texture
|
// Test that it's valid to destroy a destroyed texture
|
||||||
TEST_F(TextureValidationTest, DestroyDestroyedTexture) {
|
TEST_F(TextureValidationTest, DestroyDestroyedTexture) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||||
texture.Destroy();
|
texture.Destroy();
|
||||||
texture.Destroy();
|
texture.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that it's invalid to submit a destroyed texture in a queue
|
// Test that it's invalid to submit a destroyed texture in a queue
|
||||||
// in the case of destroy, encode, submit
|
// in the case of destroy, encode, submit
|
||||||
TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
|
TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||||
wgpu::TextureView textureView = texture.CreateView();
|
wgpu::TextureView textureView = texture.CreateView();
|
||||||
|
@ -293,11 +294,11 @@ TEST_F(TextureValidationTest, DestroyEncodeSubmit) {
|
||||||
|
|
||||||
// Submit should fail due to destroyed texture
|
// Submit should fail due to destroyed texture
|
||||||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that it's invalid to submit a destroyed texture in a queue
|
// Test that it's invalid to submit a destroyed texture in a queue
|
||||||
// in the case of encode, destroy, submit
|
// in the case of encode, destroy, submit
|
||||||
TEST_F(TextureValidationTest, EncodeDestroySubmit) {
|
TEST_F(TextureValidationTest, EncodeDestroySubmit) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||||
wgpu::TextureView textureView = texture.CreateView();
|
wgpu::TextureView textureView = texture.CreateView();
|
||||||
|
@ -316,10 +317,10 @@ TEST_F(TextureValidationTest, EncodeDestroySubmit) {
|
||||||
|
|
||||||
// Submit should fail due to destroyed texture
|
// Submit should fail due to destroyed texture
|
||||||
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test it is an error to create an OutputAttachment texture with a non-renderable format.
|
// Test it is an error to create an OutputAttachment texture with a non-renderable format.
|
||||||
TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
|
TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
|
||||||
wgpu::TextureDescriptor descriptor;
|
wgpu::TextureDescriptor descriptor;
|
||||||
descriptor.size = {1, 1, 1};
|
descriptor.size = {1, 1, 1};
|
||||||
descriptor.usage = wgpu::TextureUsage::OutputAttachment;
|
descriptor.usage = wgpu::TextureUsage::OutputAttachment;
|
||||||
|
@ -340,11 +341,11 @@ TEST_F(TextureValidationTest, NonRenderableAndOutputAttachment) {
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test it is an error to create a Storage texture with any format that doesn't support
|
// Test it is an error to create a Storage texture with any format that doesn't support
|
||||||
// TextureUsage::Storage texture usages.
|
// TextureUsage::Storage texture usages.
|
||||||
TEST_F(TextureValidationTest, TextureFormatNotSupportTextureUsageStorage) {
|
TEST_F(TextureValidationTest, TextureFormatNotSupportTextureUsageStorage) {
|
||||||
wgpu::TextureDescriptor descriptor;
|
wgpu::TextureDescriptor descriptor;
|
||||||
descriptor.size = {1, 1, 1};
|
descriptor.size = {1, 1, 1};
|
||||||
descriptor.usage = wgpu::TextureUsage::Storage;
|
descriptor.usage = wgpu::TextureUsage::Storage;
|
||||||
|
@ -357,18 +358,18 @@ TEST_F(TextureValidationTest, TextureFormatNotSupportTextureUsageStorage) {
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test it is an error to create a texture with format "Undefined".
|
// Test it is an error to create a texture with format "Undefined".
|
||||||
TEST_F(TextureValidationTest, TextureFormatUndefined) {
|
TEST_F(TextureValidationTest, TextureFormatUndefined) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
descriptor.format = wgpu::TextureFormat::Undefined;
|
descriptor.format = wgpu::TextureFormat::Undefined;
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with
|
// TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with
|
||||||
// compressed texture formats.
|
// compressed texture formats.
|
||||||
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||||
public:
|
public:
|
||||||
CompressedTextureFormatsValidationTests() : TextureValidationTest() {
|
CompressedTextureFormatsValidationTests() : TextureValidationTest() {
|
||||||
device = CreateDeviceFromAdapter(adapter, {"texture_compression_bc"});
|
device = CreateDeviceFromAdapter(adapter, {"texture_compression_bc"});
|
||||||
|
@ -378,8 +379,8 @@ class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||||
wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
|
wgpu::TextureDescriptor CreateDefaultTextureDescriptor() {
|
||||||
wgpu::TextureDescriptor descriptor =
|
wgpu::TextureDescriptor descriptor =
|
||||||
TextureValidationTest::CreateDefaultTextureDescriptor();
|
TextureValidationTest::CreateDefaultTextureDescriptor();
|
||||||
descriptor.usage =
|
descriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst |
|
||||||
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
|
wgpu::TextureUsage::Sampled;
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,10 +392,10 @@ class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||||
wgpu::TextureFormat::BC5RGUnorm, wgpu::TextureFormat::BC5RGSnorm,
|
wgpu::TextureFormat::BC5RGUnorm, wgpu::TextureFormat::BC5RGSnorm,
|
||||||
wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBSfloat,
|
wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBSfloat,
|
||||||
wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb};
|
wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test the validation of texture size when creating textures in compressed texture formats.
|
// Test the validation of texture size when creating textures in compressed texture formats.
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
||||||
// Test that it is invalid to use a number that is not a multiple of 4 (the compressed block
|
// 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.
|
// width and height of all BC formats) as the width or height of textures in BC formats.
|
||||||
for (wgpu::TextureFormat format : kBCFormats) {
|
for (wgpu::TextureFormat format : kBCFormats) {
|
||||||
|
@ -427,11 +428,11 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
||||||
device.CreateTexture(&descriptor);
|
device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the creation of a texture with BC format will fail when the extension textureCompressionBC
|
// Test the creation of a texture with BC format will fail when the extension
|
||||||
// is not enabled.
|
// textureCompressionBC is not enabled.
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtension) {
|
TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtension) {
|
||||||
const std::vector<const char*> kEmptyVector;
|
const std::vector<const char*> kEmptyVector;
|
||||||
wgpu::Device deviceWithoutExtension = CreateDeviceFromAdapter(adapter, kEmptyVector);
|
wgpu::Device deviceWithoutExtension = CreateDeviceFromAdapter(adapter, kEmptyVector);
|
||||||
for (wgpu::TextureFormat format : kBCFormats) {
|
for (wgpu::TextureFormat format : kBCFormats) {
|
||||||
|
@ -439,10 +440,10 @@ TEST_F(CompressedTextureFormatsValidationTests, UseBCFormatWithoutEnablingExtens
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
ASSERT_DEVICE_ERROR(deviceWithoutExtension.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(deviceWithoutExtension.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the validation of texture usages when creating textures in compressed texture formats.
|
// Test the validation of texture usages when creating textures in compressed texture formats.
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
||||||
// Test that only CopySrc, CopyDst and Sampled are accepted as the texture usage of the
|
// Test that only CopySrc, CopyDst and Sampled are accepted as the texture usage of the
|
||||||
// textures in BC formats.
|
// textures in BC formats.
|
||||||
for (wgpu::TextureFormat format : kBCFormats) {
|
for (wgpu::TextureFormat format : kBCFormats) {
|
||||||
|
@ -467,21 +468,22 @@ TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the validation of sample count when creating textures in compressed texture formats.
|
// Test the validation of sample count when creating textures in compressed texture formats.
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
|
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
|
||||||
// Test that it is invalid to specify SampleCount > 1 when we create a texture in BC formats.
|
// Test that it is invalid to specify SampleCount > 1 when we create a texture in BC
|
||||||
|
// formats.
|
||||||
for (wgpu::TextureFormat format : kBCFormats) {
|
for (wgpu::TextureFormat format : kBCFormats) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
descriptor.format = format;
|
descriptor.format = format;
|
||||||
descriptor.sampleCount = 4;
|
descriptor.sampleCount = 4;
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the validation of creating 2D array textures in compressed texture formats.
|
// Test the validation of creating 2D array textures in compressed texture formats.
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {
|
TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {
|
||||||
// Test that it is allowed to create a 2D array texture in BC formats.
|
// Test that it is allowed to create a 2D array texture in BC formats.
|
||||||
for (wgpu::TextureFormat format : kBCFormats) {
|
for (wgpu::TextureFormat format : kBCFormats) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
@ -489,6 +491,6 @@ TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {
|
||||||
descriptor.size.depth = 6;
|
descriptor.size.depth = 6;
|
||||||
device.CreateTexture(&descriptor);
|
device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -16,16 +16,15 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class TextureViewValidationTest : public ValidationTest {
|
class TextureViewValidationTest : public ValidationTest {};
|
||||||
};
|
|
||||||
|
|
||||||
constexpr uint32_t kWidth = 32u;
|
constexpr uint32_t kWidth = 32u;
|
||||||
constexpr uint32_t kHeight = 32u;
|
constexpr uint32_t kHeight = 32u;
|
||||||
constexpr uint32_t kDefaultMipLevels = 6u;
|
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 arrayLayerCount,
|
||||||
uint32_t width = kWidth,
|
uint32_t width = kWidth,
|
||||||
uint32_t height = kHeight,
|
uint32_t height = kHeight,
|
||||||
|
@ -41,9 +40,9 @@ wgpu::Texture Create2DArrayTexture(wgpu::Device& device,
|
||||||
descriptor.mipLevelCount = mipLevelCount;
|
descriptor.mipLevelCount = mipLevelCount;
|
||||||
descriptor.usage = wgpu::TextureUsage::Sampled;
|
descriptor.usage = wgpu::TextureUsage::Sampled;
|
||||||
return device.CreateTexture(&descriptor);
|
return device.CreateTexture(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) {
|
wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) {
|
||||||
wgpu::TextureViewDescriptor descriptor;
|
wgpu::TextureViewDescriptor descriptor;
|
||||||
descriptor.format = kDefaultTextureFormat;
|
descriptor.format = kDefaultTextureFormat;
|
||||||
descriptor.dimension = dimension;
|
descriptor.dimension = dimension;
|
||||||
|
@ -52,10 +51,10 @@ wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimensi
|
||||||
descriptor.baseArrayLayer = 0;
|
descriptor.baseArrayLayer = 0;
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test creating texture view on a 2D non-array texture
|
// Test creating texture view on a 2D non-array texture
|
||||||
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
|
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
|
||||||
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
||||||
|
|
||||||
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
||||||
|
@ -114,10 +113,10 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) {
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test creating texture view on a 2D array texture
|
// Test creating texture view on a 2D array texture
|
||||||
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
|
TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
|
||||||
constexpr uint32_t kDefaultArrayLayers = 6;
|
constexpr uint32_t kDefaultArrayLayers = 6;
|
||||||
|
|
||||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||||
|
@ -171,12 +170,12 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using the "none" ("default") values validates the same as explicitly
|
// Using the "none" ("default") values validates the same as explicitly
|
||||||
// specifying the values they're supposed to default to.
|
// specifying the values they're supposed to default to.
|
||||||
// Variant for a texture with more than 1 array layer.
|
// Variant for a texture with more than 1 array layer.
|
||||||
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
|
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
|
||||||
constexpr uint32_t kDefaultArrayLayers = 6;
|
constexpr uint32_t kDefaultArrayLayers = 6;
|
||||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||||
|
|
||||||
|
@ -212,12 +211,12 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsArray) {
|
||||||
descriptor.mipLevelCount = kDefaultMipLevels;
|
descriptor.mipLevelCount = kDefaultMipLevels;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using the "none" ("default") values validates the same as explicitly
|
// Using the "none" ("default") values validates the same as explicitly
|
||||||
// specifying the values they're supposed to default to.
|
// specifying the values they're supposed to default to.
|
||||||
// Variant for a texture with only 1 array layer.
|
// Variant for a texture with only 1 array layer.
|
||||||
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
|
TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
|
||||||
constexpr uint32_t kDefaultArrayLayers = 1;
|
constexpr uint32_t kDefaultArrayLayers = 1;
|
||||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||||
|
|
||||||
|
@ -256,10 +255,10 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsNonArray) {
|
||||||
descriptor.arrayLayerCount = kDefaultArrayLayers;
|
descriptor.arrayLayerCount = kDefaultArrayLayers;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test creating cube map texture view
|
// Test creating cube map texture view
|
||||||
TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
||||||
constexpr uint32_t kDefaultArrayLayers = 16;
|
constexpr uint32_t kDefaultArrayLayers = 16;
|
||||||
|
|
||||||
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
wgpu::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||||
|
@ -318,11 +317,11 @@ TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
||||||
descriptor.arrayLayerCount = 12;
|
descriptor.arrayLayerCount = 12;
|
||||||
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateView(&descriptor));
|
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateView(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the format compatibility rules when creating a texture view.
|
// Test the format compatibility rules when creating a texture view.
|
||||||
// TODO(jiawei.shao@intel.com): add more tests when the rules are fully implemented.
|
// TODO(jiawei.shao@intel.com): add more tests when the rules are fully implemented.
|
||||||
TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
|
TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
|
||||||
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
||||||
|
|
||||||
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
||||||
|
@ -334,19 +333,19 @@ TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
|
||||||
descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that it's invalid to create a texture view from a destroyed texture
|
// Test that it's invalid to create a texture view from a destroyed texture
|
||||||
TEST_F(TextureViewValidationTest, DestroyCreateTextureView) {
|
TEST_F(TextureViewValidationTest, DestroyCreateTextureView) {
|
||||||
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
wgpu::Texture texture = Create2DArrayTexture(device, 1);
|
||||||
wgpu::TextureViewDescriptor descriptor =
|
wgpu::TextureViewDescriptor descriptor =
|
||||||
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
|
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
|
||||||
texture.Destroy();
|
texture.Destroy();
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that only TextureAspect::All is supported
|
// Test that only TextureAspect::All is supported
|
||||||
TEST_F(TextureViewValidationTest, AspectMustBeAll) {
|
TEST_F(TextureViewValidationTest, AspectMustBeAll) {
|
||||||
wgpu::TextureDescriptor descriptor = {};
|
wgpu::TextureDescriptor descriptor = {};
|
||||||
descriptor.size = {1, 1, 1};
|
descriptor.size = {1, 1, 1};
|
||||||
descriptor.format = wgpu::TextureFormat::Depth32Float;
|
descriptor.format = wgpu::TextureFormat::Depth32Float;
|
||||||
|
@ -359,6 +358,6 @@ TEST_F(TextureViewValidationTest, AspectMustBeAll) {
|
||||||
|
|
||||||
viewDescriptor.aspect = wgpu::TextureAspect::DepthOnly;
|
viewDescriptor.aspect = wgpu::TextureAspect::DepthOnly;
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDescriptor));
|
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -16,11 +16,10 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class ToggleValidationTest : public ValidationTest {
|
class ToggleValidationTest : public ValidationTest {};
|
||||||
};
|
|
||||||
|
|
||||||
// Tests querying the detail of a toggle from dawn_native::InstanceBase works correctly.
|
// Tests querying the detail of a toggle from dawn_native::InstanceBase works correctly.
|
||||||
TEST_F(ToggleValidationTest, QueryToggleInfo) {
|
TEST_F(ToggleValidationTest, QueryToggleInfo) {
|
||||||
// Query with a valid toggle name
|
// Query with a valid toggle name
|
||||||
{
|
{
|
||||||
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
||||||
|
@ -37,10 +36,10 @@ TEST_F(ToggleValidationTest, QueryToggleInfo) {
|
||||||
const dawn_native::ToggleInfo* toggleInfo = instance->GetToggleInfo(kInvalidToggleName);
|
const dawn_native::ToggleInfo* toggleInfo = instance->GetToggleInfo(kInvalidToggleName);
|
||||||
ASSERT_EQ(nullptr, toggleInfo);
|
ASSERT_EQ(nullptr, toggleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests overriding toggles when creating a device works correctly.
|
// Tests overriding toggles when creating a device works correctly.
|
||||||
TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||||
// Create device with a valid name of a toggle
|
// Create device with a valid name of a toggle
|
||||||
{
|
{
|
||||||
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
const char* kValidToggleName = "emulate_store_and_msaa_resolve";
|
||||||
|
@ -74,9 +73,9 @@ TEST_F(ToggleValidationTest, OverrideToggleUsage) {
|
||||||
}
|
}
|
||||||
ASSERT_EQ(InvalidToggleExists, false);
|
ASSERT_EQ(InvalidToggleExists, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
||||||
const char* kValidToggleName = "turn_off_vsync";
|
const char* kValidToggleName = "turn_off_vsync";
|
||||||
dawn_native::DeviceDescriptor descriptor;
|
dawn_native::DeviceDescriptor descriptor;
|
||||||
descriptor.forceEnabledToggles.push_back(kValidToggleName);
|
descriptor.forceEnabledToggles.push_back(kValidToggleName);
|
||||||
|
@ -90,5 +89,5 @@ TEST_F(ToggleValidationTest, TurnOffVsyncWithToggle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT_EQ(validToggleExists, true);
|
ASSERT_EQ(validToggleExists, true);
|
||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
|
@ -27,7 +27,7 @@ ValidationTest::ValidationTest() {
|
||||||
|
|
||||||
// Validation tests run against the null backend, find the corresponding adapter
|
// Validation tests run against the null backend, find the corresponding adapter
|
||||||
bool foundNullAdapter = false;
|
bool foundNullAdapter = false;
|
||||||
for (auto ¤tAdapter : adapters) {
|
for (auto& currentAdapter : adapters) {
|
||||||
wgpu::AdapterProperties adapterProperties;
|
wgpu::AdapterProperties adapterProperties;
|
||||||
currentAdapter.GetProperties(&adapterProperties);
|
currentAdapter.GetProperties(&adapterProperties);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ ValidationTest::DummyRenderPass::DummyRenderPass(const wgpu::Device& device)
|
||||||
wgpu::TextureView view = attachment.CreateView();
|
wgpu::TextureView view = attachment.CreateView();
|
||||||
mColorAttachment.attachment = view;
|
mColorAttachment.attachment = view;
|
||||||
mColorAttachment.resolveTarget = nullptr;
|
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.loadOp = wgpu::LoadOp::Clear;
|
||||||
mColorAttachment.storeOp = wgpu::StoreOp::Store;
|
mColorAttachment.storeOp = wgpu::StoreOp::Store;
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,6 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
||||||
FlushClient();
|
FlushClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Test that the wire is able to send objects as value arguments
|
// Test that the wire is able to send objects as value arguments
|
||||||
TEST_F(WireArgumentTests, ObjectAsValueArgument) {
|
TEST_F(WireArgumentTests, ObjectAsValueArgument) {
|
||||||
WGPUCommandEncoder cmdBufEncoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
|
WGPUCommandEncoder cmdBufEncoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
|
||||||
|
|
|
@ -613,4 +613,3 @@ TEST_F(WireBufferMappingTests, CreateBufferMappedThenMapFailure) {
|
||||||
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ class WireErrorCallbackTests : public WireTest {
|
||||||
WireTest::SetUp();
|
WireTest::SetUp();
|
||||||
|
|
||||||
mockDeviceErrorCallback = std::make_unique<StrictMock<MockDeviceErrorCallback>>();
|
mockDeviceErrorCallback = std::make_unique<StrictMock<MockDeviceErrorCallback>>();
|
||||||
mockDevicePopErrorScopeCallback = std::make_unique<StrictMock<MockDevicePopErrorScopeCallback>>();
|
mockDevicePopErrorScopeCallback =
|
||||||
|
std::make_unique<StrictMock<MockDevicePopErrorScopeCallback>>();
|
||||||
mockDeviceLostCallback = std::make_unique<StrictMock<MockDeviceLostCallback>>();
|
mockDeviceLostCallback = std::make_unique<StrictMock<MockDeviceLostCallback>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,8 +207,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeDeviceDestroyed) {
|
||||||
|
|
||||||
EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
|
EXPECT_TRUE(wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this));
|
||||||
|
|
||||||
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _))
|
EXPECT_CALL(api, OnDevicePopErrorScopeCallback(apiDevice, _, _)).WillOnce(Return(true));
|
||||||
.WillOnce(Return(true));
|
|
||||||
FlushClient();
|
FlushClient();
|
||||||
|
|
||||||
// Incomplete callback called in Device destructor.
|
// Incomplete callback called in Device destructor.
|
||||||
|
|
|
@ -40,7 +40,8 @@ TEST_F(WireExtensionTests, ChainedStruct) {
|
||||||
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
|
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
|
||||||
EXPECT_STREQ(serverDesc->label, clientDesc.label);
|
EXPECT_STREQ(serverDesc->label, clientDesc.label);
|
||||||
|
|
||||||
const auto* ext = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
const auto* ext =
|
||||||
|
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
||||||
serverDesc->nextInChain);
|
serverDesc->nextInChain);
|
||||||
EXPECT_EQ(ext->chain.sType, clientExt.chain.sType);
|
EXPECT_EQ(ext->chain.sType, clientExt.chain.sType);
|
||||||
EXPECT_EQ(ext->maxAnisotropy, clientExt.maxAnisotropy);
|
EXPECT_EQ(ext->maxAnisotropy, clientExt.maxAnisotropy);
|
||||||
|
@ -73,12 +74,14 @@ TEST_F(WireExtensionTests, MutlipleChainedStructs) {
|
||||||
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
|
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
|
||||||
EXPECT_STREQ(serverDesc->label, clientDesc.label);
|
EXPECT_STREQ(serverDesc->label, clientDesc.label);
|
||||||
|
|
||||||
const auto* ext1 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
const auto* ext1 =
|
||||||
|
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
||||||
serverDesc->nextInChain);
|
serverDesc->nextInChain);
|
||||||
EXPECT_EQ(ext1->chain.sType, clientExt1.chain.sType);
|
EXPECT_EQ(ext1->chain.sType, clientExt1.chain.sType);
|
||||||
EXPECT_EQ(ext1->maxAnisotropy, clientExt1.maxAnisotropy);
|
EXPECT_EQ(ext1->maxAnisotropy, clientExt1.maxAnisotropy);
|
||||||
|
|
||||||
const auto* ext2 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
const auto* ext2 =
|
||||||
|
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
||||||
ext1->chain.next);
|
ext1->chain.next);
|
||||||
EXPECT_EQ(ext2->chain.sType, clientExt2.chain.sType);
|
EXPECT_EQ(ext2->chain.sType, clientExt2.chain.sType);
|
||||||
EXPECT_EQ(ext2->maxAnisotropy, clientExt2.maxAnisotropy);
|
EXPECT_EQ(ext2->maxAnisotropy, clientExt2.maxAnisotropy);
|
||||||
|
@ -99,12 +102,14 @@ TEST_F(WireExtensionTests, MutlipleChainedStructs) {
|
||||||
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
|
.WillOnce(Invoke([&](Unused, const WGPUSamplerDescriptor* serverDesc) -> WGPUSampler {
|
||||||
EXPECT_STREQ(serverDesc->label, clientDesc.label);
|
EXPECT_STREQ(serverDesc->label, clientDesc.label);
|
||||||
|
|
||||||
const auto* ext2 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
const auto* ext2 =
|
||||||
|
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
||||||
serverDesc->nextInChain);
|
serverDesc->nextInChain);
|
||||||
EXPECT_EQ(ext2->chain.sType, clientExt2.chain.sType);
|
EXPECT_EQ(ext2->chain.sType, clientExt2.chain.sType);
|
||||||
EXPECT_EQ(ext2->maxAnisotropy, clientExt2.maxAnisotropy);
|
EXPECT_EQ(ext2->maxAnisotropy, clientExt2.maxAnisotropy);
|
||||||
|
|
||||||
const auto* ext1 = reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
const auto* ext1 =
|
||||||
|
reinterpret_cast<const WGPUSamplerDescriptorDummyAnisotropicFiltering*>(
|
||||||
ext2->chain.next);
|
ext2->chain.next);
|
||||||
EXPECT_EQ(ext1->chain.sType, clientExt1.chain.sType);
|
EXPECT_EQ(ext1->chain.sType, clientExt1.chain.sType);
|
||||||
EXPECT_EQ(ext1->maxAnisotropy, clientExt1.maxAnisotropy);
|
EXPECT_EQ(ext1->maxAnisotropy, clientExt1.maxAnisotropy);
|
||||||
|
|
|
@ -180,9 +180,7 @@ class WireMemoryTransferServiceTests : public WireTest {
|
||||||
ClientReadHandle* handle = clientMemoryTransferService.NewReadHandle();
|
ClientReadHandle* handle = clientMemoryTransferService.NewReadHandle();
|
||||||
|
|
||||||
EXPECT_CALL(clientMemoryTransferService, OnCreateReadHandle(sizeof(mBufferContent)))
|
EXPECT_CALL(clientMemoryTransferService, OnCreateReadHandle(sizeof(mBufferContent)))
|
||||||
.WillOnce(InvokeWithoutArgs([=]() {
|
.WillOnce(InvokeWithoutArgs([=]() { return handle; }));
|
||||||
return handle;
|
|
||||||
}));
|
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -259,9 +257,7 @@ class WireMemoryTransferServiceTests : public WireTest {
|
||||||
ClientWriteHandle* handle = clientMemoryTransferService.NewWriteHandle();
|
ClientWriteHandle* handle = clientMemoryTransferService.NewWriteHandle();
|
||||||
|
|
||||||
EXPECT_CALL(clientMemoryTransferService, OnCreateWriteHandle(sizeof(mBufferContent)))
|
EXPECT_CALL(clientMemoryTransferService, OnCreateWriteHandle(sizeof(mBufferContent)))
|
||||||
.WillOnce(InvokeWithoutArgs([=]() {
|
.WillOnce(InvokeWithoutArgs([=]() { return handle; }));
|
||||||
return handle;
|
|
||||||
}));
|
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -300,22 +296,18 @@ class WireMemoryTransferServiceTests : public WireTest {
|
||||||
EXPECT_CALL(serverMemoryTransferService,
|
EXPECT_CALL(serverMemoryTransferService,
|
||||||
OnDeserializeWriteHandle(Pointee(Eq(mSerializeCreateInfo)),
|
OnDeserializeWriteHandle(Pointee(Eq(mSerializeCreateInfo)),
|
||||||
sizeof(mSerializeCreateInfo), _))
|
sizeof(mSerializeCreateInfo), _))
|
||||||
.WillOnce(InvokeWithoutArgs([&]() {
|
.WillOnce(InvokeWithoutArgs([&]() { return false; }));
|
||||||
return false;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpectClientWriteHandleOpen(ClientWriteHandle* handle, uint32_t* mappedData) {
|
void ExpectClientWriteHandleOpen(ClientWriteHandle* handle, uint32_t* mappedData) {
|
||||||
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleOpen(handle))
|
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleOpen(handle))
|
||||||
.WillOnce(InvokeWithoutArgs([=]() {
|
.WillOnce(InvokeWithoutArgs(
|
||||||
return std::make_pair(mappedData, sizeof(*mappedData));
|
[=]() { return std::make_pair(mappedData, sizeof(*mappedData)); }));
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockClientWriteHandleOpenFailure(ClientWriteHandle* handle) {
|
void MockClientWriteHandleOpenFailure(ClientWriteHandle* handle) {
|
||||||
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleOpen(handle))
|
EXPECT_CALL(clientMemoryTransferService, OnWriteHandleOpen(handle))
|
||||||
.WillOnce(InvokeWithoutArgs(
|
.WillOnce(InvokeWithoutArgs([&]() { return std::make_pair(nullptr, 0); }));
|
||||||
[&]() { return std::make_pair(nullptr, 0); }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpectClientWriteHandleSerializeFlush(ClientWriteHandle* handle) {
|
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
|
// 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
|
// 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
|
// test expectations will check that serialized values are passed to the respective
|
||||||
// function.
|
// deserialization function.
|
||||||
static uint32_t mSerializeCreateInfo;
|
static uint32_t mSerializeCreateInfo;
|
||||||
static uint32_t mSerializeInitialDataInfo;
|
static uint32_t mSerializeInitialDataInfo;
|
||||||
static uint32_t mSerializeFlushInfo;
|
static uint32_t mSerializeFlushInfo;
|
||||||
|
@ -360,8 +352,9 @@ class WireMemoryTransferServiceTests : public WireTest {
|
||||||
// The client's zero-initialized buffer for writing.
|
// The client's zero-initialized buffer for writing.
|
||||||
uint32_t mMappedBufferContent = 0;
|
uint32_t mMappedBufferContent = 0;
|
||||||
|
|
||||||
// |mMappedBufferContent| should be set equal to |mUpdatedBufferContent| when the client performs a write.
|
// |mMappedBufferContent| should be set equal to |mUpdatedBufferContent| when the client
|
||||||
// Test expectations should check that |mBufferContent == mUpdatedBufferContent| after all writes are flushed.
|
// performs a write. Test expectations should check that |mBufferContent ==
|
||||||
|
// mUpdatedBufferContent| after all writes are flushed.
|
||||||
static uint32_t mUpdatedBufferContent;
|
static uint32_t mUpdatedBufferContent;
|
||||||
|
|
||||||
testing::StrictMock<dawn_wire::server::MockMemoryTransferService> serverMemoryTransferService;
|
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*> {
|
class StringMessageMatcher : public testing::MatcherInterface<const char*> {
|
||||||
public:
|
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) {
|
if (message == nullptr) {
|
||||||
*listener << "missing error message";
|
*listener << "missing error message";
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue