D3D12: Unify both buffer<->texture copy paths.
The two paths were duplicated with extremely similar code. Unifying them will help implement the buffer<->1D texture copies by having a single place to change. Bug: dawn:814 Change-Id: Id574bf62fc85e5e72ab54ba5066e52ff37000e87 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78723 Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
0cb5c0edeb
commit
9dfcc20750
|
@ -215,23 +215,23 @@ namespace dawn::native::d3d12 {
|
||||||
DAWN_TRY_ASSIGN(tempBufferBase, device->CreateBuffer(&tempBufferDescriptor));
|
DAWN_TRY_ASSIGN(tempBufferBase, device->CreateBuffer(&tempBufferDescriptor));
|
||||||
Ref<Buffer> tempBuffer = ToBackend(std::move(tempBufferBase));
|
Ref<Buffer> tempBuffer = ToBackend(std::move(tempBufferBase));
|
||||||
|
|
||||||
// Copy from source texture into tempBuffer
|
|
||||||
Texture* srcTexture = ToBackend(srcCopy.texture).Get();
|
|
||||||
tempBuffer->TrackUsageAndTransitionNow(recordingContext, wgpu::BufferUsage::CopyDst);
|
|
||||||
BufferCopy bufferCopy;
|
BufferCopy bufferCopy;
|
||||||
bufferCopy.buffer = tempBuffer;
|
bufferCopy.buffer = tempBuffer;
|
||||||
bufferCopy.offset = 0;
|
bufferCopy.offset = 0;
|
||||||
bufferCopy.bytesPerRow = bytesPerRow;
|
bufferCopy.bytesPerRow = bytesPerRow;
|
||||||
bufferCopy.rowsPerImage = rowsPerImage;
|
bufferCopy.rowsPerImage = rowsPerImage;
|
||||||
RecordCopyTextureToBuffer(recordingContext->GetCommandList(), srcCopy, bufferCopy,
|
|
||||||
srcTexture, tempBuffer.Get(), copySize);
|
// Copy from source texture into tempBuffer
|
||||||
|
tempBuffer->TrackUsageAndTransitionNow(recordingContext, wgpu::BufferUsage::CopyDst);
|
||||||
|
RecordBufferTextureCopy(BufferTextureCopyDirection::T2B,
|
||||||
|
recordingContext->GetCommandList(), bufferCopy, srcCopy,
|
||||||
|
copySize);
|
||||||
|
|
||||||
// Copy from tempBuffer into destination texture
|
// Copy from tempBuffer into destination texture
|
||||||
tempBuffer->TrackUsageAndTransitionNow(recordingContext, wgpu::BufferUsage::CopySrc);
|
tempBuffer->TrackUsageAndTransitionNow(recordingContext, wgpu::BufferUsage::CopySrc);
|
||||||
Texture* dstTexture = ToBackend(dstCopy.texture).Get();
|
RecordBufferTextureCopy(BufferTextureCopyDirection::B2T,
|
||||||
RecordCopyBufferToTexture(recordingContext, dstCopy, tempBuffer->GetD3D12Resource(), 0,
|
recordingContext->GetCommandList(), bufferCopy, dstCopy,
|
||||||
bytesPerRow, rowsPerImage, copySize, dstTexture,
|
copySize);
|
||||||
dstCopy.aspect);
|
|
||||||
|
|
||||||
// Save tempBuffer into recordingContext
|
// Save tempBuffer into recordingContext
|
||||||
recordingContext->AddToTempBuffers(std::move(tempBuffer));
|
recordingContext->AddToTempBuffers(std::move(tempBuffer));
|
||||||
|
@ -760,10 +760,8 @@ namespace dawn::native::d3d12 {
|
||||||
texture->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst,
|
texture->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst,
|
||||||
subresources);
|
subresources);
|
||||||
|
|
||||||
RecordCopyBufferToTexture(commandContext, copy->destination,
|
RecordBufferTextureCopy(BufferTextureCopyDirection::B2T, commandList,
|
||||||
buffer->GetD3D12Resource(), copy->source.offset,
|
copy->source, copy->destination, copy->copySize);
|
||||||
copy->source.bytesPerRow, copy->source.rowsPerImage,
|
|
||||||
copy->copySize, texture, subresources.aspects);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -790,8 +788,8 @@ namespace dawn::native::d3d12 {
|
||||||
subresources);
|
subresources);
|
||||||
buffer->TrackUsageAndTransitionNow(commandContext, wgpu::BufferUsage::CopyDst);
|
buffer->TrackUsageAndTransitionNow(commandContext, wgpu::BufferUsage::CopyDst);
|
||||||
|
|
||||||
RecordCopyTextureToBuffer(commandList, copy->source, copy->destination, texture,
|
RecordBufferTextureCopy(BufferTextureCopyDirection::T2B, commandList,
|
||||||
buffer, copy->copySize);
|
copy->destination, copy->source, copy->copySize);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -511,9 +511,10 @@ namespace dawn::native::d3d12 {
|
||||||
|
|
||||||
texture->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst, range);
|
texture->TrackUsageAndTransitionNow(commandContext, wgpu::TextureUsage::CopyDst, range);
|
||||||
|
|
||||||
RecordCopyBufferToTexture(commandContext, *dst, ToBackend(source)->GetResource(),
|
RecordBufferTextureCopyWithBufferHandle(
|
||||||
src.offset, src.bytesPerRow, src.rowsPerImage, copySizePixels,
|
BufferTextureCopyDirection::B2T, commandContext->GetCommandList(),
|
||||||
texture, range.aspects);
|
ToBackend(source)->GetResource(), src.offset, src.bytesPerRow, src.rowsPerImage, *dst,
|
||||||
|
copySizePixels);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1101,9 +1101,6 @@ namespace dawn::native::d3d12 {
|
||||||
// compute d3d12 texture copy locations for texture and buffer
|
// compute d3d12 texture copy locations for texture and buffer
|
||||||
Extent3D copySize = GetMipLevelPhysicalSize(level);
|
Extent3D copySize = GetMipLevelPhysicalSize(level);
|
||||||
|
|
||||||
TextureCopySubresource copySplit = Compute2DTextureCopySubresource(
|
|
||||||
{0, 0, 0}, copySize, blockInfo, uploadHandle.startOffset, bytesPerRow);
|
|
||||||
|
|
||||||
for (uint32_t layer = range.baseArrayLayer;
|
for (uint32_t layer = range.baseArrayLayer;
|
||||||
layer < range.baseArrayLayer + range.layerCount; ++layer) {
|
layer < range.baseArrayLayer + range.layerCount; ++layer) {
|
||||||
if (clearValue == TextureBase::ClearValue::Zero &&
|
if (clearValue == TextureBase::ClearValue::Zero &&
|
||||||
|
@ -1113,10 +1110,16 @@ namespace dawn::native::d3d12 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordCopyBufferToTextureFromTextureCopySplit(
|
TextureCopy textureCopy;
|
||||||
commandList, copySplit,
|
textureCopy.texture = this;
|
||||||
ToBackend(uploadHandle.stagingBuffer)->GetResource(), 0, bytesPerRow,
|
textureCopy.origin = {0, 0, layer};
|
||||||
this, level, layer, aspect);
|
textureCopy.mipLevel = level;
|
||||||
|
textureCopy.aspect = aspect;
|
||||||
|
RecordBufferTextureCopyWithBufferHandle(
|
||||||
|
BufferTextureCopyDirection::B2T, commandList,
|
||||||
|
ToBackend(uploadHandle.stagingBuffer)->GetResource(),
|
||||||
|
uploadHandle.startOffset, bytesPerRow, GetHeight(), textureCopy,
|
||||||
|
copySize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,16 +144,17 @@ namespace dawn::native::d3d12 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
void RecordBufferTextureCopyFromSplits(BufferTextureCopyDirection direction,
|
||||||
const TextureCopySubresource& baseCopySplit,
|
ID3D12GraphicsCommandList* commandList,
|
||||||
ID3D12Resource* bufferResource,
|
const TextureCopySubresource& baseCopySplit,
|
||||||
uint64_t baseOffset,
|
ID3D12Resource* bufferResource,
|
||||||
uint64_t bufferBytesPerRow,
|
uint64_t baseOffset,
|
||||||
Texture* texture,
|
uint64_t bufferBytesPerRow,
|
||||||
uint32_t textureMiplevel,
|
TextureBase* textureBase,
|
||||||
uint32_t textureLayer,
|
uint32_t textureMiplevel,
|
||||||
Aspect aspect) {
|
uint32_t textureLayer,
|
||||||
ASSERT(HasOneBit(aspect));
|
Aspect aspect) {
|
||||||
|
Texture* texture = ToBackend(textureBase);
|
||||||
const D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
const D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
||||||
ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureLayer, aspect);
|
ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureLayer, aspect);
|
||||||
|
|
||||||
|
@ -166,27 +167,35 @@ namespace dawn::native::d3d12 {
|
||||||
const D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
const D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
||||||
ComputeBufferLocationForCopyTextureRegion(texture, bufferResource, info.bufferSize,
|
ComputeBufferLocationForCopyTextureRegion(texture, bufferResource, info.bufferSize,
|
||||||
offsetBytes, bufferBytesPerRow, aspect);
|
offsetBytes, bufferBytesPerRow, aspect);
|
||||||
const D3D12_BOX sourceRegion =
|
if (direction == BufferTextureCopyDirection::B2T) {
|
||||||
ComputeD3D12BoxFromOffsetAndSize(info.bufferOffset, info.copySize);
|
const D3D12_BOX sourceRegion =
|
||||||
|
ComputeD3D12BoxFromOffsetAndSize(info.bufferOffset, info.copySize);
|
||||||
|
|
||||||
commandList->CopyTextureRegion(&textureLocation, info.textureOffset.x,
|
commandList->CopyTextureRegion(&textureLocation, info.textureOffset.x,
|
||||||
info.textureOffset.y, info.textureOffset.z,
|
info.textureOffset.y, info.textureOffset.z,
|
||||||
&bufferLocation, &sourceRegion);
|
&bufferLocation, &sourceRegion);
|
||||||
|
} else {
|
||||||
|
ASSERT(direction == BufferTextureCopyDirection::T2B);
|
||||||
|
const D3D12_BOX sourceRegion =
|
||||||
|
ComputeD3D12BoxFromOffsetAndSize(info.textureOffset, info.copySize);
|
||||||
|
|
||||||
|
commandList->CopyTextureRegion(&bufferLocation, info.bufferOffset.x,
|
||||||
|
info.bufferOffset.y, info.bufferOffset.z,
|
||||||
|
&textureLocation, &sourceRegion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyBufferTo2DTextureWithCopySplit(CommandRecordingContext* commandContext,
|
void Record2DBufferTextureCopyWithSplit(BufferTextureCopyDirection direction,
|
||||||
const TextureCopy& textureCopy,
|
ID3D12GraphicsCommandList* commandList,
|
||||||
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,
|
const TextureCopy& textureCopy,
|
||||||
Texture* texture,
|
const TexelBlockInfo& blockInfo,
|
||||||
Aspect aspect) {
|
const Extent3D& copySize) {
|
||||||
ASSERT(HasOneBit(aspect));
|
|
||||||
// See comments in Compute2DTextureCopySplits() for more details.
|
// See comments in Compute2DTextureCopySplits() for more details.
|
||||||
const TexelBlockInfo& blockInfo = texture->GetFormat().GetAspectInfo(aspect).block;
|
|
||||||
const TextureCopySplits copySplits = Compute2DTextureCopySplits(
|
const TextureCopySplits copySplits = Compute2DTextureCopySplits(
|
||||||
textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
|
textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
|
||||||
|
|
||||||
|
@ -210,166 +219,66 @@ namespace dawn::native::d3d12 {
|
||||||
const uint64_t bufferOffsetForNextLayer = bufferOffsetsForNextLayer[splitIndex];
|
const uint64_t bufferOffsetForNextLayer = bufferOffsetsForNextLayer[splitIndex];
|
||||||
const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z;
|
const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z;
|
||||||
|
|
||||||
RecordCopyBufferToTextureFromTextureCopySplit(
|
RecordBufferTextureCopyFromSplits(direction, commandList, copySplitPerLayerBase,
|
||||||
commandContext->GetCommandList(), copySplitPerLayerBase, bufferResource,
|
bufferResource, bufferOffsetForNextLayer, bytesPerRow,
|
||||||
bufferOffsetForNextLayer, bytesPerRow, texture, textureCopy.mipLevel,
|
textureCopy.texture.Get(), textureCopy.mipLevel,
|
||||||
copyTextureLayer, aspect);
|
copyTextureLayer, textureCopy.aspect);
|
||||||
|
|
||||||
bufferOffsetsForNextLayer[splitIndex] +=
|
bufferOffsetsForNextLayer[splitIndex] +=
|
||||||
bytesPerLayer * copySplits.copySubresources.size();
|
bytesPerLayer * copySplits.copySubresources.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyBufferTo3DTexture(CommandRecordingContext* commandContext,
|
void RecordBufferTextureCopyWithBufferHandle(BufferTextureCopyDirection direction,
|
||||||
const TextureCopy& textureCopy,
|
ID3D12GraphicsCommandList* commandList,
|
||||||
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,
|
const TextureCopy& textureCopy,
|
||||||
Texture* texture,
|
const Extent3D& copySize) {
|
||||||
Aspect aspect) {
|
|
||||||
ASSERT(HasOneBit(aspect));
|
|
||||||
// See comments in Compute3DTextureCopySplits() for more details.
|
|
||||||
const TexelBlockInfo& blockInfo = texture->GetFormat().GetAspectInfo(aspect).block;
|
|
||||||
const TextureCopySubresource copyRegions = Compute3DTextureCopySplits(
|
|
||||||
textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
|
|
||||||
|
|
||||||
RecordCopyBufferToTextureFromTextureCopySplit(commandContext->GetCommandList(), copyRegions,
|
|
||||||
bufferResource, 0, bytesPerRow, texture,
|
|
||||||
textureCopy.mipLevel, 0, aspect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecordCopyBufferToTexture(CommandRecordingContext* commandContext,
|
|
||||||
const TextureCopy& textureCopy,
|
|
||||||
ID3D12Resource* bufferResource,
|
|
||||||
const uint64_t offset,
|
|
||||||
const uint32_t bytesPerRow,
|
|
||||||
const uint32_t rowsPerImage,
|
|
||||||
const Extent3D& copySize,
|
|
||||||
Texture* texture,
|
|
||||||
Aspect aspect) {
|
|
||||||
// Record the CopyTextureRegion commands for 3D textures. Multiple depths of 3D
|
|
||||||
// textures can be copied in one shot and copySplits are not needed.
|
|
||||||
if (texture->GetDimension() == wgpu::TextureDimension::e3D) {
|
|
||||||
CopyBufferTo3DTexture(commandContext, textureCopy, bufferResource, offset, bytesPerRow,
|
|
||||||
rowsPerImage, copySize, texture, aspect);
|
|
||||||
} else {
|
|
||||||
// Compute the copySplits and record the CopyTextureRegion commands for 2D
|
|
||||||
// textures.
|
|
||||||
CopyBufferTo2DTextureWithCopySplit(commandContext, textureCopy, bufferResource, offset,
|
|
||||||
bytesPerRow, rowsPerImage, copySize, texture,
|
|
||||||
aspect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
|
||||||
const TextureCopySubresource& baseCopySplit,
|
|
||||||
Buffer* buffer,
|
|
||||||
uint64_t baseOffset,
|
|
||||||
uint64_t bufferBytesPerRow,
|
|
||||||
Texture* texture,
|
|
||||||
uint32_t textureMiplevel,
|
|
||||||
uint32_t textureLayer,
|
|
||||||
Aspect aspect) {
|
|
||||||
const D3D12_TEXTURE_COPY_LOCATION textureLocation =
|
|
||||||
ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureLayer, aspect);
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < baseCopySplit.count; ++i) {
|
|
||||||
const TextureCopySubresource::CopyInfo& info = baseCopySplit.copies[i];
|
|
||||||
|
|
||||||
// TODO(jiawei.shao@intel.com): pre-compute bufferLocation and sourceRegion as
|
|
||||||
// members in TextureCopySubresource::CopyInfo.
|
|
||||||
const uint64_t offsetBytes = info.alignedOffset + baseOffset;
|
|
||||||
const D3D12_TEXTURE_COPY_LOCATION bufferLocation =
|
|
||||||
ComputeBufferLocationForCopyTextureRegion(texture, buffer->GetD3D12Resource(),
|
|
||||||
info.bufferSize, offsetBytes,
|
|
||||||
bufferBytesPerRow, aspect);
|
|
||||||
const D3D12_BOX sourceRegion =
|
|
||||||
ComputeD3D12BoxFromOffsetAndSize(info.textureOffset, info.copySize);
|
|
||||||
|
|
||||||
commandList->CopyTextureRegion(&bufferLocation, info.bufferOffset.x,
|
|
||||||
info.bufferOffset.y, info.bufferOffset.z,
|
|
||||||
&textureLocation, &sourceRegion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Copy2DTextureToBufferWithCopySplit(ID3D12GraphicsCommandList* commandList,
|
|
||||||
const TextureCopy& textureCopy,
|
|
||||||
const BufferCopy& bufferCopy,
|
|
||||||
Texture* texture,
|
|
||||||
Buffer* buffer,
|
|
||||||
const Extent3D& copySize) {
|
|
||||||
ASSERT(HasOneBit(textureCopy.aspect));
|
ASSERT(HasOneBit(textureCopy.aspect));
|
||||||
|
|
||||||
|
TextureBase* texture = textureCopy.texture.Get();
|
||||||
const TexelBlockInfo& blockInfo =
|
const TexelBlockInfo& blockInfo =
|
||||||
texture->GetFormat().GetAspectInfo(textureCopy.aspect).block;
|
texture->GetFormat().GetAspectInfo(textureCopy.aspect).block;
|
||||||
|
|
||||||
// See comments around Compute2DTextureCopySplits() for more details.
|
switch (texture->GetDimension()) {
|
||||||
const TextureCopySplits copySplits =
|
case wgpu::TextureDimension::e1D: {
|
||||||
Compute2DTextureCopySplits(textureCopy.origin, copySize, blockInfo, bufferCopy.offset,
|
UNREACHABLE();
|
||||||
bufferCopy.bytesPerRow, bufferCopy.rowsPerImage);
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
const uint64_t bytesPerLayer = bufferCopy.bytesPerRow * bufferCopy.rowsPerImage;
|
// Record the CopyTextureRegion commands for 2D textures, with special handling of array
|
||||||
|
// layers since each require their own set of copies.
|
||||||
|
case wgpu::TextureDimension::e2D:
|
||||||
|
Record2DBufferTextureCopyWithSplit(direction, commandList, bufferResource, offset,
|
||||||
|
bytesPerRow, rowsPerImage, textureCopy,
|
||||||
|
blockInfo, copySize);
|
||||||
|
break;
|
||||||
|
|
||||||
// copySplits.copySubresources[1] is always calculated for the second copy layer with
|
case wgpu::TextureDimension::e3D: {
|
||||||
// extra "bytesPerLayer" copy offset compared with the first copy layer. So
|
// See comments in Compute3DTextureCopySplits() for more details.
|
||||||
// here we use an array bufferOffsetsForNextLayer to record the extra offsets
|
const TextureCopySubresource copyRegions = Compute3DTextureCopySplits(
|
||||||
// for each copy layer: bufferOffsetsForNextLayer[0] is the extra offset for
|
textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
|
||||||
// the next copy layer that uses copySplits.copySubresources[0], and
|
|
||||||
// bufferOffsetsForNextLayer[1] is the extra offset for the next copy layer
|
|
||||||
// that uses copySplits.copySubresources[1].
|
|
||||||
std::array<uint64_t, TextureCopySplits::kMaxTextureCopySubresources>
|
|
||||||
bufferOffsetsForNextLayer = {{0u, 0u}};
|
|
||||||
for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) {
|
|
||||||
const uint32_t splitIndex = copyLayer % copySplits.copySubresources.size();
|
|
||||||
|
|
||||||
const TextureCopySubresource& copySplitPerLayerBase =
|
RecordBufferTextureCopyFromSplits(direction, commandList, copyRegions,
|
||||||
copySplits.copySubresources[splitIndex];
|
bufferResource, 0, bytesPerRow, texture,
|
||||||
const uint64_t bufferOffsetForNextLayer = bufferOffsetsForNextLayer[splitIndex];
|
textureCopy.mipLevel, 0, textureCopy.aspect);
|
||||||
const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z;
|
break;
|
||||||
|
}
|
||||||
RecordCopyTextureToBufferFromTextureCopySplit(
|
|
||||||
commandList, copySplitPerLayerBase, buffer, bufferOffsetForNextLayer,
|
|
||||||
bufferCopy.bytesPerRow, texture, textureCopy.mipLevel, copyTextureLayer,
|
|
||||||
textureCopy.aspect);
|
|
||||||
|
|
||||||
bufferOffsetsForNextLayer[splitIndex] +=
|
|
||||||
bytesPerLayer * copySplits.copySubresources.size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Copy3DTextureToBuffer(ID3D12GraphicsCommandList* commandList,
|
void RecordBufferTextureCopy(BufferTextureCopyDirection direction,
|
||||||
const TextureCopy& textureCopy,
|
ID3D12GraphicsCommandList* commandList,
|
||||||
const BufferCopy& bufferCopy,
|
const BufferCopy& bufferCopy,
|
||||||
Texture* texture,
|
const TextureCopy& textureCopy,
|
||||||
Buffer* buffer,
|
const Extent3D& copySize) {
|
||||||
const Extent3D& copySize) {
|
RecordBufferTextureCopyWithBufferHandle(direction, commandList,
|
||||||
ASSERT(HasOneBit(textureCopy.aspect));
|
ToBackend(bufferCopy.buffer)->GetD3D12Resource(),
|
||||||
const TexelBlockInfo& blockInfo =
|
bufferCopy.offset, bufferCopy.bytesPerRow,
|
||||||
texture->GetFormat().GetAspectInfo(textureCopy.aspect).block;
|
bufferCopy.rowsPerImage, textureCopy, copySize);
|
||||||
|
|
||||||
// See comments around Compute3DTextureCopySplits() for more details.
|
|
||||||
const TextureCopySubresource copyRegions =
|
|
||||||
Compute3DTextureCopySplits(textureCopy.origin, copySize, blockInfo, bufferCopy.offset,
|
|
||||||
bufferCopy.bytesPerRow, bufferCopy.rowsPerImage);
|
|
||||||
|
|
||||||
RecordCopyTextureToBufferFromTextureCopySplit(commandList, copyRegions, buffer, 0,
|
|
||||||
bufferCopy.bytesPerRow, texture,
|
|
||||||
textureCopy.mipLevel, 0, textureCopy.aspect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecordCopyTextureToBuffer(ID3D12GraphicsCommandList* commandList,
|
|
||||||
const TextureCopy& textureCopy,
|
|
||||||
const BufferCopy& bufferCopy,
|
|
||||||
Texture* texture,
|
|
||||||
Buffer* buffer,
|
|
||||||
const Extent3D& copySize) {
|
|
||||||
if (texture->GetDimension() == wgpu::TextureDimension::e3D) {
|
|
||||||
Copy3DTextureToBuffer(commandList, textureCopy, bufferCopy, texture, buffer, copySize);
|
|
||||||
} else {
|
|
||||||
Copy2DTextureToBufferWithCopySplit(commandList, textureCopy, bufferCopy, texture,
|
|
||||||
buffer, copySize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDebugName(Device* device, ID3D12Object* object, const char* prefix, std::string label) {
|
void SetDebugName(Device* device, ID3D12Object* object, const char* prefix, std::string label) {
|
||||||
|
|
|
@ -44,42 +44,25 @@ namespace dawn::native::d3d12 {
|
||||||
|
|
||||||
bool IsTypeless(DXGI_FORMAT format);
|
bool IsTypeless(DXGI_FORMAT format);
|
||||||
|
|
||||||
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
enum class BufferTextureCopyDirection {
|
||||||
const TextureCopySubresource& baseCopySplit,
|
B2T,
|
||||||
ID3D12Resource* bufferResource,
|
T2B,
|
||||||
uint64_t baseOffset,
|
};
|
||||||
uint64_t bufferBytesPerRow,
|
|
||||||
Texture* texture,
|
|
||||||
uint32_t textureMiplevel,
|
|
||||||
uint32_t textureLayer,
|
|
||||||
Aspect aspect);
|
|
||||||
|
|
||||||
void RecordCopyBufferToTexture(CommandRecordingContext* commandContext,
|
void RecordBufferTextureCopyWithBufferHandle(BufferTextureCopyDirection direction,
|
||||||
const TextureCopy& textureCopy,
|
ID3D12GraphicsCommandList* commandList,
|
||||||
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,
|
const TextureCopy& textureCopy,
|
||||||
Texture* texture,
|
const Extent3D& copySize);
|
||||||
Aspect aspect);
|
|
||||||
|
|
||||||
void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
|
void RecordBufferTextureCopy(BufferTextureCopyDirection direction,
|
||||||
const TextureCopySubresource& baseCopySplit,
|
ID3D12GraphicsCommandList* commandList,
|
||||||
Buffer* buffer,
|
const BufferCopy& bufferCopy,
|
||||||
uint64_t baseOffset,
|
const TextureCopy& textureCopy,
|
||||||
uint64_t bufferBytesPerRow,
|
const Extent3D& copySize);
|
||||||
Texture* texture,
|
|
||||||
uint32_t textureMiplevel,
|
|
||||||
uint32_t textureLayer,
|
|
||||||
Aspect aspect);
|
|
||||||
|
|
||||||
void RecordCopyTextureToBuffer(ID3D12GraphicsCommandList* commandList,
|
|
||||||
const TextureCopy& textureCopy,
|
|
||||||
const BufferCopy& bufferCopy,
|
|
||||||
Texture* texture,
|
|
||||||
Buffer* buffer,
|
|
||||||
const Extent3D& copySize);
|
|
||||||
|
|
||||||
void SetDebugName(Device* device,
|
void SetDebugName(Device* device,
|
||||||
ID3D12Object* object,
|
ID3D12Object* object,
|
||||||
|
|
Loading…
Reference in New Issue