Rename GetMipLevelSize

Functions GetMipLevel*Size() are somehow unclear and misleading on
whether the array layers are counted into the z-axis of the returned
Extent3D (Extent3D.depthOrArrayLayers).

This change renames them to GetMipLevelSingleSubresource*Size(),
making it clear that array layers are not included in its z-axis.
Because different array layers are different subreources, they are
not in a single subresource. However, depth slices in 3D textures can
be in a single subresource and can be counted.

Bug: dawn:1288
Change-Id: Ifa1776befa863d0f5a11999cab4099e2e7e5996a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92124
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Yunchao He
2022-06-02 19:07:41 +00:00
committed by Dawn LUCI CQ
parent 4313dba514
commit 7bfcdca419
13 changed files with 46 additions and 37 deletions

View File

@@ -422,7 +422,8 @@ void ResolveMultisampledRenderTargets(const OpenGLFunctions& gl,
Extent3D ComputeTextureCopyExtent(const TextureCopy& textureCopy, const Extent3D& copySize) {
Extent3D validTextureCopyExtent = copySize;
const TextureBase* texture = textureCopy.texture.Get();
Extent3D virtualSizeAtLevel = texture->GetMipLevelVirtualSize(textureCopy.mipLevel);
Extent3D virtualSizeAtLevel =
texture->GetMipLevelSingleSubresourceVirtualSize(textureCopy.mipLevel);
ASSERT(textureCopy.origin.x <= virtualSizeAtLevel.width);
ASSERT(textureCopy.origin.y <= virtualSizeAtLevel.height);
if (copySize.width > virtualSizeAtLevel.width - textureCopy.origin.x) {
@@ -1240,7 +1241,7 @@ void DoTexSubImage(const OpenGLFunctions& gl,
uint32_t z = destination.origin.z;
if (texture->GetFormat().isCompressed) {
size_t rowSize = copySize.width / blockInfo.width * blockInfo.byteSize;
Extent3D virtSize = texture->GetMipLevelVirtualSize(destination.mipLevel);
Extent3D virtSize = texture->GetMipLevelSingleSubresourceVirtualSize(destination.mipLevel);
uint32_t width = std::min(copySize.width, virtSize.width - x);
// In GLES glPixelStorei() doesn't affect CompressedTexSubImage*D() and

View File

@@ -378,7 +378,7 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range,
const GLFormat& glFormat = GetGLFormat();
for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount;
++level) {
Extent3D mipSize = GetMipLevelPhysicalSize(level);
Extent3D mipSize = GetMipLevelSingleSubresourcePhysicalSize(level);
for (uint32_t layer = range.baseArrayLayer;
layer < range.baseArrayLayer + range.layerCount; ++layer) {
if (clearValue == TextureBase::ClearValue::Zero &&
@@ -448,7 +448,8 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range,
DoClear();
break;
case wgpu::TextureDimension::e3D:
uint32_t depth = GetMipLevelVirtualSize(level).depthOrArrayLayers;
uint32_t depth = GetMipLevelSingleSubresourceVirtualSize(level)
.depthOrArrayLayers;
for (GLint z = 0; z < static_cast<GLint>(depth); ++z) {
gl.FramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attachment,
GetHandle(), level, z);
@@ -477,7 +478,7 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range,
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(Aspect::Color).block;
ASSERT(kTextureBytesPerRowAlignment % blockInfo.byteSize == 0);
Extent3D largestMipSize = GetMipLevelPhysicalSize(range.baseMipLevel);
Extent3D largestMipSize = GetMipLevelSingleSubresourcePhysicalSize(range.baseMipLevel);
uint32_t bytesPerRow =
Align((largestMipSize.width / blockInfo.width) * blockInfo.byteSize, 4);
@@ -521,7 +522,7 @@ MaybeError Texture::ClearTexture(const SubresourceRange& range,
dataLayout.bytesPerRow = bytesPerRow;
dataLayout.rowsPerImage = largestMipSize.height;
Extent3D mipSize = GetMipLevelPhysicalSize(level);
Extent3D mipSize = GetMipLevelSingleSubresourcePhysicalSize(level);
for (uint32_t layer = range.baseArrayLayer;
layer < range.baseArrayLayer + range.layerCount; ++layer) {