Return false from IsTextureSubresourceInitialized for error textures
Otherwise, callers of this method will hit an ASSERT for error textures. Bug: chromium:1359106 Change-Id: I2602d209d837b3b27916221578f9ac4041f8848b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/103281 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
417acaf650
commit
45a2c5193a
|
@ -267,6 +267,9 @@ bool IsTextureSubresourceInitialized(WGPUTexture texture,
|
|||
uint32_t layerCount,
|
||||
WGPUTextureAspect cAspect) {
|
||||
TextureBase* textureBase = FromAPI(texture);
|
||||
if (textureBase->IsError()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Aspect aspect =
|
||||
ConvertAspect(textureBase->GetFormat(), static_cast<wgpu::TextureAspect>(cAspect));
|
||||
|
|
|
@ -1703,6 +1703,24 @@ TEST_P(TextureZeroInitTest, WriteTextureHalfAtMipLevel) {
|
|||
kMipLevel);
|
||||
}
|
||||
|
||||
// Test that error textures are always considered uninitialized.
|
||||
TEST_P(TextureZeroInitTest, ErrorTextureIsUninitialized) {
|
||||
wgpu::TextureDescriptor descriptor =
|
||||
CreateTextureDescriptor(1, 1, wgpu::TextureUsage::CopyDst, kColorFormat);
|
||||
|
||||
// Test CreateErrorTexture.
|
||||
wgpu::Texture texture = device.CreateErrorTexture(&descriptor);
|
||||
EXPECT_FALSE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1));
|
||||
|
||||
// Test CreateTexture with an error descriptor.
|
||||
if (!HasToggleEnabled("skip_validation")) {
|
||||
descriptor = CreateTextureDescriptor(1, 1, wgpu::TextureUsage::CopyDst,
|
||||
static_cast<wgpu::TextureFormat>(-4));
|
||||
ASSERT_DEVICE_ERROR(texture = device.CreateTexture(&descriptor));
|
||||
EXPECT_FALSE(dawn::native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
|
||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"},
|
||||
|
|
Loading…
Reference in New Issue