mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 06:03:34 +00:00
Metal: use physical size to compute parameters for clearing with a copy
Bug: None Change-Id: I720cd7c0b2fe808d54def5b65882f1bd5742a23a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90200 Reviewed-by: Shrek Shao <shrekshao@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
59e23943f3
commit
a064872983
@ -930,23 +930,18 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Extent3D largestMipSize = GetMipLevelVirtualSize(range.baseMipLevel);
|
|
||||||
|
|
||||||
// Encode a buffer to texture copy to clear each subresource.
|
// Encode a buffer to texture copy to clear each subresource.
|
||||||
for (Aspect aspect : IterateEnumMask(range.aspects)) {
|
for (Aspect aspect : IterateEnumMask(range.aspects)) {
|
||||||
// Compute the buffer size big enough to fill the largest mip.
|
// Compute the buffer size big enough to fill the largest mip.
|
||||||
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(aspect).block;
|
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(aspect).block;
|
||||||
|
|
||||||
// Metal validation layers: sourceBytesPerRow must be at least 64.
|
// 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);
|
||||||
uint32_t largestMipBytesPerRow =
|
uint32_t largestMipBytesPerRow =
|
||||||
std::max((largestMipSize.width / blockInfo.width) * blockInfo.byteSize, 64u);
|
(largestMipSize.width / blockInfo.width) * blockInfo.byteSize;
|
||||||
|
uint64_t largestMipBytesPerImage = static_cast<uint64_t>(largestMipBytesPerRow) *
|
||||||
// Metal validation layers: sourceBytesPerImage must be at least 512.
|
(largestMipSize.height / blockInfo.height);
|
||||||
uint64_t largestMipBytesPerImage =
|
|
||||||
std::max(static_cast<uint64_t>(largestMipBytesPerRow) *
|
|
||||||
(largestMipSize.height / blockInfo.height),
|
|
||||||
512llu);
|
|
||||||
|
|
||||||
uint64_t bufferSize = largestMipBytesPerImage * largestMipSize.depthOrArrayLayers;
|
uint64_t bufferSize = largestMipBytesPerImage * largestMipSize.depthOrArrayLayers;
|
||||||
|
|
||||||
if (bufferSize > std::numeric_limits<NSUInteger>::max()) {
|
if (bufferSize > std::numeric_limits<NSUInteger>::max()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user