mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +00:00
Rename nxt:: to dawn:: in tests
This commit is contained in:
committed by
Corentin Wallez
parent
83a9c9d6d9
commit
54e58c20b2
@@ -21,11 +21,11 @@ class BindGroupValidationTest : public ValidationTest {
|
||||
TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
auto layout = utils::MakeBindGroupLayout(
|
||||
device, {
|
||||
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer},
|
||||
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
||||
});
|
||||
|
||||
auto buffer = device.CreateBufferBuilder()
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Uniform)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Uniform)
|
||||
.SetSize(512)
|
||||
.GetResult();
|
||||
|
||||
@@ -37,7 +37,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
|
||||
auto bindGroup = AssertWillBeSuccess(device.CreateBindGroupBuilder())
|
||||
.SetLayout(layout)
|
||||
.SetUsage(nxt::BindGroupUsage::Frozen)
|
||||
.SetUsage(dawn::BindGroupUsage::Frozen)
|
||||
.SetBufferViews(0, 1, &bufferView)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -50,7 +50,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
|
||||
auto bindGroup = AssertWillBeSuccess(device.CreateBindGroupBuilder())
|
||||
.SetLayout(layout)
|
||||
.SetUsage(nxt::BindGroupUsage::Frozen)
|
||||
.SetUsage(dawn::BindGroupUsage::Frozen)
|
||||
.SetBufferViews(0, 1, &bufferView)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -63,7 +63,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
|
||||
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
|
||||
.SetLayout(layout)
|
||||
.SetUsage(nxt::BindGroupUsage::Frozen)
|
||||
.SetUsage(dawn::BindGroupUsage::Frozen)
|
||||
.SetBufferViews(0, 1, &bufferView)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -75,7 +75,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
|
||||
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
|
||||
.SetLayout(layout)
|
||||
.SetUsage(nxt::BindGroupUsage::Frozen)
|
||||
.SetUsage(dawn::BindGroupUsage::Frozen)
|
||||
.SetBufferViews(0, 1, &bufferView)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -87,7 +87,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
|
||||
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
|
||||
.SetLayout(layout)
|
||||
.SetUsage(nxt::BindGroupUsage::Frozen)
|
||||
.SetUsage(dawn::BindGroupUsage::Frozen)
|
||||
.SetBufferViews(0, 1, &bufferView)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -99,7 +99,7 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
|
||||
auto bindGroup = AssertWillBeError(device.CreateBindGroupBuilder())
|
||||
.SetLayout(layout)
|
||||
.SetUsage(nxt::BindGroupUsage::Frozen)
|
||||
.SetUsage(dawn::BindGroupUsage::Frozen)
|
||||
.SetBufferViews(0, 1, &bufferView)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -112,11 +112,11 @@ TEST_F(BindGroupValidationTest, BufferViewOffset) {
|
||||
TEST_F(BindGroupValidationTest, BindGroupLayoutCache) {
|
||||
auto layout1 = utils::MakeBindGroupLayout(
|
||||
device, {
|
||||
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer},
|
||||
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
||||
});
|
||||
auto layout2 = utils::MakeBindGroupLayout(
|
||||
device, {
|
||||
{0, nxt::ShaderStageBit::Vertex, nxt::BindingType::UniformBuffer},
|
||||
{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
|
||||
});
|
||||
|
||||
// Caching should cause these to be the same.
|
||||
|
||||
@@ -21,17 +21,17 @@ class BlendStateValidationTest : public ValidationTest {
|
||||
TEST_F(BlendStateValidationTest, CreationSuccess) {
|
||||
// Success for setting all properties
|
||||
{
|
||||
nxt::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
|
||||
dawn::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
|
||||
.SetBlendEnabled(true)
|
||||
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One)
|
||||
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One)
|
||||
.SetColorWriteMask(nxt::ColorWriteMask::Red)
|
||||
.SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
|
||||
.SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
|
||||
.SetColorWriteMask(dawn::ColorWriteMask::Red)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Success for empty builder
|
||||
{
|
||||
nxt::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
|
||||
dawn::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ TEST_F(BlendStateValidationTest, CreationSuccess) {
|
||||
TEST_F(BlendStateValidationTest, CreationDuplicates) {
|
||||
// Test failure when specifying blend enabled multiple times
|
||||
{
|
||||
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
.SetBlendEnabled(true)
|
||||
.SetBlendEnabled(false)
|
||||
.GetResult();
|
||||
@@ -48,25 +48,25 @@ TEST_F(BlendStateValidationTest, CreationDuplicates) {
|
||||
|
||||
// Test failure when specifying alpha blend multiple times
|
||||
{
|
||||
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One)
|
||||
.SetAlphaBlend(nxt::BlendOperation::Add, nxt::BlendFactor::Zero, nxt::BlendFactor::Zero)
|
||||
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
.SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
|
||||
.SetAlphaBlend(dawn::BlendOperation::Add, dawn::BlendFactor::Zero, dawn::BlendFactor::Zero)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Test failure when specifying color blend multiple times
|
||||
{
|
||||
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::One, nxt::BlendFactor::One)
|
||||
.SetColorBlend(nxt::BlendOperation::Add, nxt::BlendFactor::Zero, nxt::BlendFactor::Zero)
|
||||
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
.SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::One, dawn::BlendFactor::One)
|
||||
.SetColorBlend(dawn::BlendOperation::Add, dawn::BlendFactor::Zero, dawn::BlendFactor::Zero)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Test failure when specifying color write mask multiple times
|
||||
{
|
||||
nxt::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
.SetColorWriteMask(nxt::ColorWriteMask::Red)
|
||||
.SetColorWriteMask(nxt::ColorWriteMask::Green)
|
||||
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
|
||||
.SetColorWriteMask(dawn::ColorWriteMask::Red)
|
||||
.SetColorWriteMask(dawn::ColorWriteMask::Green)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,26 +42,26 @@ static void ToMockBufferMapWriteCallback(nxtBufferMapAsyncStatus status, void* p
|
||||
|
||||
class BufferValidationTest : public ValidationTest {
|
||||
protected:
|
||||
nxt::Buffer CreateMapReadBuffer(uint32_t size) {
|
||||
dawn::Buffer CreateMapReadBuffer(uint32_t size) {
|
||||
return device.CreateBufferBuilder()
|
||||
.SetSize(size)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::MapRead)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapRead)
|
||||
.GetResult();
|
||||
}
|
||||
nxt::Buffer CreateMapWriteBuffer(uint32_t size) {
|
||||
dawn::Buffer CreateMapWriteBuffer(uint32_t size) {
|
||||
return device.CreateBufferBuilder()
|
||||
.SetSize(size)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapWrite)
|
||||
.GetResult();
|
||||
}
|
||||
nxt::Buffer CreateSetSubDataBuffer(uint32_t size) {
|
||||
dawn::Buffer CreateSetSubDataBuffer(uint32_t size) {
|
||||
return device.CreateBufferBuilder()
|
||||
.SetSize(size)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::TransferDst)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
nxt::Queue queue;
|
||||
dawn::Queue queue;
|
||||
|
||||
private:
|
||||
void SetUp() override {
|
||||
@@ -84,9 +84,9 @@ class BufferValidationTest : public ValidationTest {
|
||||
TEST_F(BufferValidationTest, CreationSuccess) {
|
||||
// Success
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder())
|
||||
dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder())
|
||||
.SetSize(4)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Uniform)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Uniform)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -95,19 +95,19 @@ TEST_F(BufferValidationTest, CreationSuccess) {
|
||||
TEST_F(BufferValidationTest, CreationDuplicates) {
|
||||
// When size is specified multiple times
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
.SetSize(4)
|
||||
.SetSize(3)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Uniform)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Uniform)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// When allowed usage is specified multiple times
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
.SetSize(4)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Vertex)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Uniform)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Vertex)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Uniform)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -116,15 +116,15 @@ TEST_F(BufferValidationTest, CreationDuplicates) {
|
||||
TEST_F(BufferValidationTest, CreationMissingProperties) {
|
||||
// When allowed usage is missing
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
.SetSize(4)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// When size is missing
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Vertex)
|
||||
dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder())
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Vertex)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -133,32 +133,32 @@ TEST_F(BufferValidationTest, CreationMissingProperties) {
|
||||
TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
|
||||
// MapRead with TransferDst is ok
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "1")
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst)
|
||||
dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "1")
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst)
|
||||
.SetSize(4)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// MapRead with something else is an error
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "2")
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::Uniform)
|
||||
dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "2")
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::Uniform)
|
||||
.SetSize(4)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// MapWrite with TransferSrc is ok
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "3")
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::TransferSrc)
|
||||
dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder(), "3")
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc)
|
||||
.SetSize(4)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// MapWrite with something else is an error
|
||||
{
|
||||
nxt::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "4")
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::Uniform)
|
||||
dawn::Buffer buf = AssertWillBeError(device.CreateBufferBuilder(), "4")
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::Uniform)
|
||||
.SetSize(4)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -166,9 +166,9 @@ TEST_F(BufferValidationTest, CreationMapUsageRestrictions) {
|
||||
|
||||
// Test the success case for mapping buffer for reading
|
||||
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);
|
||||
|
||||
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_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);
|
||||
|
||||
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_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))
|
||||
.Times(1);
|
||||
|
||||
@@ -205,9 +205,9 @@ TEST_F(BufferValidationTest, MapReadOutOfRange) {
|
||||
|
||||
// Test map writing out of range causes an error
|
||||
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))
|
||||
.Times(1);
|
||||
|
||||
@@ -216,12 +216,12 @@ TEST_F(BufferValidationTest, MapWriteOutOfRange) {
|
||||
|
||||
// Test map reading a buffer with wrong current usage
|
||||
TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
||||
nxt::Buffer buf = device.CreateBufferBuilder()
|
||||
dawn::Buffer buf = device.CreateBufferBuilder()
|
||||
.SetSize(4)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::TransferDst)
|
||||
.GetResult();
|
||||
|
||||
nxt::CallbackUserdata userdata = 40600;
|
||||
dawn::CallbackUserdata userdata = 40600;
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
||||
.Times(1);
|
||||
|
||||
@@ -230,12 +230,12 @@ TEST_F(BufferValidationTest, MapReadWrongUsage) {
|
||||
|
||||
// Test map writing a buffer with wrong current usage
|
||||
TEST_F(BufferValidationTest, MapWriteWrongUsage) {
|
||||
nxt::Buffer buf = device.CreateBufferBuilder()
|
||||
dawn::Buffer buf = device.CreateBufferBuilder()
|
||||
.SetSize(4)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::TransferSrc)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::TransferSrc)
|
||||
.GetResult();
|
||||
|
||||
nxt::CallbackUserdata userdata = 40600;
|
||||
dawn::CallbackUserdata userdata = 40600;
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata))
|
||||
.Times(1);
|
||||
|
||||
@@ -244,14 +244,14 @@ TEST_F(BufferValidationTest, MapWriteWrongUsage) {
|
||||
|
||||
// Test map reading a buffer that is already mapped
|
||||
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);
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
||||
.Times(1);
|
||||
|
||||
nxt::CallbackUserdata userdata2 = 40602;
|
||||
dawn::CallbackUserdata userdata2 = 40602;
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
||||
.Times(1);
|
||||
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_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);
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata1))
|
||||
.Times(1);
|
||||
|
||||
nxt::CallbackUserdata userdata2 = 40602;
|
||||
dawn::CallbackUserdata userdata2 = 40602;
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata2))
|
||||
.Times(1);
|
||||
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_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);
|
||||
|
||||
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_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);
|
||||
|
||||
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.
|
||||
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);
|
||||
|
||||
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.
|
||||
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);
|
||||
|
||||
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
|
||||
// works as expected and we don't get the cancelled request's data.
|
||||
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);
|
||||
|
||||
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
|
||||
// works as expected and we don't get the cancelled request's data.
|
||||
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);
|
||||
|
||||
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_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);
|
||||
|
||||
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_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);
|
||||
|
||||
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_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);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapReadCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
buf = nxt::Buffer();
|
||||
buf = dawn::Buffer();
|
||||
}));
|
||||
|
||||
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_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);
|
||||
|
||||
EXPECT_CALL(*mockBufferMapWriteCallback, Call(NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, Ne(nullptr), userdata))
|
||||
.WillOnce(InvokeWithoutArgs([&]() {
|
||||
buf = nxt::Buffer();
|
||||
buf = dawn::Buffer();
|
||||
}));
|
||||
|
||||
queue.Submit(0, nullptr);
|
||||
@@ -452,7 +452,7 @@ TEST_F(BufferValidationTest, DestroyInsideMapWriteCallback) {
|
||||
|
||||
// Test the success case for Buffer::SetSubData
|
||||
TEST_F(BufferValidationTest, SetSubDataSuccess) {
|
||||
nxt::Buffer buf = CreateSetSubDataBuffer(1);
|
||||
dawn::Buffer buf = CreateSetSubDataBuffer(1);
|
||||
|
||||
uint8_t foo = 0;
|
||||
buf.SetSubData(0, sizeof(foo), &foo);
|
||||
@@ -460,7 +460,7 @@ TEST_F(BufferValidationTest, SetSubDataSuccess) {
|
||||
|
||||
// Test error case for SetSubData out of bounds
|
||||
TEST_F(BufferValidationTest, SetSubDataOutOfBounds) {
|
||||
nxt::Buffer buf = CreateSetSubDataBuffer(1);
|
||||
dawn::Buffer buf = CreateSetSubDataBuffer(1);
|
||||
|
||||
uint8_t foo = 0;
|
||||
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_F(BufferValidationTest, SetSubDataWrongUsage) {
|
||||
nxt::Buffer buf = device.CreateBufferBuilder()
|
||||
dawn::Buffer buf = device.CreateBufferBuilder()
|
||||
.SetSize(1)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Vertex)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Vertex)
|
||||
.GetResult();
|
||||
|
||||
uint8_t foo = 0;
|
||||
|
||||
@@ -18,18 +18,18 @@
|
||||
|
||||
class CopyCommandTest : public ValidationTest {
|
||||
protected:
|
||||
nxt::Buffer CreateFrozenBuffer(uint32_t size, nxt::BufferUsageBit usage) {
|
||||
nxt::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder())
|
||||
dawn::Buffer CreateFrozenBuffer(uint32_t size, dawn::BufferUsageBit usage) {
|
||||
dawn::Buffer buf = AssertWillBeSuccess(device.CreateBufferBuilder())
|
||||
.SetSize(size)
|
||||
.SetAllowedUsage(usage)
|
||||
.GetResult();
|
||||
return buf;
|
||||
}
|
||||
|
||||
nxt::Texture Create2DTexture(uint32_t width, uint32_t height, uint32_t levels,
|
||||
nxt::TextureFormat format, nxt::TextureUsageBit usage) {
|
||||
nxt::Texture tex = AssertWillBeSuccess(device.CreateTextureBuilder())
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
dawn::Texture Create2DTexture(uint32_t width, uint32_t height, uint32_t levels,
|
||||
dawn::TextureFormat format, dawn::TextureUsageBit usage) {
|
||||
dawn::Texture tex = AssertWillBeSuccess(device.CreateTextureBuilder())
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
.SetExtent(width, height, 1)
|
||||
.SetFormat(format)
|
||||
.SetMipLevels(levels)
|
||||
@@ -51,12 +51,12 @@ class CopyCommandTest_B2B : public CopyCommandTest {
|
||||
|
||||
// Test a successfull B2B copy
|
||||
TEST_F(CopyCommandTest_B2B, Success) {
|
||||
nxt::Buffer source = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferDst);
|
||||
|
||||
// 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, 8, destination, 0, 8)
|
||||
.CopyBufferToBuffer(source, 0, destination, 8, 8)
|
||||
@@ -65,7 +65,7 @@ TEST_F(CopyCommandTest_B2B, Success) {
|
||||
|
||||
// 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, 16, 0)
|
||||
.CopyBufferToBuffer(source, 16, destination, 0, 0)
|
||||
@@ -75,19 +75,19 @@ TEST_F(CopyCommandTest_B2B, Success) {
|
||||
|
||||
// Test B2B copies with OOB
|
||||
TEST_F(CopyCommandTest_B2B, OutOfBounds) {
|
||||
nxt::Buffer source = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferDst);
|
||||
|
||||
// OOB on the source
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 8, destination, 0, 12)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// OOB on the destination
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 0, destination, 8, 12)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -95,20 +95,20 @@ TEST_F(CopyCommandTest_B2B, OutOfBounds) {
|
||||
|
||||
// Test B2B copies with incorrect buffer usage
|
||||
TEST_F(CopyCommandTest_B2B, BadUsage) {
|
||||
nxt::Buffer source = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(16, nxt::BufferUsageBit::TransferDst);
|
||||
nxt::Buffer vertex = CreateFrozenBuffer(16, nxt::BufferUsageBit::Vertex);
|
||||
dawn::Buffer source = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(16, dawn::BufferUsageBit::TransferDst);
|
||||
dawn::Buffer vertex = CreateFrozenBuffer(16, dawn::BufferUsageBit::Vertex);
|
||||
|
||||
// Source with incorrect usage
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(vertex, 0, destination, 0, 16)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Destination with incorrect usage
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 0, vertex, 0, 16)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -120,13 +120,13 @@ class CopyCommandTest_B2T : public CopyCommandTest {
|
||||
// Test a successfull B2T copy
|
||||
TEST_F(CopyCommandTest_B2T, Success) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
|
||||
// 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.
|
||||
.CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 4, 4, 1, 0)
|
||||
// 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
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
// Unaligned region
|
||||
.CopyBufferToTexture(source, 0, 256, destination, 0, 0, 0, 3, 4, 1, 0)
|
||||
// Unaligned region with texture offset
|
||||
@@ -152,7 +152,7 @@ TEST_F(CopyCommandTest_B2T, Success) {
|
||||
|
||||
// Empty copies are valid
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
// An empty copy
|
||||
.CopyBufferToTexture(source, 0, 0, destination, 0, 0, 0, 0, 0, 1, 0)
|
||||
// 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_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -196,8 +196,8 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
|
||||
{
|
||||
uint32_t sourceBufferSize = BufferSizeForTextureCopy(7, 3, 1);
|
||||
ASSERT_TRUE(256 * 3 > sourceBufferSize) << "row pitch * height should overflow buffer";
|
||||
nxt::Buffer sourceBuffer = CreateFrozenBuffer(sourceBufferSize, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
dawn::Buffer sourceBuffer = CreateFrozenBuffer(sourceBufferSize, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToTexture(sourceBuffer, 0, 256, destination, 0, 0, 0, 7, 3, 1, 0)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -206,34 +206,34 @@ TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {
|
||||
// Test OOB conditions on the texture
|
||||
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.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_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
|
||||
nxt::Buffer source = CreateFrozenBuffer(16 * 4, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(16 * 4, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -262,23 +262,23 @@ TEST_F(CopyCommandTest_B2T, ZDepthConstraintFor2DTextures) {
|
||||
|
||||
// Test B2T copies with incorrect buffer usage
|
||||
TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
|
||||
nxt::Buffer source = CreateFrozenBuffer(16 * 4, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Buffer vertex = CreateFrozenBuffer(16 * 4, nxt::BufferUsageBit::Vertex);
|
||||
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
nxt::Texture sampled = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::Sampled);
|
||||
dawn::Buffer source = CreateFrozenBuffer(16 * 4, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Buffer vertex = CreateFrozenBuffer(16 * 4, dawn::BufferUsageBit::Vertex);
|
||||
dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
dawn::Texture sampled = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::Sampled);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -286,27 +286,27 @@ TEST_F(CopyCommandTest_B2T, IncorrectUsage) {
|
||||
|
||||
TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
||||
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Texture destination = Create2DTexture(128, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Texture destination = Create2DTexture(128, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -315,29 +315,29 @@ TEST_F(CopyCommandTest_B2T, IncorrectRowPitch) {
|
||||
// Test B2T copies with incorrect buffer offset usage
|
||||
TEST_F(CopyCommandTest_B2T, IncorrectBufferOffset) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Buffer source = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc);
|
||||
nxt::Texture destination = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
dawn::Buffer source = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
|
||||
dawn::Texture destination = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
// 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)
|
||||
.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)
|
||||
.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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -349,13 +349,13 @@ class CopyCommandTest_T2B : public CopyCommandTest {
|
||||
// Test a successfull T2B copy
|
||||
TEST_F(CopyCommandTest_T2B, Success) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst);
|
||||
dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
|
||||
|
||||
// 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.
|
||||
.CopyTextureToBuffer(source, 0, 0, 0, 4, 4, 1, 0, destination, 0, 256)
|
||||
// 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
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
// Unaligned region
|
||||
.CopyTextureToBuffer(source, 0, 0, 0, 3, 4, 1, 0, destination, 0, 256)
|
||||
// Unaligned region with texture offset
|
||||
@@ -381,7 +381,7 @@ TEST_F(CopyCommandTest_T2B, Success) {
|
||||
|
||||
// Empty copies are valid
|
||||
{
|
||||
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
// An empty copy
|
||||
.CopyTextureToBuffer(source, 0, 0, 0, 0, 0, 1, 0, destination, 0, 0)
|
||||
// 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_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst);
|
||||
dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -431,27 +431,27 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {
|
||||
// Test OOB conditions on the buffer
|
||||
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst);
|
||||
dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -461,8 +461,8 @@ TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {
|
||||
{
|
||||
uint32_t destinationBufferSize = BufferSizeForTextureCopy(7, 3, 1);
|
||||
ASSERT_TRUE(256 * 3 > destinationBufferSize) << "row pitch * height should overflow buffer";
|
||||
nxt::Buffer destinationBuffer = CreateFrozenBuffer(destinationBufferSize, nxt::BufferUsageBit::TransferDst);
|
||||
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
dawn::Buffer destinationBuffer = CreateFrozenBuffer(destinationBufferSize, dawn::BufferUsageBit::TransferDst);
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.CopyTextureToBuffer(source, 0, 0, 0, 7, 3, 1, 0, destinationBuffer, 0, 256)
|
||||
.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_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst);
|
||||
dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -493,23 +493,23 @@ TEST_F(CopyCommandTest_T2B, ZDepthConstraintFor2DTextures) {
|
||||
// Test T2B copies with incorrect buffer usage
|
||||
TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||
nxt::Texture source = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferSrc);
|
||||
nxt::Texture sampled = Create2DTexture(16, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::Sampled);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst);
|
||||
nxt::Buffer vertex = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::Vertex);
|
||||
dawn::Texture source = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferSrc);
|
||||
dawn::Texture sampled = Create2DTexture(16, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::Sampled);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
|
||||
dawn::Buffer vertex = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::Vertex);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -517,27 +517,27 @@ TEST_F(CopyCommandTest_T2B, IncorrectUsage) {
|
||||
|
||||
TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
||||
nxt::Texture source = Create2DTexture(128, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferDst);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferSrc);
|
||||
dawn::Texture source = Create2DTexture(128, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferDst);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferSrc);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -546,29 +546,29 @@ TEST_F(CopyCommandTest_T2B, IncorrectRowPitch) {
|
||||
// Test T2B copies with incorrect buffer offset usage
|
||||
TEST_F(CopyCommandTest_T2B, IncorrectBufferOffset) {
|
||||
uint32_t bufferSize = BufferSizeForTextureCopy(128, 16, 1);
|
||||
nxt::Texture source = Create2DTexture(128, 16, 5, nxt::TextureFormat::R8G8B8A8Unorm,
|
||||
nxt::TextureUsageBit::TransferSrc);
|
||||
nxt::Buffer destination = CreateFrozenBuffer(bufferSize, nxt::BufferUsageBit::TransferDst);
|
||||
dawn::Texture source = Create2DTexture(128, 16, 5, dawn::TextureFormat::R8G8B8A8Unorm,
|
||||
dawn::TextureUsageBit::TransferSrc);
|
||||
dawn::Buffer destination = CreateFrozenBuffer(bufferSize, dawn::BufferUsageBit::TransferDst);
|
||||
|
||||
// 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)
|
||||
.GetResult();
|
||||
}
|
||||
// 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)
|
||||
.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)
|
||||
.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)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -21,28 +21,28 @@ class DepthStencilStateValidationTest : public ValidationTest {
|
||||
TEST_F(DepthStencilStateValidationTest, CreationSuccess) {
|
||||
// Success for setting all properties
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||
.SetDepthCompareFunction(nxt::CompareFunction::Less)
|
||||
dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
||||
.SetDepthWriteEnabled(true)
|
||||
.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)
|
||||
.SetStencilMask(0x0, 0x1)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Success for empty builder
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||
dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Test success when setting stencil function on separate faces
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||
.SetStencilFunction(nxt::Face::Front, nxt::CompareFunction::Less,
|
||||
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace)
|
||||
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Greater,
|
||||
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace)
|
||||
dawn::DepthStencilState ds = AssertWillBeSuccess(device.CreateDepthStencilStateBuilder())
|
||||
.SetStencilFunction(dawn::Face::Front, dawn::CompareFunction::Less,
|
||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
|
||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ TEST_F(DepthStencilStateValidationTest, CreationSuccess) {
|
||||
TEST_F(DepthStencilStateValidationTest, CreationDuplicates) {
|
||||
// Test failure when specifying depth write enabled multiple times
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetDepthWriteEnabled(true)
|
||||
.SetDepthWriteEnabled(false)
|
||||
.GetResult();
|
||||
@@ -59,15 +59,15 @@ TEST_F(DepthStencilStateValidationTest, CreationDuplicates) {
|
||||
|
||||
// Test failure when specifying depth compare function multiple times
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetDepthCompareFunction(nxt::CompareFunction::Less)
|
||||
.SetDepthCompareFunction(nxt::CompareFunction::Greater)
|
||||
dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetDepthCompareFunction(dawn::CompareFunction::Less)
|
||||
.SetDepthCompareFunction(dawn::CompareFunction::Greater)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Test failure when setting stencil mask multiple times
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetStencilMask(0x00, 0x00)
|
||||
.SetStencilMask(0xff, 0xff)
|
||||
.GetResult();
|
||||
@@ -75,21 +75,21 @@ TEST_F(DepthStencilStateValidationTest, CreationDuplicates) {
|
||||
|
||||
// Test failure when directly setting stencil function on a face multiple times
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Less,
|
||||
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace)
|
||||
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Greater,
|
||||
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace)
|
||||
dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Less,
|
||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
|
||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Test failure when indirectly setting stencil function on a face multiple times
|
||||
{
|
||||
nxt::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Less,
|
||||
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace)
|
||||
.SetStencilFunction(nxt::Face::Back, nxt::CompareFunction::Greater,
|
||||
nxt::StencilOperation::Replace, nxt::StencilOperation::Replace, nxt::StencilOperation::Replace)
|
||||
dawn::DepthStencilState ds = AssertWillBeError(device.CreateDepthStencilStateBuilder())
|
||||
.SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Less,
|
||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
||||
.SetStencilFunction(dawn::Face::Back, dawn::CompareFunction::Greater,
|
||||
dawn::StencilOperation::Replace, dawn::StencilOperation::Replace, dawn::StencilOperation::Replace)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,24 +22,24 @@ static constexpr uint32_t kMaxVertexInputs = 16u;
|
||||
|
||||
class InputStateTest : public ValidationTest {
|
||||
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();
|
||||
|
||||
nxt::ShaderModuleBuilder vsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
|
||||
utils::FillShaderModuleBuilder(vsModuleBuilder, nxt::ShaderStage::Vertex, vertexSource.c_str());
|
||||
nxt::ShaderModule vsModule = vsModuleBuilder.GetResult();
|
||||
dawn::ShaderModuleBuilder vsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
|
||||
utils::FillShaderModuleBuilder(vsModuleBuilder, dawn::ShaderStage::Vertex, vertexSource.c_str());
|
||||
dawn::ShaderModule vsModule = vsModuleBuilder.GetResult();
|
||||
|
||||
nxt::ShaderModuleBuilder fsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
|
||||
utils::FillShaderModuleBuilder(fsModuleBuilder, nxt::ShaderStage::Fragment, R"(
|
||||
dawn::ShaderModuleBuilder fsModuleBuilder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
|
||||
utils::FillShaderModuleBuilder(fsModuleBuilder, dawn::ShaderStage::Fragment, R"(
|
||||
#version 450
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
void main() {
|
||||
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) {
|
||||
builder = AssertWillBeSuccess(device.CreateRenderPipelineBuilder());
|
||||
} else {
|
||||
@@ -47,8 +47,8 @@ class InputStateTest : public ValidationTest {
|
||||
}
|
||||
|
||||
return builder.SetColorAttachmentFormat(0, renderpassData.attachmentFormat)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetInputState(inputState)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class InputStateTest : public ValidationTest {
|
||||
|
||||
// Check an empty input state is valid
|
||||
TEST_F(InputStateTest, EmptyIsOk) {
|
||||
nxt::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
dawn::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.GetResult();
|
||||
|
||||
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
|
||||
TEST_F(InputStateTest, PipelineCompatibility) {
|
||||
nxt::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 2 * sizeof(float), nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetAttribute(1, 0, nxt::VertexFormat::FloatR32, sizeof(float))
|
||||
dawn::InputState state = AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 2 * sizeof(float), dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.SetAttribute(1, 0, dawn::VertexFormat::FloatR32, sizeof(float))
|
||||
.GetResult();
|
||||
|
||||
// Control case: pipeline with one input per attribute
|
||||
@@ -108,13 +108,13 @@ TEST_F(InputStateTest, PipelineCompatibility) {
|
||||
TEST_F(InputStateTest, StrideZero) {
|
||||
// Works ok without attributes
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.GetResult();
|
||||
|
||||
// Works ok with attributes at a large-ish offset
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 128)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 128)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -122,13 +122,13 @@ TEST_F(InputStateTest, StrideZero) {
|
||||
TEST_F(InputStateTest, AlreadySetInput) {
|
||||
// Control case
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.GetResult();
|
||||
|
||||
// Oh no, input 0 is set twice
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -136,12 +136,12 @@ TEST_F(InputStateTest, AlreadySetInput) {
|
||||
TEST_F(InputStateTest, SetInputOutOfBounds) {
|
||||
// Control case, setting last input
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(kMaxVertexInputs - 1, 0, nxt::InputStepMode::Vertex)
|
||||
.SetInput(kMaxVertexInputs - 1, 0, dawn::InputStepMode::Vertex)
|
||||
.GetResult();
|
||||
|
||||
// Test OOB
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(kMaxVertexInputs, 0, nxt::InputStepMode::Vertex)
|
||||
.SetInput(kMaxVertexInputs, 0, dawn::InputStepMode::Vertex)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -149,15 +149,15 @@ TEST_F(InputStateTest, SetInputOutOfBounds) {
|
||||
TEST_F(InputStateTest, AlreadySetAttribute) {
|
||||
// Control case, setting last attribute
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
|
||||
// Oh no, attribute 0 is set twice
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -165,14 +165,14 @@ TEST_F(InputStateTest, AlreadySetAttribute) {
|
||||
TEST_F(InputStateTest, SetAttributeOutOfBounds) {
|
||||
// Control case, setting last attribute
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(kMaxVertexAttributes - 1, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(kMaxVertexAttributes - 1, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
|
||||
// Test OOB
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(kMaxVertexAttributes, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(kMaxVertexAttributes, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -180,14 +180,14 @@ TEST_F(InputStateTest, SetAttributeOutOfBounds) {
|
||||
TEST_F(InputStateTest, RequireInputForAttribute) {
|
||||
// Control case
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
|
||||
// Attribute 0 uses input 1 which doesn't exist
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 1, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 1, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -195,13 +195,13 @@ TEST_F(InputStateTest, RequireInputForAttribute) {
|
||||
TEST_F(InputStateTest, SetAttributeOOBCheckForInputs) {
|
||||
// Control case
|
||||
AssertWillBeSuccess(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 0, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
|
||||
// Could crash if we didn't check for OOB
|
||||
AssertWillBeError(device.CreateInputStateBuilder())
|
||||
.SetInput(0, 0, nxt::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 1000000, nxt::VertexFormat::FloatR32, 0)
|
||||
.SetInput(0, 0, dawn::InputStepMode::Vertex)
|
||||
.SetAttribute(0, 1000000, dawn::VertexFormat::FloatR32, 0)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ using namespace testing;
|
||||
|
||||
class PushConstantTest : public ValidationTest {
|
||||
protected:
|
||||
nxt::Queue queue;
|
||||
dawn::Queue queue;
|
||||
uint32_t constants[kMaxPushConstants] = {0};
|
||||
|
||||
void TestCreateShaderModule(bool success, std::string vertexSource) {
|
||||
nxt::ShaderModuleBuilder builder;
|
||||
dawn::ShaderModuleBuilder builder;
|
||||
if (success) {
|
||||
builder = AssertWillBeSuccess(device.CreateShaderModuleBuilder());
|
||||
} else {
|
||||
builder = AssertWillBeError(device.CreateShaderModuleBuilder());
|
||||
}
|
||||
utils::FillShaderModuleBuilder(builder, nxt::ShaderStage::Vertex, vertexSource.c_str());
|
||||
utils::FillShaderModuleBuilder(builder, dawn::ShaderStage::Vertex, vertexSource.c_str());
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
@@ -51,22 +51,22 @@ TEST_F(PushConstantTest, Success) {
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
// PushConstants in a compute pass
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
|
||||
// PushConstants in a render pass
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
|
||||
// Setting all constants
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
|
||||
.EndComputePass()
|
||||
|
||||
// Setting constants at an offset
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, kMaxPushConstants - 1, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, kMaxPushConstants - 1, 1, constants)
|
||||
.EndComputePass()
|
||||
|
||||
.GetResult();
|
||||
@@ -80,7 +80,7 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -89,7 +89,7 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, kMaxPushConstants + 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants + 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -98,7 +98,7 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 1, kMaxPushConstants, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 1, kMaxPushConstants, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -111,11 +111,11 @@ TEST_F(PushConstantTest, NotInPass) {
|
||||
// Setting outside of any pass is invalid.
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.SetPushConstants(nxt::ShaderStageBit::Vertex, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ TEST_F(PushConstantTest, StageForComputePass) {
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -135,7 +135,7 @@ TEST_F(PushConstantTest, StageForComputePass) {
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::Vertex, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -144,7 +144,7 @@ TEST_F(PushConstantTest, StageForComputePass) {
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(nxt::ShaderStageBit::None, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -158,7 +158,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -167,7 +167,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(nxt::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
}
|
||||
@@ -176,7 +176,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(nxt::ShaderStageBit::None, 0, 1, constants)
|
||||
.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ namespace {
|
||||
class RenderPassDescriptorValidationTest : public ValidationTest {
|
||||
};
|
||||
|
||||
nxt::TextureView Create2DAttachment(nxt::Device& device, uint32_t width, uint32_t height, nxt::TextureFormat format) {
|
||||
nxt::Texture attachment = device.CreateTextureBuilder()
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
dawn::TextureView Create2DAttachment(dawn::Device& device, uint32_t width, uint32_t height, dawn::TextureFormat format) {
|
||||
dawn::Texture attachment = device.CreateTextureBuilder()
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
.SetExtent(width, height, 1)
|
||||
.SetFormat(format)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
|
||||
return attachment.CreateTextureViewBuilder()
|
||||
@@ -44,16 +44,16 @@ TEST_F(RenderPassDescriptorValidationTest, Empty) {
|
||||
TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
||||
// 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())
|
||||
.SetColorAttachment(0, color, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, color, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
// 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())
|
||||
.SetDepthStencilAttachment(depthStencil, nxt::LoadOp::Clear, nxt::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -62,31 +62,31 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
||||
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
|
||||
// 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())
|
||||
.SetColorAttachment(kMaxColorAttachments - 1, color, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(kMaxColorAttachments - 1, color, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
// 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())
|
||||
.SetColorAttachment(kMaxColorAttachments, color, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(kMaxColorAttachments, color, dawn::LoadOp::Clear)
|
||||
.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
|
||||
{
|
||||
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)
|
||||
.GetResult();
|
||||
}
|
||||
// For setting the clear color, OOB
|
||||
{
|
||||
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)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -94,26 +94,26 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
|
||||
|
||||
// Test setting a clear value without an attachment and vice-versa is ok.
|
||||
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
|
||||
{
|
||||
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)
|
||||
.GetResult();
|
||||
}
|
||||
// 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())
|
||||
.SetDepthStencilAttachment(depthStencil, nxt::LoadOp::Clear, nxt::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
// Clear values for depth-stencil when it isn't used
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachment(0, color, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, color, dawn::LoadOp::Clear)
|
||||
.SetDepthStencilAttachmentClearValue(0.0f, 0)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -121,56 +121,56 @@ TEST_F(RenderPassDescriptorValidationTest, ClearAndAttachmentMismatchIsOk) {
|
||||
|
||||
// Attachments must have the same size
|
||||
TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
|
||||
nxt::TextureView color1x1A = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm);
|
||||
nxt::TextureView color1x1B = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm);
|
||||
nxt::TextureView color2x2 = Create2DAttachment(device, 2, 2, nxt::TextureFormat::R8G8B8A8Unorm);
|
||||
nxt::TextureView depthStencil1x1 = Create2DAttachment(device, 1, 1, nxt::TextureFormat::D32FloatS8Uint);
|
||||
nxt::TextureView depthStencil2x2 = Create2DAttachment(device, 2, 2, nxt::TextureFormat::D32FloatS8Uint);
|
||||
dawn::TextureView color1x1A = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView color1x1B = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView color2x2 = Create2DAttachment(device, 2, 2, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView depthStencil1x1 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
|
||||
dawn::TextureView depthStencil2x2 = Create2DAttachment(device, 2, 2, dawn::TextureFormat::D32FloatS8Uint);
|
||||
|
||||
// Control case: all the same size (1x1)
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachment(0, color1x1A, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(1, color1x1B, nxt::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil1x1, nxt::LoadOp::Clear, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
|
||||
.SetColorAttachment(1, color1x1B, dawn::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil1x1, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// One of the color attachments has a different size
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachment(0, color1x1A, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(1, color2x2, nxt::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil1x1, nxt::LoadOp::Clear, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
|
||||
.SetColorAttachment(1, color2x2, dawn::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil1x1, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// The depth stencil attachment has a different size
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachment(0, color1x1A, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(1, color1x1B, nxt::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil2x2, nxt::LoadOp::Clear, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
|
||||
.SetColorAttachment(1, color1x1B, dawn::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencil2x2, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
// Attachments formats must match whether they are used for color or depth-stencil
|
||||
TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
||||
nxt::TextureView color = Create2DAttachment(device, 1, 1, nxt::TextureFormat::R8G8B8A8Unorm);
|
||||
nxt::TextureView depthStencil = Create2DAttachment(device, 1, 1, nxt::TextureFormat::D32FloatS8Uint);
|
||||
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView depthStencil = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
|
||||
|
||||
// Using depth-stencil for color
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachment(0, depthStencil, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, depthStencil, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Using color for depth-stencil
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(color, nxt::LoadOp::Clear, nxt::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(color, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,20 +24,20 @@ class RenderPipelineValidationTest : public ValidationTest {
|
||||
|
||||
renderpass = CreateSimpleRenderPass();
|
||||
|
||||
nxt::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr);
|
||||
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr);
|
||||
|
||||
inputState = device.CreateInputStateBuilder().GetResult();
|
||||
|
||||
blendState = device.CreateBlendStateBuilder().GetResult();
|
||||
|
||||
vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"(
|
||||
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
|
||||
#version 450
|
||||
void main() {
|
||||
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
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
void main() {
|
||||
@@ -45,21 +45,21 @@ class RenderPipelineValidationTest : public ValidationTest {
|
||||
})");
|
||||
}
|
||||
|
||||
nxt::RenderPipelineBuilder& AddDefaultStates(nxt::RenderPipelineBuilder&& builder) {
|
||||
builder.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
dawn::RenderPipelineBuilder& AddDefaultStates(dawn::RenderPipelineBuilder&& builder) {
|
||||
builder.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList);
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList);
|
||||
return builder;
|
||||
}
|
||||
|
||||
nxt::RenderPassDescriptor renderpass;
|
||||
nxt::ShaderModule vsModule;
|
||||
nxt::ShaderModule fsModule;
|
||||
nxt::InputState inputState;
|
||||
nxt::BlendState blendState;
|
||||
nxt::PipelineLayout pipelineLayout;
|
||||
dawn::RenderPassDescriptor renderpass;
|
||||
dawn::ShaderModule vsModule;
|
||||
dawn::ShaderModule fsModule;
|
||||
dawn::InputState inputState;
|
||||
dawn::BlendState blendState;
|
||||
dawn::PipelineLayout pipelineLayout;
|
||||
};
|
||||
|
||||
// Test cases where creation should succeed
|
||||
@@ -81,20 +81,20 @@ TEST_F(RenderPipelineValidationTest, CreationMissingProperty) {
|
||||
// Vertex stage not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Fragment stage not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -102,9 +102,9 @@ TEST_F(RenderPipelineValidationTest, CreationMissingProperty) {
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -114,21 +114,21 @@ TEST_F(RenderPipelineValidationTest, BlendState) {
|
||||
{
|
||||
// This one succeeds because attachment 0 is the color attachment
|
||||
AssertWillBeSuccess(device.CreateRenderPipelineBuilder())
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
|
||||
.SetColorAttachmentBlendState(0, blendState)
|
||||
.GetResult();
|
||||
|
||||
// This fails because attachment 1 is not one of the color attachments
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
|
||||
.SetColorAttachmentBlendState(1, blendState)
|
||||
.GetResult();
|
||||
}
|
||||
@@ -154,20 +154,20 @@ TEST_F(RenderPipelineValidationTest, DISABLED_TodoCreationMissingProperty) {
|
||||
// Fails because pipeline layout is not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Fails because primitive topology is not set
|
||||
{
|
||||
AssertWillBeError(device.CreateRenderPipelineBuilder())
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetLayout(pipelineLayout)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
@@ -184,21 +184,21 @@ TEST_F(RenderPipelineValidationTest, DISABLED_CreationDuplicates) {
|
||||
// Fails because primitive topology is set twice
|
||||
{
|
||||
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
|
||||
.SetPrimitiveTopology(nxt::PrimitiveTopology::TriangleList)
|
||||
.SetPrimitiveTopology(dawn::PrimitiveTopology::TriangleList)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Fails because vertex stage is set twice
|
||||
{
|
||||
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
// Fails because fragment stage is set twice
|
||||
{
|
||||
AddDefaultStates(AssertWillBeError(device.CreateRenderPipelineBuilder()))
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ ValidationTest::ValidationTest() {
|
||||
backend::null::Init(&procs, &cDevice);
|
||||
|
||||
nxtSetProcs(&procs);
|
||||
device = nxt::Device::Acquire(cDevice);
|
||||
device = dawn::Device::Acquire(cDevice);
|
||||
|
||||
device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast<nxtCallbackUserdata>(reinterpret_cast<uintptr_t>(this)));
|
||||
}
|
||||
@@ -36,7 +36,7 @@ ValidationTest::ValidationTest() {
|
||||
ValidationTest::~ValidationTest() {
|
||||
// We need to destroy NXT objects before setting the procs to null otherwise the nxt*Release
|
||||
// will call a nullptr
|
||||
device = nxt::Device();
|
||||
device = dawn::Device();
|
||||
nxtSetProcs(nullptr);
|
||||
}
|
||||
|
||||
@@ -69,19 +69,19 @@ bool ValidationTest::EndExpectDeviceError() {
|
||||
return mError;
|
||||
}
|
||||
|
||||
nxt::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
|
||||
dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
|
||||
auto colorBuffer = device.CreateTextureBuilder()
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
.SetExtent(640, 480, 1)
|
||||
.SetFormat(nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetFormat(dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
auto colorView = colorBuffer.CreateTextureViewBuilder()
|
||||
.GetResult();
|
||||
|
||||
return device.CreateRenderPassDescriptorBuilder()
|
||||
.SetColorAttachment(0, colorView, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void ValidationTest::OnDeviceError(const char* message, nxtCallbackUserdata user
|
||||
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));
|
||||
size_t index = static_cast<size_t>(userdata2);
|
||||
|
||||
@@ -116,20 +116,20 @@ ValidationTest::DummyRenderPass ValidationTest::CreateDummyRenderPass() {
|
||||
DummyRenderPass dummy;
|
||||
dummy.width = 400;
|
||||
dummy.height = 400;
|
||||
dummy.attachmentFormat = nxt::TextureFormat::R8G8B8A8Unorm;
|
||||
dummy.attachmentFormat = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
|
||||
dummy.attachment = AssertWillBeSuccess(device.CreateTextureBuilder())
|
||||
.SetDimension(nxt::TextureDimension::e2D)
|
||||
.SetDimension(dawn::TextureDimension::e2D)
|
||||
.SetExtent(dummy.width, dummy.height, 1)
|
||||
.SetFormat(dummy.attachmentFormat)
|
||||
.SetMipLevels(1)
|
||||
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment)
|
||||
.SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment)
|
||||
.GetResult();
|
||||
|
||||
nxt::TextureView view = AssertWillBeSuccess(dummy.attachment.CreateTextureViewBuilder()).GetResult();
|
||||
dawn::TextureView view = AssertWillBeSuccess(dummy.attachment.CreateTextureViewBuilder()).GetResult();
|
||||
|
||||
dummy.renderPass = AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachment(0, view, nxt::LoadOp::Clear)
|
||||
.SetColorAttachment(0, view, dawn::LoadOp::Clear)
|
||||
.GetResult();
|
||||
|
||||
return dummy;
|
||||
|
||||
@@ -34,7 +34,7 @@ class ValidationTest : public testing::Test {
|
||||
// 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:
|
||||
//
|
||||
// nxt::Foo foo = AssertWillBe[Success|Error](device.CreateFooBuilder(), "my foo")
|
||||
// dawn::Foo foo = AssertWillBe[Success|Error](device.CreateFooBuilder(), "my foo")
|
||||
// .SetBar(1)
|
||||
// .GetResult();
|
||||
//
|
||||
@@ -48,21 +48,21 @@ class ValidationTest : public testing::Test {
|
||||
void StartExpectDeviceError();
|
||||
bool EndExpectDeviceError();
|
||||
|
||||
nxt::RenderPassDescriptor CreateSimpleRenderPass();
|
||||
dawn::RenderPassDescriptor CreateSimpleRenderPass();
|
||||
|
||||
// Helper functions to create objects to test validation.
|
||||
|
||||
struct DummyRenderPass {
|
||||
nxt::RenderPassDescriptor renderPass;
|
||||
nxt::Texture attachment;
|
||||
nxt::TextureFormat attachmentFormat;
|
||||
dawn::RenderPassDescriptor renderPass;
|
||||
dawn::Texture attachment;
|
||||
dawn::TextureFormat attachmentFormat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
DummyRenderPass CreateDummyRenderPass();
|
||||
|
||||
protected:
|
||||
nxt::Device device;
|
||||
dawn::Device device;
|
||||
|
||||
private:
|
||||
static void OnDeviceError(const char* message, nxtCallbackUserdata userdata);
|
||||
@@ -82,7 +82,7 @@ class ValidationTest : public testing::Test {
|
||||
template<typename Builder>
|
||||
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
|
||||
|
||||
@@ -25,7 +25,7 @@ class VertexBufferValidationTest : public ValidationTest {
|
||||
|
||||
renderpass = CreateSimpleRenderPass();
|
||||
|
||||
fsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Fragment, R"(
|
||||
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
|
||||
#version 450
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
void main() {
|
||||
@@ -34,18 +34,18 @@ class VertexBufferValidationTest : public ValidationTest {
|
||||
}
|
||||
|
||||
template <unsigned int N>
|
||||
std::array<nxt::Buffer, N> MakeVertexBuffers() {
|
||||
std::array<nxt::Buffer, N> buffers;
|
||||
std::array<dawn::Buffer, N> MakeVertexBuffers() {
|
||||
std::array<dawn::Buffer, N> buffers;
|
||||
for (auto& buffer : buffers) {
|
||||
buffer = device.CreateBufferBuilder()
|
||||
.SetSize(256)
|
||||
.SetAllowedUsage(nxt::BufferUsageBit::Vertex)
|
||||
.SetAllowedUsage(dawn::BufferUsageBit::Vertex)
|
||||
.GetResult();
|
||||
}
|
||||
return buffers;
|
||||
}
|
||||
|
||||
nxt::ShaderModule MakeVertexShader(unsigned int numInputs) {
|
||||
dawn::ShaderModule MakeVertexShader(unsigned int numInputs) {
|
||||
std::ostringstream vs;
|
||||
vs << "#version 450\n";
|
||||
for (unsigned int i = 0; i < numInputs; ++i) {
|
||||
@@ -64,29 +64,29 @@ class VertexBufferValidationTest : public ValidationTest {
|
||||
|
||||
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();
|
||||
for (unsigned int i = 0; i < numInputs; ++i) {
|
||||
builder.SetAttribute(i, i, nxt::VertexFormat::FloatR32G32B32, 0);
|
||||
builder.SetInput(i, 0, nxt::InputStepMode::Vertex);
|
||||
builder.SetAttribute(i, i, dawn::VertexFormat::FloatR32G32B32, 0);
|
||||
builder.SetInput(i, 0, dawn::InputStepMode::Vertex);
|
||||
}
|
||||
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()
|
||||
.SetColorAttachmentFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetColorAttachmentFormat(0, dawn::TextureFormat::R8G8B8A8Unorm)
|
||||
.SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetInputState(inputState)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
nxt::RenderPassDescriptor renderpass;
|
||||
nxt::ShaderModule fsModule;
|
||||
dawn::RenderPassDescriptor renderpass;
|
||||
dawn::ShaderModule fsModule;
|
||||
};
|
||||
|
||||
TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
||||
|
||||
Reference in New Issue
Block a user