Rename nxt:: to dawn:: in tests

This commit is contained in:
Corentin Wallez 2018-07-18 13:43:49 +02:00 committed by Corentin Wallez
parent 83a9c9d6d9
commit 54e58c20b2
31 changed files with 986 additions and 986 deletions

View File

@ -99,9 +99,9 @@ namespace {
NXTTest::~NXTTest() { NXTTest::~NXTTest() {
// We need to destroy child objects before the Device // We need to destroy child objects before the Device
mReadbackSlots.clear(); mReadbackSlots.clear();
queue = nxt::Queue(); queue = dawn::Queue();
swapchain = nxt::SwapChain(); swapchain = dawn::SwapChain();
device = nxt::Device(); device = dawn::Device();
delete mBinding; delete mBinding;
mBinding = nullptr; mBinding = nullptr;
@ -145,15 +145,15 @@ void NXTTest::SetUp() {
nxtProcTable procs; nxtProcTable procs;
if (gTestUsesWire) { if (gTestUsesWire) {
mC2sBuf = new nxt::wire::TerribleCommandBuffer(); mC2sBuf = new dawn::wire::TerribleCommandBuffer();
mS2cBuf = new nxt::wire::TerribleCommandBuffer(); mS2cBuf = new dawn::wire::TerribleCommandBuffer();
mWireServer = nxt::wire::NewServerCommandHandler(backendDevice, backendProcs, mS2cBuf); mWireServer = dawn::wire::NewServerCommandHandler(backendDevice, backendProcs, mS2cBuf);
mC2sBuf->SetHandler(mWireServer); mC2sBuf->SetHandler(mWireServer);
nxtDevice clientDevice; nxtDevice clientDevice;
nxtProcTable clientProcs; nxtProcTable clientProcs;
mWireClient = nxt::wire::NewClientDevice(&clientProcs, &clientDevice, mC2sBuf); mWireClient = dawn::wire::NewClientDevice(&clientProcs, &clientDevice, mC2sBuf);
mS2cBuf->SetHandler(mWireClient); mS2cBuf->SetHandler(mWireClient);
procs = clientProcs; procs = clientProcs;
@ -166,7 +166,7 @@ void NXTTest::SetUp() {
// Set up the device and queue because all tests need them, and NXTTest needs them too for the // Set up the device and queue because all tests need them, and NXTTest needs them too for the
// deferred expectations. // deferred expectations.
nxtSetProcs(&procs); nxtSetProcs(&procs);
device = nxt::Device::Acquire(cDevice); device = dawn::Device::Acquire(cDevice);
queue = device.CreateQueue(); queue = device.CreateQueue();
// The swapchain isn't used by tests but is useful when debugging with graphics debuggers that // The swapchain isn't used by tests but is useful when debugging with graphics debuggers that
@ -174,8 +174,8 @@ void NXTTest::SetUp() {
swapchain = device.CreateSwapChainBuilder() swapchain = device.CreateSwapChainBuilder()
.SetImplementation(mBinding->GetSwapChainImplementation()) .SetImplementation(mBinding->GetSwapChainImplementation())
.GetResult(); .GetResult();
swapchain.Configure(static_cast<nxt::TextureFormat>(mBinding->GetPreferredSwapChainTextureFormat()), swapchain.Configure(static_cast<dawn::TextureFormat>(mBinding->GetPreferredSwapChainTextureFormat()),
nxt::TextureUsageBit::OutputAttachment, 400, 400); dawn::TextureUsageBit::OutputAttachment, 400, 400);
// The end2end tests should never cause validation errors. These should be tested in unittests. // The end2end tests should never cause validation errors. These should be tested in unittests.
device.SetErrorCallback(DeviceErrorCauseTestFailure, 0); device.SetErrorCallback(DeviceErrorCauseTestFailure, 0);
@ -204,14 +204,14 @@ void NXTTest::TearDown() {
} }
} }
std::ostringstream& NXTTest::AddBufferExpectation(const char* file, int line, const nxt::Buffer& buffer, uint32_t offset, uint32_t size, detail::Expectation* expectation) { std::ostringstream& NXTTest::AddBufferExpectation(const char* file, int line, const dawn::Buffer& buffer, uint32_t offset, uint32_t size, detail::Expectation* expectation) {
nxt::Buffer source = buffer.Clone(); dawn::Buffer source = buffer.Clone();
auto readback = ReserveReadback(size); auto readback = ReserveReadback(size);
// We need to enqueue the copy immediately because by the time we resolve the expectation, // We need to enqueue the copy immediately because by the time we resolve the expectation,
// the buffer might have been modified. // the buffer might have been modified.
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.CopyBufferToBuffer(source, offset, readback.buffer, readback.offset, size) .CopyBufferToBuffer(source, offset, readback.buffer, readback.offset, size)
.GetResult(); .GetResult();
@ -232,8 +232,8 @@ std::ostringstream& NXTTest::AddBufferExpectation(const char* file, int line, co
return *(mDeferredExpectations.back().message.get()); return *(mDeferredExpectations.back().message.get());
} }
std::ostringstream& NXTTest::AddTextureExpectation(const char* file, int line, const nxt::Texture& texture, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t level, uint32_t pixelSize, detail::Expectation* expectation) { std::ostringstream& NXTTest::AddTextureExpectation(const char* file, int line, const dawn::Texture& texture, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t level, uint32_t pixelSize, detail::Expectation* expectation) {
nxt::Texture source = texture.Clone(); dawn::Texture source = texture.Clone();
uint32_t rowPitch = Align(width * pixelSize, kTextureRowPitchAlignment); uint32_t rowPitch = Align(width * pixelSize, kTextureRowPitchAlignment);
uint32_t size = rowPitch * (height - 1) + width * pixelSize; uint32_t size = rowPitch * (height - 1) + width * pixelSize;
@ -241,7 +241,7 @@ std::ostringstream& NXTTest::AddTextureExpectation(const char* file, int line, c
// We need to enqueue the copy immediately because by the time we resolve the expectation, // We need to enqueue the copy immediately because by the time we resolve the expectation,
// the texture might have been modified. // the texture might have been modified.
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.CopyTextureToBuffer(source, x, y, 0, width, height, 1, level, readback.buffer, readback.offset, rowPitch) .CopyTextureToBuffer(source, x, y, 0, width, height, 1, level, readback.buffer, readback.offset, rowPitch)
.GetResult(); .GetResult();
@ -271,7 +271,7 @@ void NXTTest::WaitABit() {
void NXTTest::SwapBuffersForCapture() { void NXTTest::SwapBuffersForCapture() {
// Insert a frame boundary for API capture tools. // Insert a frame boundary for API capture tools.
nxt::Texture backBuffer = swapchain.GetNextTexture(); dawn::Texture backBuffer = swapchain.GetNextTexture();
swapchain.Present(backBuffer); swapchain.Present(backBuffer);
} }
@ -289,7 +289,7 @@ NXTTest::ReadbackReservation NXTTest::ReserveReadback(uint32_t readbackSize) {
slot.bufferSize = readbackSize; slot.bufferSize = readbackSize;
slot.buffer = device.CreateBufferBuilder() slot.buffer = device.CreateBufferBuilder()
.SetSize(readbackSize) .SetSize(readbackSize)
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
ReadbackReservation reservation; ReadbackReservation reservation;
@ -310,7 +310,7 @@ void NXTTest::MapSlotsSynchronously() {
auto userdata = new MapReadUserdata{this, i}; auto userdata = new MapReadUserdata{this, i};
auto& slot = mReadbackSlots[i]; auto& slot = mReadbackSlots[i];
slot.buffer.MapReadAsync(0, slot.bufferSize, SlotMapReadCallback, static_cast<nxt::CallbackUserdata>(reinterpret_cast<uintptr_t>(userdata))); slot.buffer.MapReadAsync(0, slot.bufferSize, SlotMapReadCallback, static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(userdata)));
} }
// Busy wait until all map operations are done. // Busy wait until all map operations are done.

View File

@ -69,7 +69,7 @@ namespace detail {
namespace nxt { namespace wire { namespace nxt { namespace wire {
class CommandHandler; class CommandHandler;
class TerribleCommandBuffer; class TerribleCommandBuffer;
}} // namespace nxt::wire }} // namespace dawn::wire
class NXTTest : public ::testing::TestWithParam<BackendType> { class NXTTest : public ::testing::TestWithParam<BackendType> {
public: public:
@ -84,20 +84,20 @@ class NXTTest : public ::testing::TestWithParam<BackendType> {
bool IsVulkan() const; bool IsVulkan() const;
protected: protected:
nxt::Device device; dawn::Device device;
nxt::Queue queue; dawn::Queue queue;
nxt::SwapChain swapchain; dawn::SwapChain swapchain;
// Helper methods to implement the EXPECT_ macros // Helper methods to implement the EXPECT_ macros
std::ostringstream& AddBufferExpectation(const char* file, std::ostringstream& AddBufferExpectation(const char* file,
int line, int line,
const nxt::Buffer& buffer, const dawn::Buffer& buffer,
uint32_t offset, uint32_t offset,
uint32_t size, uint32_t size,
detail::Expectation* expectation); detail::Expectation* expectation);
std::ostringstream& AddTextureExpectation(const char* file, std::ostringstream& AddTextureExpectation(const char* file,
int line, int line,
const nxt::Texture& texture, const dawn::Texture& texture,
uint32_t x, uint32_t x,
uint32_t y, uint32_t y,
uint32_t width, uint32_t width,
@ -112,15 +112,15 @@ class NXTTest : public ::testing::TestWithParam<BackendType> {
private: private:
// Things used to set up testing through the Wire. // Things used to set up testing through the Wire.
nxt::wire::CommandHandler* mWireServer = nullptr; dawn::wire::CommandHandler* mWireServer = nullptr;
nxt::wire::CommandHandler* mWireClient = nullptr; dawn::wire::CommandHandler* mWireClient = nullptr;
nxt::wire::TerribleCommandBuffer* mC2sBuf = nullptr; dawn::wire::TerribleCommandBuffer* mC2sBuf = nullptr;
nxt::wire::TerribleCommandBuffer* mS2cBuf = nullptr; dawn::wire::TerribleCommandBuffer* mS2cBuf = nullptr;
void FlushWire(); void FlushWire();
// MapRead buffers used to get data for the expectations // MapRead buffers used to get data for the expectations
struct ReadbackSlot { struct ReadbackSlot {
nxt::Buffer buffer; dawn::Buffer buffer;
uint32_t bufferSize; uint32_t bufferSize;
const void* mappedData = nullptr; const void* mappedData = nullptr;
}; };
@ -135,7 +135,7 @@ class NXTTest : public ::testing::TestWithParam<BackendType> {
// Reserve space where the data for an expectation can be copied // Reserve space where the data for an expectation can be copied
struct ReadbackReservation { struct ReadbackReservation {
nxt::Buffer buffer; dawn::Buffer buffer;
size_t slot; size_t slot;
uint32_t offset; uint32_t offset;
}; };

View File

@ -22,9 +22,9 @@ class BasicTests : public NXTTest {
// Test Buffer::SetSubData changes the content of the buffer, but really this is the most // Test Buffer::SetSubData changes the content of the buffer, but really this is the most
// basic test possible, and tests the test harness // basic test possible, and tests the test harness
TEST_P(BasicTests, BufferSetSubData) { TEST_P(BasicTests, BufferSetSubData) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
uint8_t value = 187; uint8_t value = 187;

View File

@ -28,7 +28,7 @@ class BlendStateTest : public NXTTest {
void SetUp() override { void SetUp() override {
NXTTest::SetUp(); NXTTest::SetUp();
vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
void main() { void main() {
const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(3.f, -1.f), vec2(-1.f, 3.f)); const vec2 pos[3] = vec2[3](vec2(-1.f, -1.f), vec2(3.f, -1.f), vec2(-1.f, 3.f));
@ -38,7 +38,7 @@ class BlendStateTest : public NXTTest {
bindGroupLayout = utils::MakeBindGroupLayout( bindGroupLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, nxt::ShaderStageBit::Fragment, nxt::BindingType::UniformBuffer}, {0, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer},
}); });
pipelineLayout = utils::MakeBasicPipelineLayout(device, &bindGroupLayout); pipelineLayout = utils::MakeBasicPipelineLayout(device, &bindGroupLayout);
@ -52,8 +52,8 @@ class BlendStateTest : public NXTTest {
}; };
// Set up basePipeline and testPipeline. testPipeline has the given blend state on the first attachment. basePipeline has no blending // Set up basePipeline and testPipeline. testPipeline has the given blend state on the first attachment. basePipeline has no blending
void SetupSingleSourcePipelines(const nxt::BlendState &blendState) { void SetupSingleSourcePipelines(const dawn::BlendState &blendState) {
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(set = 0, binding = 0) uniform myBlock { layout(set = 0, binding = 0) uniform myBlock {
vec4 color; vec4 color;
@ -69,22 +69,22 @@ class BlendStateTest : public NXTTest {
basePipeline = device.CreateRenderPipelineBuilder() basePipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
testPipeline = device.CreateRenderPipelineBuilder() testPipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetColorAttachmentBlendState(0, blendState) .SetColorAttachmentBlendState(0, blendState)
.GetResult(); .GetResult();
} }
// Create a bind group to set the colors as a uniform buffer // Create a bind group to set the colors as a uniform buffer
template <size_t N> template <size_t N>
nxt::BindGroup MakeBindGroupForColors(std::array<RGBA8, N> colors) { dawn::BindGroup MakeBindGroupForColors(std::array<RGBA8, N> colors) {
std::array<float, 4 * N> data; std::array<float, 4 * N> data;
for (unsigned int i = 0; i < N; ++i) { for (unsigned int i = 0; i < N; ++i) {
data[4 * i + 0] = static_cast<float>(colors[i].r) / 255.f; data[4 * i + 0] = static_cast<float>(colors[i].r) / 255.f;
@ -95,22 +95,22 @@ class BlendStateTest : public NXTTest {
uint32_t bufferSize = static_cast<uint32_t>(4 * N * sizeof(float)); uint32_t bufferSize = static_cast<uint32_t>(4 * N * sizeof(float));
nxt::Buffer buffer = utils::CreateBufferFromData(device, &data, bufferSize, nxt::BufferUsageBit::Uniform); dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, bufferSize, dawn::BufferUsageBit::Uniform);
nxt::BufferView view = buffer.CreateBufferViewBuilder() dawn::BufferView view = buffer.CreateBufferViewBuilder()
.SetExtent(0, bufferSize) .SetExtent(0, bufferSize)
.GetResult(); .GetResult();
return device.CreateBindGroupBuilder() return device.CreateBindGroupBuilder()
.SetLayout(bindGroupLayout) .SetLayout(bindGroupLayout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &view) .SetBufferViews(0, 1, &view)
.GetResult(); .GetResult();
} }
// Test that after drawing a triangle with the base color, and then the given triangle spec, the color is as expected // Test that after drawing a triangle with the base color, and then the given triangle spec, the color is as expected
void DoSingleSourceTest(RGBA8 base, const TriangleSpec& triangle, const RGBA8& expected) { void DoSingleSourceTest(RGBA8 base, const TriangleSpec& triangle, const RGBA8& expected) {
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
// First use the base pipeline to draw a triangle with no blending // First use the base pipeline to draw a triangle with no blending
.SetRenderPipeline(basePipeline) .SetRenderPipeline(basePipeline)
@ -132,11 +132,11 @@ class BlendStateTest : public NXTTest {
} }
// Given a vector of tests where each element is <testColor, expectedColor>, check that all expectations are true for the given blend operation // Given a vector of tests where each element is <testColor, expectedColor>, check that all expectations are true for the given blend operation
void CheckBlendOperation(RGBA8 base, nxt::BlendOperation operation, std::vector<std::pair<RGBA8, RGBA8>> tests) { void CheckBlendOperation(RGBA8 base, dawn::BlendOperation operation, std::vector<std::pair<RGBA8, RGBA8>> tests) {
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(operation, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(operation, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(operation, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(operation, dawn::BlendFactor::One, dawn::BlendFactor::One)
.GetResult(); .GetResult();
SetupSingleSourcePipelines(blendState); SetupSingleSourcePipelines(blendState);
@ -147,11 +147,11 @@ class BlendStateTest : public NXTTest {
} }
// Given a vector of tests where each element is <testSpec, expectedColor>, check that all expectations are true for the given blend factors // Given a vector of tests where each element is <testSpec, expectedColor>, check that all expectations are true for the given blend factors
void CheckBlendFactor(RGBA8 base, nxt::BlendFactor colorSrcFactor, nxt::BlendFactor colorDstFactor, nxt::BlendFactor alphaSrcFactor, nxt::BlendFactor alphaDstFactor, std::vector<std::pair<TriangleSpec, RGBA8>> tests) { void CheckBlendFactor(RGBA8 base, dawn::BlendFactor colorSrcFactor, dawn::BlendFactor colorDstFactor, dawn::BlendFactor alphaSrcFactor, dawn::BlendFactor alphaDstFactor, std::vector<std::pair<TriangleSpec, RGBA8>> tests) {
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Add, colorSrcFactor, colorDstFactor) .SetColorBlend(dawn::BlendOperation::Add, colorSrcFactor, colorDstFactor)
.SetAlphaBlend(nxt::BlendOperation::Add, alphaSrcFactor, alphaDstFactor) .SetAlphaBlend(dawn::BlendOperation::Add, alphaSrcFactor, alphaDstFactor)
.GetResult(); .GetResult();
SetupSingleSourcePipelines(blendState); SetupSingleSourcePipelines(blendState);
@ -161,20 +161,20 @@ class BlendStateTest : public NXTTest {
} }
} }
void CheckSrcBlendFactor(RGBA8 base, nxt::BlendFactor colorFactor, nxt::BlendFactor alphaFactor, std::vector<std::pair<TriangleSpec, RGBA8>> tests) { void CheckSrcBlendFactor(RGBA8 base, dawn::BlendFactor colorFactor, dawn::BlendFactor alphaFactor, std::vector<std::pair<TriangleSpec, RGBA8>> tests) {
CheckBlendFactor(base, colorFactor, nxt::BlendFactor::One, alphaFactor, nxt::BlendFactor::One, tests); CheckBlendFactor(base, colorFactor, dawn::BlendFactor::One, alphaFactor, dawn::BlendFactor::One, tests);
} }
void CheckDstBlendFactor(RGBA8 base, nxt::BlendFactor colorFactor, nxt::BlendFactor alphaFactor, std::vector<std::pair<TriangleSpec, RGBA8>> tests) { void CheckDstBlendFactor(RGBA8 base, dawn::BlendFactor colorFactor, dawn::BlendFactor alphaFactor, std::vector<std::pair<TriangleSpec, RGBA8>> tests) {
CheckBlendFactor(base, nxt::BlendFactor::One, colorFactor, nxt::BlendFactor::One, alphaFactor, tests); CheckBlendFactor(base, dawn::BlendFactor::One, colorFactor, dawn::BlendFactor::One, alphaFactor, tests);
} }
utils::BasicRenderPass renderPass; utils::BasicRenderPass renderPass;
nxt::RenderPipeline basePipeline; dawn::RenderPipeline basePipeline;
nxt::RenderPipeline testPipeline; dawn::RenderPipeline testPipeline;
nxt::ShaderModule vsModule; dawn::ShaderModule vsModule;
nxt::BindGroupLayout bindGroupLayout; dawn::BindGroupLayout bindGroupLayout;
nxt::PipelineLayout pipelineLayout; dawn::PipelineLayout pipelineLayout;
}; };
namespace { namespace {
@ -264,7 +264,7 @@ namespace {
// Test compilation and usage of the fixture // Test compilation and usage of the fixture
TEST_P(BlendStateTest, Basic) { TEST_P(BlendStateTest, Basic) {
nxt::BlendState blendState = device.CreateBlendStateBuilder().GetResult(); dawn::BlendState blendState = device.CreateBlendStateBuilder().GetResult();
SetupSingleSourcePipelines(blendState); SetupSingleSourcePipelines(blendState);
DoSingleSourceTest(RGBA8(0, 0, 0, 0), { RGBA8(255, 0, 0, 0) }, RGBA8(255, 0, 0, 0)); DoSingleSourceTest(RGBA8(0, 0, 0, 0), { RGBA8(255, 0, 0, 0) }, RGBA8(255, 0, 0, 0));
@ -277,7 +277,7 @@ TEST_P(BlendStateTest, BlendOperationAdd) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(color, base + color); return std::make_pair(color, base + color);
}); });
CheckBlendOperation(base, nxt::BlendOperation::Add, tests); CheckBlendOperation(base, dawn::BlendOperation::Add, tests);
} }
TEST_P(BlendStateTest, BlendOperationSubtract) { TEST_P(BlendStateTest, BlendOperationSubtract) {
@ -286,7 +286,7 @@ TEST_P(BlendStateTest, BlendOperationSubtract) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(color, color - base); return std::make_pair(color, color - base);
}); });
CheckBlendOperation(base, nxt::BlendOperation::Subtract, tests); CheckBlendOperation(base, dawn::BlendOperation::Subtract, tests);
} }
TEST_P(BlendStateTest, BlendOperationReverseSubtract) { TEST_P(BlendStateTest, BlendOperationReverseSubtract) {
@ -295,7 +295,7 @@ TEST_P(BlendStateTest, BlendOperationReverseSubtract) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(color, base - color); return std::make_pair(color, base - color);
}); });
CheckBlendOperation(base, nxt::BlendOperation::ReverseSubtract, tests); CheckBlendOperation(base, dawn::BlendOperation::ReverseSubtract, tests);
} }
TEST_P(BlendStateTest, BlendOperationMin) { TEST_P(BlendStateTest, BlendOperationMin) {
@ -304,7 +304,7 @@ TEST_P(BlendStateTest, BlendOperationMin) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(color, min(base, color)); return std::make_pair(color, min(base, color));
}); });
CheckBlendOperation(base, nxt::BlendOperation::Min, tests); CheckBlendOperation(base, dawn::BlendOperation::Min, tests);
} }
TEST_P(BlendStateTest, BlendOperationMax) { TEST_P(BlendStateTest, BlendOperationMax) {
@ -313,7 +313,7 @@ TEST_P(BlendStateTest, BlendOperationMax) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(color, max(base, color)); return std::make_pair(color, max(base, color));
}); });
CheckBlendOperation(base, nxt::BlendOperation::Max, tests); CheckBlendOperation(base, dawn::BlendOperation::Max, tests);
} }
// The following tests check that the Source blend factor works // The following tests check that the Source blend factor works
@ -323,7 +323,7 @@ TEST_P(BlendStateTest, SrcBlendFactorZero) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(TriangleSpec({ { color } }), base); return std::make_pair(TriangleSpec({ { color } }), base);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::Zero, nxt::BlendFactor::Zero, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::Zero, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorOne) { TEST_P(BlendStateTest, SrcBlendFactorOne) {
@ -332,7 +332,7 @@ TEST_P(BlendStateTest, SrcBlendFactorOne) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(TriangleSpec({ { color } }), base + color); return std::make_pair(TriangleSpec({ { color } }), base + color);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::One, nxt::BlendFactor::One, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::One, dawn::BlendFactor::One, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorSrcColor) { TEST_P(BlendStateTest, SrcBlendFactorSrcColor) {
@ -344,7 +344,7 @@ TEST_P(BlendStateTest, SrcBlendFactorSrcColor) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::SrcColor, nxt::BlendFactor::Zero, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::SrcColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorOneMinusSrcColor) { TEST_P(BlendStateTest, SrcBlendFactorOneMinusSrcColor) {
@ -356,7 +356,7 @@ TEST_P(BlendStateTest, SrcBlendFactorOneMinusSrcColor) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::OneMinusSrcColor, nxt::BlendFactor::Zero, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::OneMinusSrcColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorSrcAlpha) { TEST_P(BlendStateTest, SrcBlendFactorSrcAlpha) {
@ -367,7 +367,7 @@ TEST_P(BlendStateTest, SrcBlendFactorSrcAlpha) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::SrcAlpha, nxt::BlendFactor::SrcAlpha, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::SrcAlpha, dawn::BlendFactor::SrcAlpha, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorOneMinusSrcAlpha) { TEST_P(BlendStateTest, SrcBlendFactorOneMinusSrcAlpha) {
@ -378,7 +378,7 @@ TEST_P(BlendStateTest, SrcBlendFactorOneMinusSrcAlpha) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::OneMinusSrcAlpha, nxt::BlendFactor::OneMinusSrcAlpha, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::OneMinusSrcAlpha, dawn::BlendFactor::OneMinusSrcAlpha, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorDstColor) { TEST_P(BlendStateTest, SrcBlendFactorDstColor) {
@ -390,7 +390,7 @@ TEST_P(BlendStateTest, SrcBlendFactorDstColor) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::DstColor, nxt::BlendFactor::Zero, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::DstColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorOneMinusDstColor) { TEST_P(BlendStateTest, SrcBlendFactorOneMinusDstColor) {
@ -402,7 +402,7 @@ TEST_P(BlendStateTest, SrcBlendFactorOneMinusDstColor) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::OneMinusDstColor, nxt::BlendFactor::Zero, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::OneMinusDstColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorDstAlpha) { TEST_P(BlendStateTest, SrcBlendFactorDstAlpha) {
@ -413,7 +413,7 @@ TEST_P(BlendStateTest, SrcBlendFactorDstAlpha) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::DstAlpha, nxt::BlendFactor::DstAlpha, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::DstAlpha, dawn::BlendFactor::DstAlpha, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorOneMinusDstAlpha) { TEST_P(BlendStateTest, SrcBlendFactorOneMinusDstAlpha) {
@ -424,7 +424,7 @@ TEST_P(BlendStateTest, SrcBlendFactorOneMinusDstAlpha) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::OneMinusDstAlpha, nxt::BlendFactor::OneMinusDstAlpha, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::OneMinusDstAlpha, dawn::BlendFactor::OneMinusDstAlpha, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorSrcAlphaSaturated) { TEST_P(BlendStateTest, SrcBlendFactorSrcAlphaSaturated) {
@ -436,7 +436,7 @@ TEST_P(BlendStateTest, SrcBlendFactorSrcAlphaSaturated) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::SrcAlphaSaturated, nxt::BlendFactor::SrcAlphaSaturated, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::SrcAlphaSaturated, dawn::BlendFactor::SrcAlphaSaturated, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorBlendColor) { TEST_P(BlendStateTest, SrcBlendFactorBlendColor) {
@ -447,7 +447,7 @@ TEST_P(BlendStateTest, SrcBlendFactorBlendColor) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, triangleSpec.blendFactor); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, triangleSpec.blendFactor);
return std::make_pair(triangleSpec, expected); return std::make_pair(triangleSpec, expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::BlendColor, nxt::BlendFactor::BlendColor, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::BlendColor, dawn::BlendFactor::BlendColor, tests);
} }
TEST_P(BlendStateTest, SrcBlendFactorOneMinusBlendColor) { TEST_P(BlendStateTest, SrcBlendFactorOneMinusBlendColor) {
@ -459,7 +459,7 @@ TEST_P(BlendStateTest, SrcBlendFactorOneMinusBlendColor) {
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, f); RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, f);
return std::make_pair(triangleSpec, expected); return std::make_pair(triangleSpec, expected);
}); });
CheckSrcBlendFactor(base, nxt::BlendFactor::OneMinusBlendColor, nxt::BlendFactor::OneMinusBlendColor, tests); CheckSrcBlendFactor(base, dawn::BlendFactor::OneMinusBlendColor, dawn::BlendFactor::OneMinusBlendColor, tests);
} }
// The following tests check that the Destination blend factor works // The following tests check that the Destination blend factor works
@ -469,7 +469,7 @@ TEST_P(BlendStateTest, DstBlendFactorZero) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(TriangleSpec({ { color } }), color); return std::make_pair(TriangleSpec({ { color } }), color);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::Zero, nxt::BlendFactor::Zero, tests); CheckDstBlendFactor(base, dawn::BlendFactor::Zero, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorOne) { TEST_P(BlendStateTest, DstBlendFactorOne) {
@ -478,7 +478,7 @@ TEST_P(BlendStateTest, DstBlendFactorOne) {
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) { std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests), [&](const RGBA8& color) {
return std::make_pair(TriangleSpec({ { color } }), base + color); return std::make_pair(TriangleSpec({ { color } }), base + color);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::One, nxt::BlendFactor::One, tests); CheckDstBlendFactor(base, dawn::BlendFactor::One, dawn::BlendFactor::One, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorSrcColor) { TEST_P(BlendStateTest, DstBlendFactorSrcColor) {
@ -490,7 +490,7 @@ TEST_P(BlendStateTest, DstBlendFactorSrcColor) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::SrcColor, nxt::BlendFactor::Zero, tests); CheckDstBlendFactor(base, dawn::BlendFactor::SrcColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorOneMinusSrcColor) { TEST_P(BlendStateTest, DstBlendFactorOneMinusSrcColor) {
@ -502,7 +502,7 @@ TEST_P(BlendStateTest, DstBlendFactorOneMinusSrcColor) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::OneMinusSrcColor, nxt::BlendFactor::Zero, tests); CheckDstBlendFactor(base, dawn::BlendFactor::OneMinusSrcColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorSrcAlpha) { TEST_P(BlendStateTest, DstBlendFactorSrcAlpha) {
@ -513,7 +513,7 @@ TEST_P(BlendStateTest, DstBlendFactorSrcAlpha) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::SrcAlpha, nxt::BlendFactor::SrcAlpha, tests); CheckDstBlendFactor(base, dawn::BlendFactor::SrcAlpha, dawn::BlendFactor::SrcAlpha, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorOneMinusSrcAlpha) { TEST_P(BlendStateTest, DstBlendFactorOneMinusSrcAlpha) {
@ -524,7 +524,7 @@ TEST_P(BlendStateTest, DstBlendFactorOneMinusSrcAlpha) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::OneMinusSrcAlpha, nxt::BlendFactor::OneMinusSrcAlpha, tests); CheckDstBlendFactor(base, dawn::BlendFactor::OneMinusSrcAlpha, dawn::BlendFactor::OneMinusSrcAlpha, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorDstColor) { TEST_P(BlendStateTest, DstBlendFactorDstColor) {
@ -536,7 +536,7 @@ TEST_P(BlendStateTest, DstBlendFactorDstColor) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::DstColor, nxt::BlendFactor::Zero, tests); CheckDstBlendFactor(base, dawn::BlendFactor::DstColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorOneMinusDstColor) { TEST_P(BlendStateTest, DstBlendFactorOneMinusDstColor) {
@ -548,7 +548,7 @@ TEST_P(BlendStateTest, DstBlendFactorOneMinusDstColor) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::OneMinusDstColor, nxt::BlendFactor::Zero, tests); CheckDstBlendFactor(base, dawn::BlendFactor::OneMinusDstColor, dawn::BlendFactor::Zero, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorDstAlpha) { TEST_P(BlendStateTest, DstBlendFactorDstAlpha) {
@ -559,7 +559,7 @@ TEST_P(BlendStateTest, DstBlendFactorDstAlpha) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::DstAlpha, nxt::BlendFactor::DstAlpha, tests); CheckDstBlendFactor(base, dawn::BlendFactor::DstAlpha, dawn::BlendFactor::DstAlpha, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorOneMinusDstAlpha) { TEST_P(BlendStateTest, DstBlendFactorOneMinusDstAlpha) {
@ -570,7 +570,7 @@ TEST_P(BlendStateTest, DstBlendFactorOneMinusDstAlpha) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::OneMinusDstAlpha, nxt::BlendFactor::OneMinusDstAlpha, tests); CheckDstBlendFactor(base, dawn::BlendFactor::OneMinusDstAlpha, dawn::BlendFactor::OneMinusDstAlpha, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorSrcAlphaSaturated) { TEST_P(BlendStateTest, DstBlendFactorSrcAlphaSaturated) {
@ -582,7 +582,7 @@ TEST_P(BlendStateTest, DstBlendFactorSrcAlphaSaturated) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
return std::make_pair(TriangleSpec({ { color } }), expected); return std::make_pair(TriangleSpec({ { color } }), expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::SrcAlphaSaturated, nxt::BlendFactor::SrcAlphaSaturated, tests); CheckDstBlendFactor(base, dawn::BlendFactor::SrcAlphaSaturated, dawn::BlendFactor::SrcAlphaSaturated, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorBlendColor) { TEST_P(BlendStateTest, DstBlendFactorBlendColor) {
@ -593,7 +593,7 @@ TEST_P(BlendStateTest, DstBlendFactorBlendColor) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, triangleSpec.blendFactor); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, triangleSpec.blendFactor);
return std::make_pair(triangleSpec, expected); return std::make_pair(triangleSpec, expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::BlendColor, nxt::BlendFactor::BlendColor, tests); CheckDstBlendFactor(base, dawn::BlendFactor::BlendColor, dawn::BlendFactor::BlendColor, tests);
} }
TEST_P(BlendStateTest, DstBlendFactorOneMinusBlendColor) { TEST_P(BlendStateTest, DstBlendFactorOneMinusBlendColor) {
@ -605,18 +605,18 @@ TEST_P(BlendStateTest, DstBlendFactorOneMinusBlendColor) {
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, f); RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, f);
return std::make_pair(triangleSpec, expected); return std::make_pair(triangleSpec, expected);
}); });
CheckDstBlendFactor(base, nxt::BlendFactor::OneMinusBlendColor, nxt::BlendFactor::OneMinusBlendColor, tests); CheckDstBlendFactor(base, dawn::BlendFactor::OneMinusBlendColor, dawn::BlendFactor::OneMinusBlendColor, tests);
} }
// Check that the color write mask works // Check that the color write mask works
TEST_P(BlendStateTest, ColorWriteMask) { TEST_P(BlendStateTest, ColorWriteMask) {
{ {
// Test single channel color write // Test single channel color write
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetColorWriteMask(nxt::ColorWriteMask::Red) .SetColorWriteMask(dawn::ColorWriteMask::Red)
.GetResult(); .GetResult();
SetupSingleSourcePipelines(blendState); SetupSingleSourcePipelines(blendState);
@ -629,11 +629,11 @@ TEST_P(BlendStateTest, ColorWriteMask) {
{ {
// Test multi channel color write // Test multi channel color write
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetColorWriteMask(nxt::ColorWriteMask::Green | nxt::ColorWriteMask::Alpha) .SetColorWriteMask(dawn::ColorWriteMask::Green | dawn::ColorWriteMask::Alpha)
.GetResult(); .GetResult();
SetupSingleSourcePipelines(blendState); SetupSingleSourcePipelines(blendState);
@ -646,11 +646,11 @@ TEST_P(BlendStateTest, ColorWriteMask) {
{ {
// Test no channel color write // Test no channel color write
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetColorWriteMask(nxt::ColorWriteMask::None) .SetColorWriteMask(dawn::ColorWriteMask::None)
.GetResult(); .GetResult();
SetupSingleSourcePipelines(blendState); SetupSingleSourcePipelines(blendState);
@ -664,15 +664,15 @@ TEST_P(BlendStateTest, ColorWriteMask) {
// Check that the color write mask works when blending is disabled // Check that the color write mask works when blending is disabled
TEST_P(BlendStateTest, ColorWriteMaskBlendingDisabled) { TEST_P(BlendStateTest, ColorWriteMaskBlendingDisabled) {
{ {
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(false) .SetBlendEnabled(false)
.SetColorWriteMask(nxt::ColorWriteMask::Red) .SetColorWriteMask(dawn::ColorWriteMask::Red)
.GetResult(); .GetResult();
SetupSingleSourcePipelines(blendState); SetupSingleSourcePipelines(blendState);
RGBA8 base(32, 64, 128, 192); RGBA8 base(32, 64, 128, 192);
RGBA8 expected(32, 0, 0, 0); RGBA8 expected(32, 0, 0, 0);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(testPipeline) .SetRenderPipeline(testPipeline)
.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { base } }))) .SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { base } })))
@ -688,28 +688,28 @@ TEST_P(BlendStateTest, ColorWriteMaskBlendingDisabled) {
// Test that independent blend states on render targets works // Test that independent blend states on render targets works
TEST_P(BlendStateTest, IndependentBlendState) { TEST_P(BlendStateTest, IndependentBlendState) {
std::array<nxt::Texture, 4> renderTargets; std::array<dawn::Texture, 4> renderTargets;
std::array<nxt::TextureView, 4> renderTargetViews; std::array<dawn::TextureView, 4> renderTargetViews;
for (uint32_t i = 0; i < 4; ++i) { for (uint32_t i = 0; i < 4; ++i) {
renderTargets[i] = device.CreateTextureBuilder() renderTargets[i] = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(kRTSize, kRTSize, 1) .SetExtent(kRTSize, kRTSize, 1)
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm) .SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment | nxt::TextureUsageBit::TransferSrc) .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc)
.GetResult(); .GetResult();
renderTargetViews[i] = renderTargets[i].CreateTextureViewBuilder().GetResult(); renderTargetViews[i] = renderTargets[i].CreateTextureViewBuilder().GetResult();
} }
nxt::RenderPassDescriptor renderpass = device.CreateRenderPassDescriptorBuilder() dawn::RenderPassDescriptor renderpass = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetViews[0], nxt::LoadOp::Clear) .SetColorAttachment(0, renderTargetViews[0], dawn::LoadOp::Clear)
.SetColorAttachment(1, renderTargetViews[1], nxt::LoadOp::Clear) .SetColorAttachment(1, renderTargetViews[1], dawn::LoadOp::Clear)
.SetColorAttachment(2, renderTargetViews[2], nxt::LoadOp::Clear) .SetColorAttachment(2, renderTargetViews[2], dawn::LoadOp::Clear)
.SetColorAttachment(3, renderTargetViews[3], nxt::LoadOp::Clear) .SetColorAttachment(3, renderTargetViews[3], dawn::LoadOp::Clear)
.GetResult(); .GetResult();
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(set = 0, binding = 0) uniform myBlock { layout(set = 0, binding = 0) uniform myBlock {
vec4 color0; vec4 color0;
@ -731,42 +731,42 @@ TEST_P(BlendStateTest, IndependentBlendState) {
} }
)"); )");
std::array<nxt::BlendState, 3> blendStates = { { std::array<dawn::BlendState, 3> blendStates = { {
device.CreateBlendStateBuilder() device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.GetResult(), .GetResult(),
device.CreateBlendStateBuilder() device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Subtract, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Subtract, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Subtract, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Subtract, dawn::BlendFactor::One, dawn::BlendFactor::One)
.GetResult(), .GetResult(),
device.CreateBlendStateBuilder() device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Min, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Min, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Min, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Min, dawn::BlendFactor::One, dawn::BlendFactor::One)
.GetResult(), .GetResult(),
} }; } };
basePipeline = device.CreateRenderPipelineBuilder() basePipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetColorAttachmentFormat(1, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(1, dawn::TextureFormat::R8G8B8A8Unorm)
.SetColorAttachmentFormat(2, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(2, dawn::TextureFormat::R8G8B8A8Unorm)
.SetColorAttachmentFormat(3, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(3, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
testPipeline = device.CreateRenderPipelineBuilder() testPipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetColorAttachmentFormat(1, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(1, dawn::TextureFormat::R8G8B8A8Unorm)
.SetColorAttachmentFormat(2, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(2, dawn::TextureFormat::R8G8B8A8Unorm)
.SetColorAttachmentFormat(3, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(3, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetColorAttachmentBlendState(0, blendStates[0]) .SetColorAttachmentBlendState(0, blendStates[0])
.SetColorAttachmentBlendState(1, blendStates[1]) .SetColorAttachmentBlendState(1, blendStates[1])
// Blend state not set on third color attachment. It should be default // Blend state not set on third color attachment. It should be default
@ -786,7 +786,7 @@ TEST_P(BlendStateTest, IndependentBlendState) {
RGBA8 expected2 = color2; RGBA8 expected2 = color2;
RGBA8 expected3 = min(color3, base); RGBA8 expected3 = min(color3, base);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderpass) .BeginRenderPass(renderpass)
.SetRenderPipeline(basePipeline) .SetRenderPipeline(basePipeline)
.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 4>({ { base, base, base, base } }))) .SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 4>({ { base, base, base, base } })))
@ -809,13 +809,13 @@ TEST_P(BlendStateTest, IndependentBlendState) {
// Test that the default blend color is correctly set at the beginning of every subpass // Test that the default blend color is correctly set at the beginning of every subpass
TEST_P(BlendStateTest, DefaultBlendColor) { TEST_P(BlendStateTest, DefaultBlendColor) {
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::BlendColor, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::BlendColor, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::BlendColor, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::BlendColor, dawn::BlendFactor::One)
.GetResult(); .GetResult();
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(set = 0, binding = 0) uniform myBlock { layout(set = 0, binding = 0) uniform myBlock {
vec4 color; vec4 color;
@ -831,21 +831,21 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
basePipeline = device.CreateRenderPipelineBuilder() basePipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
testPipeline = device.CreateRenderPipelineBuilder() testPipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetColorAttachmentBlendState(0, blendState) .SetColorAttachmentBlendState(0, blendState)
.GetResult(); .GetResult();
// Check that the initial blend color is (0,0,0,0) // Check that the initial blend color is (0,0,0,0)
{ {
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(basePipeline) .SetRenderPipeline(basePipeline)
.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } }))) .SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })))
@ -863,7 +863,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
// Check that setting the blend color works // Check that setting the blend color works
{ {
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(basePipeline) .SetRenderPipeline(basePipeline)
.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } }))) .SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })))
@ -882,7 +882,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
// Check that the blend color is not inherited between render passes // Check that the blend color is not inherited between render passes
{ {
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(basePipeline) .SetRenderPipeline(basePipeline)
.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } }))) .SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })))

View File

@ -27,8 +27,8 @@ class BufferMapReadTests : public NXTTest {
test->mappedData = data; test->mappedData = data;
} }
const void* MapReadAsyncAndWait(const nxt::Buffer& buffer, uint32_t start, uint32_t offset) { const void* MapReadAsyncAndWait(const dawn::Buffer& buffer, uint32_t start, uint32_t offset) {
buffer.MapReadAsync(start, offset, MapReadCallback, static_cast<nxt::CallbackUserdata>(reinterpret_cast<uintptr_t>(this))); buffer.MapReadAsync(start, offset, MapReadCallback, static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
while (mappedData == nullptr) { while (mappedData == nullptr) {
WaitABit(); WaitABit();
@ -43,9 +43,9 @@ class BufferMapReadTests : public NXTTest {
// Test that the simplest map read (one u8 at offset 0) works. // Test that the simplest map read (one u8 at offset 0) works.
TEST_P(BufferMapReadTests, SmallReadAtZero) { TEST_P(BufferMapReadTests, SmallReadAtZero) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(1) .SetSize(1)
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
uint8_t myData = 187; uint8_t myData = 187;
@ -59,9 +59,9 @@ TEST_P(BufferMapReadTests, SmallReadAtZero) {
// Test mapping a buffer at an offset. // Test mapping a buffer at an offset.
TEST_P(BufferMapReadTests, SmallReadAtOffset) { TEST_P(BufferMapReadTests, SmallReadAtOffset) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(4000) .SetSize(4000)
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
uint8_t myData = 234; uint8_t myData = 234;
@ -75,9 +75,9 @@ TEST_P(BufferMapReadTests, SmallReadAtOffset) {
// Test mapping a buffer at an offset that's not uint32-aligned. // Test mapping a buffer at an offset that's not uint32-aligned.
TEST_P(BufferMapReadTests, SmallReadAtUnalignedOffset) { TEST_P(BufferMapReadTests, SmallReadAtUnalignedOffset) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(4000) .SetSize(4000)
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
uint8_t myData = 213; uint8_t myData = 213;
@ -97,9 +97,9 @@ TEST_P(BufferMapReadTests, LargeRead) {
myData.push_back(i); myData.push_back(i);
} }
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(static_cast<uint32_t>(kDataSize * sizeof(uint32_t))) .SetSize(static_cast<uint32_t>(kDataSize * sizeof(uint32_t)))
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
buffer.SetSubData(0, kDataSize * sizeof(uint32_t), reinterpret_cast<uint8_t*>(myData.data())); buffer.SetSubData(0, kDataSize * sizeof(uint32_t), reinterpret_cast<uint8_t*>(myData.data()));
@ -123,8 +123,8 @@ class BufferMapWriteTests : public NXTTest {
test->mappedData = data; test->mappedData = data;
} }
void* MapWriteAsyncAndWait(const nxt::Buffer& buffer, uint32_t start, uint32_t offset) { void* MapWriteAsyncAndWait(const dawn::Buffer& buffer, uint32_t start, uint32_t offset) {
buffer.MapWriteAsync(start, offset, MapWriteCallback, static_cast<nxt::CallbackUserdata>(reinterpret_cast<uintptr_t>(this))); buffer.MapWriteAsync(start, offset, MapWriteCallback, static_cast<dawn::CallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
while (mappedData == nullptr) { while (mappedData == nullptr) {
WaitABit(); WaitABit();
@ -139,9 +139,9 @@ class BufferMapWriteTests : public NXTTest {
// Test that the simplest map write (one u32 at offset 0) works. // Test that the simplest map write (one u32 at offset 0) works.
TEST_P(BufferMapWriteTests, SmallWriteAtZero) { TEST_P(BufferMapWriteTests, SmallWriteAtZero) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::TransferSrc) .SetAllowedUsage(dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc)
.GetResult(); .GetResult();
uint32_t myData = 2934875; uint32_t myData = 2934875;
@ -154,9 +154,9 @@ TEST_P(BufferMapWriteTests, SmallWriteAtZero) {
// Test mapping a buffer at an offset. // Test mapping a buffer at an offset.
TEST_P(BufferMapWriteTests, SmallWriteAtOffset) { TEST_P(BufferMapWriteTests, SmallWriteAtOffset) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(4000) .SetSize(4000)
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::TransferSrc) .SetAllowedUsage(dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc)
.GetResult(); .GetResult();
uint32_t myData = 2934875; uint32_t myData = 2934875;
@ -175,9 +175,9 @@ TEST_P(BufferMapWriteTests, LargeWrite) {
myData.push_back(i); myData.push_back(i);
} }
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(static_cast<uint32_t>(kDataSize * sizeof(uint32_t))) .SetSize(static_cast<uint32_t>(kDataSize * sizeof(uint32_t)))
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::TransferSrc) .SetAllowedUsage(dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc)
.GetResult(); .GetResult();
void* mappedData = MapWriteAsyncAndWait(buffer, 0, kDataSize * sizeof(uint32_t)); void* mappedData = MapWriteAsyncAndWait(buffer, 0, kDataSize * sizeof(uint32_t));
@ -194,9 +194,9 @@ class BufferSetSubDataTests : public NXTTest {
// Test the simplest set sub data: setting one u8 at offset 0. // Test the simplest set sub data: setting one u8 at offset 0.
TEST_P(BufferSetSubDataTests, SmallDataAtZero) { TEST_P(BufferSetSubDataTests, SmallDataAtZero) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(1) .SetSize(1)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
uint8_t value = 171; uint8_t value = 171;
@ -207,9 +207,9 @@ TEST_P(BufferSetSubDataTests, SmallDataAtZero) {
// Test that SetSubData offset works. // Test that SetSubData offset works.
TEST_P(BufferSetSubDataTests, SmallDataAtOffset) { TEST_P(BufferSetSubDataTests, SmallDataAtOffset) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(4000) .SetSize(4000)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
constexpr uint32_t kOffset = 2000; constexpr uint32_t kOffset = 2000;
@ -230,9 +230,9 @@ TEST_P(BufferSetSubDataTests, ManySetSubData) {
constexpr uint32_t kSize = 4000 * 1000; constexpr uint32_t kSize = 4000 * 1000;
constexpr uint32_t kElements = 1000 * 1000; constexpr uint32_t kElements = 1000 * 1000;
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(kSize) .SetSize(kSize)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
std::vector<uint32_t> expectedData; std::vector<uint32_t> expectedData;
@ -248,9 +248,9 @@ TEST_P(BufferSetSubDataTests, ManySetSubData) {
TEST_P(BufferSetSubDataTests, LargeSetSubData) { TEST_P(BufferSetSubDataTests, LargeSetSubData) {
constexpr uint32_t kSize = 4000 * 1000; constexpr uint32_t kSize = 4000 * 1000;
constexpr uint32_t kElements = 1000 * 1000; constexpr uint32_t kElements = 1000 * 1000;
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(kSize) .SetSize(kSize)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
std::vector<uint32_t> expectedData; std::vector<uint32_t> expectedData;

View File

@ -30,24 +30,24 @@ class ComputeCopyStorageBufferTests : public NXTTest {
void ComputeCopyStorageBufferTests::BasicTest(const char* shader) { void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
auto bgl = utils::MakeBindGroupLayout( auto bgl = utils::MakeBindGroupLayout(
device, { device, {
{0, nxt::ShaderStageBit::Compute, nxt::BindingType::StorageBuffer}, {0, dawn::ShaderStageBit::Compute, dawn::BindingType::StorageBuffer},
{1, nxt::ShaderStageBit::Compute, nxt::BindingType::StorageBuffer}, {1, dawn::ShaderStageBit::Compute, dawn::BindingType::StorageBuffer},
}); });
// Set up shader and pipeline // Set up shader and pipeline
auto module = utils::CreateShaderModule(device, nxt::ShaderStage::Compute, shader); auto module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, shader);
auto pl = utils::MakeBasicPipelineLayout(device, &bgl); auto pl = utils::MakeBasicPipelineLayout(device, &bgl);
auto pipeline = device.CreateComputePipelineBuilder() auto pipeline = device.CreateComputePipelineBuilder()
.SetLayout(pl) .SetLayout(pl)
.SetStage(nxt::ShaderStage::Compute, module, "main") .SetStage(dawn::ShaderStage::Compute, module, "main")
.GetResult(); .GetResult();
// Set up src storage buffer // Set up src storage buffer
auto src = auto src =
device.CreateBufferBuilder() device.CreateBufferBuilder()
.SetSize(kNumUints * sizeof(uint32_t)) .SetSize(kNumUints * sizeof(uint32_t))
.SetAllowedUsage(nxt::BufferUsageBit::Storage | nxt::BufferUsageBit::TransferSrc | .SetAllowedUsage(dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::TransferSrc |
nxt::BufferUsageBit::TransferDst) dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
std::array<uint32_t, kNumUints> expected; std::array<uint32_t, kNumUints> expected;
for (uint32_t i = 0; i < kNumUints; ++i) { for (uint32_t i = 0; i < kNumUints; ++i) {
@ -62,8 +62,8 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
auto dst = auto dst =
device.CreateBufferBuilder() device.CreateBufferBuilder()
.SetSize(kNumUints * sizeof(uint32_t)) .SetSize(kNumUints * sizeof(uint32_t))
.SetAllowedUsage(nxt::BufferUsageBit::Storage | nxt::BufferUsageBit::TransferSrc | .SetAllowedUsage(dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::TransferSrc |
nxt::BufferUsageBit::TransferDst) dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
std::array<uint32_t, kNumUints> zero{}; std::array<uint32_t, kNumUints> zero{};
dst.SetSubData(0, sizeof(zero), reinterpret_cast<const uint8_t*>(zero.data())); dst.SetSubData(0, sizeof(zero), reinterpret_cast<const uint8_t*>(zero.data()));
@ -73,7 +73,7 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
// Set up bind group and issue dispatch // Set up bind group and issue dispatch
auto bindGroup = device.CreateBindGroupBuilder() auto bindGroup = device.CreateBindGroupBuilder()
.SetLayout(bgl) .SetLayout(bgl)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &srcView) .SetBufferViews(0, 1, &srcView)
.SetBufferViews(1, 1, &dstView) .SetBufferViews(1, 1, &dstView)
.GetResult(); .GetResult();

View File

@ -72,12 +72,12 @@ class CopyTests_T2B : public CopyTests {
void DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) { void DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) {
// Create a texture that is `width` x `height` with (`level` + 1) mip levels. // Create a texture that is `width` x `height` with (`level` + 1) mip levels.
nxt::Texture texture = device.CreateTextureBuilder() dawn::Texture texture = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(textureSpec.width, textureSpec.height, 1) .SetExtent(textureSpec.width, textureSpec.height, 1)
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm) .SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
.SetMipLevels(textureSpec.level + 1) .SetMipLevels(textureSpec.level + 1)
.SetAllowedUsage(nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::TransferSrc) .SetAllowedUsage(dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::TransferSrc)
.GetResult(); .GetResult();
uint32_t width = textureSpec.width >> textureSpec.level; uint32_t width = textureSpec.width >> textureSpec.level;
@ -89,9 +89,9 @@ class CopyTests_T2B : public CopyTests {
// Create an upload buffer and use it to populate the `level` mip of the texture // Create an upload buffer and use it to populate the `level` mip of the texture
std::vector<RGBA8> textureData(texelCount); std::vector<RGBA8> textureData(texelCount);
FillTextureData(width, height, rowPitch / kBytesPerTexel, textureData.data()); FillTextureData(width, height, rowPitch / kBytesPerTexel, textureData.data());
nxt::Buffer uploadBuffer = utils::CreateBufferFromData(device, textureData.data(), static_cast<uint32_t>(sizeof(RGBA8) * textureData.size()), nxt::BufferUsageBit::TransferSrc); dawn::Buffer uploadBuffer = utils::CreateBufferFromData(device, textureData.data(), static_cast<uint32_t>(sizeof(RGBA8) * textureData.size()), dawn::BufferUsageBit::TransferSrc);
nxt::CommandBuffer commands[2]; dawn::CommandBuffer commands[2];
commands[0] = device.CreateCommandBufferBuilder() commands[0] = device.CreateCommandBufferBuilder()
.CopyBufferToTexture(uploadBuffer, 0, rowPitch, texture, 0, 0, 0, width, height, 1, textureSpec.level) .CopyBufferToTexture(uploadBuffer, 0, rowPitch, texture, 0, 0, 0, width, height, 1, textureSpec.level)
@ -100,9 +100,9 @@ class CopyTests_T2B : public CopyTests {
// Create a buffer of size `size` and populate it with empty data (0,0,0,0) // Create a buffer of size `size` and populate it with empty data (0,0,0,0)
// Note: Prepopulating the buffer with empty data ensures that there is not random data in the expectation // Note: Prepopulating the buffer with empty data ensures that there is not random data in the expectation
// and helps ensure that the padding due to the row pitch is not modified by the copy // and helps ensure that the padding due to the row pitch is not modified by the copy
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(bufferSpec.size) .SetSize(bufferSpec.size)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
std::vector<RGBA8> emptyData(bufferSpec.size / kBytesPerTexel); std::vector<RGBA8> emptyData(bufferSpec.size / kBytesPerTexel);
buffer.SetSubData(0, static_cast<uint32_t>(emptyData.size() * sizeof(RGBA8)), reinterpret_cast<const uint8_t*>(emptyData.data())); buffer.SetSubData(0, static_cast<uint32_t>(emptyData.size() * sizeof(RGBA8)), reinterpret_cast<const uint8_t*>(emptyData.data()));
@ -147,24 +147,24 @@ protected:
void DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) { void DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) {
// Create a buffer of size `size` and populate it with data // Create a buffer of size `size` and populate it with data
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetSize(bufferSpec.size) .SetSize(bufferSpec.size)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
std::vector<RGBA8> bufferData(bufferSpec.size / kBytesPerTexel); std::vector<RGBA8> bufferData(bufferSpec.size / kBytesPerTexel);
FillBufferData(bufferData.data(), bufferData.size()); FillBufferData(bufferData.data(), bufferData.size());
buffer.SetSubData(0, static_cast<uint32_t>(bufferData.size() * sizeof(RGBA8)), reinterpret_cast<const uint8_t*>(bufferData.data())); buffer.SetSubData(0, static_cast<uint32_t>(bufferData.size() * sizeof(RGBA8)), reinterpret_cast<const uint8_t*>(bufferData.data()));
// Create a texture that is `width` x `height` with (`level` + 1) mip levels. // Create a texture that is `width` x `height` with (`level` + 1) mip levels.
nxt::Texture texture = device.CreateTextureBuilder() dawn::Texture texture = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(textureSpec.width, textureSpec.height, 1) .SetExtent(textureSpec.width, textureSpec.height, 1)
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm) .SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
.SetMipLevels(textureSpec.level + 1) .SetMipLevels(textureSpec.level + 1)
.SetAllowedUsage(nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::TransferSrc) .SetAllowedUsage(dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::TransferSrc)
.GetResult(); .GetResult();
nxt::CommandBuffer commands[2]; dawn::CommandBuffer commands[2];
// Create an upload buffer filled with empty data and use it to populate the `level` mip of the texture // Create an upload buffer filled with empty data and use it to populate the `level` mip of the texture
// Note: Prepopulating the texture with empty data ensures that there is not random data in the expectation // Note: Prepopulating the texture with empty data ensures that there is not random data in the expectation
@ -177,7 +177,7 @@ protected:
uint32_t texelCount = texelsPerRow * (height - 1) + width; uint32_t texelCount = texelsPerRow * (height - 1) + width;
std::vector<RGBA8> emptyData(texelCount); std::vector<RGBA8> emptyData(texelCount);
nxt::Buffer uploadBuffer = utils::CreateBufferFromData(device, emptyData.data(), static_cast<uint32_t>(sizeof(RGBA8) * emptyData.size()), nxt::BufferUsageBit::TransferSrc); dawn::Buffer uploadBuffer = utils::CreateBufferFromData(device, emptyData.data(), static_cast<uint32_t>(sizeof(RGBA8) * emptyData.size()), dawn::BufferUsageBit::TransferSrc);
commands[0] = device.CreateCommandBufferBuilder() commands[0] = device.CreateCommandBufferBuilder()
.CopyBufferToTexture(uploadBuffer, 0, rowPitch, texture, 0, 0, 0, width, height, 1, textureSpec.level) .CopyBufferToTexture(uploadBuffer, 0, rowPitch, texture, 0, 0, 0, width, height, 1, textureSpec.level)

View File

@ -25,31 +25,31 @@ class DepthStencilStateTest : public NXTTest {
NXTTest::SetUp(); NXTTest::SetUp();
renderTarget = device.CreateTextureBuilder() renderTarget = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(kRTSize, kRTSize, 1) .SetExtent(kRTSize, kRTSize, 1)
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm) .SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment | nxt::TextureUsageBit::TransferSrc) .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc)
.GetResult(); .GetResult();
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult(); renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
depthTexture = device.CreateTextureBuilder() depthTexture = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(kRTSize, kRTSize, 1) .SetExtent(kRTSize, kRTSize, 1)
.SetFormat(nxt::TextureFormat::D32FloatS8Uint) .SetFormat(dawn::TextureFormat::D32FloatS8Uint)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment) .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
.GetResult(); .GetResult();
depthTextureView = depthTexture.CreateTextureViewBuilder().GetResult(); depthTextureView = depthTexture.CreateTextureViewBuilder().GetResult();
renderpass = device.CreateRenderPassDescriptorBuilder() renderpass = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, nxt::LoadOp::Clear) .SetColorAttachment(0, renderTargetView, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthTextureView, nxt::LoadOp::Clear, nxt::LoadOp::Clear) .SetDepthStencilAttachment(depthTextureView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
layout(set = 0, binding = 0) uniform myBlock { layout(set = 0, binding = 0) uniform myBlock {
vec3 color; vec3 color;
@ -64,7 +64,7 @@ class DepthStencilStateTest : public NXTTest {
} }
)"); )");
fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(set = 0, binding = 0) uniform myBlock { layout(set = 0, binding = 0) uniform myBlock {
vec3 color; vec3 color;
@ -78,15 +78,15 @@ class DepthStencilStateTest : public NXTTest {
bindGroupLayout = utils::MakeBindGroupLayout( bindGroupLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment, {0, dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment,
nxt::BindingType::UniformBuffer}, dawn::BindingType::UniformBuffer},
}); });
pipelineLayout = utils::MakeBasicPipelineLayout(device, &bindGroupLayout); pipelineLayout = utils::MakeBasicPipelineLayout(device, &bindGroupLayout);
} }
struct TestSpec { struct TestSpec {
const nxt::DepthStencilState& depthStencilState; const dawn::DepthStencilState& depthStencilState;
RGBA8 color; RGBA8 color;
float depth; float depth;
uint32_t stencil; uint32_t stencil;
@ -94,13 +94,13 @@ class DepthStencilStateTest : public NXTTest {
// 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(nxt::CompareFunction compareFunction, bool less, bool equal, bool greater) { void CheckDepthCompareFunction(dawn::CompareFunction compareFunction, bool less, bool equal, bool greater) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetDepthCompareFunction(nxt::CompareFunction::Always) .SetDepthCompareFunction(dawn::CompareFunction::Always)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetDepthCompareFunction(compareFunction) .SetDepthCompareFunction(compareFunction)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.GetResult(); .GetResult();
@ -125,13 +125,13 @@ class DepthStencilStateTest : public NXTTest {
// 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(nxt::CompareFunction compareFunction, bool less, bool equal, bool greater) { void CheckStencilCompareFunction(dawn::CompareFunction compareFunction, bool less, bool equal, bool greater) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, compareFunction, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep) .SetStencilFunction(dawn::Face::Both, compareFunction, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
.GetResult(); .GetResult();
RGBA8 baseColor = RGBA8(255, 255, 255, 255); RGBA8 baseColor = RGBA8(255, 255, 255, 255);
@ -153,13 +153,13 @@ class DepthStencilStateTest : public NXTTest {
} }
// 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(nxt::StencilOperation stencilOperation, uint32_t initialStencil, uint32_t reference, uint32_t expectedStencil) { void CheckStencilOperation(dawn::StencilOperation stencilOperation, uint32_t initialStencil, uint32_t reference, uint32_t expectedStencil) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, stencilOperation) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, stencilOperation)
.GetResult(); .GetResult();
CheckStencil({ CheckStencil({
@ -173,8 +173,8 @@ class DepthStencilStateTest : public NXTTest {
// 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
void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) { void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) {
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Equal, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
.GetResult(); .GetResult();
testParams.push_back({ state, RGBA8(0, 255, 0, 255), 0, expectedStencil }); testParams.push_back({ state, RGBA8(0, 255, 0, 255), 0, expectedStencil });
@ -184,7 +184,7 @@ class DepthStencilStateTest : public NXTTest {
// 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 depthStencil state, one frontfacing, one backfacing
// Draw the triangles in order and check the expected colors for the frontfaces and backfaces // Draw the triangles in order and check the expected colors for the frontfaces and backfaces
void DoTest(const std::vector<TestSpec> &testParams, const RGBA8& expectedFront, const RGBA8& expectedBack) { void DoTest(const std::vector<TestSpec> &testParams, const RGBA8& expectedFront, const RGBA8& expectedBack) {
nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder(); dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
struct TriangleData { struct TriangleData {
float color[3]; float color[3];
@ -201,26 +201,26 @@ class DepthStencilStateTest : public NXTTest {
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
nxt::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData), nxt::BufferUsageBit::Uniform); dawn::Buffer buffer = utils::CreateBufferFromData(device, &data, sizeof(TriangleData), dawn::BufferUsageBit::Uniform);
nxt::BufferView view = buffer.CreateBufferViewBuilder() dawn::BufferView view = buffer.CreateBufferViewBuilder()
.SetExtent(0, sizeof(TriangleData)) .SetExtent(0, sizeof(TriangleData))
.GetResult(); .GetResult();
// Create a bind group for the data // Create a bind group for the data
nxt::BindGroup bindGroup = device.CreateBindGroupBuilder() dawn::BindGroup bindGroup = device.CreateBindGroupBuilder()
.SetLayout(bindGroupLayout) .SetLayout(bindGroupLayout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &view) .SetBufferViews(0, 1, &view)
.GetResult(); .GetResult();
// 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
nxt::RenderPipeline pipeline = device.CreateRenderPipelineBuilder() dawn::RenderPipeline pipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetDepthStencilAttachmentFormat(nxt::TextureFormat::D32FloatS8Uint) .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetDepthStencilState(test.depthStencilState) .SetDepthStencilState(test.depthStencilState)
.GetResult(); .GetResult();
@ -230,7 +230,7 @@ class DepthStencilStateTest : public NXTTest {
.DrawArrays(6, 1, 0, 0); .DrawArrays(6, 1, 0, 0);
} }
nxt::CommandBuffer commands = builder dawn::CommandBuffer commands = builder
.EndRenderPass() .EndRenderPass()
.GetResult(); .GetResult();
@ -244,20 +244,20 @@ class DepthStencilStateTest : public NXTTest {
DoTest(testParams, expected, expected); DoTest(testParams, expected, expected);
} }
nxt::RenderPassDescriptor renderpass; dawn::RenderPassDescriptor renderpass;
nxt::Texture renderTarget; dawn::Texture renderTarget;
nxt::Texture depthTexture; dawn::Texture depthTexture;
nxt::TextureView renderTargetView; dawn::TextureView renderTargetView;
nxt::TextureView depthTextureView; dawn::TextureView depthTextureView;
nxt::ShaderModule vsModule; dawn::ShaderModule vsModule;
nxt::ShaderModule fsModule; dawn::ShaderModule fsModule;
nxt::BindGroupLayout bindGroupLayout; dawn::BindGroupLayout bindGroupLayout;
nxt::PipelineLayout pipelineLayout; dawn::PipelineLayout pipelineLayout;
}; };
// Test compilation and usage of the fixture // Test compilation and usage of the fixture
TEST_P(DepthStencilStateTest, Basic) { TEST_P(DepthStencilStateTest, Basic) {
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.GetResult(); .GetResult();
DoTest({ DoTest({
@ -267,7 +267,7 @@ TEST_P(DepthStencilStateTest, Basic) {
// Test defaults: depth and stencil tests disabled // Test defaults: depth and stencil tests disabled
TEST_P(DepthStencilStateTest, DepthStencilDisabled) { TEST_P(DepthStencilStateTest, DepthStencilDisabled) {
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.GetResult(); .GetResult();
TestSpec specs[3] = { TestSpec specs[3] = {
@ -288,51 +288,51 @@ TEST_P(DepthStencilStateTest, DepthStencilDisabled) {
// The following tests check that each depth comparison function works // The following tests check that each depth comparison function works
TEST_P(DepthStencilStateTest, DepthAlways) { TEST_P(DepthStencilStateTest, DepthAlways) {
CheckDepthCompareFunction(nxt::CompareFunction::Always , true, true, true); CheckDepthCompareFunction(dawn::CompareFunction::Always , true, true, true);
} }
TEST_P(DepthStencilStateTest, DepthEqual) { TEST_P(DepthStencilStateTest, DepthEqual) {
CheckDepthCompareFunction(nxt::CompareFunction::Equal, false, true, false); CheckDepthCompareFunction(dawn::CompareFunction::Equal, false, true, false);
} }
TEST_P(DepthStencilStateTest, DepthGreater) { TEST_P(DepthStencilStateTest, DepthGreater) {
CheckDepthCompareFunction(nxt::CompareFunction::Greater, false, false, true); CheckDepthCompareFunction(dawn::CompareFunction::Greater, false, false, true);
} }
TEST_P(DepthStencilStateTest, DepthGreaterEqual) { TEST_P(DepthStencilStateTest, DepthGreaterEqual) {
CheckDepthCompareFunction(nxt::CompareFunction::GreaterEqual, false, true, true); CheckDepthCompareFunction(dawn::CompareFunction::GreaterEqual, false, true, true);
} }
TEST_P(DepthStencilStateTest, DepthLess) { TEST_P(DepthStencilStateTest, DepthLess) {
CheckDepthCompareFunction(nxt::CompareFunction::Less, true, false, false); CheckDepthCompareFunction(dawn::CompareFunction::Less, true, false, false);
} }
TEST_P(DepthStencilStateTest, DepthLessEqual) { TEST_P(DepthStencilStateTest, DepthLessEqual) {
CheckDepthCompareFunction(nxt::CompareFunction::LessEqual, true, true, false); CheckDepthCompareFunction(dawn::CompareFunction::LessEqual, true, true, false);
} }
TEST_P(DepthStencilStateTest, DepthNever) { TEST_P(DepthStencilStateTest, DepthNever) {
CheckDepthCompareFunction(nxt::CompareFunction::Never, false, false, false); CheckDepthCompareFunction(dawn::CompareFunction::Never, false, false, false);
} }
TEST_P(DepthStencilStateTest, DepthNotEqual) { TEST_P(DepthStencilStateTest, DepthNotEqual) {
CheckDepthCompareFunction(nxt::CompareFunction::NotEqual, true, false, true); CheckDepthCompareFunction(dawn::CompareFunction::NotEqual, true, false, true);
} }
// Test that disabling depth writes works and leaves the depth buffer unchanged // Test that disabling depth writes works and leaves the depth buffer unchanged
TEST_P(DepthStencilStateTest, DepthWriteDisabled) { TEST_P(DepthStencilStateTest, DepthWriteDisabled) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetDepthCompareFunction(nxt::CompareFunction::Always) .SetDepthCompareFunction(dawn::CompareFunction::Always)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.GetResult(); .GetResult();
nxt::DepthStencilState noDepthWrite = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState noDepthWrite = device.CreateDepthStencilStateBuilder()
.SetDepthCompareFunction(nxt::CompareFunction::Always) .SetDepthCompareFunction(dawn::CompareFunction::Always)
.SetDepthWriteEnabled(false) .SetDepthWriteEnabled(false)
.GetResult(); .GetResult();
nxt::DepthStencilState checkState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState checkState = device.CreateDepthStencilStateBuilder()
.SetDepthCompareFunction(nxt::CompareFunction::Equal) .SetDepthCompareFunction(dawn::CompareFunction::Equal)
.GetResult(); .GetResult();
DoTest({ DoTest({
@ -344,82 +344,82 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) {
// The following tests check that each stencil comparison function works // The following tests check that each stencil comparison function works
TEST_P(DepthStencilStateTest, StencilAlways) { TEST_P(DepthStencilStateTest, StencilAlways) {
CheckStencilCompareFunction(nxt::CompareFunction::Always, true, true, true); CheckStencilCompareFunction(dawn::CompareFunction::Always, true, true, true);
} }
TEST_P(DepthStencilStateTest, StencilEqual) { TEST_P(DepthStencilStateTest, StencilEqual) {
CheckStencilCompareFunction(nxt::CompareFunction::Equal, false, true, false); CheckStencilCompareFunction(dawn::CompareFunction::Equal, false, true, false);
} }
TEST_P(DepthStencilStateTest, StencilGreater) { TEST_P(DepthStencilStateTest, StencilGreater) {
CheckStencilCompareFunction(nxt::CompareFunction::Greater, false, false, true); CheckStencilCompareFunction(dawn::CompareFunction::Greater, false, false, true);
} }
TEST_P(DepthStencilStateTest, StencilGreaterEqual) { TEST_P(DepthStencilStateTest, StencilGreaterEqual) {
CheckStencilCompareFunction(nxt::CompareFunction::GreaterEqual, false, true, true); CheckStencilCompareFunction(dawn::CompareFunction::GreaterEqual, false, true, true);
} }
TEST_P(DepthStencilStateTest, StencilLess) { TEST_P(DepthStencilStateTest, StencilLess) {
CheckStencilCompareFunction(nxt::CompareFunction::Less, true, false, false); CheckStencilCompareFunction(dawn::CompareFunction::Less, true, false, false);
} }
TEST_P(DepthStencilStateTest, StencilLessEqual) { TEST_P(DepthStencilStateTest, StencilLessEqual) {
CheckStencilCompareFunction(nxt::CompareFunction::LessEqual, true, true, false); CheckStencilCompareFunction(dawn::CompareFunction::LessEqual, true, true, false);
} }
TEST_P(DepthStencilStateTest, StencilNever) { TEST_P(DepthStencilStateTest, StencilNever) {
CheckStencilCompareFunction(nxt::CompareFunction::Never, false, false, false); CheckStencilCompareFunction(dawn::CompareFunction::Never, false, false, false);
} }
TEST_P(DepthStencilStateTest, StencilNotEqual) { TEST_P(DepthStencilStateTest, StencilNotEqual) {
CheckStencilCompareFunction(nxt::CompareFunction::NotEqual, true, false, true); CheckStencilCompareFunction(dawn::CompareFunction::NotEqual, true, false, true);
} }
// The following tests check that each stencil operation works // The following tests check that each stencil operation works
TEST_P(DepthStencilStateTest, StencilKeep) { TEST_P(DepthStencilStateTest, StencilKeep) {
CheckStencilOperation(nxt::StencilOperation::Keep, 1, 3, 1); CheckStencilOperation(dawn::StencilOperation::Keep, 1, 3, 1);
} }
TEST_P(DepthStencilStateTest, StencilZero) { TEST_P(DepthStencilStateTest, StencilZero) {
CheckStencilOperation(nxt::StencilOperation::Zero, 1, 3, 0); CheckStencilOperation(dawn::StencilOperation::Zero, 1, 3, 0);
} }
TEST_P(DepthStencilStateTest, StencilReplace) { TEST_P(DepthStencilStateTest, StencilReplace) {
CheckStencilOperation(nxt::StencilOperation::Replace, 1, 3, 3); CheckStencilOperation(dawn::StencilOperation::Replace, 1, 3, 3);
} }
TEST_P(DepthStencilStateTest, StencilInvert) { TEST_P(DepthStencilStateTest, StencilInvert) {
CheckStencilOperation(nxt::StencilOperation::Invert, 0xf0, 3, 0x0f); CheckStencilOperation(dawn::StencilOperation::Invert, 0xf0, 3, 0x0f);
} }
TEST_P(DepthStencilStateTest, StencilIncrementClamp) { TEST_P(DepthStencilStateTest, StencilIncrementClamp) {
CheckStencilOperation(nxt::StencilOperation::IncrementClamp, 1, 3, 2); CheckStencilOperation(dawn::StencilOperation::IncrementClamp, 1, 3, 2);
CheckStencilOperation(nxt::StencilOperation::IncrementClamp, 0xff, 3, 0xff); CheckStencilOperation(dawn::StencilOperation::IncrementClamp, 0xff, 3, 0xff);
} }
TEST_P(DepthStencilStateTest, StencilIncrementWrap) { TEST_P(DepthStencilStateTest, StencilIncrementWrap) {
CheckStencilOperation(nxt::StencilOperation::IncrementWrap, 1, 3, 2); CheckStencilOperation(dawn::StencilOperation::IncrementWrap, 1, 3, 2);
CheckStencilOperation(nxt::StencilOperation::IncrementWrap, 0xff, 3, 0); CheckStencilOperation(dawn::StencilOperation::IncrementWrap, 0xff, 3, 0);
} }
TEST_P(DepthStencilStateTest, StencilDecrementClamp) { TEST_P(DepthStencilStateTest, StencilDecrementClamp) {
CheckStencilOperation(nxt::StencilOperation::DecrementClamp, 1, 3, 0); CheckStencilOperation(dawn::StencilOperation::DecrementClamp, 1, 3, 0);
CheckStencilOperation(nxt::StencilOperation::DecrementClamp, 0, 3, 0); CheckStencilOperation(dawn::StencilOperation::DecrementClamp, 0, 3, 0);
} }
TEST_P(DepthStencilStateTest, StencilDecrementWrap) { TEST_P(DepthStencilStateTest, StencilDecrementWrap) {
CheckStencilOperation(nxt::StencilOperation::DecrementWrap, 1, 3, 0); CheckStencilOperation(dawn::StencilOperation::DecrementWrap, 1, 3, 0);
CheckStencilOperation(nxt::StencilOperation::DecrementWrap, 0, 3, 0xff); CheckStencilOperation(dawn::StencilOperation::DecrementWrap, 0, 3, 0xff);
} }
// Check that the setting a stencil read mask works // Check that the setting a stencil read mask works
TEST_P(DepthStencilStateTest, StencilReadMask) { TEST_P(DepthStencilStateTest, StencilReadMask) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Equal, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
.SetStencilMask(0x2, 0xff) .SetStencilMask(0x2, 0xff)
.GetResult(); .GetResult();
@ -434,13 +434,13 @@ TEST_P(DepthStencilStateTest, StencilReadMask) {
// Check that setting a stencil write mask works // Check that setting a stencil write mask works
TEST_P(DepthStencilStateTest, StencilWriteMask) { TEST_P(DepthStencilStateTest, StencilWriteMask) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.SetStencilMask(0xff, 0x1) .SetStencilMask(0xff, 0x1)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Equal, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
.GetResult(); .GetResult();
RGBA8 baseColor = RGBA8(255, 255, 255, 255); RGBA8 baseColor = RGBA8(255, 255, 255, 255);
@ -453,12 +453,12 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) {
// Test that the stencil operation is executed on stencil fail // Test that the stencil operation is executed on stencil fail
TEST_P(DepthStencilStateTest, StencilFail) { TEST_P(DepthStencilStateTest, StencilFail) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Less, nxt::StencilOperation::Replace, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Less, dawn::StencilOperation::Replace, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep)
.GetResult(); .GetResult();
CheckStencil({ CheckStencil({
@ -469,15 +469,15 @@ TEST_P(DepthStencilStateTest, StencilFail) {
// Test that the stencil operation is executed on stencil pass, depth fail // Test that the stencil operation is executed on stencil pass, depth fail
TEST_P(DepthStencilStateTest, StencilDepthFail) { TEST_P(DepthStencilStateTest, StencilDepthFail) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Greater, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace, nxt::StencilOperation::Keep) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Greater, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace, dawn::StencilOperation::Keep)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.SetDepthCompareFunction(nxt::CompareFunction::Less) .SetDepthCompareFunction(dawn::CompareFunction::Less)
.GetResult(); .GetResult();
CheckStencil({ CheckStencil({
@ -488,15 +488,15 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) {
// Test that the stencil operation is executed on stencil pass, depth pass // Test that the stencil operation is executed on stencil pass, depth pass
TEST_P(DepthStencilStateTest, StencilDepthPass) { TEST_P(DepthStencilStateTest, StencilDepthPass) {
nxt::DepthStencilState baseState = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState baseState = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.GetResult(); .GetResult();
nxt::DepthStencilState state = device.CreateDepthStencilStateBuilder() dawn::DepthStencilState state = device.CreateDepthStencilStateBuilder()
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Greater, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Greater, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.SetDepthCompareFunction(nxt::CompareFunction::Less) .SetDepthCompareFunction(dawn::CompareFunction::Less)
.GetResult(); .GetResult();
CheckStencil({ CheckStencil({

View File

@ -25,12 +25,12 @@ class DrawElementsTest : public NXTTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
nxt::InputState inputState = device.CreateInputStateBuilder() dawn::InputState inputState = device.CreateInputStateBuilder()
.SetInput(0, 4 * sizeof(float), nxt::InputStepMode::Vertex) .SetInput(0, 4 * sizeof(float), dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32G32B32A32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32G32B32A32, 0)
.GetResult(); .GetResult();
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
layout(location = 0) in vec4 pos; layout(location = 0) in vec4 pos;
void main() { void main() {
@ -38,7 +38,7 @@ class DrawElementsTest : public NXTTest {
})" })"
); );
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
@ -48,33 +48,33 @@ class DrawElementsTest : public NXTTest {
pipeline = device.CreateRenderPipelineBuilder() pipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleStrip) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleStrip)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetIndexFormat(nxt::IndexFormat::Uint32) .SetIndexFormat(dawn::IndexFormat::Uint32)
.SetInputState(inputState) .SetInputState(inputState)
.GetResult(); .GetResult();
vertexBuffer = utils::CreateBufferFromData<float>(device, nxt::BufferUsageBit::Vertex, { vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
-1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f 1.0f, -1.0f, 0.0f, 1.0f
}); });
indexBuffer = utils::CreateBufferFromData<uint32_t>(device, nxt::BufferUsageBit::Index, { indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
0, 1, 2, 0, 3, 1 0, 1, 2, 0, 3, 1
}); });
} }
utils::BasicRenderPass renderPass; utils::BasicRenderPass renderPass;
nxt::RenderPipeline pipeline; dawn::RenderPipeline pipeline;
nxt::Buffer vertexBuffer; dawn::Buffer vertexBuffer;
nxt::Buffer indexBuffer; dawn::Buffer indexBuffer;
void Test(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, void Test(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex,
uint32_t firstInstance, RGBA8 bottomLeftExpected, RGBA8 topRightExpected) { uint32_t firstInstance, RGBA8 bottomLeftExpected, RGBA8 topRightExpected) {
uint32_t zeroOffset = 0; uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset) .SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset)

View File

@ -29,13 +29,13 @@ class IndexFormatTest : public NXTTest {
utils::BasicRenderPass renderPass; utils::BasicRenderPass renderPass;
nxt::RenderPipeline MakeTestPipeline(nxt::IndexFormat format) { dawn::RenderPipeline MakeTestPipeline(dawn::IndexFormat format) {
nxt::InputState inputState = device.CreateInputStateBuilder() dawn::InputState inputState = device.CreateInputStateBuilder()
.SetInput(0, 4 * sizeof(float), nxt::InputStepMode::Vertex) .SetInput(0, 4 * sizeof(float), dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32G32B32A32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32G32B32A32, 0)
.GetResult(); .GetResult();
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
layout(location = 0) in vec4 pos; layout(location = 0) in vec4 pos;
void main() { void main() {
@ -43,7 +43,7 @@ class IndexFormatTest : public NXTTest {
})" })"
); );
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
@ -53,9 +53,9 @@ class IndexFormatTest : public NXTTest {
return device.CreateRenderPipelineBuilder() return device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleStrip) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleStrip)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetIndexFormat(format) .SetIndexFormat(format)
.SetInputState(inputState) .SetInputState(inputState)
.GetResult(); .GetResult();
@ -64,21 +64,21 @@ class IndexFormatTest : public NXTTest {
// Test that the Uint32 index format is correctly interpreted // Test that the Uint32 index format is correctly interpreted
TEST_P(IndexFormatTest, Uint32) { TEST_P(IndexFormatTest, Uint32) {
nxt::RenderPipeline pipeline = MakeTestPipeline(nxt::IndexFormat::Uint32); dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
nxt::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, nxt::BufferUsageBit::Vertex, { dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1] -1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
-1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f -1.0f, -1.0f, 0.0f, 1.0f
}); });
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing. // If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
nxt::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, nxt::BufferUsageBit::Index, { dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
1, 2, 3 1, 2, 3
}); });
uint32_t zeroOffset = 0; uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset) .SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset)
@ -94,20 +94,20 @@ TEST_P(IndexFormatTest, Uint32) {
// Test that the Uint16 index format is correctly interpreted // Test that the Uint16 index format is correctly interpreted
TEST_P(IndexFormatTest, Uint16) { TEST_P(IndexFormatTest, Uint16) {
nxt::RenderPipeline pipeline = MakeTestPipeline(nxt::IndexFormat::Uint16); dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint16);
nxt::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, nxt::BufferUsageBit::Vertex, { dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
-1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f -1.0f, -1.0f, 0.0f, 1.0f
}); });
// If this is interpreted as uint32, it will have index 1 and 2 be both 0 and render nothing // If this is interpreted as uint32, it will have index 1 and 2 be both 0 and render nothing
nxt::Buffer indexBuffer = utils::CreateBufferFromData<uint16_t>(device, nxt::BufferUsageBit::Index, { dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsageBit::Index, {
1, 2, 0, 0, 0, 0 1, 2, 0, 0, 0, 0
}); });
uint32_t zeroOffset = 0; uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset) .SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset)
@ -135,21 +135,21 @@ TEST_P(IndexFormatTest, Uint16) {
// Test use of primitive restart with an Uint32 index format // Test use of primitive restart with an Uint32 index format
TEST_P(IndexFormatTest, Uint32PrimitiveRestart) { TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
nxt::RenderPipeline pipeline = MakeTestPipeline(nxt::IndexFormat::Uint32); dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
nxt::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, nxt::BufferUsageBit::Vertex, { dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, -1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
}); });
nxt::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, nxt::BufferUsageBit::Index, { dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
0, 1, 2, 0xFFFFFFFFu, 3, 4, 2, 0, 1, 2, 0xFFFFFFFFu, 3, 4, 2,
}); });
uint32_t zeroOffset = 0; uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset) .SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset)
@ -167,21 +167,21 @@ TEST_P(IndexFormatTest, Uint32PrimitiveRestart) {
// Test use of primitive restart with an Uint16 index format // Test use of primitive restart with an Uint16 index format
TEST_P(IndexFormatTest, Uint16PrimitiveRestart) { TEST_P(IndexFormatTest, Uint16PrimitiveRestart) {
nxt::RenderPipeline pipeline = MakeTestPipeline(nxt::IndexFormat::Uint16); dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint16);
nxt::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, nxt::BufferUsageBit::Vertex, { dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, -1.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f,
}); });
nxt::Buffer indexBuffer = utils::CreateBufferFromData<uint16_t>(device, nxt::BufferUsageBit::Index, { dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint16_t>(device, dawn::BufferUsageBit::Index, {
0, 1, 2, 0xFFFFu, 3, 4, 2, 0, 1, 2, 0xFFFFu, 3, 4, 2,
}); });
uint32_t zeroOffset = 0; uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset) .SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset)
@ -206,22 +206,22 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
return; return;
} }
nxt::RenderPipeline pipeline32 = MakeTestPipeline(nxt::IndexFormat::Uint32); dawn::RenderPipeline pipeline32 = MakeTestPipeline(dawn::IndexFormat::Uint32);
nxt::RenderPipeline pipeline16 = MakeTestPipeline(nxt::IndexFormat::Uint16); dawn::RenderPipeline pipeline16 = MakeTestPipeline(dawn::IndexFormat::Uint16);
nxt::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, nxt::BufferUsageBit::Vertex, { dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
-1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1] -1.0f, 1.0f, 0.0f, 1.0f, // Note Vertices[0] = Vertices[1]
-1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f -1.0f, -1.0f, 0.0f, 1.0f
}); });
// If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing. // If this is interpreted as Uint16, then it would be 0, 1, 0, ... and would draw nothing.
nxt::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, nxt::BufferUsageBit::Index, { dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
1, 2, 3 1, 2, 3
}); });
uint32_t zeroOffset = 0; uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline16) .SetRenderPipeline(pipeline16)
.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset) .SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset)
@ -242,19 +242,19 @@ TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) {
// TODO(cwallez@chromium.org): This is currently disallowed by the validation but // TODO(cwallez@chromium.org): This is currently disallowed by the validation but
// we want to support eventually. // we want to support eventually.
TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) { TEST_P(IndexFormatTest, DISABLED_SetIndexBufferBeforeSetPipeline) {
nxt::RenderPipeline pipeline = MakeTestPipeline(nxt::IndexFormat::Uint32); dawn::RenderPipeline pipeline = MakeTestPipeline(dawn::IndexFormat::Uint32);
nxt::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, nxt::BufferUsageBit::Vertex, { dawn::Buffer vertexBuffer = utils::CreateBufferFromData<float>(device, dawn::BufferUsageBit::Vertex, {
-1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f -1.0f, -1.0f, 0.0f, 1.0f
}); });
nxt::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, nxt::BufferUsageBit::Index, { dawn::Buffer indexBuffer = utils::CreateBufferFromData<uint32_t>(device, dawn::BufferUsageBit::Index, {
0, 1, 2 0, 1, 2
}); });
uint32_t zeroOffset = 0; uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetIndexBuffer(indexBuffer, 0) .SetIndexBuffer(indexBuffer, 0)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)

View File

@ -17,8 +17,8 @@
#include "common/Assert.h" #include "common/Assert.h"
#include "utils/NXTHelpers.h" #include "utils/NXTHelpers.h"
using nxt::InputStepMode; using dawn::InputStepMode;
using nxt::VertexFormat; using dawn::VertexFormat;
// Input state tests all work the same way: the test will render triangles in a grid up to 4x4. Each triangle // Input state tests all work the same way: the test will render triangles in a grid up to 4x4. Each triangle
// is position in the grid such that X will correspond to the "triangle number" and the Y to the instance number. // is position in the grid such that X will correspond to the "triangle number" and the Y to the instance number.
@ -63,7 +63,7 @@ class InputStateTest : public NXTTest {
VertexFormat format; VertexFormat format;
InputStepMode step; InputStepMode step;
}; };
nxt::RenderPipeline MakeTestPipeline(const nxt::InputState& inputState, int multiplier, std::vector<ShaderTestSpec> testSpec) { dawn::RenderPipeline MakeTestPipeline(const dawn::InputState& inputState, int multiplier, std::vector<ShaderTestSpec> testSpec) {
std::ostringstream vs; std::ostringstream vs;
vs << "#version 450\n"; vs << "#version 450\n";
@ -110,8 +110,8 @@ class InputStateTest : public NXTTest {
vs << " }\n;"; vs << " }\n;";
vs << "}\n"; vs << "}\n";
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, vs.str().c_str()); dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs.str().c_str());
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) in vec4 color; layout(location = 0) in vec4 color;
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
@ -122,8 +122,8 @@ class InputStateTest : public NXTTest {
return device.CreateRenderPipelineBuilder() return device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetInputState(inputState) .SetInputState(inputState)
.GetResult(); .GetResult();
} }
@ -139,8 +139,8 @@ class InputStateTest : public NXTTest {
uint32_t offset; uint32_t offset;
VertexFormat format; VertexFormat format;
}; };
nxt::InputState MakeInputState(std::vector<InputSpec> inputs, std::vector<AttributeSpec> attributes) { dawn::InputState MakeInputState(std::vector<InputSpec> inputs, std::vector<AttributeSpec> attributes) {
nxt::InputStateBuilder builder = device.CreateInputStateBuilder(); dawn::InputStateBuilder builder = device.CreateInputStateBuilder();
for (const auto& input : inputs) { for (const auto& input : inputs) {
builder.SetInput(input.slot, input.stride, input.step); builder.SetInput(input.slot, input.stride, input.step);
@ -154,19 +154,19 @@ class InputStateTest : public NXTTest {
} }
template<typename T> template<typename T>
nxt::Buffer MakeVertexBuffer(std::vector<T> data) { dawn::Buffer MakeVertexBuffer(std::vector<T> data) {
return utils::CreateBufferFromData(device, data.data(), static_cast<uint32_t>(data.size() * sizeof(T)), nxt::BufferUsageBit::Vertex); return utils::CreateBufferFromData(device, data.data(), static_cast<uint32_t>(data.size() * sizeof(T)), dawn::BufferUsageBit::Vertex);
} }
struct DrawVertexBuffer { struct DrawVertexBuffer {
uint32_t location; uint32_t location;
nxt::Buffer* buffer; dawn::Buffer* buffer;
}; };
void DoTestDraw(const nxt::RenderPipeline& pipeline, unsigned int triangles, unsigned int instances, std::vector<DrawVertexBuffer> vertexBuffers) { void DoTestDraw(const dawn::RenderPipeline& pipeline, unsigned int triangles, unsigned int instances, std::vector<DrawVertexBuffer> vertexBuffers) {
EXPECT_LE(triangles, 4u); EXPECT_LE(triangles, 4u);
EXPECT_LE(instances, 4u); EXPECT_LE(instances, 4u);
nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder(); dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
builder.BeginRenderPass(renderPass.renderPassInfo) builder.BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline); .SetRenderPipeline(pipeline);
@ -176,7 +176,7 @@ class InputStateTest : public NXTTest {
builder.SetVertexBuffers(buffer.location, 1, buffer.buffer, &zeroOffset); builder.SetVertexBuffers(buffer.location, 1, buffer.buffer, &zeroOffset);
} }
nxt::CommandBuffer commands = builder dawn::CommandBuffer commands = builder
.DrawArrays(triangles * 3, instances, 0, 0) .DrawArrays(triangles * 3, instances, 0, 0)
.EndRenderPass() .EndRenderPass()
.GetResult(); .GetResult();
@ -203,17 +203,17 @@ class InputStateTest : public NXTTest {
// Test compilation and usage of the fixture :) // Test compilation and usage of the fixture :)
TEST_P(InputStateTest, Basic) { TEST_P(InputStateTest, Basic) {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 4 * sizeof(float), InputStepMode::Vertex} {0, 4 * sizeof(float), InputStepMode::Vertex}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32B32A32} {0, 0, 0, VertexFormat::FloatR32G32B32A32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
{0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex} {0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 1, 2, 3,
1, 2, 3, 4, 1, 2, 3, 4,
2, 3, 4, 5 2, 3, 4, 5
@ -223,17 +223,17 @@ TEST_P(InputStateTest, Basic) {
// Test a stride of 0 works // Test a stride of 0 works
TEST_P(InputStateTest, ZeroStride) { TEST_P(InputStateTest, ZeroStride) {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 0, InputStepMode::Vertex} {0, 0, InputStepMode::Vertex}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32B32A32} {0, 0, 0, VertexFormat::FloatR32G32B32A32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
{0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex} {0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 1, 2, 3,
}); });
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
@ -243,51 +243,51 @@ TEST_P(InputStateTest, ZeroStride) {
TEST_P(InputStateTest, AttributeExpanding) { TEST_P(InputStateTest, AttributeExpanding) {
// R32F case // R32F case
{ {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 0, InputStepMode::Vertex} {0, 0, InputStepMode::Vertex}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32} {0, 0, 0, VertexFormat::FloatR32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
{0, VertexFormat::FloatR32, InputStepMode::Vertex} {0, VertexFormat::FloatR32, InputStepMode::Vertex}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3 0, 1, 2, 3
}); });
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
} }
// RG32F case // RG32F case
{ {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 0, InputStepMode::Vertex} {0, 0, InputStepMode::Vertex}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32} {0, 0, 0, VertexFormat::FloatR32G32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
{0, VertexFormat::FloatR32G32, InputStepMode::Vertex} {0, VertexFormat::FloatR32G32, InputStepMode::Vertex}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3 0, 1, 2, 3
}); });
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
} }
// RGB32F case // RGB32F case
{ {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 0, InputStepMode::Vertex} {0, 0, InputStepMode::Vertex}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32B32} {0, 0, 0, VertexFormat::FloatR32G32B32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 0, {
{0, VertexFormat::FloatR32G32B32, InputStepMode::Vertex} {0, VertexFormat::FloatR32G32B32, InputStepMode::Vertex}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3 0, 1, 2, 3
}); });
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
@ -296,17 +296,17 @@ TEST_P(InputStateTest, AttributeExpanding) {
// Test a stride larger than the attributes // Test a stride larger than the attributes
TEST_P(InputStateTest, StrideLargerThanAttributes) { TEST_P(InputStateTest, StrideLargerThanAttributes) {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 8 * sizeof(float), InputStepMode::Vertex} {0, 8 * sizeof(float), InputStepMode::Vertex}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32B32A32} {0, 0, 0, VertexFormat::FloatR32G32B32A32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
{0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex} {0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0,
1, 2, 3, 4, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0, 0,
2, 3, 4, 5, 0, 0, 0, 0, 2, 3, 4, 5, 0, 0, 0, 0,
@ -316,18 +316,18 @@ TEST_P(InputStateTest, StrideLargerThanAttributes) {
// Test two attributes at an offset, vertex version // Test two attributes at an offset, vertex version
TEST_P(InputStateTest, TwoAttributesAtAnOffsetVertex) { TEST_P(InputStateTest, TwoAttributesAtAnOffsetVertex) {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 8 * sizeof(float), InputStepMode::Vertex} {0, 8 * sizeof(float), InputStepMode::Vertex}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32B32A32}, {0, 0, 0, VertexFormat::FloatR32G32B32A32},
{1, 0, 4 * sizeof(float), VertexFormat::FloatR32G32B32A32} {1, 0, 4 * sizeof(float), VertexFormat::FloatR32G32B32A32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
{0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex} {0, VertexFormat::FloatR32G32B32A32, InputStepMode::Vertex}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5,
@ -337,18 +337,18 @@ TEST_P(InputStateTest, TwoAttributesAtAnOffsetVertex) {
// Test two attributes at an offset, instance version // Test two attributes at an offset, instance version
TEST_P(InputStateTest, TwoAttributesAtAnOffsetInstance) { TEST_P(InputStateTest, TwoAttributesAtAnOffsetInstance) {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 8 * sizeof(float), InputStepMode::Instance} {0, 8 * sizeof(float), InputStepMode::Instance}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32B32A32}, {0, 0, 0, VertexFormat::FloatR32G32B32A32},
{1, 0, 4 * sizeof(float), VertexFormat::FloatR32G32B32A32} {1, 0, 4 * sizeof(float), VertexFormat::FloatR32G32B32A32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
{0, VertexFormat::FloatR32G32B32A32, InputStepMode::Instance} {0, VertexFormat::FloatR32G32B32A32, InputStepMode::Instance}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5, 2, 3, 4, 5,
@ -358,17 +358,17 @@ TEST_P(InputStateTest, TwoAttributesAtAnOffsetInstance) {
// Test a pure-instance input state // Test a pure-instance input state
TEST_P(InputStateTest, PureInstance) { TEST_P(InputStateTest, PureInstance) {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 4 * sizeof(float), InputStepMode::Instance} {0, 4 * sizeof(float), InputStepMode::Instance}
}, { }, {
{0, 0, 0, VertexFormat::FloatR32G32B32A32} {0, 0, 0, VertexFormat::FloatR32G32B32A32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
{0, VertexFormat::FloatR32G32B32A32, InputStepMode::Instance} {0, VertexFormat::FloatR32G32B32A32, InputStepMode::Instance}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 1, 2, 3,
1, 2, 3, 4, 1, 2, 3, 4,
2, 3, 4, 5, 2, 3, 4, 5,
@ -380,7 +380,7 @@ TEST_P(InputStateTest, PureInstance) {
// Test with mixed everything, vertex vs. instance, different stride and offsets // Test with mixed everything, vertex vs. instance, different stride and offsets
// different attribute types // different attribute types
TEST_P(InputStateTest, MixedEverything) { TEST_P(InputStateTest, MixedEverything) {
nxt::InputState inputState = MakeInputState({ dawn::InputState inputState = MakeInputState({
{0, 12 * sizeof(float), InputStepMode::Vertex}, {0, 12 * sizeof(float), InputStepMode::Vertex},
{1, 10 * sizeof(float), InputStepMode::Instance}, {1, 10 * sizeof(float), InputStepMode::Instance},
}, { }, {
@ -390,20 +390,20 @@ TEST_P(InputStateTest, MixedEverything) {
{3, 1, 5 * sizeof(float), VertexFormat::FloatR32G32B32A32} {3, 1, 5 * sizeof(float), VertexFormat::FloatR32G32B32A32}
} }
); );
nxt::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, { dawn::RenderPipeline pipeline = MakeTestPipeline(inputState, 1, {
{0, VertexFormat::FloatR32, InputStepMode::Vertex}, {0, VertexFormat::FloatR32, InputStepMode::Vertex},
{1, VertexFormat::FloatR32G32, InputStepMode::Vertex}, {1, VertexFormat::FloatR32G32, InputStepMode::Vertex},
{2, VertexFormat::FloatR32G32B32, InputStepMode::Instance}, {2, VertexFormat::FloatR32G32B32, InputStepMode::Instance},
{3, VertexFormat::FloatR32G32B32A32, InputStepMode::Instance} {3, VertexFormat::FloatR32G32B32A32, InputStepMode::Instance}
}); });
nxt::Buffer buffer0 = MakeVertexBuffer<float>({ dawn::Buffer buffer0 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0,
1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0,
2, 3, 4, 5, 0, 0, 2, 3, 4, 5, 0, 0, 2, 3, 4, 5, 0, 0, 2, 3, 4, 5, 0, 0,
3, 4, 5, 6, 0, 0, 3, 4, 5, 6, 0, 0, 3, 4, 5, 6, 0, 0, 3, 4, 5, 6, 0, 0,
}); });
nxt::Buffer buffer1 = MakeVertexBuffer<float>({ dawn::Buffer buffer1 = MakeVertexBuffer<float>({
0, 1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 1, 2, 3, 0,
1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0,
2, 3, 4, 5, 0, 2, 3, 4, 5, 0, 2, 3, 4, 5, 0, 2, 3, 4, 5, 0,

View File

@ -149,7 +149,7 @@ class PrimitiveTopologyTest : public NXTTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
layout(location = 0) in vec4 pos; layout(location = 0) in vec4 pos;
void main() { void main() {
@ -157,7 +157,7 @@ class PrimitiveTopologyTest : public NXTTest {
})" })"
); );
fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
@ -165,11 +165,11 @@ class PrimitiveTopologyTest : public NXTTest {
})"); })");
inputState = device.CreateInputStateBuilder() inputState = device.CreateInputStateBuilder()
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32G32B32A32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32G32B32A32, 0)
.SetInput(0, 4 * sizeof(float), nxt::InputStepMode::Vertex) .SetInput(0, 4 * sizeof(float), dawn::InputStepMode::Vertex)
.GetResult(); .GetResult();
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), nxt::BufferUsageBit::Vertex); vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices), dawn::BufferUsageBit::Vertex);
} }
struct LocationSpec { struct LocationSpec {
@ -184,17 +184,17 @@ class PrimitiveTopologyTest : public NXTTest {
} }
// 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(nxt::PrimitiveTopology primitiveTopology, const std::vector<LocationSpec> &locationSpecs) { void DoTest(dawn::PrimitiveTopology primitiveTopology, const std::vector<LocationSpec> &locationSpecs) {
nxt::RenderPipeline pipeline = device.CreateRenderPipelineBuilder() dawn::RenderPipeline pipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetInputState(inputState) .SetInputState(inputState)
.SetPrimitiveTopology(primitiveTopology) .SetPrimitiveTopology(primitiveTopology)
.GetResult(); .GetResult();
static const uint32_t zeroOffset = 0; static const uint32_t zeroOffset = 0;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset) .SetVertexBuffers(0, 1, &vertexBuffer, &zeroOffset)
@ -215,15 +215,15 @@ class PrimitiveTopologyTest : public NXTTest {
} }
utils::BasicRenderPass renderPass; utils::BasicRenderPass renderPass;
nxt::ShaderModule vsModule; dawn::ShaderModule vsModule;
nxt::ShaderModule fsModule; dawn::ShaderModule fsModule;
nxt::InputState inputState; dawn::InputState inputState;
nxt::Buffer vertexBuffer; dawn::Buffer vertexBuffer;
}; };
// Test Point primitive topology // Test Point primitive topology
TEST_P(PrimitiveTopologyTest, PointList) { TEST_P(PrimitiveTopologyTest, PointList) {
DoTest(nxt::PrimitiveTopology::PointList, { DoTest(dawn::PrimitiveTopology::PointList, {
// Check that the points are drawn // Check that the points are drawn
TestPoints(kPointTestLocations, true), TestPoints(kPointTestLocations, true),
@ -237,7 +237,7 @@ TEST_P(PrimitiveTopologyTest, PointList) {
// Test Line primitive topology // Test Line primitive topology
TEST_P(PrimitiveTopologyTest, LineList) { TEST_P(PrimitiveTopologyTest, LineList) {
DoTest(nxt::PrimitiveTopology::LineList, { DoTest(dawn::PrimitiveTopology::LineList, {
// Check that lines are drawn // Check that lines are drawn
TestPoints(kLineTestLocations, true), TestPoints(kLineTestLocations, true),
@ -250,7 +250,7 @@ TEST_P(PrimitiveTopologyTest, LineList) {
// Test LineStrip primitive topology // Test LineStrip primitive topology
TEST_P(PrimitiveTopologyTest, LineStrip) { TEST_P(PrimitiveTopologyTest, LineStrip) {
DoTest(nxt::PrimitiveTopology::LineStrip, { DoTest(dawn::PrimitiveTopology::LineStrip, {
// Check that lines are drawn // Check that lines are drawn
TestPoints(kLineTestLocations, true), TestPoints(kLineTestLocations, true),
TestPoints(kLineStripTestLocations, true), TestPoints(kLineStripTestLocations, true),
@ -263,7 +263,7 @@ TEST_P(PrimitiveTopologyTest, LineStrip) {
// Test Triangle primitive topology // Test Triangle primitive topology
TEST_P(PrimitiveTopologyTest, TriangleList) { TEST_P(PrimitiveTopologyTest, TriangleList) {
DoTest(nxt::PrimitiveTopology::TriangleList, { DoTest(dawn::PrimitiveTopology::TriangleList, {
// Check that triangles are drawn // Check that triangles are drawn
TestPoints(kTriangleTestLocations, true), TestPoints(kTriangleTestLocations, true),
@ -274,7 +274,7 @@ TEST_P(PrimitiveTopologyTest, TriangleList) {
// Test TriangleStrip primitive topology // Test TriangleStrip primitive topology
TEST_P(PrimitiveTopologyTest, TriangleStrip) { TEST_P(PrimitiveTopologyTest, TriangleStrip) {
DoTest(nxt::PrimitiveTopology::TriangleStrip, { DoTest(dawn::PrimitiveTopology::TriangleStrip, {
TestPoints(kTriangleTestLocations, true), TestPoints(kTriangleTestLocations, true),
TestPoints(kTriangleStripTestLocations, true), TestPoints(kTriangleStripTestLocations, true),
}); });

View File

@ -25,43 +25,43 @@ class PushConstantTest: public NXTTest {
// Layout, bind group and friends to store results for compute tests, can have an extra buffer // Layout, bind group and friends to store results for compute tests, can have an extra buffer
// so that two different pipeline layout can be created. // so that two different pipeline layout can be created.
struct TestBindings { struct TestBindings {
nxt::PipelineLayout layout; dawn::PipelineLayout layout;
nxt::BindGroup bindGroup; dawn::BindGroup bindGroup;
nxt::Buffer resultBuffer; dawn::Buffer resultBuffer;
}; };
TestBindings MakeTestBindings(bool extraBuffer) { TestBindings MakeTestBindings(bool extraBuffer) {
nxt::Buffer buf1 = device.CreateBufferBuilder() dawn::Buffer buf1 = device.CreateBufferBuilder()
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::Storage | nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::Storage | dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
uint32_t one = 1; uint32_t one = 1;
buf1.SetSubData(0, sizeof(one), reinterpret_cast<uint8_t*>(&one)); buf1.SetSubData(0, sizeof(one), reinterpret_cast<uint8_t*>(&one));
nxt::Buffer buf2 = device.CreateBufferBuilder() dawn::Buffer buf2 = device.CreateBufferBuilder()
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::Storage) .SetAllowedUsage(dawn::BufferUsageBit::Storage)
.GetResult(); .GetResult();
nxt::ShaderStageBit kAllStages = nxt::ShaderStageBit::Compute | nxt::ShaderStageBit::Fragment | nxt::ShaderStageBit::Vertex; dawn::ShaderStageBit kAllStages = dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment | dawn::ShaderStageBit::Vertex;
constexpr nxt::ShaderStageBit kNoStages{}; constexpr dawn::ShaderStageBit kNoStages{};
nxt::BindGroupLayout bgl = utils::MakeBindGroupLayout( dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, device,
{ {
{0, kAllStages, nxt::BindingType::StorageBuffer}, {0, kAllStages, dawn::BindingType::StorageBuffer},
{1, extraBuffer ? kAllStages : kNoStages, nxt::BindingType::StorageBuffer}, {1, extraBuffer ? kAllStages : kNoStages, dawn::BindingType::StorageBuffer},
}); });
nxt::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl); dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
nxt::BufferView views[2] = { dawn::BufferView views[2] = {
buf1.CreateBufferViewBuilder().SetExtent(0, 4).GetResult(), buf1.CreateBufferViewBuilder().SetExtent(0, 4).GetResult(),
buf2.CreateBufferViewBuilder().SetExtent(0, 4).GetResult(), buf2.CreateBufferViewBuilder().SetExtent(0, 4).GetResult(),
}; };
nxt::BindGroup bg = device.CreateBindGroupBuilder() dawn::BindGroup bg = device.CreateBindGroupBuilder()
.SetLayout(bgl) .SetLayout(bgl)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, extraBuffer ? 2 : 1, views) .SetBufferViews(0, extraBuffer ? 2 : 1, views)
.GetResult(); .GetResult();
@ -132,8 +132,8 @@ class PushConstantTest: public NXTTest {
} }
// The compute pipeline ANDs the result of the test in the SSBO // The compute pipeline ANDs the result of the test in the SSBO
nxt::ComputePipeline MakeTestComputePipeline(const nxt::PipelineLayout& pl, PushConstantSpec spec) { dawn::ComputePipeline MakeTestComputePipeline(const dawn::PipelineLayout& pl, PushConstantSpec spec) {
nxt::ShaderModule module = utils::CreateShaderModule(device, nxt::ShaderStage::Compute, (R"( dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, (R"(
#version 450 #version 450
layout(set = 0, binding = 0) buffer Result { layout(set = 0, binding = 0) buffer Result {
int success; int success;
@ -151,18 +151,18 @@ class PushConstantTest: public NXTTest {
return device.CreateComputePipelineBuilder() return device.CreateComputePipelineBuilder()
.SetLayout(pl) .SetLayout(pl)
.SetStage(nxt::ShaderStage::Compute, module, "main") .SetStage(dawn::ShaderStage::Compute, module, "main")
.GetResult(); .GetResult();
} }
nxt::PipelineLayout MakeEmptyLayout() { dawn::PipelineLayout MakeEmptyLayout() {
return utils::MakeBasicPipelineLayout(device, nullptr); return utils::MakeBasicPipelineLayout(device, nullptr);
} }
// The render pipeline adds one to the red channel for successful vertex push constant test // The render pipeline adds one to the red channel for successful vertex push constant test
// and adds one to green for the frgament test. // and adds one to green for the frgament test.
nxt::RenderPipeline MakeTestRenderPipeline(nxt::PipelineLayout& layout, PushConstantSpec vsSpec, PushConstantSpec fsSpec) { dawn::RenderPipeline MakeTestRenderPipeline(dawn::PipelineLayout& layout, PushConstantSpec vsSpec, PushConstantSpec fsSpec) {
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, (R"( dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, (R"(
#version 450 #version 450
)" + MakePushConstantBlock(vsSpec) + R"( )" + MakePushConstantBlock(vsSpec) + R"(
layout(location = 0) out float red; layout(location = 0) out float red;
@ -173,7 +173,7 @@ class PushConstantTest: public NXTTest {
gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f); gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);
})").c_str() })").c_str()
); );
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, (R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, (R"(
#version 450 #version 450
)" + MakePushConstantBlock(fsSpec) + R"( )" + MakePushConstantBlock(fsSpec) + R"(
layout(location = 0) out vec4 color; layout(location = 0) out vec4 color;
@ -185,18 +185,18 @@ class PushConstantTest: public NXTTest {
})").c_str() })").c_str()
); );
nxt::BlendState blendState = device.CreateBlendStateBuilder() dawn::BlendState blendState = device.CreateBlendStateBuilder()
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.GetResult(); .GetResult();
return device.CreateRenderPipelineBuilder() return device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(layout) .SetLayout(layout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::PointList) .SetPrimitiveTopology(dawn::PrimitiveTopology::PointList)
.SetColorAttachmentBlendState(0, blendState) .SetColorAttachmentBlendState(0, blendState)
.GetResult(); .GetResult();
} }
@ -207,10 +207,10 @@ TEST_P(PushConstantTest, ComputePassDefaultsToZero) {
auto binding = MakeTestBindings(false); auto binding = MakeTestBindings(false);
// Expect push constants to be zero in all dispatches of this test. // Expect push constants to be zero in all dispatches of this test.
nxt::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, MakeAllZeroSpec()); dawn::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, MakeAllZeroSpec());
uint32_t notZero = 42; uint32_t notZero = 42;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginComputePass() .BeginComputePass()
// Test compute push constants are set to zero by default. // Test compute push constants are set to zero by default.
.SetComputePipeline(pipeline) .SetComputePipeline(pipeline)
@ -218,7 +218,7 @@ TEST_P(PushConstantTest, ComputePassDefaultsToZero) {
.Dispatch(1, 1, 1) .Dispatch(1, 1, 1)
// Set push constants to non-zero value to check they will be reset to zero // Set push constants to non-zero value to check they will be reset to zero
// on the next BeginComputePass // on the next BeginComputePass
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, &notZero) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, &notZero)
.EndComputePass() .EndComputePass()
.BeginComputePass() .BeginComputePass()
.SetComputePipeline(pipeline) .SetComputePipeline(pipeline)
@ -238,10 +238,10 @@ TEST_P(PushConstantTest, RenderPassDefaultsToZero) {
// Expect push constants to be zero in all draws of this test. // Expect push constants to be zero in all draws of this test.
PushConstantSpec allZeros = MakeAllZeroSpec(); PushConstantSpec allZeros = MakeAllZeroSpec();
nxt::PipelineLayout layout = MakeEmptyLayout(); dawn::PipelineLayout layout = MakeEmptyLayout();
nxt::RenderPipeline pipeline = MakeTestRenderPipeline(layout, MakeAllZeroSpec(), MakeAllZeroSpec()); dawn::RenderPipeline pipeline = MakeTestRenderPipeline(layout, MakeAllZeroSpec(), MakeAllZeroSpec());
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
// Test render push constants are set to zero by default. // Test render push constants are set to zero by default.
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
@ -266,12 +266,12 @@ TEST_P(PushConstantTest, VariousConstantTypes) {
auto binding = MakeTestBindings(false); auto binding = MakeTestBindings(false);
PushConstantSpec spec = {{Int, -1}, {UInt, 3}, {Float, 4}}; PushConstantSpec spec = {{Int, -1}, {UInt, 3}, {Float, 4}};
nxt::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, spec); dawn::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, spec);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 3, reinterpret_cast<uint32_t*>(&values)) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 3, reinterpret_cast<uint32_t*>(&values))
.SetComputePipeline(pipeline) .SetComputePipeline(pipeline)
.SetBindGroup(0, binding.bindGroup) .SetBindGroup(0, binding.bindGroup)
.Dispatch(1, 1, 1) .Dispatch(1, 1, 1)
@ -290,20 +290,20 @@ TEST_P(PushConstantTest, InheritThroughPipelineLayoutChange) {
auto binding2 = MakeTestBindings(true); auto binding2 = MakeTestBindings(true);
PushConstantSpec spec1 = {{Int, 1}}; PushConstantSpec spec1 = {{Int, 1}};
PushConstantSpec spec2 = {{Int, 2}}; PushConstantSpec spec2 = {{Int, 2}};
nxt::ComputePipeline pipeline1 = MakeTestComputePipeline(binding1.layout, spec1); dawn::ComputePipeline pipeline1 = MakeTestComputePipeline(binding1.layout, spec1);
nxt::ComputePipeline pipeline2 = MakeTestComputePipeline(binding2.layout, spec2); dawn::ComputePipeline pipeline2 = MakeTestComputePipeline(binding2.layout, spec2);
uint32_t one = 1; uint32_t one = 1;
uint32_t two = 2; uint32_t two = 2;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginComputePass() .BeginComputePass()
// Set Push constant before there is a pipeline set // Set Push constant before there is a pipeline set
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, &one) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, &one)
.SetComputePipeline(pipeline1) .SetComputePipeline(pipeline1)
.SetBindGroup(0, binding1.bindGroup) .SetBindGroup(0, binding1.bindGroup)
.Dispatch(1, 1, 1) .Dispatch(1, 1, 1)
// Change the push constant before changing pipeline layout // Change the push constant before changing pipeline layout
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, &two) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, &two)
.SetComputePipeline(pipeline2) .SetComputePipeline(pipeline2)
.SetBindGroup(0, binding2.bindGroup) .SetBindGroup(0, binding2.bindGroup)
.Dispatch(1, 1, 1) .Dispatch(1, 1, 1)
@ -326,11 +326,11 @@ TEST_P(PushConstantTest, SetAllConstantsToNonZero) {
} }
auto binding = MakeTestBindings(false); auto binding = MakeTestBindings(false);
nxt::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, spec); dawn::ComputePipeline pipeline = MakeTestComputePipeline(binding.layout, spec);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, kMaxPushConstants, &values[0]) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, &values[0])
.SetComputePipeline(pipeline) .SetComputePipeline(pipeline)
.SetBindGroup(0, binding.bindGroup) .SetBindGroup(0, binding.bindGroup)
.Dispatch(1, 1, 1) .Dispatch(1, 1, 1)
@ -349,15 +349,15 @@ TEST_P(PushConstantTest, SeparateVertexAndFragmentConstants) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
nxt::PipelineLayout layout = MakeEmptyLayout(); dawn::PipelineLayout layout = MakeEmptyLayout();
nxt::RenderPipeline pipeline = MakeTestRenderPipeline(layout, vsSpec, fsSpec); dawn::RenderPipeline pipeline = MakeTestRenderPipeline(layout, vsSpec, fsSpec);
uint32_t one = 1; uint32_t one = 1;
uint32_t two = 2; uint32_t two = 2;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetPushConstants(nxt::ShaderStageBit::Vertex, 0, 1, &one) .SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, &one)
.SetPushConstants(nxt::ShaderStageBit::Fragment, 0, 1, &two) .SetPushConstants(dawn::ShaderStageBit::Fragment, 0, 1, &two)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.DrawArrays(1, 1, 0, 0) .DrawArrays(1, 1, 0, 0)
.EndRenderPass() .EndRenderPass()
@ -374,13 +374,13 @@ TEST_P(PushConstantTest, SimultaneousVertexAndFragmentConstants) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
nxt::PipelineLayout layout = MakeEmptyLayout(); dawn::PipelineLayout layout = MakeEmptyLayout();
nxt::RenderPipeline pipeline = MakeTestRenderPipeline(layout, spec, spec); dawn::RenderPipeline pipeline = MakeTestRenderPipeline(layout, spec, spec);
uint32_t two = 2; uint32_t two = 2;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetPushConstants(nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment, 0, 1, &two) .SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, &two)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.DrawArrays(1, 1, 0, 0) .DrawArrays(1, 1, 0, 0)
.EndRenderPass() .EndRenderPass()

View File

@ -23,20 +23,20 @@ constexpr static unsigned int kRTSize = 16;
class DrawQuad { class DrawQuad {
public: public:
DrawQuad() {} DrawQuad() {}
DrawQuad(nxt::Device* device, const char* vsSource, const char* fsSource) DrawQuad(dawn::Device* device, const char* vsSource, const char* fsSource)
: device(device) { : device(device) {
vsModule = utils::CreateShaderModule(*device, nxt::ShaderStage::Vertex, vsSource); vsModule = utils::CreateShaderModule(*device, dawn::ShaderStage::Vertex, vsSource);
fsModule = utils::CreateShaderModule(*device, nxt::ShaderStage::Fragment, fsSource); fsModule = utils::CreateShaderModule(*device, dawn::ShaderStage::Fragment, fsSource);
pipelineLayout = utils::MakeBasicPipelineLayout(*device, nullptr); pipelineLayout = utils::MakeBasicPipelineLayout(*device, nullptr);
} }
void Draw(nxt::CommandBufferBuilder* builder) { void Draw(dawn::CommandBufferBuilder* builder) {
auto renderPipeline = device->CreateRenderPipelineBuilder() auto renderPipeline = device->CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
builder->SetRenderPipeline(renderPipeline); builder->SetRenderPipeline(renderPipeline);
@ -44,10 +44,10 @@ class DrawQuad {
} }
private: private:
nxt::Device* device = nullptr; dawn::Device* device = nullptr;
nxt::ShaderModule vsModule = {}; dawn::ShaderModule vsModule = {};
nxt::ShaderModule fsModule = {}; dawn::ShaderModule fsModule = {};
nxt::PipelineLayout pipelineLayout = {}; dawn::PipelineLayout pipelineLayout = {};
}; };
class RenderPassLoadOpTests : public NXTTest { class RenderPassLoadOpTests : public NXTTest {
@ -56,11 +56,11 @@ class RenderPassLoadOpTests : public NXTTest {
NXTTest::SetUp(); NXTTest::SetUp();
renderTarget = device.CreateTextureBuilder() renderTarget = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(kRTSize, kRTSize, 1) .SetExtent(kRTSize, kRTSize, 1)
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm) .SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment | nxt::TextureUsageBit::TransferSrc) .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc)
.GetResult(); .GetResult();
renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult(); renderTargetView = renderTarget.CreateTextureViewBuilder().GetResult();
@ -94,8 +94,8 @@ class RenderPassLoadOpTests : public NXTTest {
blueQuad = DrawQuad(&device, vsSource, fsSource); blueQuad = DrawQuad(&device, vsSource, fsSource);
} }
nxt::Texture renderTarget; dawn::Texture renderTarget;
nxt::TextureView renderTargetView; dawn::TextureView renderTargetView;
std::array<RGBA8, kRTSize * kRTSize> expectZero; std::array<RGBA8, kRTSize * kRTSize> expectZero;
std::array<RGBA8, kRTSize * kRTSize> expectGreen; std::array<RGBA8, kRTSize * kRTSize> expectGreen;
@ -110,7 +110,7 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
// Part 1: clear once, check to make sure it's cleared // Part 1: clear once, check to make sure it's cleared
auto renderPassClearZero = device.CreateRenderPassDescriptorBuilder() auto renderPassClearZero = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, nxt::LoadOp::Clear) .SetColorAttachment(0, renderTargetView, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(0, 0.0f, 0.0f, 0.0f, 0.0f) .SetColorAttachmentClearColor(0, 0.0f, 0.0f, 0.0f, 0.0f)
.GetResult(); .GetResult();
@ -122,7 +122,7 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
.GetResult(); .GetResult();
auto renderPassClearGreen = device.CreateRenderPassDescriptorBuilder() auto renderPassClearGreen = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, nxt::LoadOp::Clear) .SetColorAttachment(0, renderTargetView, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(0, 0.0f, 1.0f, 0.0f, 1.0f) .SetColorAttachmentClearColor(0, 0.0f, 1.0f, 0.0f, 1.0f)
.GetResult(); .GetResult();
@ -142,10 +142,10 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
// Part 2: draw a blue quad into the right half of the render target, and check result // Part 2: draw a blue quad into the right half of the render target, and check result
auto renderPassLoad = device.CreateRenderPassDescriptorBuilder() auto renderPassLoad = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, nxt::LoadOp::Load) .SetColorAttachment(0, renderTargetView, dawn::LoadOp::Load)
.GetResult(); .GetResult();
nxt::CommandBuffer commandsLoad; dawn::CommandBuffer commandsLoad;
{ {
auto builder = device.CreateCommandBufferBuilder() auto builder = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPassLoad) .BeginRenderPass(renderPassLoad)

View File

@ -25,14 +25,14 @@ constexpr static unsigned int kRTSize = 64;
namespace { namespace {
struct AddressModeTestCase { struct AddressModeTestCase {
nxt::AddressMode mMode; dawn::AddressMode mMode;
uint8_t mExpected2; uint8_t mExpected2;
uint8_t mExpected3; uint8_t mExpected3;
}; };
AddressModeTestCase addressModes[] = { AddressModeTestCase addressModes[] = {
{ nxt::AddressMode::Repeat, 0, 255, }, { dawn::AddressMode::Repeat, 0, 255, },
{ nxt::AddressMode::MirroredRepeat, 255, 0, }, { dawn::AddressMode::MirroredRepeat, 255, 0, },
{ nxt::AddressMode::ClampToEdge, 255, 255, }, { dawn::AddressMode::ClampToEdge, 255, 255, },
}; };
} }
@ -44,13 +44,13 @@ protected:
mBindGroupLayout = utils::MakeBindGroupLayout( mBindGroupLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, nxt::ShaderStageBit::Fragment, nxt::BindingType::Sampler}, {0, dawn::ShaderStageBit::Fragment, dawn::BindingType::Sampler},
{1, nxt::ShaderStageBit::Fragment, nxt::BindingType::SampledTexture}, {1, dawn::ShaderStageBit::Fragment, dawn::BindingType::SampledTexture},
}); });
auto pipelineLayout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout); auto pipelineLayout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
auto vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( auto vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
void main() { void main() {
const vec2 pos[6] = vec2[6](vec2(-2.f, -2.f), const vec2 pos[6] = vec2[6](vec2(-2.f, -2.f),
@ -62,7 +62,7 @@ protected:
gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f); gl_Position = vec4(pos[gl_VertexIndex], 0.f, 1.f);
} }
)"); )");
auto fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( auto fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, 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 texture2D texture0; layout(set = 0, binding = 1) uniform texture2D texture0;
@ -76,16 +76,16 @@ protected:
mPipeline = device.CreateRenderPipelineBuilder() mPipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, mRenderPass.colorFormat) .SetColorAttachmentFormat(0, mRenderPass.colorFormat)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
auto texture = device.CreateTextureBuilder() auto texture = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(2, 2, 1) .SetExtent(2, 2, 1)
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm) .SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::Sampled) .SetAllowedUsage(dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled)
.GetResult(); .GetResult();
// Create a 2x2 checkerboard texture, with black in the top left and bottom right corners. // Create a 2x2 checkerboard texture, with black in the top left and bottom right corners.
@ -96,8 +96,8 @@ protected:
data[0] = data[rowPixels + 1] = black; data[0] = data[rowPixels + 1] = black;
data[1] = data[rowPixels] = white; data[1] = data[rowPixels] = white;
nxt::Buffer stagingBuffer = utils::CreateBufferFromData(device, data, sizeof(data), nxt::BufferUsageBit::TransferSrc); dawn::Buffer stagingBuffer = utils::CreateBufferFromData(device, data, sizeof(data), dawn::BufferUsageBit::TransferSrc);
nxt::CommandBuffer copy = device.CreateCommandBufferBuilder() dawn::CommandBuffer copy = device.CreateCommandBufferBuilder()
.CopyBufferToTexture(stagingBuffer, 0, 256, texture, 0, 0, 0, 2, 2, 1, 0) .CopyBufferToTexture(stagingBuffer, 0, 256, texture, 0, 0, 0, 2, 2, 1, 0)
.GetResult(); .GetResult();
@ -106,12 +106,12 @@ protected:
} }
void TestAddressModes(AddressModeTestCase u, AddressModeTestCase v, AddressModeTestCase w) { void TestAddressModes(AddressModeTestCase u, AddressModeTestCase v, AddressModeTestCase w) {
nxt::Sampler sampler; dawn::Sampler sampler;
{ {
nxt::SamplerDescriptor descriptor; dawn::SamplerDescriptor descriptor;
descriptor.minFilter = nxt::FilterMode::Nearest; descriptor.minFilter = dawn::FilterMode::Nearest;
descriptor.magFilter = nxt::FilterMode::Nearest; descriptor.magFilter = dawn::FilterMode::Nearest;
descriptor.mipmapFilter = nxt::FilterMode::Nearest; descriptor.mipmapFilter = dawn::FilterMode::Nearest;
descriptor.addressModeU = u.mMode; descriptor.addressModeU = u.mMode;
descriptor.addressModeV = v.mMode; descriptor.addressModeV = v.mMode;
descriptor.addressModeW = w.mMode; descriptor.addressModeW = w.mMode;
@ -120,12 +120,12 @@ protected:
auto bindGroup = device.CreateBindGroupBuilder() auto bindGroup = device.CreateBindGroupBuilder()
.SetLayout(mBindGroupLayout) .SetLayout(mBindGroupLayout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetSamplers(0, 1, &sampler) .SetSamplers(0, 1, &sampler)
.SetTextureViews(1, 1, &mTextureView) .SetTextureViews(1, 1, &mTextureView)
.GetResult(); .GetResult();
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(mRenderPass.renderPassInfo) .BeginRenderPass(mRenderPass.renderPassInfo)
.SetRenderPipeline(mPipeline) .SetRenderPipeline(mPipeline)
.SetBindGroup(0, bindGroup) .SetBindGroup(0, bindGroup)
@ -153,9 +153,9 @@ protected:
} }
utils::BasicRenderPass mRenderPass; utils::BasicRenderPass mRenderPass;
nxt::BindGroupLayout mBindGroupLayout; dawn::BindGroupLayout mBindGroupLayout;
nxt::RenderPipeline mPipeline; dawn::RenderPipeline mPipeline;
nxt::TextureView mTextureView; dawn::TextureView mTextureView;
}; };
// Test drawing a rect with a checkerboard texture with different address modes. // Test drawing a rect with a checkerboard texture with different address modes.

View File

@ -18,8 +18,8 @@
class ScissorTest: public NXTTest { class ScissorTest: public NXTTest {
protected: protected:
nxt::RenderPipeline CreateQuadPipeline(nxt::TextureFormat format) { dawn::RenderPipeline CreateQuadPipeline(dawn::TextureFormat format) {
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
const vec2 pos[6] = vec2[6]( const vec2 pos[6] = vec2[6](
vec2(-1.0f, -1.0f), vec2(-1.0f, 1.0f), vec2(1.0f, -1.0f), vec2(-1.0f, -1.0f), vec2(-1.0f, 1.0f), vec2(1.0f, -1.0f),
@ -29,17 +29,17 @@ class ScissorTest: public NXTTest {
gl_Position = vec4(pos[gl_VertexIndex], 0.5, 1.0); gl_Position = vec4(pos[gl_VertexIndex], 0.5, 1.0);
})"); })");
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
fragColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); fragColor = vec4(0.0f, 1.0f, 0.0f, 1.0f);
})"); })");
nxt::RenderPipeline pipeline = device.CreateRenderPipelineBuilder() dawn::RenderPipeline pipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, format) .SetColorAttachmentFormat(0, format)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
return pipeline; return pipeline;
@ -49,9 +49,9 @@ class ScissorTest: public NXTTest {
// Test that by default the scissor test is disabled and the whole attachment can be drawn to. // Test that by default the scissor test is disabled and the whole attachment can be drawn to.
TEST_P(ScissorTest, DefaultsToWholeRenderTarget) { TEST_P(ScissorTest, DefaultsToWholeRenderTarget) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100);
nxt::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat); dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.DrawArrays(6, 1, 0, 0) .DrawArrays(6, 1, 0, 0)
@ -69,9 +69,9 @@ TEST_P(ScissorTest, DefaultsToWholeRenderTarget) {
// Test setting the scissor to something larger than the attachments. // Test setting the scissor to something larger than the attachments.
TEST_P(ScissorTest, LargerThanAttachment) { TEST_P(ScissorTest, LargerThanAttachment) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100);
nxt::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat); dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetScissorRect(0, 0, 200, 200) .SetScissorRect(0, 0, 200, 200)
@ -95,9 +95,9 @@ TEST_P(ScissorTest, EmptyRect) {
} }
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
nxt::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat); dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetScissorRect(0, 0, 0, 0) .SetScissorRect(0, 0, 0, 0)
@ -116,14 +116,14 @@ TEST_P(ScissorTest, EmptyRect) {
// Test setting a partial scissor (not empty, not full attachment) // Test setting a partial scissor (not empty, not full attachment)
TEST_P(ScissorTest, PartialRect) { TEST_P(ScissorTest, PartialRect) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100);
nxt::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat); dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
constexpr uint32_t kX = 3; constexpr uint32_t kX = 3;
constexpr uint32_t kY = 7; constexpr uint32_t kY = 7;
constexpr uint32_t kW = 5; constexpr uint32_t kW = 5;
constexpr uint32_t kH = 13; constexpr uint32_t kH = 13;
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.SetScissorRect(kX, kY, kW, kH) .SetScissorRect(kX, kY, kW, kH)
@ -144,9 +144,9 @@ TEST_P(ScissorTest, PartialRect) {
// Test that the scissor setting doesn't get inherited between renderpasses // Test that the scissor setting doesn't get inherited between renderpasses
TEST_P(ScissorTest, NoInheritanceBetweenRenderPass) { TEST_P(ScissorTest, NoInheritanceBetweenRenderPass) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 100, 100);
nxt::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat); dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
// RenderPass 1 set the scissor // RenderPass 1 set the scissor
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetScissorRect(0, 0, 0, 0) .SetScissorRect(0, 0, 0, 0)

View File

@ -22,27 +22,27 @@ class ViewportOrientationTests : public NXTTest {};
TEST_P(ViewportOrientationTests, OriginAt0x0) { TEST_P(ViewportOrientationTests, OriginAt0x0) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
void main() { void main() {
gl_Position = vec4(-0.5f, -0.5f, 0.0f, 1.0f); gl_Position = vec4(-0.5f, -0.5f, 0.0f, 1.0f);
})"); })");
nxt::ShaderModule fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
fragColor = vec4(0.0f, 1.0f, 0.0f, 1.0f); fragColor = vec4(0.0f, 1.0f, 0.0f, 1.0f);
})"); })");
nxt::RenderPipeline pipeline = device.CreateRenderPipelineBuilder() dawn::RenderPipeline pipeline = device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, renderPass.colorFormat) .SetColorAttachmentFormat(0, renderPass.colorFormat)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::PointList) .SetPrimitiveTopology(dawn::PrimitiveTopology::PointList)
.GetResult(); .GetResult();
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
.BeginRenderPass(renderPass.renderPassInfo) .BeginRenderPass(renderPass.renderPassInfo)
.SetRenderPipeline(pipeline) .SetRenderPipeline(pipeline)
.DrawArrays(1, 1, 0, 0) .DrawArrays(1, 1, 0, 0)

View File

@ -16,7 +16,7 @@
#include "nxt/nxtcpp.h" #include "nxt/nxtcpp.h"
class Object : public nxt::ObjectBase<Object, int*> { class Object : public dawn::ObjectBase<Object, int*> {
public: public:
using ObjectBase::ObjectBase; using ObjectBase::ObjectBase;
using ObjectBase::operator=; using ObjectBase::operator=;

View File

@ -20,70 +20,70 @@ using namespace backend;
// Tests for StageBit // Tests for StageBit
TEST(PerStage, StageBit) { TEST(PerStage, StageBit) {
ASSERT_EQ(StageBit(nxt::ShaderStage::Vertex), nxt::ShaderStageBit::Vertex); ASSERT_EQ(StageBit(dawn::ShaderStage::Vertex), dawn::ShaderStageBit::Vertex);
ASSERT_EQ(StageBit(nxt::ShaderStage::Fragment), nxt::ShaderStageBit::Fragment); ASSERT_EQ(StageBit(dawn::ShaderStage::Fragment), dawn::ShaderStageBit::Fragment);
ASSERT_EQ(StageBit(nxt::ShaderStage::Compute), nxt::ShaderStageBit::Compute); ASSERT_EQ(StageBit(dawn::ShaderStage::Compute), dawn::ShaderStageBit::Compute);
} }
// Basic test for the PerStage container // Basic test for the PerStage container
TEST(PerStage, PerStage) { TEST(PerStage, PerStage) {
PerStage<int> data; PerStage<int> data;
// Store data using nxt::ShaderStage // Store data using dawn::ShaderStage
data[nxt::ShaderStage::Vertex] = 42; data[dawn::ShaderStage::Vertex] = 42;
data[nxt::ShaderStage::Fragment] = 3; data[dawn::ShaderStage::Fragment] = 3;
data[nxt::ShaderStage::Compute] = -1; data[dawn::ShaderStage::Compute] = -1;
// Load it using nxt::ShaderStageBit // Load it using dawn::ShaderStageBit
ASSERT_EQ(data[nxt::ShaderStageBit::Vertex], 42); ASSERT_EQ(data[dawn::ShaderStageBit::Vertex], 42);
ASSERT_EQ(data[nxt::ShaderStageBit::Fragment], 3); ASSERT_EQ(data[dawn::ShaderStageBit::Fragment], 3);
ASSERT_EQ(data[nxt::ShaderStageBit::Compute], -1); ASSERT_EQ(data[dawn::ShaderStageBit::Compute], -1);
} }
// Test IterateStages with kAllStages // Test IterateStages with kAllStages
TEST(PerStage, IterateAllStages) { TEST(PerStage, IterateAllStages) {
PerStage<int> counts; PerStage<int> counts;
counts[nxt::ShaderStage::Vertex] = 0; counts[dawn::ShaderStage::Vertex] = 0;
counts[nxt::ShaderStage::Fragment] = 0; counts[dawn::ShaderStage::Fragment] = 0;
counts[nxt::ShaderStage::Compute] = 0; counts[dawn::ShaderStage::Compute] = 0;
for (auto stage : IterateStages(kAllStages)) { for (auto stage : IterateStages(kAllStages)) {
counts[stage] ++; counts[stage] ++;
} }
ASSERT_EQ(counts[nxt::ShaderStageBit::Vertex], 1); ASSERT_EQ(counts[dawn::ShaderStageBit::Vertex], 1);
ASSERT_EQ(counts[nxt::ShaderStageBit::Fragment], 1); ASSERT_EQ(counts[dawn::ShaderStageBit::Fragment], 1);
ASSERT_EQ(counts[nxt::ShaderStageBit::Compute], 1); ASSERT_EQ(counts[dawn::ShaderStageBit::Compute], 1);
} }
// Test IterateStages with one stage // Test IterateStages with one stage
TEST(PerStage, IterateOneStage) { TEST(PerStage, IterateOneStage) {
PerStage<int> counts; PerStage<int> counts;
counts[nxt::ShaderStage::Vertex] = 0; counts[dawn::ShaderStage::Vertex] = 0;
counts[nxt::ShaderStage::Fragment] = 0; counts[dawn::ShaderStage::Fragment] = 0;
counts[nxt::ShaderStage::Compute] = 0; counts[dawn::ShaderStage::Compute] = 0;
for (auto stage : IterateStages(nxt::ShaderStageBit::Fragment)) { for (auto stage : IterateStages(dawn::ShaderStageBit::Fragment)) {
counts[stage] ++; counts[stage] ++;
} }
ASSERT_EQ(counts[nxt::ShaderStageBit::Vertex], 0); ASSERT_EQ(counts[dawn::ShaderStageBit::Vertex], 0);
ASSERT_EQ(counts[nxt::ShaderStageBit::Fragment], 1); ASSERT_EQ(counts[dawn::ShaderStageBit::Fragment], 1);
ASSERT_EQ(counts[nxt::ShaderStageBit::Compute], 0); ASSERT_EQ(counts[dawn::ShaderStageBit::Compute], 0);
} }
// Test IterateStages with no stage // Test IterateStages with no stage
TEST(PerStage, IterateNoStages) { TEST(PerStage, IterateNoStages) {
PerStage<int> counts; PerStage<int> counts;
counts[nxt::ShaderStage::Vertex] = 0; counts[dawn::ShaderStage::Vertex] = 0;
counts[nxt::ShaderStage::Fragment] = 0; counts[dawn::ShaderStage::Fragment] = 0;
counts[nxt::ShaderStage::Compute] = 0; counts[dawn::ShaderStage::Compute] = 0;
for (auto stage : IterateStages(nxt::ShaderStageBit::Fragment & nxt::ShaderStageBit::Vertex)) { for (auto stage : IterateStages(dawn::ShaderStageBit::Fragment & dawn::ShaderStageBit::Vertex)) {
counts[stage] ++; counts[stage] ++;
} }
ASSERT_EQ(counts[nxt::ShaderStageBit::Vertex], 0); ASSERT_EQ(counts[dawn::ShaderStageBit::Vertex], 0);
ASSERT_EQ(counts[nxt::ShaderStageBit::Fragment], 0); ASSERT_EQ(counts[dawn::ShaderStageBit::Fragment], 0);
ASSERT_EQ(counts[nxt::ShaderStageBit::Compute], 0); ASSERT_EQ(counts[dawn::ShaderStageBit::Compute], 0);
} }

View File

@ -21,11 +21,11 @@ class BindGroupValidationTest : public ValidationTest {
TEST_F(BindGroupValidationTest, BufferViewOffset) { TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto layout = utils::MakeBindGroupLayout( auto layout = utils::MakeBindGroupLayout(
device, { device, {
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer}, {0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
}); });
auto buffer = device.CreateBufferBuilder() auto buffer = device.CreateBufferBuilder()
.SetAllowedUsage(nxt::BufferUsageBit::Uniform) .SetAllowedUsage(dawn::BufferUsageBit::Uniform)
.SetSize(512) .SetSize(512)
.GetResult(); .GetResult();
@ -37,7 +37,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto bindGroup = AssertWillBeSuccess(device.CreateBindGroupBuilder()) auto bindGroup = AssertWillBeSuccess(device.CreateBindGroupBuilder())
.SetLayout(layout) .SetLayout(layout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &bufferView) .SetBufferViews(0, 1, &bufferView)
.GetResult(); .GetResult();
} }
@ -50,7 +50,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto bindGroup = AssertWillBeSuccess(device.CreateBindGroupBuilder()) auto bindGroup = AssertWillBeSuccess(device.CreateBindGroupBuilder())
.SetLayout(layout) .SetLayout(layout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &bufferView) .SetBufferViews(0, 1, &bufferView)
.GetResult(); .GetResult();
} }
@ -63,7 +63,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder()) auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
.SetLayout(layout) .SetLayout(layout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &bufferView) .SetBufferViews(0, 1, &bufferView)
.GetResult(); .GetResult();
} }
@ -75,7 +75,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder()) auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
.SetLayout(layout) .SetLayout(layout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &bufferView) .SetBufferViews(0, 1, &bufferView)
.GetResult(); .GetResult();
} }
@ -87,7 +87,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder()) auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
.SetLayout(layout) .SetLayout(layout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &bufferView) .SetBufferViews(0, 1, &bufferView)
.GetResult(); .GetResult();
} }
@ -99,7 +99,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder()) auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
.SetLayout(layout) .SetLayout(layout)
.SetUsage(nxt::BindGroupUsage::Frozen) .SetUsage(dawn::BindGroupUsage::Frozen)
.SetBufferViews(0, 1, &bufferView) .SetBufferViews(0, 1, &bufferView)
.GetResult(); .GetResult();
} }
@ -112,11 +112,11 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
TEST_F(BindGroupValidationTest, BindGroupLayoutCache) { TEST_F(BindGroupValidationTest, BindGroupLayoutCache) {
auto layout1 = utils::MakeBindGroupLayout( auto layout1 = utils::MakeBindGroupLayout(
device, { device, {
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer}, {0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
}); });
auto layout2 = utils::MakeBindGroupLayout( auto layout2 = utils::MakeBindGroupLayout(
device, { device, {
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer}, {0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
}); });
// Caching should cause these to be the same. // Caching should cause these to be the same.

View File

@ -21,17 +21,17 @@ class BlendStateValidationTest : public ValidationTest {
TEST_F(BlendStateValidationTest, CreationSuccess) { TEST_F(BlendStateValidationTest, CreationSuccess) {
// Success for setting all properties // Success for setting all properties
{ {
nxt::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder()) dawn::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetColorWriteMask(nxt::ColorWriteMask::Red) .SetColorWriteMask(dawn::ColorWriteMask::Red)
.GetResult(); .GetResult();
} }
// Success for empty builder // Success for empty builder
{ {
nxt::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder()) dawn::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
.GetResult(); .GetResult();
} }
} }
@ -40,7 +40,7 @@ TEST_F(BlendStateValidationTest, CreationSuccess) {
TEST_F(BlendStateValidationTest, CreationDuplicates) { TEST_F(BlendStateValidationTest, CreationDuplicates) {
// Test failure when specifying blend enabled multiple times // Test failure when specifying blend enabled multiple times
{ {
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder()) dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetBlendEnabled(true) .SetBlendEnabled(true)
.SetBlendEnabled(false) .SetBlendEnabled(false)
.GetResult(); .GetResult();
@ -48,25 +48,25 @@ TEST_F(BlendStateValidationTest, CreationDuplicates) {
// Test failure when specifying alpha blend multiple times // Test failure when specifying alpha blend multiple times
{ {
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder()) dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::Zero, nxt::BlendFactor::Zero) .SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::Zero, dawn::BlendFactor::Zero)
.GetResult(); .GetResult();
} }
// Test failure when specifying color blend multiple times // Test failure when specifying color blend multiple times
{ {
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder()) dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::Zero, nxt::BlendFactor::Zero) .SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::Zero, dawn::BlendFactor::Zero)
.GetResult(); .GetResult();
} }
// Test failure when specifying color write mask multiple times // Test failure when specifying color write mask multiple times
{ {
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder()) dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetColorWriteMask(nxt::ColorWriteMask::Red) .SetColorWriteMask(dawn::ColorWriteMask::Red)
.SetColorWriteMask(nxt::ColorWriteMask::Green) .SetColorWriteMask(dawn::ColorWriteMask::Green)
.GetResult(); .GetResult();
} }

View File

@ -42,26 +42,26 @@ static void ToMockBufferMapWriteCallback(nxtBufferMapAsyncStatus status, void* p
class BufferValidationTest : public ValidationTest { class BufferValidationTest : public ValidationTest {
protected: protected:
nxt::Buffer CreateMapReadBuffer(uint32_t size) { dawn::Buffer CreateMapReadBuffer(uint32_t size) {
return device.CreateBufferBuilder() return device.CreateBufferBuilder()
.SetSize(size) .SetSize(size)
.SetAllowedUsage(nxt::BufferUsageBit::MapRead) .SetAllowedUsage(dawn::BufferUsageBit::MapRead)
.GetResult(); .GetResult();
} }
nxt::Buffer CreateMapWriteBuffer(uint32_t size) { dawn::Buffer CreateMapWriteBuffer(uint32_t size) {
return device.CreateBufferBuilder() return device.CreateBufferBuilder()
.SetSize(size) .SetSize(size)
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite) .SetAllowedUsage(dawn::BufferUsageBit::MapWrite)
.GetResult(); .GetResult();
} }
nxt::Buffer CreateSetSubDataBuffer(uint32_t size) { dawn::Buffer CreateSetSubDataBuffer(uint32_t size) {
return device.CreateBufferBuilder() return device.CreateBufferBuilder()
.SetSize(size) .SetSize(size)
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
} }
nxt::Queue queue; dawn::Queue queue;
private: private:
void SetUp() override { void SetUp() override {
@ -84,9 +84,9 @@ class BufferValidationTest : public ValidationTest {
TEST_F(BufferValidationTest, CreationSuccess) { TEST_F(BufferValidationTest, CreationSuccess) {
// Success // Success
{ {
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder()) dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder())
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::Uniform) .SetAllowedUsage(dawn::BufferUsageBit::Uniform)
.GetResult(); .GetResult();
} }
} }
@ -95,19 +95,19 @@ TEST_F(BufferValidationTest, CreationSuccess) {
TEST_F(BufferValidationTest, CreationDuplicates) { TEST_F(BufferValidationTest, CreationDuplicates) {
// When size is specified multiple times // When size is specified multiple times
{ {
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder()) dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
.SetSize(4) .SetSize(4)
.SetSize(3) .SetSize(3)
.SetAllowedUsage(nxt::BufferUsageBit::Uniform) .SetAllowedUsage(dawn::BufferUsageBit::Uniform)
.GetResult(); .GetResult();
} }
// When allowed usage is specified multiple times // When allowed usage is specified multiple times
{ {
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder()) dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::Vertex) .SetAllowedUsage(dawn::BufferUsageBit::Vertex)
.SetAllowedUsage(nxt::BufferUsageBit::Uniform) .SetAllowedUsage(dawn::BufferUsageBit::Uniform)
.GetResult(); .GetResult();
} }
} }
@ -116,15 +116,15 @@ TEST_F(BufferValidationTest, CreationDuplicates) {
TEST_F(BufferValidationTest, CreationMissingProperties) { TEST_F(BufferValidationTest, CreationMissingProperties) {
// When allowed usage is missing // When allowed usage is missing
{ {
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder()) dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
.SetSize(4) .SetSize(4)
.GetResult(); .GetResult();
} }
// When size is missing // When size is missing
{ {
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder()) dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
.SetAllowedUsage(nxt::BufferUsageBit::Vertex) .SetAllowedUsage(dawn::BufferUsageBit::Vertex)
.GetResult(); .GetResult();
} }
} }
@ -133,32 +133,32 @@ TEST_F(BufferValidationTest, CreationMissingProperties) {
TEST_F(BufferValidationTest, CreationMapUsageRestrictions) { TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
// MapRead with TransferDst is ok // MapRead with TransferDst is ok
{ {
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "1") dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "1")
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
.SetSize(4) .SetSize(4)
.GetResult(); .GetResult();
} }
// MapRead with something else is an error // MapRead with something else is an error
{ {
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "2") dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "2")
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::Uniform) .SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::Uniform)
.SetSize(4) .SetSize(4)
.GetResult(); .GetResult();
} }
// MapWrite with TransferSrc is ok // MapWrite with TransferSrc is ok
{ {
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "3") dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "3")
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::TransferSrc) .SetAllowedUsage(dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc)
.SetSize(4) .SetSize(4)
.GetResult(); .GetResult();
} }
// MapWrite with something else is an error // MapWrite with something else is an error
{ {
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "4") dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "4")
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform) .SetAllowedUsage(dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::Uniform)
.SetSize(4) .SetSize(4)
.GetResult(); .GetResult();
} }
@ -166,9 +166,9 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
// Test the success case for mapping buffer for reading // Test the success case for mapping buffer for reading
TEST_F(BufferValidationTest, MapReadSuccess) { TEST_F(BufferValidationTest, MapReadSuccess) {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata = 40598; dawn::CallbackUserdata userdata = 40598;
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata); buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
@ -180,9 +180,9 @@ TEST_F(BufferValidationTest, MapReadSuccess) {
// Test the success case for mapping buffer for writing // Test the success case for mapping buffer for writing
TEST_F(BufferValidationTest, MapWriteSuccess) { TEST_F(BufferValidationTest, MapWriteSuccess) {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata = 40598; dawn::CallbackUserdata userdata = 40598;
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata); buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
@ -194,9 +194,9 @@ TEST_F(BufferValidationTest, MapWriteSuccess) {
// Test map reading out of range causes an error // Test map reading out of range causes an error
TEST_F(BufferValidationTest, MapReadOutOfRange) { TEST_F(BufferValidationTest, MapReadOutOfRange) {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata = 40599; dawn::CallbackUserdata userdata = 40599;
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
.Times(1); .Times(1);
@ -205,9 +205,9 @@ TEST_F(BufferValidationTest, MapReadOutOfRange) {
// Test map writing out of range causes an error // Test map writing out of range causes an error
TEST_F(BufferValidationTest, MapWriteOutOfRange) { TEST_F(BufferValidationTest, MapWriteOutOfRange) {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata = 40599; dawn::CallbackUserdata userdata = 40599;
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
.Times(1); .Times(1);
@ -216,12 +216,12 @@ TEST_F(BufferValidationTest, MapWriteOutOfRange) {
// Test map reading a buffer with wrong current usage // Test map reading a buffer with wrong current usage
TEST_F(BufferValidationTest, MapReadWrongUsage) { TEST_F(BufferValidationTest, MapReadWrongUsage) {
nxt::Buffer buf = device.CreateBufferBuilder() dawn::Buffer buf = device.CreateBufferBuilder()
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst) .SetAllowedUsage(dawn::BufferUsageBit::TransferDst)
.GetResult(); .GetResult();
nxt::CallbackUserdata userdata = 40600; dawn::CallbackUserdata userdata = 40600;
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
.Times(1); .Times(1);
@ -230,12 +230,12 @@ TEST_F(BufferValidationTest, MapReadWrongUsage) {
// Test map writing a buffer with wrong current usage // Test map writing a buffer with wrong current usage
TEST_F(BufferValidationTest, MapWriteWrongUsage) { TEST_F(BufferValidationTest, MapWriteWrongUsage) {
nxt::Buffer buf = device.CreateBufferBuilder() dawn::Buffer buf = device.CreateBufferBuilder()
.SetSize(4) .SetSize(4)
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc) .SetAllowedUsage(dawn::BufferUsageBit::TransferSrc)
.GetResult(); .GetResult();
nxt::CallbackUserdata userdata = 40600; dawn::CallbackUserdata userdata = 40600;
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
.Times(1); .Times(1);
@ -244,14 +244,14 @@ TEST_F(BufferValidationTest, MapWriteWrongUsage) {
// Test map reading a buffer that is already mapped // Test map reading a buffer that is already mapped
TEST_F(BufferValidationTest, MapReadAlreadyMapped) { TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata1 = 40601; dawn::CallbackUserdata userdata1 = 40601;
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata1); buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata1);
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
.Times(1); .Times(1);
nxt::CallbackUserdata userdata2 = 40602; dawn::CallbackUserdata userdata2 = 40602;
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
.Times(1); .Times(1);
ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata2)); ASSERT_DEVICE_ERROR(buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata2));
@ -261,14 +261,14 @@ TEST_F(BufferValidationTest, MapReadAlreadyMapped) {
// Test map writing a buffer that is already mapped // Test map writing a buffer that is already mapped
TEST_F(BufferValidationTest, MapWriteAlreadyMapped) { TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata1 = 40601; dawn::CallbackUserdata userdata1 = 40601;
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata1); buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata1);
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
.Times(1); .Times(1);
nxt::CallbackUserdata userdata2 = 40602; dawn::CallbackUserdata userdata2 = 40602;
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
.Times(1); .Times(1);
ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata2)); ASSERT_DEVICE_ERROR(buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata2));
@ -279,9 +279,9 @@ TEST_F(BufferValidationTest, MapWriteAlreadyMapped) {
// Test unmapping before having the result gives UNKNOWN - for reading // Test unmapping before having the result gives UNKNOWN - for reading
TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) { TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata = 40603; dawn::CallbackUserdata userdata = 40603;
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata); buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
@ -295,9 +295,9 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResult) {
// Test unmapping before having the result gives UNKNOWN - for writing // Test unmapping before having the result gives UNKNOWN - for writing
TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) { TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata = 40603; dawn::CallbackUserdata userdata = 40603;
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata); buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
@ -314,9 +314,9 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResult) {
// when its external ref count reaches 0. // when its external ref count reaches 0.
TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) { TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) {
{ {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata = 40604; dawn::CallbackUserdata userdata = 40604;
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata); buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
@ -333,9 +333,9 @@ TEST_F(BufferValidationTest, DISABLED_MapReadDestroyBeforeResult) {
// when its external ref count reaches 0. // when its external ref count reaches 0.
TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) { TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
{ {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata = 40604; dawn::CallbackUserdata userdata = 40604;
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata); buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
@ -350,9 +350,9 @@ TEST_F(BufferValidationTest, DISABLED_MapWriteDestroyBeforeResult) {
// When a MapRead is cancelled with Unmap it might still be in flight, test doing a new request // When a MapRead is cancelled with Unmap it might still be in flight, test doing a new request
// works as expected and we don't get the cancelled request's data. // works as expected and we don't get the cancelled request's data.
TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) { TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata = 40605; dawn::CallbackUserdata userdata = 40605;
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata); buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
@ -372,9 +372,9 @@ TEST_F(BufferValidationTest, MapReadUnmapBeforeResultThenMapAgain) {
// When a MapWrite is cancelled with Unmap it might still be in flight, test doing a new request // When a MapWrite is cancelled with Unmap it might still be in flight, test doing a new request
// works as expected and we don't get the cancelled request's data. // works as expected and we don't get the cancelled request's data.
TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) { TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata = 40605; dawn::CallbackUserdata userdata = 40605;
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata); buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr, userdata))
@ -392,9 +392,9 @@ TEST_F(BufferValidationTest, MapWriteUnmapBeforeResultThenMapAgain) {
// Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback // Test that the MapReadCallback isn't fired twice when unmap() is called inside the callback
TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) { TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata = 40678; dawn::CallbackUserdata userdata = 40678;
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata); buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
@ -407,9 +407,9 @@ TEST_F(BufferValidationTest, UnmapInsideMapReadCallback) {
// Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback // Test that the MapWriteCallback isn't fired twice when unmap() is called inside the callback
TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) { TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata = 40678; dawn::CallbackUserdata userdata = 40678;
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata); buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
@ -422,14 +422,14 @@ TEST_F(BufferValidationTest, UnmapInsideMapWriteCallback) {
// 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) {
nxt::Buffer buf = CreateMapReadBuffer(4); dawn::Buffer buf = CreateMapReadBuffer(4);
nxt::CallbackUserdata userdata = 40679; dawn::CallbackUserdata userdata = 40679;
buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata); buf.MapReadAsync(0, 4, ToMockBufferMapReadCallback, userdata);
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata)) EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
buf = nxt::Buffer(); buf = dawn::Buffer();
})); }));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -437,14 +437,14 @@ TEST_F(BufferValidationTest, DestroyInsideMapReadCallback) {
// 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) {
nxt::Buffer buf = CreateMapWriteBuffer(4); dawn::Buffer buf = CreateMapWriteBuffer(4);
nxt::CallbackUserdata userdata = 40679; dawn::CallbackUserdata userdata = 40679;
buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata); buf.MapWriteAsync(0, 4, ToMockBufferMapWriteCallback, userdata);
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata)) EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
.WillOnce(InvokeWithoutArgs([&]() { .WillOnce(InvokeWithoutArgs([&]() {
buf = nxt::Buffer(); buf = dawn::Buffer();
})); }));
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
@ -452,7 +452,7 @@ TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
// Test the success case for Buffer::SetSubData // Test the success case for Buffer::SetSubData
TEST_F(BufferValidationTest, SetSubDataSuccess) { TEST_F(BufferValidationTest, SetSubDataSuccess) {
nxt::Buffer buf = CreateSetSubDataBuffer(1); dawn::Buffer buf = CreateSetSubDataBuffer(1);
uint8_t foo = 0; uint8_t foo = 0;
buf.SetSubData(0, sizeof(foo), &foo); buf.SetSubData(0, sizeof(foo), &foo);
@ -460,7 +460,7 @@ TEST_F(BufferValidationTest, SetSubDataSuccess) {
// Test error case for SetSubData out of bounds // Test error case for SetSubData out of bounds
TEST_F(BufferValidationTest, SetSubDataOutOfBounds) { TEST_F(BufferValidationTest, SetSubDataOutOfBounds) {
nxt::Buffer buf = CreateSetSubDataBuffer(1); dawn::Buffer buf = CreateSetSubDataBuffer(1);
uint8_t foo = 0; uint8_t foo = 0;
ASSERT_DEVICE_ERROR(buf.SetSubData(0, 2, &foo)); ASSERT_DEVICE_ERROR(buf.SetSubData(0, 2, &foo));
@ -468,9 +468,9 @@ TEST_F(BufferValidationTest, SetSubDataOutOfBounds) {
// Test error case for SetSubData with the wrong usage // Test error case for SetSubData with the wrong usage
TEST_F(BufferValidationTest, SetSubDataWrongUsage) { TEST_F(BufferValidationTest, SetSubDataWrongUsage) {
nxt::Buffer buf = device.CreateBufferBuilder() dawn::Buffer buf = device.CreateBufferBuilder()
.SetSize(1) .SetSize(1)
.SetAllowedUsage(nxt::BufferUsageBit::Vertex) .SetAllowedUsage(dawn::BufferUsageBit::Vertex)
.GetResult(); .GetResult();
uint8_t foo = 0; uint8_t foo = 0;

View File

@ -18,18 +18,18 @@
class CopyCommandTest : public ValidationTest { class CopyCommandTest : public ValidationTest {
protected: protected:
nxt::Buffer CreateFrozenBuffer(uint32_t size, nxt::BufferUsageBit usage) { dawn::Buffer CreateFrozenBuffer(uint32_t size, dawn::BufferUsageBit usage) {
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder()) dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder())
.SetSize(size) .SetSize(size)
.SetAllowedUsage(usage) .SetAllowedUsage(usage)
.GetResult(); .GetResult();
return buf; return buf;
} }
nxt::Texture Create2DTexture(uint32_t width, uint32_t height, uint32_t levels, dawn::Texture Create2DTexture(uint32_t width, uint32_t height, uint32_t levels,
nxt::TextureFormat format, nxt::TextureUsageBit usage) { dawn::TextureFormat format, dawn::TextureUsageBit usage) {
nxt::Texture tex = AssertWillBeSuccess(device.CreateTextureBuilder()) dawn::Texture tex = AssertWillBeSuccess(device.CreateTextureBuilder())
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(width, height, 1) .SetExtent(width, height, 1)
.SetFormat(format) .SetFormat(format)
.SetMipLevels(levels) .SetMipLevels(levels)
@ -51,12 +51,12 @@ class CopyCommandTest_B2B : public CopyCommandTest {
// Test a successfull B2B copy // Test a successfull B2B copy
TEST_F(CopyCommandTest_B2B, Success) { TEST_F(CopyCommandTest_B2B, Success) {
nxt::Buffer source = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferDst);
// Copy different copies, including some that touch the OOB condition // Copy different copies, including some that touch the OOB condition
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.CopyBufferToBuffer(source, 0, destination, 0, 16) .CopyBufferToBuffer(source, 0, destination, 0, 16)
.CopyBufferToBuffer(source, 8, destination, 0, 8) .CopyBufferToBuffer(source, 8, destination, 0, 8)
.CopyBufferToBuffer(source, 0, destination, 8, 8) .CopyBufferToBuffer(source, 0, destination, 8, 8)
@ -65,7 +65,7 @@ TEST_F(CopyCommandTest_B2B, Success) {
// Empty copies are valid // Empty copies are valid
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.CopyBufferToBuffer(source, 0, destination, 0, 0) .CopyBufferToBuffer(source, 0, destination, 0, 0)
.CopyBufferToBuffer(source, 0, destination, 16, 0) .CopyBufferToBuffer(source, 0, destination, 16, 0)
.CopyBufferToBuffer(source, 16, destination, 0, 0) .CopyBufferToBuffer(source, 16, destination, 0, 0)
@ -75,19 +75,19 @@ TEST_F(CopyCommandTest_B2B, Success) {
// Test B2B copies with OOB // Test B2B copies with OOB
TEST_F(CopyCommandTest_B2B, OutOfBounds) { TEST_F(CopyCommandTest_B2B, OutOfBounds) {
nxt::Buffer source = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferDst);
// OOB on the source // OOB on the source
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToBuffer(source, 8, destination, 0, 12) .CopyBufferToBuffer(source, 8, destination, 0, 12)
.GetResult(); .GetResult();
} }
// OOB on the destination // OOB on the destination
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToBuffer(source, 0, destination, 8, 12) .CopyBufferToBuffer(source, 0, destination, 8, 12)
.GetResult(); .GetResult();
} }
@ -95,20 +95,20 @@ TEST_F(CopyCommandTest_B2B, OutOfBounds) {
// Test B2B copies with incorrect buffer usage // Test B2B copies with incorrect buffer usage
TEST_F(CopyCommandTest_B2B, BadUsage) { TEST_F(CopyCommandTest_B2B, BadUsage) {
nxt::Buffer source = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferDst);
nxt::Buffer vertex = CreateFrozenBuffer(16, nxt::BufferUsageBit::Vertex); dawn::Buffer vertex = CreateFrozenBuffer(16, dawn::BufferUsageBit::Vertex);
// Source with incorrect usage // Source with incorrect usage
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToBuffer(vertex, 0, destination, 0, 16) .CopyBufferToBuffer(vertex, 0, destination, 0, 16)
.GetResult(); .GetResult();
} }
// Destination with incorrect usage // Destination with incorrect usage
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToBuffer(source, 0, vertex, 0, 16) .CopyBufferToBuffer(source, 0, vertex, 0, 16)
.GetResult(); .GetResult();
} }
@ -120,13 +120,13 @@ class CopyCommandTest_B2T : public CopyCommandTest {
// Test a successfull B2T copy // Test a successfull B2T copy
TEST_F(CopyCommandTest_B2T, Success) { TEST_F(CopyCommandTest_B2T, Success) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
// Different copies, including some that touch the OOB condition // Different copies, including some that touch the OOB condition
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// Copy 4x4 block in corner of first mip. // Copy 4x4 block in corner of first mip.
.CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 4, 4, 1, 0) .CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 4, 4, 1, 0)
// Copy 4x4 block in opposite corner of first mip. // Copy 4x4 block in opposite corner of first mip.
@ -140,7 +140,7 @@ TEST_F(CopyCommandTest_B2T, Success) {
// Copies with a 256-byte aligned row pitch but unaligned texture region // Copies with a 256-byte aligned row pitch but unaligned texture region
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// Unaligned region // Unaligned region
.CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 3, 4, 1, 0) .CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 3, 4, 1, 0)
// Unaligned region with texture offset // Unaligned region with texture offset
@ -152,7 +152,7 @@ TEST_F(CopyCommandTest_B2T, Success) {
// Empty copies are valid // Empty copies are valid
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// An empty copy // An empty copy
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 1, 0) .CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 1, 0)
// An empty copy touching the end of the buffer // An empty copy touching the end of the buffer
@ -166,27 +166,27 @@ TEST_F(CopyCommandTest_B2T, Success) {
// Test OOB conditions on the buffer // Test OOB conditions on the buffer
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) { TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
// OOB on the buffer because we copy too many pixels // OOB on the buffer because we copy too many pixels
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 4, 5, 1, 0) .CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 4, 5, 1, 0)
.GetResult(); .GetResult();
} }
// OOB on the buffer because of the offset // OOB on the buffer because of the offset
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 4, 256, destination, 0, 0, 0, 4, 4, 1, 0) .CopyBufferToTexture(source, 4, 256, destination, 0, 0, 0, 4, 4, 1, 0)
.GetResult(); .GetResult();
} }
// OOB on the buffer because (row pitch * (height - 1) + width) * depth overflows // OOB on the buffer because (row pitch * (height - 1) + width) * depth overflows
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 512, destination, 0, 0, 0, 4, 3, 1, 0) .CopyBufferToTexture(source, 0, 512, destination, 0, 0, 0, 4, 3, 1, 0)
.GetResult(); .GetResult();
} }
@ -196,8 +196,8 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
{ {
uint32_t sourceBufferSize = BufferSizeForTextureCopy(7, 3, 1); uint32_t sourceBufferSize = BufferSizeForTextureCopy(7, 3, 1);
ASSERT_TRUE(256 * 3 > sourceBufferSize) << "row pitch * height should overflow buffer"; ASSERT_TRUE(256 * 3 > sourceBufferSize) << "row pitch * height should overflow buffer";
nxt::Buffer sourceBuffer = CreateFrozenBuffer(sourceBufferSize, nxt::BufferUsageBit::TransferSrc); dawn::Buffer sourceBuffer = CreateFrozenBuffer(sourceBufferSize, dawn::BufferUsageBit::TransferSrc);
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(sourceBuffer, 0, 256, destination, 0, 0, 0, 7, 3, 1, 0) .CopyBufferToTexture(sourceBuffer, 0, 256, destination, 0, 0, 0, 7, 3, 1, 0)
.GetResult(); .GetResult();
} }
@ -206,34 +206,34 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
// Test OOB conditions on the texture // Test OOB conditions on the texture
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) { TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
// OOB on the texture because x + width overflows // OOB on the texture because x + width overflows
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 256, destination, 13, 12, 0, 4, 4, 1, 0) .CopyBufferToTexture(source, 0, 256, destination, 13, 12, 0, 4, 4, 1, 0)
.GetResult(); .GetResult();
} }
// OOB on the texture because y + width overflows // OOB on the texture because y + width overflows
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 256, destination, 12, 13, 0, 4, 4, 1, 0) .CopyBufferToTexture(source, 0, 256, destination, 12, 13, 0, 4, 4, 1, 0)
.GetResult(); .GetResult();
} }
// OOB on the texture because we overflow a non-zero mip // OOB on the texture because we overflow a non-zero mip
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 256, destination, 1, 0, 0, 4, 4, 1, 2) .CopyBufferToTexture(source, 0, 256, destination, 1, 0, 0, 4, 4, 1, 2)
.GetResult(); .GetResult();
} }
// OOB on the texture even on an empty copy when we copy to a non-existent mip. // OOB on the texture even on an empty copy when we copy to a non-existent mip.
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 1, 5) .CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 1, 5)
.GetResult(); .GetResult();
} }
@ -241,20 +241,20 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {
// Test that we force Z=0 and Depth=1 on copies to 2D textures // Test that we force Z=0 and Depth=1 on copies to 2D textures
TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) { TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
nxt::Buffer source = CreateFrozenBuffer(16 * 4, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(16 * 4, dawn::BufferUsageBit::TransferSrc);
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
// Z=1 on an empty copy still errors // Z=1 on an empty copy still errors
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 1, 0, 0, 1, 0) .CopyBufferToTexture(source, 0, 0, destination, 0, 0, 1, 0, 0, 1, 0)
.GetResult(); .GetResult();
} }
// Depth=0 on an empty copy still errors // Depth=0 on an empty copy still errors
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 0, 0) .CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 0, 0)
.GetResult(); .GetResult();
} }
@ -262,23 +262,23 @@ TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
// Test B2T copies with incorrect buffer usage // Test B2T copies with incorrect buffer usage
TEST_F(CopyCommandTest_B2T, IncorrectUsage) { TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
nxt::Buffer source = CreateFrozenBuffer(16 * 4, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(16 * 4, dawn::BufferUsageBit::TransferSrc);
nxt::Buffer vertex = CreateFrozenBuffer(16 * 4, nxt::BufferUsageBit::Vertex); dawn::Buffer vertex = CreateFrozenBuffer(16 * 4, dawn::BufferUsageBit::Vertex);
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
nxt::Texture sampled = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture sampled = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::Sampled); dawn::TextureUsageBit::Sampled);
// Incorrect source usage // Incorrect source usage
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(vertex, 0, 256, destination, 0, 0, 0, 4, 4, 1, 0) .CopyBufferToTexture(vertex, 0, 256, destination, 0, 0, 0, 4, 4, 1, 0)
.GetResult(); .GetResult();
} }
// Incorrect destination usage // Incorrect destination usage
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 256, sampled, 0, 0, 0, 4, 4, 1, 0) .CopyBufferToTexture(source, 0, 256, sampled, 0, 0, 0, 4, 4, 1, 0)
.GetResult(); .GetResult();
} }
@ -286,27 +286,27 @@ TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) { TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) {
uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1); uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
nxt::Texture destination = Create2DTexture(128, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture destination = Create2DTexture(128, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
// Default row pitch is not 256-byte aligned // Default row pitch is not 256-byte aligned
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 3, 4, 1, 0) .CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 3, 4, 1, 0)
.GetResult(); .GetResult();
} }
// Row pitch is not 256-byte aligned // Row pitch is not 256-byte aligned
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 128, destination, 0, 0, 0, 4, 4, 1, 0) .CopyBufferToTexture(source, 0, 128, destination, 0, 0, 0, 4, 4, 1, 0)
.GetResult(); .GetResult();
} }
// Row pitch is less than width * bytesPerPixel // Row pitch is less than width * bytesPerPixel
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 65, 1, 1, 0) .CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 65, 1, 1, 0)
.GetResult(); .GetResult();
} }
@ -315,29 +315,29 @@ TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) {
// Test B2T copies with incorrect buffer offset usage // Test B2T copies with incorrect buffer offset usage
TEST_F(CopyCommandTest_B2T, IncorrectBufferOffset) { TEST_F(CopyCommandTest_B2T, IncorrectBufferOffset) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc); dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
// Correct usage // Correct usage
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, bufferSize - 4, 256, destination, 0, 0, 0, 1, 1, 1, 0) .CopyBufferToTexture(source, bufferSize - 4, 256, destination, 0, 0, 0, 1, 1, 1, 0)
.GetResult(); .GetResult();
} }
// Incorrect usages // Incorrect usages
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, bufferSize - 5, 256, destination, 0, 0, 0, 1, 1, 1, 0) .CopyBufferToTexture(source, bufferSize - 5, 256, destination, 0, 0, 0, 1, 1, 1, 0)
.GetResult(); .GetResult();
} }
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, bufferSize - 6, 256, destination, 0, 0, 0, 1, 1, 1, 0) .CopyBufferToTexture(source, bufferSize - 6, 256, destination, 0, 0, 0, 1, 1, 1, 0)
.GetResult(); .GetResult();
} }
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyBufferToTexture(source, bufferSize - 7, 256, destination, 0, 0, 0, 1, 1, 1, 0) .CopyBufferToTexture(source, bufferSize - 7, 256, destination, 0, 0, 0, 1, 1, 1, 0)
.GetResult(); .GetResult();
} }
@ -349,13 +349,13 @@ class CopyCommandTest_T2B : public CopyCommandTest {
// Test a successfull T2B copy // Test a successfull T2B copy
TEST_F(CopyCommandTest_T2B, Success) { TEST_F(CopyCommandTest_T2B, Success) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferSrc); dawn::TextureUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
// Different copies, including some that touch the OOB condition // Different copies, including some that touch the OOB condition
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// Copy from 4x4 block in corner of first mip. // Copy from 4x4 block in corner of first mip.
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 0, 256) .CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 0, 256)
// Copy from 4x4 block in opposite corner of first mip. // Copy from 4x4 block in opposite corner of first mip.
@ -369,7 +369,7 @@ TEST_F(CopyCommandTest_T2B, Success) {
// Copies with a 256-byte aligned row pitch but unaligned texture region // Copies with a 256-byte aligned row pitch but unaligned texture region
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// Unaligned region // Unaligned region
.CopyTextureToBuffer(source, 0, 0, 0, 3, 4, 1, 0, destination, 0, 256) .CopyTextureToBuffer(source, 0, 0, 0, 3, 4, 1, 0, destination, 0, 256)
// Unaligned region with texture offset // Unaligned region with texture offset
@ -381,7 +381,7 @@ TEST_F(CopyCommandTest_T2B, Success) {
// Empty copies are valid // Empty copies are valid
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// An empty copy // An empty copy
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 0, destination, 0, 0) .CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 0, destination, 0, 0)
// An empty copy touching the end of the buffer // An empty copy touching the end of the buffer
@ -395,34 +395,34 @@ TEST_F(CopyCommandTest_T2B, Success) {
// Test OOB conditions on the texture // Test OOB conditions on the texture
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) { TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferSrc); dawn::TextureUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
// OOB on the texture because x + width overflows // OOB on the texture because x + width overflows
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 13, 12, 0, 4, 4, 1, 0, destination, 0, 256) .CopyTextureToBuffer(source, 13, 12, 0, 4, 4, 1, 0, destination, 0, 256)
.GetResult(); .GetResult();
} }
// OOB on the texture because y + width overflows // OOB on the texture because y + width overflows
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 12, 13, 0, 4, 4, 1, 0, destination, 0, 256) .CopyTextureToBuffer(source, 12, 13, 0, 4, 4, 1, 0, destination, 0, 256)
.GetResult(); .GetResult();
} }
// OOB on the texture because we overflow a non-zero mip // OOB on the texture because we overflow a non-zero mip
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 1, 0, 0, 4, 4, 1, 2, destination, 0, 256) .CopyTextureToBuffer(source, 1, 0, 0, 4, 4, 1, 2, destination, 0, 256)
.GetResult(); .GetResult();
} }
// OOB on the texture even on an empty copy when we copy from a non-existent mip. // OOB on the texture even on an empty copy when we copy from a non-existent mip.
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 5, destination, 0, 0) .CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 5, destination, 0, 0)
.GetResult(); .GetResult();
} }
@ -431,27 +431,27 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
// Test OOB conditions on the buffer // Test OOB conditions on the buffer
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) { TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferSrc); dawn::TextureUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
// OOB on the buffer because we copy too many pixels // OOB on the buffer because we copy too many pixels
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 5, 1, 0, destination, 0, 256) .CopyTextureToBuffer(source, 0, 0, 0, 4, 5, 1, 0, destination, 0, 256)
.GetResult(); .GetResult();
} }
// OOB on the buffer because of the offset // OOB on the buffer because of the offset
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 4, 256) .CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 4, 256)
.GetResult(); .GetResult();
} }
// OOB on the buffer because (row pitch * (height - 1) + width) * depth overflows // OOB on the buffer because (row pitch * (height - 1) + width) * depth overflows
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 3, 1, 0, destination, 0, 512) .CopyTextureToBuffer(source, 0, 0, 0, 4, 3, 1, 0, destination, 0, 512)
.GetResult(); .GetResult();
} }
@ -461,8 +461,8 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
{ {
uint32_t destinationBufferSize = BufferSizeForTextureCopy(7, 3, 1); uint32_t destinationBufferSize = BufferSizeForTextureCopy(7, 3, 1);
ASSERT_TRUE(256 * 3 > destinationBufferSize) << "row pitch * height should overflow buffer"; ASSERT_TRUE(256 * 3 > destinationBufferSize) << "row pitch * height should overflow buffer";
nxt::Buffer destinationBuffer = CreateFrozenBuffer(destinationBufferSize, nxt::BufferUsageBit::TransferDst); dawn::Buffer destinationBuffer = CreateFrozenBuffer(destinationBufferSize, dawn::BufferUsageBit::TransferDst);
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 7, 3, 1, 0, destinationBuffer, 0, 256) .CopyTextureToBuffer(source, 0, 0, 0, 7, 3, 1, 0, destinationBuffer, 0, 256)
.GetResult(); .GetResult();
} }
@ -471,20 +471,20 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
// Test that we force Z=0 and Depth=1 on copies from to 2D textures // Test that we force Z=0 and Depth=1 on copies from to 2D textures
TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) { TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferSrc); dawn::TextureUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
// Z=1 on an empty copy still errors // Z=1 on an empty copy still errors
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 1, 0, 0, 1, 0, destination, 0, 0) .CopyTextureToBuffer(source, 0, 0, 1, 0, 0, 1, 0, destination, 0, 0)
.GetResult(); .GetResult();
} }
// Depth=0 on an empty copy still errors // Depth=0 on an empty copy still errors
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 0, 0, destination, 0, 0) .CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 0, 0, destination, 0, 0)
.GetResult(); .GetResult();
} }
@ -493,23 +493,23 @@ TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
// Test T2B copies with incorrect buffer usage // Test T2B copies with incorrect buffer usage
TEST_F(CopyCommandTest_T2B, IncorrectUsage) { TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1); uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferSrc); dawn::TextureUsageBit::TransferSrc);
nxt::Texture sampled = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture sampled = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::Sampled); dawn::TextureUsageBit::Sampled);
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
nxt::Buffer vertex = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::Vertex); dawn::Buffer vertex = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::Vertex);
// Incorrect source usage // Incorrect source usage
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(sampled, 0, 0, 0, 4, 4, 1, 0, destination, 0, 256) .CopyTextureToBuffer(sampled, 0, 0, 0, 4, 4, 1, 0, destination, 0, 256)
.GetResult(); .GetResult();
} }
// Incorrect destination usage // Incorrect destination usage
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, vertex, 0, 256) .CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, vertex, 0, 256)
.GetResult(); .GetResult();
} }
@ -517,27 +517,27 @@ TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) { TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) {
uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1); uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
nxt::Texture source = Create2DTexture(128, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture source = Create2DTexture(128, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferDst); dawn::TextureUsageBit::TransferDst);
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc); dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
// Default row pitch is not 256-byte aligned // Default row pitch is not 256-byte aligned
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 3, 4, 1, 0, destination, 0, 256) .CopyTextureToBuffer(source, 0, 0, 0, 3, 4, 1, 0, destination, 0, 256)
.GetResult(); .GetResult();
} }
// Row pitch is not 256-byte aligned // Row pitch is not 256-byte aligned
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 0, 257) .CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 0, 257)
.GetResult(); .GetResult();
} }
// Row pitch is less than width * bytesPerPixel // Row pitch is less than width * bytesPerPixel
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 65, 1, 1, 0, destination, 0, 256) .CopyTextureToBuffer(source, 0, 0, 0, 65, 1, 1, 0, destination, 0, 256)
.GetResult(); .GetResult();
} }
@ -546,29 +546,29 @@ TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) {
// Test T2B copies with incorrect buffer offset usage // Test T2B copies with incorrect buffer offset usage
TEST_F(CopyCommandTest_T2B, IncorrectBufferOffset) { TEST_F(CopyCommandTest_T2B, IncorrectBufferOffset) {
uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1); uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
nxt::Texture source = Create2DTexture(128, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm, dawn::Texture source = Create2DTexture(128, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
nxt::TextureUsageBit::TransferSrc); dawn::TextureUsageBit::TransferSrc);
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst); dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
// Correct usage // Correct usage
{ {
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 4, 256) .CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 4, 256)
.GetResult(); .GetResult();
} }
// Incorrect usages // Incorrect usages
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 5, 256) .CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 5, 256)
.GetResult(); .GetResult();
} }
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 6, 256) .CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 6, 256)
.GetResult(); .GetResult();
} }
{ {
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder()) dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
.CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 7, 256) .CopyTextureToBuffer(source, 0, 0, 0, 1, 1, 1, 0, destination, bufferSize - 7, 256)
.GetResult(); .GetResult();
} }

