mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-15 03:41:34 +00:00
Fix a bug about depth/stencil formats validation
Depth/stencil formats are invalid for 1D and 3D texture. This change adds this validation rule, and adds a validation test for it. Bug: dawn:730 Change-Id: Idac6d1bf7b8c7261eb7b4b59504de10e13d049cc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47200 Commit-Queue: Yunchao He <yunchao.he@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
e190045664
commit
71f3d58939
@ -304,6 +304,7 @@ namespace dawn_native {
|
|||||||
// because its size isn't well defined, is it 4, 5 or 8?
|
// because its size isn't well defined, is it 4, 5 or 8?
|
||||||
AddMultiAspectFormat(wgpu::TextureFormat::Depth24PlusStencil8,
|
AddMultiAspectFormat(wgpu::TextureFormat::Depth24PlusStencil8,
|
||||||
Aspect::Depth | Aspect::Stencil, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Stencil8, true, true);
|
Aspect::Depth | Aspect::Stencil, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Stencil8, true, true);
|
||||||
|
// TODO(dawn:690): Implement Depth16Unorm, Depth24UnormStencil8, Depth32FloatStencil8.
|
||||||
|
|
||||||
// BC compressed formats
|
// BC compressed formats
|
||||||
bool isBCFormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionBC);
|
bool isBCFormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionBC);
|
||||||
|
@ -301,6 +301,13 @@ namespace dawn_native {
|
|||||||
return DAWN_VALIDATION_ERROR("Compressed texture must be 2D");
|
return DAWN_VALIDATION_ERROR("Compressed texture must be 2D");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Depth/stencil formats are valid for 2D textures only. Metal has this limit. And D3D12
|
||||||
|
// doesn't support depth/stencil formats on 3D textures.
|
||||||
|
if (descriptor->dimension != wgpu::TextureDimension::e2D &&
|
||||||
|
(format->aspects & (Aspect::Depth | Aspect::Stencil)) != 0) {
|
||||||
|
return DAWN_VALIDATION_ERROR("Depth/stencil formats are valid for 2D textures only");
|
||||||
|
}
|
||||||
|
|
||||||
DAWN_TRY(ValidateTextureSize(descriptor, format));
|
DAWN_TRY(ValidateTextureSize(descriptor, format));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -401,6 +401,33 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that depth/stencil formats are invalid for 3D texture
|
||||||
|
TEST_F(TextureValidationTest, DepthStencilFormatsFor3D) {
|
||||||
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
||||||
|
wgpu::TextureDimension dimensions[] = {
|
||||||
|
wgpu::TextureDimension::e1D,
|
||||||
|
wgpu::TextureDimension::e3D,
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO(dawn:690): Uncomment these depth/stencil formats after we implement them in Dawn.
|
||||||
|
wgpu::TextureFormat depthStencilFormats[] = {
|
||||||
|
wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth24Plus,
|
||||||
|
wgpu::TextureFormat::Stencil8, wgpu::TextureFormat::Depth24PlusStencil8,
|
||||||
|
// wgpu::TextureFormat::Depth16Unorm,
|
||||||
|
// wgpu::TextureFormat::Depth24UnormStencil8,
|
||||||
|
// wgpu::TextureFormat::Depth32FloatStencil8,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (wgpu::TextureDimension dimension : dimensions) {
|
||||||
|
for (wgpu::TextureFormat format : depthStencilFormats) {
|
||||||
|
descriptor.format = format;
|
||||||
|
descriptor.dimension = dimension;
|
||||||
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test that it is valid to destroy a texture
|
// Test that it is valid to destroy a texture
|
||||||
TEST_F(TextureValidationTest, DestroyTexture) {
|
TEST_F(TextureValidationTest, DestroyTexture) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user