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
|
// compute the copySplits and record the CopyTextureRegion commands
|
||||||
CopyBufferToTextureWithCopySplit(
|
CopyBufferToTextureWithCopySplit(
|
||||||
commandContext, copy->destination, copy->copySize, texture,
|
commandContext, copy->destination, buffer->GetD3D12Resource(),
|
||||||
buffer->GetD3D12Resource(), copy->source.offset, copy->source.bytesPerRow,
|
copy->source.offset, copy->source.bytesPerRow, copy->source.rowsPerImage,
|
||||||
copy->source.rowsPerImage, subresources.aspects);
|
copy->copySize, texture, subresources.aspects);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,9 +417,9 @@ namespace dawn_native { namespace d3d12 {
|
||||||
texture->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst, range);
|
texture->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst, range);
|
||||||
|
|
||||||
// compute the copySplits and record the CopyTextureRegion commands
|
// compute the copySplits and record the CopyTextureRegion commands
|
||||||
CopyBufferToTextureWithCopySplit(commandContext, *dst, copySizePixels, texture,
|
CopyBufferToTextureWithCopySplit(commandContext, *dst, ToBackend(source)->GetResource(),
|
||||||
ToBackend(source)->GetResource(), src.offset,
|
src.offset, src.bytesPerRow, src.rowsPerImage,
|
||||||
src.bytesPerRow, src.rowsPerImage, range.aspects);
|
copySizePixels, texture, range.aspects);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -979,23 +979,10 @@ namespace dawn_native { namespace d3d12 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
RecordCopyBufferToTextureFromTextureCopySplit(
|
||||||
ComputeTextureCopyLocationForTexture(this, level, layer, aspect);
|
commandList, copySplit,
|
||||||
for (uint32_t i = 0; i < copySplit.count; ++i) {
|
ToBackend(uploadHandle.stagingBuffer)->GetResource(), 0, bytesPerRow,
|
||||||
Texture2DCopySplit::CopyInfo& info = copySplit.copies[i];
|
this, level, layer, aspect);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
||||||
const Texture2DCopySplit& baseCopySplit,
|
const Texture2DCopySplit& baseCopySplit,
|
||||||
ID3D12Resource* bufferResource,
|
ID3D12Resource* bufferResource,
|
||||||
uint64_t baseOffsetBytes,
|
uint64_t baseOffset,
|
||||||
uint64_t bufferBytesPerRow,
|
uint64_t bufferBytesPerRow,
|
||||||
Texture* texture,
|
Texture* texture,
|
||||||
uint32_t textureMiplevel,
|
uint32_t textureMiplevel,
|
||||||
|
@ -155,7 +155,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
const D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
const D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
||||||
ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureSlice, aspect);
|
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) {
|
for (uint32_t i = 0; i < baseCopySplit.count; ++i) {
|
||||||
const Texture2DCopySplit::CopyInfo& info = baseCopySplit.copies[i];
|
const Texture2DCopySplit::CopyInfo& info = baseCopySplit.copies[i];
|
||||||
|
@ -176,18 +176,18 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
void CopyBufferToTextureWithCopySplit(CommandRecordingContext* commandContext,
|
void CopyBufferToTextureWithCopySplit(CommandRecordingContext* commandContext,
|
||||||
const TextureCopy& textureCopy,
|
const TextureCopy& textureCopy,
|
||||||
const Extent3D& copySize,
|
|
||||||
Texture* texture,
|
|
||||||
ID3D12Resource* bufferResource,
|
ID3D12Resource* bufferResource,
|
||||||
const uint64_t offsetBytes,
|
const uint64_t offset,
|
||||||
const uint32_t bytesPerRow,
|
const uint32_t bytesPerRow,
|
||||||
const uint32_t rowsPerImage,
|
const uint32_t rowsPerImage,
|
||||||
|
const Extent3D& copySize,
|
||||||
|
Texture* texture,
|
||||||
Aspect aspect) {
|
Aspect aspect) {
|
||||||
ASSERT(HasOneBit(aspect));
|
ASSERT(HasOneBit(aspect));
|
||||||
// See comments in ComputeTextureCopySplits() for more details.
|
// See comments in ComputeTextureCopySplits() for more details.
|
||||||
const TexelBlockInfo& blockInfo = texture->GetFormat().GetAspectInfo(aspect).block;
|
const TexelBlockInfo& blockInfo = texture->GetFormat().GetAspectInfo(aspect).block;
|
||||||
const TextureCopySplits copySplits = ComputeTextureCopySplits(
|
const TextureCopySplits copySplits = ComputeTextureCopySplits(
|
||||||
textureCopy.origin, copySize, blockInfo, offsetBytes, bytesPerRow, rowsPerImage);
|
textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
|
||||||
|
|
||||||
const uint64_t bytesPerSlice = bytesPerRow * rowsPerImage;
|
const uint64_t bytesPerSlice = bytesPerRow * rowsPerImage;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
||||||
const Texture2DCopySplit& baseCopySplit,
|
const Texture2DCopySplit& baseCopySplit,
|
||||||
Buffer* buffer,
|
ID3D12Resource* bufferResource,
|
||||||
uint64_t baseOffset,
|
uint64_t baseOffset,
|
||||||
uint64_t bufferBytesPerRow,
|
uint64_t bufferBytesPerRow,
|
||||||
Texture* texture,
|
Texture* texture,
|
||||||
|
@ -56,12 +56,12 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
void CopyBufferToTextureWithCopySplit(CommandRecordingContext* commandContext,
|
void CopyBufferToTextureWithCopySplit(CommandRecordingContext* commandContext,
|
||||||
const TextureCopy& textureCopy,
|
const TextureCopy& textureCopy,
|
||||||
const Extent3D& copySize,
|
|
||||||
Texture* texture,
|
|
||||||
ID3D12Resource* bufferResource,
|
ID3D12Resource* bufferResource,
|
||||||
const uint64_t offset,
|
const uint64_t offset,
|
||||||
const uint32_t bytesPerRow,
|
const uint32_t bytesPerRow,
|
||||||
const uint32_t rowsPerImage,
|
const uint32_t rowsPerImage,
|
||||||
|
const Extent3D& copySize,
|
||||||
|
Texture* texture,
|
||||||
Aspect aspect);
|
Aspect aspect);
|
||||||
|
|
||||||
}} // namespace dawn_native::d3d12
|
}} // namespace dawn_native::d3d12
|
||||||
|
|
Loading…
Reference in New Issue