D3D12: Clear texture with RecordCopyBufferToTextureFromTextureCopySplit
This patch uses RecordCopyBufferToTextureFromTextureCopySplit() to record the D3D12 commands in Texture::ClearTexture() so that we can remove some redundant code in that function. BUG=dawn:145, dawn:693 Change-Id: Ifd0ba319c335fdf13e60bf748163451d71dad962 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42760 Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
parent
ec3f482422
commit
642ec1c30e
|
@ -709,9 +709,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
// compute the copySplits and record the CopyTextureRegion commands
|
||||
CopyBufferToTextureWithCopySplit(
|
||||
commandContext, copy->destination, copy->copySize, texture,
|
||||
buffer->GetD3D12Resource(), copy->source.offset, copy->source.bytesPerRow,
|
||||
copy->source.rowsPerImage, subresources.aspects);
|
||||
commandContext, copy->destination, buffer->GetD3D12Resource(),
|
||||
copy->source.offset, copy->source.bytesPerRow, copy->source.rowsPerImage,
|
||||
copy->copySize, texture, subresources.aspects);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -417,9 +417,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
texture->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst, range);
|
||||
|
||||
// compute the copySplits and record the CopyTextureRegion commands
|
||||
CopyBufferToTextureWithCopySplit(commandContext, *dst, copySizePixels, texture,
|
||||
ToBackend(source)->GetResource(), src.offset,
|
||||
src.bytesPerRow, src.rowsPerImage, range.aspects);
|
||||
CopyBufferToTextureWithCopySplit(commandContext, *dst, ToBackend(source)->GetResource(),
|
||||
src.offset, src.bytesPerRow, src.rowsPerImage,
|
||||
copySizePixels, texture, range.aspects);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -979,23 +979,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
continue;
|
||||
}
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
||||
ComputeTextureCopyLocationForTexture(this, level, layer, aspect);
|
||||
for (uint32_t i = 0; i < copySplit.count; ++i) {
|
||||
Texture2DCopySplit::CopyInfo& info = copySplit.copies[i];
|
||||
|
||||
D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
||||
ComputeBufferLocationForCopyTextureRegion(
|
||||
this, ToBackend(uploadHandle.stagingBuffer)->GetResource(),
|
||||
info.bufferSize, copySplit.offset, bytesPerRow, aspect);
|
||||
D3D12_BOX sourceRegion =
|
||||
ComputeD3D12BoxFromOffsetAndSize(info.bufferOffset, info.copySize);
|
||||
|
||||
// copy the buffer filled with clear color to the texture
|
||||
commandList->CopyTextureRegion(
|
||||
&textureLocation, info.textureOffset.x, info.textureOffset.y,
|
||||
info.textureOffset.z, &bufferLocation, &sourceRegion);
|
||||
}
|
||||
RecordCopyBufferToTextureFromTextureCopySplit(
|
||||
commandList, copySplit,
|
||||
ToBackend(uploadHandle.stagingBuffer)->GetResource(), 0, bytesPerRow,
|
||||
this, level, layer, aspect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
||||
const Texture2DCopySplit& baseCopySplit,
|
||||
ID3D12Resource* bufferResource,
|
||||
uint64_t baseOffsetBytes,
|
||||
uint64_t baseOffset,
|
||||
uint64_t bufferBytesPerRow,
|
||||
Texture* texture,
|
||||
uint32_t textureMiplevel,
|
||||
|
@ -155,7 +155,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
const D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
||||
ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureSlice, aspect);
|
||||
|
||||
const uint64_t offsetBytes = baseCopySplit.offset + baseOffsetBytes;
|
||||
const uint64_t offsetBytes = baseCopySplit.offset + baseOffset;
|
||||
|
||||
for (uint32_t i = 0; i < baseCopySplit.count; ++i) {
|
||||
const Texture2DCopySplit::CopyInfo& info = baseCopySplit.copies[i];
|
||||
|
@ -176,18 +176,18 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
void CopyBufferToTextureWithCopySplit(CommandRecordingContext* commandContext,
|
||||
const TextureCopy& textureCopy,
|
||||
const Extent3D& copySize,
|
||||
Texture* texture,
|
||||
ID3D12Resource* bufferResource,
|
||||
const uint64_t offsetBytes,
|
||||
const uint64_t offset,
|
||||
const uint32_t bytesPerRow,
|
||||
const uint32_t rowsPerImage,
|
||||
const Extent3D& copySize,
|
||||
Texture* texture,
|
||||
Aspect aspect) {
|
||||
ASSERT(HasOneBit(aspect));
|
||||
// See comments in ComputeTextureCopySplits() for more details.
|
||||
const TexelBlockInfo& blockInfo = texture->GetFormat().GetAspectInfo(aspect).block;
|
||||
const TextureCopySplits copySplits = ComputeTextureCopySplits(
|
||||
textureCopy.origin, copySize, blockInfo, offsetBytes, bytesPerRow, rowsPerImage);
|
||||
textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
|
||||
|
||||
const uint64_t bytesPerSlice = bytesPerRow * rowsPerImage;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
||||
const Texture2DCopySplit& baseCopySplit,
|
||||
Buffer* buffer,
|
||||
ID3D12Resource* bufferResource,
|
||||
uint64_t baseOffset,
|
||||
uint64_t bufferBytesPerRow,
|
||||
Texture* texture,
|
||||
|
@ -56,12 +56,12 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
void CopyBufferToTextureWithCopySplit(CommandRecordingContext* commandContext,
|
||||
const TextureCopy& textureCopy,
|
||||
const Extent3D& copySize,
|
||||
Texture* texture,
|
||||
ID3D12Resource* bufferResource,
|
||||
const uint64_t offset,
|
||||
const uint32_t bytesPerRow,
|
||||
const uint32_t rowsPerImage,
|
||||
const Extent3D& copySize,
|
||||
Texture* texture,
|
||||
Aspect aspect);
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
Loading…
Reference in New Issue