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:
parent
4313dba514
commit
7bfcdca419
|
@ -73,7 +73,7 @@ CommandIterator* CommandBufferBase::GetCommandIteratorForTesting() {
|
|||
bool IsCompleteSubresourceCopiedTo(const TextureBase* texture,
|
||||
const Extent3D copySize,
|
||||
const uint32_t mipLevel) {
|
||||
Extent3D extent = texture->GetMipLevelPhysicalSize(mipLevel);
|
||||
Extent3D extent = texture->GetMipLevelSingleSubresourcePhysicalSize(mipLevel);
|
||||
|
||||
switch (texture->GetDimension()) {
|
||||
case wgpu::TextureDimension::e1D:
|
||||
|
|
|
@ -126,7 +126,8 @@ MaybeError ValidateOrSetAttachmentSize(const TextureViewBase* attachment,
|
|||
uint32_t* width,
|
||||
uint32_t* height) {
|
||||
const Extent3D& attachmentSize =
|
||||
attachment->GetTexture()->GetMipLevelVirtualSize(attachment->GetBaseMipLevel());
|
||||
attachment->GetTexture()->GetMipLevelSingleSubresourceVirtualSize(
|
||||
attachment->GetBaseMipLevel());
|
||||
|
||||
if (*width == 0) {
|
||||
DAWN_ASSERT(*height == 0);
|
||||
|
@ -190,9 +191,11 @@ MaybeError ValidateResolveTarget(const DeviceBase* device,
|
|||
resolveTarget->GetLevelCount());
|
||||
|
||||
const Extent3D& colorTextureSize =
|
||||
attachment->GetTexture()->GetMipLevelVirtualSize(attachment->GetBaseMipLevel());
|
||||
attachment->GetTexture()->GetMipLevelSingleSubresourceVirtualSize(
|
||||
attachment->GetBaseMipLevel());
|
||||
const Extent3D& resolveTextureSize =
|
||||
resolveTarget->GetTexture()->GetMipLevelVirtualSize(resolveTarget->GetBaseMipLevel());
|
||||
resolveTarget->GetTexture()->GetMipLevelSingleSubresourceVirtualSize(
|
||||
resolveTarget->GetBaseMipLevel());
|
||||
DAWN_INVALID_IF(colorTextureSize.width != resolveTextureSize.width ||
|
||||
colorTextureSize.height != resolveTextureSize.height,
|
||||
"The Resolve target %s size (width: %u, height: %u) does not match the color "
|
||||
|
|
|
@ -275,7 +275,8 @@ MaybeError ValidateImageCopyTexture(DeviceBase const* device,
|
|||
texture->GetFormat().format, textureCopy.aspect);
|
||||
|
||||
if (texture->GetSampleCount() > 1 || texture->GetFormat().HasDepthOrStencil()) {
|
||||
Extent3D subresourceSize = texture->GetMipLevelPhysicalSize(textureCopy.mipLevel);
|
||||
Extent3D subresourceSize =
|
||||
texture->GetMipLevelSingleSubresourcePhysicalSize(textureCopy.mipLevel);
|
||||
ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
|
||||
DAWN_INVALID_IF(
|
||||
textureCopy.origin.x != 0 || textureCopy.origin.y != 0 ||
|
||||
|
@ -297,7 +298,7 @@ MaybeError ValidateTextureCopyRange(DeviceBase const* device,
|
|||
const TextureBase* texture = textureCopy.texture;
|
||||
|
||||
// Validation for the copy being in-bounds:
|
||||
Extent3D mipSize = texture->GetMipLevelPhysicalSize(textureCopy.mipLevel);
|
||||
Extent3D mipSize = texture->GetMipLevelSingleSubresourcePhysicalSize(textureCopy.mipLevel);
|
||||
// For 1D/2D textures, include the array layer as depth so it can be checked with other
|
||||
// dimensions.
|
||||
if (texture->GetDimension() != wgpu::TextureDimension::e3D) {
|
||||
|
|
|
@ -330,10 +330,10 @@ ResultOrError<Ref<TextureViewBase>> NewSwapChainBase::GetCurrentTextureView() {
|
|||
ASSERT(mCurrentTextureView->GetLayerCount() == 1);
|
||||
ASSERT(mCurrentTextureView->GetDimension() == wgpu::TextureViewDimension::e2D);
|
||||
ASSERT(mCurrentTextureView->GetTexture()
|
||||
->GetMipLevelVirtualSize(mCurrentTextureView->GetBaseMipLevel())
|
||||
->GetMipLevelSingleSubresourceVirtualSize(mCurrentTextureView->GetBaseMipLevel())
|
||||
.width == mWidth);
|
||||
ASSERT(mCurrentTextureView->GetTexture()
|
||||
->GetMipLevelVirtualSize(mCurrentTextureView->GetBaseMipLevel())
|
||||
->GetMipLevelSingleSubresourceVirtualSize(mCurrentTextureView->GetBaseMipLevel())
|
||||
.height == mHeight);
|
||||
|
||||
return mCurrentTextureView;
|
||||
|
|
|
@ -695,7 +695,7 @@ bool TextureBase::IsMultisampledTexture() const {
|
|||
return mSampleCount > 1;
|
||||
}
|
||||
|
||||
Extent3D TextureBase::GetMipLevelVirtualSize(uint32_t level) const {
|
||||
Extent3D TextureBase::GetMipLevelSingleSubresourceVirtualSize(uint32_t level) const {
|
||||
Extent3D extent = {std::max(mSize.width >> level, 1u), 1u, 1u};
|
||||
if (mDimension == wgpu::TextureDimension::e1D) {
|
||||
return extent;
|
||||
|
@ -710,8 +710,8 @@ Extent3D TextureBase::GetMipLevelVirtualSize(uint32_t level) const {
|
|||
return extent;
|
||||
}
|
||||
|
||||
Extent3D TextureBase::GetMipLevelPhysicalSize(uint32_t level) const {
|
||||
Extent3D extent = GetMipLevelVirtualSize(level);
|
||||
Extent3D TextureBase::GetMipLevelSingleSubresourcePhysicalSize(uint32_t level) const {
|
||||
Extent3D extent = GetMipLevelSingleSubresourceVirtualSize(level);
|
||||
|
||||
// Compressed Textures will have paddings if their width or height is not a multiple of
|
||||
// 4 at non-zero mipmap levels.
|
||||
|
@ -731,7 +731,7 @@ Extent3D TextureBase::GetMipLevelPhysicalSize(uint32_t level) const {
|
|||
Extent3D TextureBase::ClampToMipLevelVirtualSize(uint32_t level,
|
||||
const Origin3D& origin,
|
||||
const Extent3D& extent) const {
|
||||
const Extent3D virtualSizeAtLevel = GetMipLevelVirtualSize(level);
|
||||
const Extent3D virtualSizeAtLevel = GetMipLevelSingleSubresourceVirtualSize(level);
|
||||
ASSERT(origin.x <= virtualSizeAtLevel.width);
|
||||
ASSERT(origin.y <= virtualSizeAtLevel.height);
|
||||
uint32_t clampedCopyExtentWidth = (extent.width > virtualSizeAtLevel.width - origin.x)
|
||||
|
|
|
@ -87,8 +87,8 @@ class TextureBase : public ApiObjectBase {
|
|||
// size is the one with paddings if necessary, which is always a multiple of the block size
|
||||
// and used in texture copying. The virtual size is the one without paddings, which is not
|
||||
// required to be a multiple of the block size and used in texture sampling.
|
||||
Extent3D GetMipLevelPhysicalSize(uint32_t level) const;
|
||||
Extent3D GetMipLevelVirtualSize(uint32_t level) const;
|
||||
Extent3D GetMipLevelSingleSubresourcePhysicalSize(uint32_t level) const;
|
||||
Extent3D GetMipLevelSingleSubresourceVirtualSize(uint32_t level) const;
|
||||
Extent3D ClampToMipLevelVirtualSize(uint32_t level,
|
||||
const Origin3D& origin,
|
||||
const Extent3D& extent) const;
|
||||
|
|
|
@ -1086,7 +1086,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
for (Aspect aspect : IterateEnumMask(range.aspects)) {
|
||||
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(aspect).block;
|
||||
|
||||
Extent3D largestMipSize = GetMipLevelPhysicalSize(range.baseMipLevel);
|
||||
Extent3D largestMipSize = GetMipLevelSingleSubresourcePhysicalSize(range.baseMipLevel);
|
||||
|
||||
uint32_t bytesPerRow =
|
||||
Align((largestMipSize.width / blockInfo.width) * blockInfo.byteSize,
|
||||
|
@ -1103,7 +1103,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount;
|
||||
++level) {
|
||||
// compute d3d12 texture copy locations for texture and buffer
|
||||
Extent3D copySize = GetMipLevelPhysicalSize(level);
|
||||
Extent3D copySize = GetMipLevelSingleSubresourcePhysicalSize(level);
|
||||
|
||||
for (uint32_t layer = range.baseArrayLayer;
|
||||
layer < range.baseArrayLayer + range.layerCount; ++layer) {
|
||||
|
|
|
@ -869,8 +869,9 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
}
|
||||
}
|
||||
|
||||
DAWN_TRY(EncodeEmptyMetalRenderPass(device, commandContext, descriptor,
|
||||
GetMipLevelVirtualSize(level)));
|
||||
DAWN_TRY(
|
||||
EncodeEmptyMetalRenderPass(device, commandContext, descriptor,
|
||||
GetMipLevelSingleSubresourceVirtualSize(level)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -883,7 +884,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
NSRef<MTLRenderPassDescriptor> descriptor;
|
||||
uint32_t attachment = 0;
|
||||
|
||||
uint32_t numZSlices = GetMipLevelVirtualSize(level).depthOrArrayLayers;
|
||||
uint32_t depth = GetMipLevelSingleSubresourceVirtualSize(level).depthOrArrayLayers;
|
||||
|
||||
for (uint32_t arrayLayer = range.baseArrayLayer;
|
||||
arrayLayer < range.baseArrayLayer + range.layerCount; arrayLayer++) {
|
||||
|
@ -894,7 +895,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
continue;
|
||||
}
|
||||
|
||||
for (uint32_t z = 0; z < numZSlices; ++z) {
|
||||
for (uint32_t z = 0; z < depth; ++z) {
|
||||
if (descriptor == nullptr) {
|
||||
// Note that this creates a descriptor that's autoreleased so we
|
||||
// don't use AcquireNSRef
|
||||
|
@ -915,17 +916,18 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
|
||||
if (attachment == kMaxColorAttachments) {
|
||||
attachment = 0;
|
||||
DAWN_TRY(EncodeEmptyMetalRenderPass(device, commandContext,
|
||||
descriptor.Get(),
|
||||
GetMipLevelVirtualSize(level)));
|
||||
DAWN_TRY(EncodeEmptyMetalRenderPass(
|
||||
device, commandContext, descriptor.Get(),
|
||||
GetMipLevelSingleSubresourceVirtualSize(level)));
|
||||
descriptor = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor != nullptr) {
|
||||
DAWN_TRY(EncodeEmptyMetalRenderPass(device, commandContext, descriptor.Get(),
|
||||
GetMipLevelVirtualSize(level)));
|
||||
DAWN_TRY(
|
||||
EncodeEmptyMetalRenderPass(device, commandContext, descriptor.Get(),
|
||||
GetMipLevelSingleSubresourceVirtualSize(level)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -937,7 +939,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
|
||||
// Computations for the bytes per row / image height are done using the physical size
|
||||
// so that enough data is reserved for compressed textures.
|
||||
Extent3D largestMipSize = GetMipLevelPhysicalSize(range.baseMipLevel);
|
||||
Extent3D largestMipSize = GetMipLevelSingleSubresourcePhysicalSize(range.baseMipLevel);
|
||||
uint32_t largestMipBytesPerRow =
|
||||
(largestMipSize.width / blockInfo.width) * blockInfo.byteSize;
|
||||
uint64_t largestMipBytesPerImage = static_cast<uint64_t>(largestMipBytesPerRow) *
|
||||
|
@ -959,7 +961,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||
|
||||
for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount;
|
||||
++level) {
|
||||
Extent3D virtualSize = GetMipLevelVirtualSize(level);
|
||||
Extent3D virtualSize = GetMipLevelSingleSubresourceVirtualSize(level);
|
||||
|
||||
for (uint32_t arrayLayer = range.baseArrayLayer;
|
||||
arrayLayer < range.baseArrayLayer + range.layerCount; ++arrayLayer) {
|
||||
|
|
|
@ -262,7 +262,7 @@ TextureBufferCopySplit ComputeTextureBufferCopySplit(const Texture* texture,
|
|||
origin.z + copyExtent.depthOrArrayLayers - 1};
|
||||
|
||||
ASSERT(copyExtent.height - blockInfo.height <
|
||||
texture->GetMipLevelVirtualSize(mipLevel).height);
|
||||
texture->GetMipLevelSingleSubresourceVirtualSize(mipLevel).height);
|
||||
copy.copies[copy.count].copyExtent = {clampedCopyExtent.width,
|
||||
copyExtent.height - blockInfo.height, 1};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1195,7 +1195,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* recordingContext,
|
|||
ASSERT(range.aspects == Aspect::Color);
|
||||
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(range.aspects).block;
|
||||
|
||||
Extent3D largestMipSize = GetMipLevelPhysicalSize(range.baseMipLevel);
|
||||
Extent3D largestMipSize = GetMipLevelSingleSubresourcePhysicalSize(range.baseMipLevel);
|
||||
|
||||
uint32_t bytesPerRow = Align((largestMipSize.width / blockInfo.width) * blockInfo.byteSize,
|
||||
device->GetOptimalBytesPerRowAlignment());
|
||||
|
@ -1211,7 +1211,7 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* recordingContext,
|
|||
std::vector<VkBufferImageCopy> regions;
|
||||
for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount;
|
||||
++level) {
|
||||
Extent3D copySize = GetMipLevelPhysicalSize(level);
|
||||
Extent3D copySize = GetMipLevelSingleSubresourcePhysicalSize(level);
|
||||
imageRange.baseMipLevel = level;
|
||||
for (uint32_t layer = range.baseArrayLayer;
|
||||
layer < range.baseArrayLayer + range.layerCount; ++layer) {
|
||||
|
|
|
@ -114,7 +114,8 @@ VkImageAspectFlags VulkanAspectMask(const Aspect& aspects) {
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue