Implement copy for 3D texture on D3D12: non-zero mip

The change implements copy non-zero mip level for 3D textures
on D3D12 when the texture has multiple mip levels. The texture
size on level 0 can be either 256-byte aligned or 256-byte
unaligned(its size is non-power-of-two).

Bug: dawn:547

Change-Id: I8ed74fa587cfd814e7f526173dcb653d0a252a1e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51201
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He
2021-06-09 16:01:08 +00:00
committed by Dawn LUCI CQ
parent aec5b98670
commit e5b9903cc1
4 changed files with 95 additions and 12 deletions

View File

@@ -31,10 +31,11 @@ namespace utils {
return Align(bytesPerBlock * (width / blockWidth), kTextureBytesPerRowAlignment);
}
TextureDataCopyLayout GetTextureDataCopyLayoutForTexture2DAtLevel(
TextureDataCopyLayout GetTextureDataCopyLayoutForTextureAtLevel(
wgpu::TextureFormat format,
wgpu::Extent3D textureSizeAtLevel0,
uint32_t mipmapLevel,
wgpu::TextureDimension dimension,
uint32_t rowsPerImage) {
// Compressed texture formats not supported in this function yet.
ASSERT(utils::GetTextureFormatBlockWidth(format) == 1);
@@ -45,6 +46,11 @@ namespace utils {
std::max(textureSizeAtLevel0.height >> mipmapLevel, 1u),
textureSizeAtLevel0.depthOrArrayLayers};
if (dimension == wgpu::TextureDimension::e3D) {
layout.mipSize.depthOrArrayLayers =
std::max(textureSizeAtLevel0.depthOrArrayLayers >> mipmapLevel, 1u);
}
layout.bytesPerRow = GetMinimumBytesPerRow(format, layout.mipSize.width);
if (rowsPerImage == wgpu::kCopyStrideUndefined) {

View File

@@ -31,10 +31,11 @@ namespace utils {
};
uint32_t GetMinimumBytesPerRow(wgpu::TextureFormat format, uint32_t width);
TextureDataCopyLayout GetTextureDataCopyLayoutForTexture2DAtLevel(
TextureDataCopyLayout GetTextureDataCopyLayoutForTextureAtLevel(
wgpu::TextureFormat format,
wgpu::Extent3D textureSizeAtLevel0,
uint32_t mipmapLevel,
wgpu::TextureDimension dimension = wgpu::TextureDimension::e2D,
uint32_t rowsPerImage = wgpu::kCopyStrideUndefined);
uint64_t RequiredBytesInCopy(uint64_t bytesPerRow,