mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-12 16:15:55 +00:00
Add unsafe API tests for 3D textures
This change also marks 3D view creation as Unsafe API. BUG: dawn:547 Change-Id: Icdb7b48f19054d70258363f6d58ded957be72b70 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/46723 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
parent
9002c67ab4
commit
1e45c5e764
@ -1303,7 +1303,7 @@ namespace dawn_native {
|
||||
DAWN_TRY(ValidateObject(texture));
|
||||
TextureViewDescriptor desc = GetTextureViewDescriptorWithDefaults(texture, descriptor);
|
||||
if (IsValidationEnabled()) {
|
||||
DAWN_TRY(ValidateTextureViewDescriptor(texture, &desc));
|
||||
DAWN_TRY(ValidateTextureViewDescriptor(this, texture, &desc));
|
||||
}
|
||||
return CreateTextureViewImpl(texture, &desc);
|
||||
}
|
||||
|
@ -306,7 +306,8 @@ namespace dawn_native {
|
||||
return {};
|
||||
}
|
||||
|
||||
MaybeError ValidateTextureViewDescriptor(const TextureBase* texture,
|
||||
MaybeError ValidateTextureViewDescriptor(const DeviceBase* device,
|
||||
const TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor) {
|
||||
if (descriptor->nextInChain != nullptr) {
|
||||
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
||||
@ -324,6 +325,13 @@ namespace dawn_native {
|
||||
return DAWN_VALIDATION_ERROR("1D texture views aren't supported (yet).");
|
||||
}
|
||||
|
||||
// Disallow 3D views as unsafe until they are fully implemented.
|
||||
if (descriptor->dimension == wgpu::TextureViewDimension::e3D &&
|
||||
device->IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"3D views are disallowed because they are not fully implemented");
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateTextureFormat(descriptor->format));
|
||||
|
||||
DAWN_TRY(ValidateTextureAspect(descriptor->aspect));
|
||||
|
@ -30,7 +30,8 @@ namespace dawn_native {
|
||||
|
||||
MaybeError ValidateTextureDescriptor(const DeviceBase* device,
|
||||
const TextureDescriptor* descriptor);
|
||||
MaybeError ValidateTextureViewDescriptor(const TextureBase* texture,
|
||||
MaybeError ValidateTextureViewDescriptor(const DeviceBase* device,
|
||||
const TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor);
|
||||
TextureViewDescriptor GetTextureViewDescriptorWithDefaults(
|
||||
const TextureBase* texture,
|
||||
|
@ -28,6 +28,22 @@ class UnsafeAPIValidationTest : public ValidationTest {
|
||||
}
|
||||
};
|
||||
|
||||
// Check that 3D Texture creation is disallowed as part of unsafe APIs.
|
||||
TEST_F(UnsafeAPIValidationTest, 3DTextureCreationDisallowed) {
|
||||
wgpu::TextureDescriptor baseDesc;
|
||||
baseDesc.size = {32, 32, 6};
|
||||
baseDesc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
baseDesc.usage = wgpu::TextureUsage::Sampled;
|
||||
|
||||
// Control case: 2D (array) texture creation is allowed.
|
||||
device.CreateTexture(&baseDesc);
|
||||
|
||||
// 3D texture creation is disallowed.
|
||||
wgpu::TextureDescriptor texture3DDesc = baseDesc;
|
||||
texture3DDesc.dimension = wgpu::TextureDimension::e3D;
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&texture3DDesc));
|
||||
}
|
||||
|
||||
// Check that DrawIndexedIndirect is disallowed as part of unsafe APIs.
|
||||
TEST_F(UnsafeAPIValidationTest, DrawIndexedIndirectDisallowed) {
|
||||
// Create the index and indirect buffers.
|
||||
|
Loading…
x
Reference in New Issue
Block a user