D3D12: set correct data layout of dst texture for B2T copy

When we initialize the dst texture before T2T copy, we clear a
buffer with zeros and do a B2T copy in order to initialize the
texture. The T2T copy may only copy a subrect of the texture's
subresource, so does the initialization via B2T copy. As a result,
the buffer can store compact zeros for that exact subrect and then
do an exact B2T copy to initialize that area.

However, the current B2T copy uses incorrect data layout for the
buffer, making some part of the dst texture uninitialized, and
even leading to D3D12 runtime validation errors sometimes if it
goes beyond the boundary of staging buffer pool (4MB).

This change fixes this bug via using the exact height of copy area
to replace dataLayout.rowsPerImage (unnecessary padding rows included)
for the height of each depth image for 3D textures.

Bug: dawn:1288
Change-Id: I303e0d363039a6a87e352a8445898031e673cf4e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90780
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Yunchao He 2022-05-19 16:35:09 +00:00 committed by Dawn LUCI CQ
parent a98d774cd6
commit 26934d9503
1 changed files with 2 additions and 1 deletions

View File

@ -1122,7 +1122,8 @@ MaybeError Texture::ClearTexture(CommandRecordingContext* commandContext,
RecordBufferTextureCopyWithBufferHandle( RecordBufferTextureCopyWithBufferHandle(
BufferTextureCopyDirection::B2T, commandList, BufferTextureCopyDirection::B2T, commandList,
ToBackend(uploadHandle.stagingBuffer)->GetResource(), ToBackend(uploadHandle.stagingBuffer)->GetResource(),
uploadHandle.startOffset, bytesPerRow, GetHeight(), textureCopy, copySize); uploadHandle.startOffset, bytesPerRow, largestMipSize.height, textureCopy,
copySize);
} }
} }
} }