Add more constants for max texture sizes

Currently we only implemented 2D and 2DArray texture. kMaxTextureSize
is actually for 2D texture only. This patch adds a few more constants
for texture size for 1D and 3D textures, and changes kMaxTextureSize
to kMaxTextureDimension2D.

Bug: dawn:558

Change-Id: I9088dd7c060dc096a65abea37c7fb01f760524e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/36540
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He
2021-01-11 18:04:12 +00:00
committed by Commit Bot service account
parent 77fcdf7eaa
commit 0325e4503b
5 changed files with 36 additions and 33 deletions

View File

@@ -89,7 +89,8 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Swapchain size can't be empty");
}
if (descriptor->width > kMaxTextureSize || descriptor->height > kMaxTextureSize) {
if (descriptor->width > kMaxTextureDimension2D ||
descriptor->height > kMaxTextureDimension2D) {
return DAWN_VALIDATION_ERROR("Swapchain size too big");
}
}

View File

@@ -155,8 +155,8 @@ namespace dawn_native {
MaybeError ValidateTextureSize(const TextureDescriptor* descriptor, const Format* format) {
ASSERT(descriptor->size.width != 0 && descriptor->size.height != 0);
if (descriptor->size.width > kMaxTextureSize ||
descriptor->size.height > kMaxTextureSize) {
if (descriptor->size.width > kMaxTextureDimension2D ||
descriptor->size.height > kMaxTextureDimension2D) {
return DAWN_VALIDATION_ERROR("Texture max size exceeded");
}
@@ -176,7 +176,7 @@ namespace dawn_native {
}
if (descriptor->dimension == wgpu::TextureDimension::e2D &&
descriptor->size.depth > kMaxTexture2DArrayLayers) {
descriptor->size.depth > kMaxTextureArrayLayers) {
return DAWN_VALIDATION_ERROR("Texture 2D array layer count exceeded");
}
if (descriptor->mipLevelCount > kMaxTexture2DMipLevels) {
@@ -444,12 +444,12 @@ namespace dawn_native {
uint32_t TextureBase::GetSubresourceIndex(uint32_t mipLevel,
uint32_t arraySlice,
Aspect aspect) const {
ASSERT(arraySlice <= kMaxTexture2DArrayLayers);
ASSERT(arraySlice <= kMaxTextureArrayLayers);
ASSERT(mipLevel <= kMaxTexture2DMipLevels);
ASSERT(HasOneBit(aspect));
static_assert(kMaxTexture2DMipLevels <=
std::numeric_limits<uint32_t>::max() / kMaxTexture2DArrayLayers,
"texture size overflows uint32_t");
static_assert(
kMaxTexture2DMipLevels <= std::numeric_limits<uint32_t>::max() / kMaxTextureArrayLayers,
"texture size overflows uint32_t");
return mipLevel +
GetNumMipLevels() * (arraySlice + GetArrayLayers() * GetAspectIndex(aspect));
}