View File

@ -21,28 +21,28 @@ class DepthStencilStateValidationTest : public ValidationTest {
TEST_F(DepthStencilStateValidationTest, CreationSuccess) { TEST_F(DepthStencilStateValidationTest, CreationSuccess) {
// Success for setting all properties // Success for setting all properties
{ {
nxt::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
.SetDepthCompareFunction(nxt::CompareFunction::Less) .SetDepthCompareFunction(dawn::CompareFunction::Less)
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Greater, .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Greater,
nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
.SetStencilMask(0x0, 0x1) .SetStencilMask(0x0, 0x1)
.GetResult(); .GetResult();
} }
// Success for empty builder // Success for empty builder
{ {
nxt::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
.GetResult(); .GetResult();
} }
// Test success when setting stencil function on separate faces // Test success when setting stencil function on separate faces
{ {
nxt::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
.SetStencilFunction(nxt::Face::Front, nxt::CompareFunction::Less, .SetStencilFunction(dawn::Face::Front, dawn::CompareFunction::Less,
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace) dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Greater, .SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace) dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
.GetResult(); .GetResult();
} }
} }
@ -51,7 +51,7 @@ TEST_F(DepthStencilStateValidationTest, CreationSuccess) {
TEST_F(DepthStencilStateValidationTest, CreationDuplicates) { TEST_F(DepthStencilStateValidationTest, CreationDuplicates) {
// Test failure when specifying depth write enabled multiple times // Test failure when specifying depth write enabled multiple times
{ {
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
.SetDepthWriteEnabled(true) .SetDepthWriteEnabled(true)
.SetDepthWriteEnabled(false) .SetDepthWriteEnabled(false)
.GetResult(); .GetResult();
@ -59,15 +59,15 @@ TEST_F(DepthStencilStateValidationTest, CreationDuplicates) {
// Test failure when specifying depth compare function multiple times // Test failure when specifying depth compare function multiple times
{ {
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
.SetDepthCompareFunction(nxt::CompareFunction::Less) .SetDepthCompareFunction(dawn::CompareFunction::Less)
.SetDepthCompareFunction(nxt::CompareFunction::Greater) .SetDepthCompareFunction(dawn::CompareFunction::Greater)
.GetResult(); .GetResult();
} }
// Test failure when setting stencil mask multiple times // Test failure when setting stencil mask multiple times
{ {
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
.SetStencilMask(0x00, 0x00) .SetStencilMask(0x00, 0x00)
.SetStencilMask(0xff, 0xff) .SetStencilMask(0xff, 0xff)
.GetResult(); .GetResult();
@ -75,21 +75,21 @@ TEST_F(DepthStencilStateValidationTest, CreationDuplicates) {
// Test failure when directly setting stencil function on a face multiple times // Test failure when directly setting stencil function on a face multiple times
{ {
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Less, .SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Less,
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace) dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Greater, .SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace) dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
.GetResult(); .GetResult();
} }
// Test failure when indirectly setting stencil function on a face multiple times // Test failure when indirectly setting stencil function on a face multiple times
{ {
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder()) dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Less, .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Less,
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace) dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Greater, .SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace) dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
.GetResult(); .GetResult();
} }
} }

View File

@ -22,24 +22,24 @@ static constexpr uint32_t kMaxVertexInputs = 16u;
class InputStateTest : public ValidationTest { class InputStateTest : public ValidationTest {
protected: protected:
nxt::RenderPipeline CreatePipeline(bool success, const nxt::InputState& inputState, std::string vertexSource) { dawn::RenderPipeline CreatePipeline(bool success, const dawn::InputState& inputState, std::string vertexSource) {
DummyRenderPass renderpassData = CreateDummyRenderPass(); DummyRenderPass renderpassData = CreateDummyRenderPass();
nxt::ShaderModuleBuilder vsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder()); dawn::ShaderModuleBuilder vsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
utils::FillShaderModuleBuilder(vsModuleBuilder, nxt::ShaderStage::Vertex, vertexSource.c_str()); utils::FillShaderModuleBuilder(vsModuleBuilder, dawn::ShaderStage::Vertex, vertexSource.c_str());
nxt::ShaderModule vsModule = vsModuleBuilder.GetResult(); dawn::ShaderModule vsModule = vsModuleBuilder.GetResult();
nxt::ShaderModuleBuilder fsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder()); dawn::ShaderModuleBuilder fsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
utils::FillShaderModuleBuilder(fsModuleBuilder, nxt::ShaderStage::Fragment, R"( utils::FillShaderModuleBuilder(fsModuleBuilder, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
fragColor = vec4(1.0, 0.0, 0.0, 1.0); fragColor = vec4(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
nxt::ShaderModule fsModule = fsModuleBuilder.GetResult(); dawn::ShaderModule fsModule = fsModuleBuilder.GetResult();
nxt::RenderPipelineBuilder builder; dawn::RenderPipelineBuilder builder;
if (success) { if (success) {
builder = AssertWillBeSuccess(device.CreateRenderPipelineBuilder()); builder = AssertWillBeSuccess(device.CreateRenderPipelineBuilder());
} else { } else {
@ -47,8 +47,8 @@ class InputStateTest : public ValidationTest {
} }
return builder.SetColorAttachmentFormat(0, renderpassData.attachmentFormat) return builder.SetColorAttachmentFormat(0, renderpassData.attachmentFormat)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetInputState(inputState) .SetInputState(inputState)
.GetResult(); .GetResult();
} }
@ -56,7 +56,7 @@ class InputStateTest : public ValidationTest {
// Check an empty input state is valid // Check an empty input state is valid
TEST_F(InputStateTest, EmptyIsOk) { TEST_F(InputStateTest, EmptyIsOk) {
nxt::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder()) dawn::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
.GetResult(); .GetResult();
CreatePipeline(true, state, R"( CreatePipeline(true, state, R"(
@ -69,10 +69,10 @@ TEST_F(InputStateTest, EmptyIsOk) {
// Check validation that pipeline vertex inputs are backed by attributes in the input state // Check validation that pipeline vertex inputs are backed by attributes in the input state
TEST_F(InputStateTest, PipelineCompatibility) { TEST_F(InputStateTest, PipelineCompatibility) {
nxt::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder()) dawn::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 2 * sizeof(float), nxt::InputStepMode::Vertex) .SetInput(0, 2 * sizeof(float), dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
.SetAttribute(1, 0, nxt::VertexFormat::FloatR32, sizeof(float)) .SetAttribute(1, 0, dawn::VertexFormat::FloatR32, sizeof(float))
.GetResult(); .GetResult();
// Control case: pipeline with one input per attribute // Control case: pipeline with one input per attribute
@ -108,13 +108,13 @@ TEST_F(InputStateTest, PipelineCompatibility) {
TEST_F(InputStateTest, StrideZero) { TEST_F(InputStateTest, StrideZero) {
// Works ok without attributes // Works ok without attributes
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.GetResult(); .GetResult();
// Works ok with attributes at a large-ish offset // Works ok with attributes at a large-ish offset
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 128) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 128)
.GetResult(); .GetResult();
} }
@ -122,13 +122,13 @@ TEST_F(InputStateTest, StrideZero) {
TEST_F(InputStateTest, AlreadySetInput) { TEST_F(InputStateTest, AlreadySetInput) {
// Control case // Control case
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.GetResult(); .GetResult();
// Oh no, input 0 is set twice // Oh no, input 0 is set twice
AssertWillBeError(device.CreateInputStateBuilder()) AssertWillBeError(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.GetResult(); .GetResult();
} }
@ -136,12 +136,12 @@ TEST_F(InputStateTest, AlreadySetInput) {
TEST_F(InputStateTest, SetInputOutOfBounds) { TEST_F(InputStateTest, SetInputOutOfBounds) {
// Control case, setting last input // Control case, setting last input
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(kMaxVertexInputs - 1, 0, nxt::InputStepMode::Vertex) .SetInput(kMaxVertexInputs - 1, 0, dawn::InputStepMode::Vertex)
.GetResult(); .GetResult();
// Test OOB // Test OOB
AssertWillBeError(device.CreateInputStateBuilder()) AssertWillBeError(device.CreateInputStateBuilder())
.SetInput(kMaxVertexInputs, 0, nxt::InputStepMode::Vertex) .SetInput(kMaxVertexInputs, 0, dawn::InputStepMode::Vertex)
.GetResult(); .GetResult();
} }
@ -149,15 +149,15 @@ TEST_F(InputStateTest, SetInputOutOfBounds) {
TEST_F(InputStateTest, AlreadySetAttribute) { TEST_F(InputStateTest, AlreadySetAttribute) {
// Control case, setting last attribute // Control case, setting last attribute
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
// Oh no, attribute 0 is set twice // Oh no, attribute 0 is set twice
AssertWillBeError(device.CreateInputStateBuilder()) AssertWillBeError(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
} }
@ -165,14 +165,14 @@ TEST_F(InputStateTest, AlreadySetAttribute) {
TEST_F(InputStateTest, SetAttributeOutOfBounds) { TEST_F(InputStateTest, SetAttributeOutOfBounds) {
// Control case, setting last attribute // Control case, setting last attribute
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(kMaxVertexAttributes - 1, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(kMaxVertexAttributes - 1, 0, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
// Test OOB // Test OOB
AssertWillBeError(device.CreateInputStateBuilder()) AssertWillBeError(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(kMaxVertexAttributes, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(kMaxVertexAttributes, 0, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
} }
@ -180,14 +180,14 @@ TEST_F(InputStateTest, SetAttributeOutOfBounds) {
TEST_F(InputStateTest, RequireInputForAttribute) { TEST_F(InputStateTest, RequireInputForAttribute) {
// Control case // Control case
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
// Attribute 0 uses input 1 which doesn't exist // Attribute 0 uses input 1 which doesn't exist
AssertWillBeError(device.CreateInputStateBuilder()) AssertWillBeError(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(0, 1, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 1, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
} }
@ -195,13 +195,13 @@ TEST_F(InputStateTest, RequireInputForAttribute) {
TEST_F(InputStateTest, SetAttributeOOBCheckForInputs) { TEST_F(InputStateTest, SetAttributeOOBCheckForInputs) {
// Control case // Control case
AssertWillBeSuccess(device.CreateInputStateBuilder()) AssertWillBeSuccess(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
// Could crash if we didn't check for OOB // Could crash if we didn't check for OOB
AssertWillBeError(device.CreateInputStateBuilder()) AssertWillBeError(device.CreateInputStateBuilder())
.SetInput(0, 0, nxt::InputStepMode::Vertex) .SetInput(0, 0, dawn::InputStepMode::Vertex)
.SetAttribute(0, 1000000, nxt::VertexFormat::FloatR32, 0) .SetAttribute(0, 1000000, dawn::VertexFormat::FloatR32, 0)
.GetResult(); .GetResult();
} }

View File

@ -23,17 +23,17 @@ using namespace testing;
class PushConstantTest : public ValidationTest { class PushConstantTest : public ValidationTest {
protected: protected:
nxt::Queue queue; dawn::Queue queue;
uint32_t constants[kMaxPushConstants] = {0}; uint32_t constants[kMaxPushConstants] = {0};
void TestCreateShaderModule(bool success, std::string vertexSource) { void TestCreateShaderModule(bool success, std::string vertexSource) {
nxt::ShaderModuleBuilder builder; dawn::ShaderModuleBuilder builder;
if (success) { if (success) {
builder = AssertWillBeSuccess(device.CreateShaderModuleBuilder()); builder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
} else { } else {
builder = AssertWillBeError(device.CreateShaderModuleBuilder()); builder = AssertWillBeError(device.CreateShaderModuleBuilder());
} }
utils::FillShaderModuleBuilder(builder, nxt::ShaderStage::Vertex, vertexSource.c_str()); utils::FillShaderModuleBuilder(builder, dawn::ShaderStage::Vertex, vertexSource.c_str());
builder.GetResult(); builder.GetResult();
} }
@ -51,22 +51,22 @@ TEST_F(PushConstantTest, Success) {
AssertWillBeSuccess(device.CreateCommandBufferBuilder()) AssertWillBeSuccess(device.CreateCommandBufferBuilder())
// PushConstants in a compute pass // PushConstants in a compute pass
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
.EndComputePass() .EndComputePass()
// PushConstants in a render pass // PushConstants in a render pass
.BeginRenderPass(renderpassData.renderPass) .BeginRenderPass(renderpassData.renderPass)
.SetPushConstants(nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants)
.EndRenderPass() .EndRenderPass()
// Setting all constants // Setting all constants
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, kMaxPushConstants, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
.EndComputePass() .EndComputePass()
// Setting constants at an offset // Setting constants at an offset
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, kMaxPushConstants - 1, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, kMaxPushConstants - 1, 1, constants)
.EndComputePass() .EndComputePass()
.GetResult(); .GetResult();
@ -80,7 +80,7 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
{ {
AssertWillBeSuccess(device.CreateCommandBufferBuilder()) AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, kMaxPushConstants, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
.EndComputePass() .EndComputePass()
.GetResult(); .GetResult();
} }
@ -89,7 +89,7 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
{ {
AssertWillBeError(device.CreateCommandBufferBuilder()) AssertWillBeError(device.CreateCommandBufferBuilder())
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, kMaxPushConstants + 1, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants + 1, constants)
.EndComputePass() .EndComputePass()
.GetResult(); .GetResult();
} }
@ -98,7 +98,7 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
{ {
AssertWillBeError(device.CreateCommandBufferBuilder()) AssertWillBeError(device.CreateCommandBufferBuilder())
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 1, kMaxPushConstants, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 1, kMaxPushConstants, constants)
.EndComputePass() .EndComputePass()
.GetResult(); .GetResult();
} }
@ -111,11 +111,11 @@ TEST_F(PushConstantTest, NotInPass) {
// Setting outside of any pass is invalid. // Setting outside of any pass is invalid.
{ {
AssertWillBeError(device.CreateCommandBufferBuilder()) AssertWillBeError(device.CreateCommandBufferBuilder())
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
.GetResult(); .GetResult();
AssertWillBeError(device.CreateCommandBufferBuilder()) AssertWillBeError(device.CreateCommandBufferBuilder())
.SetPushConstants(nxt::ShaderStageBit::Vertex, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants)
.GetResult(); .GetResult();
} }
} }
@ -126,7 +126,7 @@ TEST_F(PushConstantTest, StageForComputePass) {
{ {
AssertWillBeSuccess(device.CreateCommandBufferBuilder()) AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
.EndComputePass() .EndComputePass()
.GetResult(); .GetResult();
} }
@ -135,7 +135,7 @@ TEST_F(PushConstantTest, StageForComputePass) {
{ {
AssertWillBeError(device.CreateCommandBufferBuilder()) AssertWillBeError(device.CreateCommandBufferBuilder())
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::Vertex, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants)
.EndComputePass() .EndComputePass()
.GetResult(); .GetResult();
} }
@ -144,7 +144,7 @@ TEST_F(PushConstantTest, StageForComputePass) {
{ {
AssertWillBeSuccess(device.CreateCommandBufferBuilder()) AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.BeginComputePass() .BeginComputePass()
.SetPushConstants(nxt::ShaderStageBit::None, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants)
.EndComputePass() .EndComputePass()
.GetResult(); .GetResult();
} }
@ -158,7 +158,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
{ {
AssertWillBeSuccess(device.CreateCommandBufferBuilder()) AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.BeginRenderPass(renderpassData.renderPass) .BeginRenderPass(renderpassData.renderPass)
.SetPushConstants(nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants)
.EndRenderPass() .EndRenderPass()
.GetResult(); .GetResult();
} }
@ -167,7 +167,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
{ {
AssertWillBeError(device.CreateCommandBufferBuilder()) AssertWillBeError(device.CreateCommandBufferBuilder())
.BeginRenderPass(renderpassData.renderPass) .BeginRenderPass(renderpassData.renderPass)
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
.EndRenderPass() .EndRenderPass()
.GetResult(); .GetResult();
} }
@ -176,7 +176,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
{ {
AssertWillBeSuccess(device.CreateCommandBufferBuilder()) AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.BeginRenderPass(renderpassData.renderPass) .BeginRenderPass(renderpassData.renderPass)
.SetPushConstants(nxt::ShaderStageBit::None, 0, 1, constants) .SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants)
.EndRenderPass() .EndRenderPass()
.GetResult(); .GetResult();
} }

View File

@ -21,13 +21,13 @@ namespace {
class RenderPassDescriptorValidationTest : public ValidationTest { class RenderPassDescriptorValidationTest : public ValidationTest {
}; };
nxt::TextureView Create2DAttachment(nxt::Device& device, uint32_t width, uint32_t height, nxt::TextureFormat format) { dawn::TextureView Create2DAttachment(dawn::Device& device, uint32_t width, uint32_t height, dawn::TextureFormat format) {
nxt::Texture attachment = device.CreateTextureBuilder() dawn::Texture attachment = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(width, height, 1) .SetExtent(width, height, 1)
.SetFormat(format) .SetFormat(format)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment) .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
.GetResult(); .GetResult();
return attachment.CreateTextureViewBuilder() return attachment.CreateTextureViewBuilder()
@ -44,16 +44,16 @@ TEST_F(RenderPassDescriptorValidationTest, Empty) {
TEST_F(RenderPassDescriptorValidationTest, OneAttachment) { TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
// One color attachment // One color attachment
{ {
nxt::TextureView color = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, nxt::LoadOp::Clear) .SetColorAttachment(0, color, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
// One depth-stencil attachment // One depth-stencil attachment
{ {
nxt::TextureView depthStencil = Create2DAttachment(device, 1, 1, nxt::TextureFormat::D32FloatS8Uint); dawn::TextureView depthStencil = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetDepthStencilAttachment(depthStencil, nxt::LoadOp::Clear, nxt::LoadOp::Clear) .SetDepthStencilAttachment(depthStencil, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
} }
@ -62,31 +62,31 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) { TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
// For setting the color attachment, control case // For setting the color attachment, control case
{ {
nxt::TextureView color = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(kMaxColorAttachments - 1, color, nxt::LoadOp::Clear) .SetColorAttachment(kMaxColorAttachments - 1, color, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
// For setting the color attachment, OOB // For setting the color attachment, OOB
{ {
nxt::TextureView color = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
AssertWillBeError(device.CreateRenderPassDescriptorBuilder()) AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(kMaxColorAttachments, color, nxt::LoadOp::Clear) .SetColorAttachment(kMaxColorAttachments, color, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
nxt::TextureView color = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
// For setting the clear color, control case // For setting the clear color, control case
{ {
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, nxt::LoadOp::Clear) .SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(kMaxColorAttachments - 1, 0.0f, 0.0f, 0.0f, 0.0f) .SetColorAttachmentClearColor(kMaxColorAttachments - 1, 0.0f, 0.0f, 0.0f, 0.0f)
.GetResult(); .GetResult();
} }
// For setting the clear color, OOB // For setting the clear color, OOB
{ {
AssertWillBeError(device.CreateRenderPassDescriptorBuilder()) AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, nxt::LoadOp::Clear) .SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(kMaxColorAttachments, 0.0f, 0.0f, 0.0f, 0.0f) .SetColorAttachmentClearColor(kMaxColorAttachments, 0.0f, 0.0f, 0.0f, 0.0f)
.GetResult(); .GetResult();
} }
@ -94,26 +94,26 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
// Test setting a clear value without an attachment and vice-versa is ok. // Test setting a clear value without an attachment and vice-versa is ok.
TEST_F(RenderPassDescriptorValidationTest, ClearAndAttachmentMismatchIsOk) { TEST_F(RenderPassDescriptorValidationTest, ClearAndAttachmentMismatchIsOk) {
nxt::TextureView color = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
// For cleared attachment 0 doesn't get a color, clear color for 1 is unused // For cleared attachment 0 doesn't get a color, clear color for 1 is unused
{ {
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, nxt::LoadOp::Clear) .SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(1, 0.0f, 0.0f, 0.0f, 0.0f) .SetColorAttachmentClearColor(1, 0.0f, 0.0f, 0.0f, 0.0f)
.GetResult(); .GetResult();
} }
// Clear depth stencil doesn't get values // Clear depth stencil doesn't get values
{ {
nxt::TextureView depthStencil = Create2DAttachment(device, 1, 1, nxt::TextureFormat::D32FloatS8Uint); dawn::TextureView depthStencil = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetDepthStencilAttachment(depthStencil, nxt::LoadOp::Clear, nxt::LoadOp::Clear) .SetDepthStencilAttachment(depthStencil, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
// Clear values for depth-stencil when it isn't used // Clear values for depth-stencil when it isn't used
{ {
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, nxt::LoadOp::Clear) .SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetDepthStencilAttachmentClearValue(0.0f, 0) .SetDepthStencilAttachmentClearValue(0.0f, 0)
.GetResult(); .GetResult();
} }
@ -121,56 +121,56 @@ TEST_F(RenderPassDescriptorValidationTest, ClearAndAttachmentMismatchIsOk) {
// Attachments must have the same size // Attachments must have the same size
TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) { TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
nxt::TextureView color1x1A = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color1x1A = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
nxt::TextureView color1x1B = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color1x1B = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
nxt::TextureView color2x2 = Create2DAttachment(device, 2, 2, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color2x2 = Create2DAttachment(device, 2, 2, dawn::TextureFormat::R8G8B8A8Unorm);
nxt::TextureView depthStencil1x1 = Create2DAttachment(device, 1, 1, nxt::TextureFormat::D32FloatS8Uint); dawn::TextureView depthStencil1x1 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
nxt::TextureView depthStencil2x2 = Create2DAttachment(device, 2, 2, nxt::TextureFormat::D32FloatS8Uint); dawn::TextureView depthStencil2x2 = Create2DAttachment(device, 2, 2, dawn::TextureFormat::D32FloatS8Uint);
// Control case: all the same size (1x1) // Control case: all the same size (1x1)
{ {
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color1x1A, nxt::LoadOp::Clear) .SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
.SetColorAttachment(1, color1x1B, nxt::LoadOp::Clear) .SetColorAttachment(1, color1x1B, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthStencil1x1, nxt::LoadOp::Clear, nxt::LoadOp::Clear) .SetDepthStencilAttachment(depthStencil1x1, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
// One of the color attachments has a different size // One of the color attachments has a different size
{ {
AssertWillBeError(device.CreateRenderPassDescriptorBuilder()) AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color1x1A, nxt::LoadOp::Clear) .SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
.SetColorAttachment(1, color2x2, nxt::LoadOp::Clear) .SetColorAttachment(1, color2x2, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthStencil1x1, nxt::LoadOp::Clear, nxt::LoadOp::Clear) .SetDepthStencilAttachment(depthStencil1x1, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
// The depth stencil attachment has a different size // The depth stencil attachment has a different size
{ {
AssertWillBeError(device.CreateRenderPassDescriptorBuilder()) AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color1x1A, nxt::LoadOp::Clear) .SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
.SetColorAttachment(1, color1x1B, nxt::LoadOp::Clear) .SetColorAttachment(1, color1x1B, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthStencil2x2, nxt::LoadOp::Clear, nxt::LoadOp::Clear) .SetDepthStencilAttachment(depthStencil2x2, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
} }
// 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) {
nxt::TextureView color = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm); dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
nxt::TextureView depthStencil = Create2DAttachment(device, 1, 1, nxt::TextureFormat::D32FloatS8Uint); dawn::TextureView depthStencil = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
// Using depth-stencil for color // Using depth-stencil for color
{ {
AssertWillBeError(device.CreateRenderPassDescriptorBuilder()) AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, depthStencil, nxt::LoadOp::Clear) .SetColorAttachment(0, depthStencil, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
// Using color for depth-stencil // Using color for depth-stencil
{ {
AssertWillBeError(device.CreateRenderPassDescriptorBuilder()) AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetDepthStencilAttachment(color, nxt::LoadOp::Clear, nxt::LoadOp::Clear) .SetDepthStencilAttachment(color, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
} }

View File

@ -24,20 +24,20 @@ class RenderPipelineValidationTest : public ValidationTest {
renderpass = CreateSimpleRenderPass(); renderpass = CreateSimpleRenderPass();
nxt::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr); dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr);
inputState = device.CreateInputStateBuilder().GetResult(); inputState = device.CreateInputStateBuilder().GetResult();
blendState = device.CreateBlendStateBuilder().GetResult(); blendState = device.CreateBlendStateBuilder().GetResult();
vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"( vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
#version 450 #version 450
void main() { void main() {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0); gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
})" })"
); );
fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
@ -45,21 +45,21 @@ class RenderPipelineValidationTest : public ValidationTest {
})"); })");
} }
nxt::RenderPipelineBuilder& AddDefaultStates(nxt::RenderPipelineBuilder&& builder) { dawn::RenderPipelineBuilder& AddDefaultStates(dawn::RenderPipelineBuilder&& builder) {
builder.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) builder.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList); .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList);
return builder; return builder;
} }
nxt::RenderPassDescriptor renderpass; dawn::RenderPassDescriptor renderpass;
nxt::ShaderModule vsModule; dawn::ShaderModule vsModule;
nxt::ShaderModule fsModule; dawn::ShaderModule fsModule;
nxt::InputState inputState; dawn::InputState inputState;
nxt::BlendState blendState; dawn::BlendState blendState;
nxt::PipelineLayout pipelineLayout; dawn::PipelineLayout pipelineLayout;
}; };
// Test cases where creation should succeed // Test cases where creation should succeed
@ -81,20 +81,20 @@ TEST_F(RenderPipelineValidationTest, CreationMissingProperty) {
// Vertex stage not set // Vertex stage not set
{ {
AssertWillBeError(device.CreateRenderPipelineBuilder()) AssertWillBeError(device.CreateRenderPipelineBuilder())
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
.GetResult(); .GetResult();
} }
// Fragment stage not set // Fragment stage not set
{ {
AssertWillBeError(device.CreateRenderPipelineBuilder()) AssertWillBeError(device.CreateRenderPipelineBuilder())
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
.GetResult(); .GetResult();
} }
@ -102,9 +102,9 @@ TEST_F(RenderPipelineValidationTest, CreationMissingProperty) {
{ {
AssertWillBeError(device.CreateRenderPipelineBuilder()) AssertWillBeError(device.CreateRenderPipelineBuilder())
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
.GetResult(); .GetResult();
} }
} }
@ -114,21 +114,21 @@ TEST_F(RenderPipelineValidationTest, BlendState) {
{ {
// This one succeeds because attachment 0 is the color attachment // This one succeeds because attachment 0 is the color attachment
AssertWillBeSuccess(device.CreateRenderPipelineBuilder()) AssertWillBeSuccess(device.CreateRenderPipelineBuilder())
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
.SetColorAttachmentBlendState(0, blendState) .SetColorAttachmentBlendState(0, blendState)
.GetResult(); .GetResult();
// This fails because attachment 1 is not one of the color attachments // This fails because attachment 1 is not one of the color attachments
AssertWillBeError(device.CreateRenderPipelineBuilder()) AssertWillBeError(device.CreateRenderPipelineBuilder())
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
.SetColorAttachmentBlendState(1, blendState) .SetColorAttachmentBlendState(1, blendState)
.GetResult(); .GetResult();
} }
@ -154,20 +154,20 @@ TEST_F(RenderPipelineValidationTest, DISABLED_TodoCreationMissingProperty) {
// Fails because pipeline layout is not set // Fails because pipeline layout is not set
{ {
AssertWillBeError(device.CreateRenderPipelineBuilder()) AssertWillBeError(device.CreateRenderPipelineBuilder())
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
.GetResult(); .GetResult();
} }
// Fails because primitive topology is not set // Fails because primitive topology is not set
{ {
AssertWillBeError(device.CreateRenderPipelineBuilder()) AssertWillBeError(device.CreateRenderPipelineBuilder())
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetLayout(pipelineLayout) .SetLayout(pipelineLayout)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
} }
} }
@ -184,21 +184,21 @@ TEST_F(RenderPipelineValidationTest, DISABLED_CreationDuplicates) {
// Fails because primitive topology is set twice // Fails because primitive topology is set twice
{ {
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder())) AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList) .SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
.GetResult(); .GetResult();
} }
// Fails because vertex stage is set twice // Fails because vertex stage is set twice
{ {
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder())) AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.GetResult(); .GetResult();
} }
// Fails because fragment stage is set twice // Fails because fragment stage is set twice
{ {
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder())) AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.GetResult(); .GetResult();
} }

View File

@ -28,7 +28,7 @@ ValidationTest::ValidationTest() {
backend::null::Init(&procs, &cDevice); backend::null::Init(&procs, &cDevice);
nxtSetProcs(&procs); nxtSetProcs(&procs);
device = nxt::Device::Acquire(cDevice); device = dawn::Device::Acquire(cDevice);
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<nxtCallbackUserdata>(reinterpret_cast<uintptr_t>(this))); device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<nxtCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
} }
@ -36,7 +36,7 @@ ValidationTest::ValidationTest() {
ValidationTest::~ValidationTest() { ValidationTest::~ValidationTest() {
// We need to destroy NXT objects before setting the procs to null otherwise the nxt*Release // We need to destroy NXT objects before setting the procs to null otherwise the nxt*Release
// will call a nullptr // will call a nullptr
device = nxt::Device(); device = dawn::Device();
nxtSetProcs(nullptr); nxtSetProcs(nullptr);
} }
@ -69,19 +69,19 @@ bool ValidationTest::EndExpectDeviceError() {
return mError; return mError;
} }
nxt::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() { dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
auto colorBuffer = device.CreateTextureBuilder() auto colorBuffer = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(640, 480, 1) .SetExtent(640, 480, 1)
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm) .SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment) .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
.GetResult(); .GetResult();
auto colorView = colorBuffer.CreateTextureViewBuilder() auto colorView = colorBuffer.CreateTextureViewBuilder()
.GetResult(); .GetResult();
return device.CreateRenderPassDescriptorBuilder() return device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, colorView, nxt::LoadOp::Clear) .SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
} }
@ -99,7 +99,7 @@ void ValidationTest::OnDeviceError(const char* message, nxtCallbackUserdata user
self->mError = true; self->mError = true;
} }
void ValidationTest::OnBuilderErrorStatus(nxtBuilderErrorStatus status, const char* message, nxt::CallbackUserdata userdata1, nxt::CallbackUserdata userdata2) { void ValidationTest::OnBuilderErrorStatus(nxtBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2) {
auto* self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata1)); auto* self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata1));
size_t index = static_cast<size_t>(userdata2); size_t index = static_cast<size_t>(userdata2);
@ -116,20 +116,20 @@ ValidationTest::DummyRenderPass ValidationTest::CreateDummyRenderPass() {
DummyRenderPass dummy; DummyRenderPass dummy;
dummy.width = 400; dummy.width = 400;
dummy.height = 400; dummy.height = 400;
dummy.attachmentFormat = nxt::TextureFormat::R8G8B8A8Unorm; dummy.attachmentFormat = dawn::TextureFormat::R8G8B8A8Unorm;
dummy.attachment = AssertWillBeSuccess(device.CreateTextureBuilder()) dummy.attachment = AssertWillBeSuccess(device.CreateTextureBuilder())
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(dummy.width, dummy.height, 1) .SetExtent(dummy.width, dummy.height, 1)
.SetFormat(dummy.attachmentFormat) .SetFormat(dummy.attachmentFormat)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment) .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
.GetResult(); .GetResult();
nxt::TextureView view = AssertWillBeSuccess(dummy.attachment.CreateTextureViewBuilder()).GetResult(); dawn::TextureView view = AssertWillBeSuccess(dummy.attachment.CreateTextureViewBuilder()).GetResult();
dummy.renderPass = AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder()) dummy.renderPass = AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, view, nxt::LoadOp::Clear) .SetColorAttachment(0, view, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
return dummy; return dummy;

View File

@ -34,7 +34,7 @@ class ValidationTest : public testing::Test {
// Use these methods to add expectations on the validation of a builder. The expectations are // Use these methods to add expectations on the validation of a builder. The expectations are
// checked on test teardown. Adding an expectation is done like the following: // checked on test teardown. Adding an expectation is done like the following:
// //
// nxt::Foo foo = AssertWillBe[Success|Error](device.CreateFooBuilder(), "my foo") // dawn::Foo foo = AssertWillBe[Success|Error](device.CreateFooBuilder(), "my foo")
// .SetBar(1) // .SetBar(1)
// .GetResult(); // .GetResult();
// //
@ -48,21 +48,21 @@ class ValidationTest : public testing::Test {
void StartExpectDeviceError(); void StartExpectDeviceError();
bool EndExpectDeviceError(); bool EndExpectDeviceError();
nxt::RenderPassDescriptor CreateSimpleRenderPass(); dawn::RenderPassDescriptor CreateSimpleRenderPass();
// Helper functions to create objects to test validation. // Helper functions to create objects to test validation.
struct DummyRenderPass { struct DummyRenderPass {
nxt::RenderPassDescriptor renderPass; dawn::RenderPassDescriptor renderPass;
nxt::Texture attachment; dawn::Texture attachment;
nxt::TextureFormat attachmentFormat; dawn::TextureFormat attachmentFormat;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
}; };
DummyRenderPass CreateDummyRenderPass(); DummyRenderPass CreateDummyRenderPass();
protected: protected:
nxt::Device device; dawn::Device device;
private: private:
static void OnDeviceError(const char* message, nxtCallbackUserdata userdata); static void OnDeviceError(const char* message, nxtCallbackUserdata userdata);
@ -82,7 +82,7 @@ class ValidationTest : public testing::Test {
template<typename Builder> template<typename Builder>
Builder AddExpectation(Builder& builder, std::string debugName, bool expectSuccess); Builder AddExpectation(Builder& builder, std::string debugName, bool expectSuccess);
static void OnBuilderErrorStatus(nxtBuilderErrorStatus status, const char* message, nxt::CallbackUserdata userdata1, nxt::CallbackUserdata userdata2); static void OnBuilderErrorStatus(nxtBuilderErrorStatus status, const char* message, dawn::CallbackUserdata userdata1, dawn::CallbackUserdata userdata2);
}; };
// Template implementation details // Template implementation details

View File

@ -25,7 +25,7 @@ class VertexBufferValidationTest : public ValidationTest {
renderpass = CreateSimpleRenderPass(); renderpass = CreateSimpleRenderPass();
fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"( fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450 #version 450
layout(location = 0) out vec4 fragColor; layout(location = 0) out vec4 fragColor;
void main() { void main() {
@ -34,18 +34,18 @@ class VertexBufferValidationTest : public ValidationTest {
} }
template <unsigned int N> template <unsigned int N>
std::array<nxt::Buffer, N> MakeVertexBuffers() { std::array<dawn::Buffer, N> MakeVertexBuffers() {
std::array<nxt::Buffer, N> buffers; std::array<dawn::Buffer, N> buffers;
for (auto& buffer : buffers) { for (auto& buffer : buffers) {
buffer = device.CreateBufferBuilder() buffer = device.CreateBufferBuilder()
.SetSize(256) .SetSize(256)
.SetAllowedUsage(nxt::BufferUsageBit::Vertex) .SetAllowedUsage(dawn::BufferUsageBit::Vertex)
.GetResult(); .GetResult();
} }
return buffers; return buffers;
} }
nxt::ShaderModule MakeVertexShader(unsigned int numInputs) { dawn::ShaderModule MakeVertexShader(unsigned int numInputs) {
std::ostringstream vs; std::ostringstream vs;
vs << "#version 450\n"; vs << "#version 450\n";
for (unsigned int i = 0; i < numInputs; ++i) { for (unsigned int i = 0; i < numInputs; ++i) {
@ -64,29 +64,29 @@ class VertexBufferValidationTest : public ValidationTest {
vs << "}\n"; vs << "}\n";
return utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, vs.str().c_str()); return utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, vs.str().c_str());
} }
nxt::InputState MakeInputState(unsigned int numInputs) { dawn::InputState MakeInputState(unsigned int numInputs) {
auto builder = device.CreateInputStateBuilder(); auto builder = device.CreateInputStateBuilder();
for (unsigned int i = 0; i < numInputs; ++i) { for (unsigned int i = 0; i < numInputs; ++i) {
builder.SetAttribute(i, i, nxt::VertexFormat::FloatR32G32B32, 0); builder.SetAttribute(i, i, dawn::VertexFormat::FloatR32G32B32, 0);
builder.SetInput(i, 0, nxt::InputStepMode::Vertex); builder.SetInput(i, 0, dawn::InputStepMode::Vertex);
} }
return builder.GetResult(); return builder.GetResult();
} }
nxt::RenderPipeline MakeRenderPipeline(const nxt::ShaderModule& vsModule, const nxt::InputState& inputState) { dawn::RenderPipeline MakeRenderPipeline(const dawn::ShaderModule& vsModule, const dawn::InputState& inputState) {
return device.CreateRenderPipelineBuilder() return device.CreateRenderPipelineBuilder()
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm) .SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main") .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
.SetInputState(inputState) .SetInputState(inputState)
.GetResult(); .GetResult();
} }
nxt::RenderPassDescriptor renderpass; dawn::RenderPassDescriptor renderpass;
nxt::ShaderModule fsModule; dawn::ShaderModule fsModule;
}; };
TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) { TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {