mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-25 07:53:32 +00:00
Adding a validation for destroyed textures in Queue::WriteTexture
That was missing. There's a new validation test for that and two tests for submitting copy commands with destroyed buffer/texture (I think only a mapped buffer was covered so far). Also fixing some error state tests. Bug: dawn:483 Change-Id: I691f34722e96866a06465b4b3b0cae9d31c08a84 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26161 Commit-Queue: Tomek Ponitka <tommek@google.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
eac38cfbc1
commit
1ea3a22f52
@ -251,7 +251,9 @@ namespace dawn_native {
|
|||||||
return DAWN_VALIDATION_ERROR("Buffer needs the CopyDst usage bit");
|
return DAWN_VALIDATION_ERROR("Buffer needs the CopyDst usage bit");
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer->ValidateCanUseOnQueueNow();
|
DAWN_TRY(buffer->ValidateCanUseOnQueueNow());
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError QueueBase::ValidateWriteTexture(const TextureCopyView* destination,
|
MaybeError QueueBase::ValidateWriteTexture(const TextureCopyView* destination,
|
||||||
@ -286,6 +288,8 @@ namespace dawn_native {
|
|||||||
*dataLayout, dataSize,
|
*dataLayout, dataSize,
|
||||||
destination->texture->GetFormat().GetTexelBlockInfo(destination->aspect), *writeSize));
|
destination->texture->GetFormat().GetTexelBlockInfo(destination->aspect), *writeSize));
|
||||||
|
|
||||||
|
DAWN_TRY(destination->texture->ValidateCanUseInSubmitNow());
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,11 +282,13 @@ TEST_F(CopyCommandTest_B2B, UnalignedOffset) {
|
|||||||
TEST_F(CopyCommandTest_B2B, BuffersInErrorState) {
|
TEST_F(CopyCommandTest_B2B, BuffersInErrorState) {
|
||||||
wgpu::BufferDescriptor errorBufferDescriptor;
|
wgpu::BufferDescriptor errorBufferDescriptor;
|
||||||
errorBufferDescriptor.size = 4;
|
errorBufferDescriptor.size = 4;
|
||||||
errorBufferDescriptor.usage = wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopySrc;
|
errorBufferDescriptor.usage =
|
||||||
|
wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||||
ASSERT_DEVICE_ERROR(wgpu::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
ASSERT_DEVICE_ERROR(wgpu::Buffer errorBuffer = device.CreateBuffer(&errorBufferDescriptor));
|
||||||
|
|
||||||
constexpr uint64_t bufferSize = 4;
|
constexpr uint64_t bufferSize = 4;
|
||||||
wgpu::Buffer validBuffer = CreateBuffer(bufferSize, wgpu::BufferUsage::CopySrc);
|
wgpu::Buffer validBuffer =
|
||||||
|
CreateBuffer(bufferSize, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst);
|
||||||
|
|
||||||
{
|
{
|
||||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
@ -588,7 +590,7 @@ TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) {
|
|||||||
wgpu::TextureCopyView errorTextureCopyView =
|
wgpu::TextureCopyView errorTextureCopyView =
|
||||||
utils::CreateTextureCopyView(errorTexture, 0, {0, 0, 0});
|
utils::CreateTextureCopyView(errorTexture, 0, {0, 0, 0});
|
||||||
|
|
||||||
wgpu::Extent3D extent3D = {1, 1, 1};
|
wgpu::Extent3D extent3D = {0, 0, 0};
|
||||||
|
|
||||||
{
|
{
|
||||||
wgpu::Texture destination = Create2DTexture(16, 16, 1, 1, wgpu::TextureFormat::RGBA8Unorm,
|
wgpu::Texture destination = Create2DTexture(16, 16, 1, 1, wgpu::TextureFormat::RGBA8Unorm,
|
||||||
@ -990,7 +992,7 @@ TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) {
|
|||||||
wgpu::TextureCopyView errorTextureCopyView =
|
wgpu::TextureCopyView errorTextureCopyView =
|
||||||
utils::CreateTextureCopyView(errorTexture, 0, {0, 0, 0});
|
utils::CreateTextureCopyView(errorTexture, 0, {0, 0, 0});
|
||||||
|
|
||||||
wgpu::Extent3D extent3D = {1, 1, 1};
|
wgpu::Extent3D extent3D = {0, 0, 0};
|
||||||
|
|
||||||
{
|
{
|
||||||
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
uint64_t bufferSize = BufferSizeForTextureCopy(4, 4, 1);
|
||||||
|
@ -280,6 +280,18 @@ namespace {
|
|||||||
TestWriteTexture(dataSize, 0, 256, 0, destination, 0, {0, 0, 0}, {2, 2, 1}));
|
TestWriteTexture(dataSize, 0, 256, 0, destination, 0, {0, 0, 0}, {2, 2, 1}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that WriteTexture cannot be run with a destroyed texture.
|
||||||
|
TEST_F(QueueWriteTextureValidationTest, DestroyedTexture) {
|
||||||
|
const uint64_t dataSize =
|
||||||
|
utils::RequiredBytesInCopy(256, 4, {4, 4, 1}, wgpu::TextureFormat::RGBA8Unorm);
|
||||||
|
wgpu::Texture destination = Create2DTexture({16, 16, 4}, 5, wgpu::TextureFormat::RGBA8Unorm,
|
||||||
|
wgpu::TextureUsage::CopyDst);
|
||||||
|
destination.Destroy();
|
||||||
|
|
||||||
|
ASSERT_DEVICE_ERROR(
|
||||||
|
TestWriteTexture(dataSize, 0, 256, 4, destination, 0, {0, 0, 0}, {4, 4, 1}));
|
||||||
|
}
|
||||||
|
|
||||||
// Test WriteTexture with texture in error state causes errors.
|
// Test WriteTexture with texture in error state causes errors.
|
||||||
TEST_F(QueueWriteTextureValidationTest, TextureInErrorState) {
|
TEST_F(QueueWriteTextureValidationTest, TextureInErrorState) {
|
||||||
wgpu::TextureDescriptor errorTextureDescriptor;
|
wgpu::TextureDescriptor errorTextureDescriptor;
|
||||||
@ -289,14 +301,11 @@ namespace {
|
|||||||
wgpu::TextureCopyView errorTextureCopyView =
|
wgpu::TextureCopyView errorTextureCopyView =
|
||||||
utils::CreateTextureCopyView(errorTexture, 0, {0, 0, 0});
|
utils::CreateTextureCopyView(errorTexture, 0, {0, 0, 0});
|
||||||
|
|
||||||
wgpu::Extent3D extent3D = {1, 1, 1};
|
wgpu::Extent3D extent3D = {0, 0, 0};
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> data(4);
|
std::vector<uint8_t> data(4);
|
||||||
wgpu::TextureDataLayout textureDataLayout;
|
wgpu::TextureDataLayout textureDataLayout = utils::CreateTextureDataLayout(0, 0, 0);
|
||||||
textureDataLayout.offset = 0;
|
|
||||||
textureDataLayout.bytesPerRow = 0;
|
|
||||||
textureDataLayout.rowsPerImage = 0;
|
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(queue.WriteTexture(&errorTextureCopyView, data.data(), 4,
|
ASSERT_DEVICE_ERROR(queue.WriteTexture(&errorTextureCopyView, data.data(), 4,
|
||||||
&textureDataLayout, &extent3D));
|
&textureDataLayout, &extent3D));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user