Only allow creating 2D textures with RenderAttachment usage
BUG=dawn:1364 TEST=dawn_unittests Change-Id: I49cdeeac8b951c3715211fc3b3b71934a19a6e64 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86622 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
parent
ec571b5774
commit
93a2bed032
|
@ -309,6 +309,13 @@ namespace dawn::native {
|
|||
"format (%s).",
|
||||
usage, wgpu::TextureUsage::RenderAttachment, format->format);
|
||||
|
||||
DAWN_INVALID_IF(
|
||||
descriptor->dimension != wgpu::TextureDimension::e2D &&
|
||||
(usage & wgpu::TextureUsage::RenderAttachment),
|
||||
"The texture usage (%s) includes %s, which is incompatible with the texture "
|
||||
"dimension (%s).",
|
||||
usage, wgpu::TextureUsage::RenderAttachment, descriptor->dimension);
|
||||
|
||||
DAWN_INVALID_IF(
|
||||
!format->supportsStorageUsage && (usage & wgpu::TextureUsage::StorageBinding),
|
||||
"The texture usage (%s) includes %s, which is incompatible with the format (%s).",
|
||||
|
|
|
@ -301,7 +301,7 @@ DAWN_INSTANTIATE_TEST_P(
|
|||
{wgpu::TextureAspect::All},
|
||||
{wgpu::TextureUsage(wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc),
|
||||
wgpu::TextureUsage::CopySrc},
|
||||
{wgpu::TextureDimension::e2D, wgpu::TextureDimension::e3D},
|
||||
{wgpu::TextureDimension::e2D},
|
||||
{1u, 7u}, // depth or array layers
|
||||
{4u}, // mip count
|
||||
{0u, 1u, 2u, 3u}, // mip
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace {
|
|||
{
|
||||
wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor();
|
||||
textureDescriptor.dimension = wgpu::TextureDimension::e3D;
|
||||
textureDescriptor.usage = wgpu::TextureUsage::TextureBinding;
|
||||
wgpu::Texture internalTexture = device.CreateTexture(&textureDescriptor);
|
||||
|
||||
wgpu::ExternalTextureDescriptor externalDesc;
|
||||
|
|
|
@ -178,6 +178,7 @@ namespace {
|
|||
// Test the validation of the mip level count
|
||||
TEST_F(TextureValidationTest, MipLevelCount) {
|
||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||
defaultDescriptor.usage = wgpu::TextureUsage::TextureBinding;
|
||||
|
||||
// mipLevelCount == 1 is allowed
|
||||
{
|
||||
|
@ -456,12 +457,13 @@ namespace {
|
|||
// Test the validation of 3D texture size
|
||||
TEST_F(TextureValidationTest, 3DTextureSize) {
|
||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||
defaultDescriptor.dimension = wgpu::TextureDimension::e3D;
|
||||
defaultDescriptor.usage = wgpu::TextureUsage::TextureBinding;
|
||||
wgpu::Limits supportedLimits = GetSupportedLimits().limits;
|
||||
|
||||
// Out-of-bound texture dimension is not allowed
|
||||
{
|
||||
wgpu::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.dimension = wgpu::TextureDimension::e3D;
|
||||
|
||||
descriptor.size = {supportedLimits.maxTextureDimension3D + 1u, 1, 1};
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
|
@ -476,7 +478,6 @@ namespace {
|
|||
// Zero-sized texture is not allowed
|
||||
{
|
||||
wgpu::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.dimension = wgpu::TextureDimension::e3D;
|
||||
|
||||
descriptor.size = {0, 1, 1};
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
|
@ -491,7 +492,6 @@ namespace {
|
|||
// Texture size less than max dimension is allowed
|
||||
{
|
||||
wgpu::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.dimension = wgpu::TextureDimension::e3D;
|
||||
|
||||
descriptor.size = {supportedLimits.maxTextureDimension3D >> 1,
|
||||
supportedLimits.maxTextureDimension3D >> 1,
|
||||
|
@ -502,7 +502,6 @@ namespace {
|
|||
// Texture size equal to max dimension is allowed
|
||||
{
|
||||
wgpu::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.dimension = wgpu::TextureDimension::e3D;
|
||||
|
||||
descriptor.size = {supportedLimits.maxTextureDimension3D,
|
||||
supportedLimits.maxTextureDimension3D,
|
||||
|
@ -625,6 +624,27 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
// Test it is an error to create a RenderAttachment texture with the texture dimensions that
|
||||
// doesn't support TextureUsage::RenderAttachment texture usages.
|
||||
TEST_F(TextureValidationTest, TextureDimensionNotSupportRenderAttachment) {
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
descriptor.size = {1, 1, 1};
|
||||
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
descriptor.usage = wgpu::TextureUsage::RenderAttachment;
|
||||
|
||||
constexpr std::array<wgpu::TextureDimension, 3> kTextureDimensions = {
|
||||
{wgpu::TextureDimension::e1D, wgpu::TextureDimension::e2D,
|
||||
wgpu::TextureDimension::e3D}};
|
||||
for (wgpu::TextureDimension dimension : kTextureDimensions) {
|
||||
descriptor.dimension = dimension;
|
||||
if (dimension == wgpu::TextureDimension::e2D) {
|
||||
device.CreateTexture(&descriptor);
|
||||
} else {
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test it is an error to create a texture with format "Undefined".
|
||||
TEST_F(TextureValidationTest, TextureFormatUndefined) {
|
||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||
|
|
|
@ -463,12 +463,6 @@ crbug.com/tint/1500 [ nvidia release win ] webgpu:shader,execution,shader_io,com
|
|||
crbug.com/dawn/0000 [ mac ] webgpu:api,operation,command_buffer,copyTextureToTexture:color_textures,non_compressed,* [ Failure ]
|
||||
crbug.com/dawn/0000 [ win ] webgpu:api,operation,command_buffer,copyTextureToTexture:color_textures,non_compressed,* [ Failure ]
|
||||
|
||||
################################################################################
|
||||
# crbug.com/dawn/1364 Add validation that render attachments must be 2D (array) textures
|
||||
# KEEP
|
||||
################################################################################
|
||||
crbug.com/dawn/1364 webgpu:api,validation,createTexture:texture_usage:* [ Failure ]
|
||||
|
||||
################################################################################
|
||||
# Triaged failures
|
||||
# KEEP
|
||||
|
|
Loading…
Reference in New Issue