diff options
Diffstat (limited to 'chromium/third_party/dawn/src/dawn_native/d3d12/UtilsD3D12.cpp')
-rw-r--r-- | chromium/third_party/dawn/src/dawn_native/d3d12/UtilsD3D12.cpp | 80 |
1 files changed, 42 insertions, 38 deletions
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/UtilsD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/UtilsD3D12.cpp index b1902100785..98e9785be97 100644 --- a/chromium/third_party/dawn/src/dawn_native/d3d12/UtilsD3D12.cpp +++ b/chromium/third_party/dawn/src/dawn_native/d3d12/UtilsD3D12.cpp @@ -68,12 +68,12 @@ namespace dawn_native { namespace d3d12 { D3D12_TEXTURE_COPY_LOCATION ComputeTextureCopyLocationForTexture(const Texture* texture, uint32_t level, - uint32_t slice, + uint32_t layer, Aspect aspect) { D3D12_TEXTURE_COPY_LOCATION copyLocation; copyLocation.pResource = texture->GetD3D12Resource(); copyLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - copyLocation.SubresourceIndex = texture->GetSubresourceIndex(level, slice, aspect); + copyLocation.SubresourceIndex = texture->GetSubresourceIndex(level, layer, aspect); return copyLocation; } @@ -143,25 +143,25 @@ namespace dawn_native { namespace d3d12 { } void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList, - const Texture2DCopySplit& baseCopySplit, + const TextureCopySubresource& baseCopySplit, ID3D12Resource* bufferResource, uint64_t baseOffset, uint64_t bufferBytesPerRow, Texture* texture, uint32_t textureMiplevel, - uint32_t textureSlice, + uint32_t textureLayer, Aspect aspect) { ASSERT(HasOneBit(aspect)); const D3D12_TEXTURE_COPY_LOCATION textureLocation = - ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureSlice, aspect); + ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureLayer, aspect); const uint64_t offsetBytes = baseCopySplit.offset + baseOffset; for (uint32_t i = 0; i < baseCopySplit.count; ++i) { - const Texture2DCopySplit::CopyInfo& info = baseCopySplit.copies[i]; + const TextureCopySubresource::CopyInfo& info = baseCopySplit.copies[i]; // TODO(jiawei.shao@intel.com): pre-compute bufferLocation and sourceRegion as - // members in Texture2DCopySplit::CopyInfo. + // members in TextureCopySubresource::CopyInfo. const D3D12_TEXTURE_COPY_LOCATION bufferLocation = ComputeBufferLocationForCopyTextureRegion(texture, bufferResource, info.bufferSize, offsetBytes, bufferBytesPerRow, aspect); @@ -191,29 +191,31 @@ namespace dawn_native { namespace d3d12 { const uint64_t bytesPerSlice = bytesPerRow * rowsPerImage; - // copySplits.copies2D[1] is always calculated for the second copy slice with + // copySplits.copySubresources[1] is always calculated for the second copy slice with // extra "bytesPerSlice" copy offset compared with the first copy slice. So // here we use an array bufferOffsetsForNextSlice to record the extra offsets // for each copy slice: bufferOffsetsForNextSlice[0] is the extra offset for - // the next copy slice that uses copySplits.copies2D[0], and + // the next copy slice that uses copySplits.copySubresources[0], and // bufferOffsetsForNextSlice[1] is the extra offset for the next copy slice - // that uses copySplits.copies2D[1]. - std::array<uint64_t, TextureCopySplits::kMaxTextureCopySplits> bufferOffsetsForNextSlice = { - {0u, 0u}}; + // that uses copySplits.copySubresources[1]. + std::array<uint64_t, TextureCopySplits::kMaxTextureCopySubresources> + bufferOffsetsForNextSlice = {{0u, 0u}}; - for (uint32_t copySlice = 0; copySlice < copySize.depthOrArrayLayers; ++copySlice) { - const uint32_t splitIndex = copySlice % copySplits.copies2D.size(); + for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) { + const uint32_t splitIndex = copyLayer % copySplits.copySubresources.size(); - const Texture2DCopySplit& copySplitPerLayerBase = copySplits.copies2D[splitIndex]; + const TextureCopySubresource& copySplitPerLayerBase = + copySplits.copySubresources[splitIndex]; const uint64_t bufferOffsetForNextSlice = bufferOffsetsForNextSlice[splitIndex]; - const uint32_t copyTextureLayer = copySlice + textureCopy.origin.z; + const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z; RecordCopyBufferToTextureFromTextureCopySplit( commandContext->GetCommandList(), copySplitPerLayerBase, bufferResource, bufferOffsetForNextSlice, bytesPerRow, texture, textureCopy.mipLevel, copyTextureLayer, aspect); - bufferOffsetsForNextSlice[splitIndex] += bytesPerSlice * copySplits.copies2D.size(); + bufferOffsetsForNextSlice[splitIndex] += + bytesPerSlice * copySplits.copySubresources.size(); } } @@ -233,8 +235,8 @@ namespace dawn_native { namespace d3d12 { textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage, true); RecordCopyBufferToTextureFromTextureCopySplit( - commandContext->GetCommandList(), copySplits.copies2D[0], bufferResource, 0, - bytesPerRow, texture, textureCopy.mipLevel, textureCopy.origin.z, aspect); + commandContext->GetCommandList(), copySplits.copySubresources[0], bufferResource, 0, + bytesPerRow, texture, textureCopy.mipLevel, 0, aspect); } void RecordCopyBufferToTexture(CommandRecordingContext* commandContext, @@ -261,24 +263,24 @@ namespace dawn_native { namespace d3d12 { } void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList, - const Texture2DCopySplit& baseCopySplit, + const TextureCopySubresource& baseCopySplit, Buffer* buffer, uint64_t baseOffset, uint64_t bufferBytesPerRow, Texture* texture, uint32_t textureMiplevel, - uint32_t textureSlice, + uint32_t textureLayer, Aspect aspect) { const D3D12_TEXTURE_COPY_LOCATION textureLocation = - ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureSlice, aspect); + ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureLayer, aspect); const uint64_t offset = baseCopySplit.offset + baseOffset; for (uint32_t i = 0; i < baseCopySplit.count; ++i) { - const Texture2DCopySplit::CopyInfo& info = baseCopySplit.copies[i]; + const TextureCopySubresource::CopyInfo& info = baseCopySplit.copies[i]; // TODO(jiawei.shao@intel.com): pre-compute bufferLocation and sourceRegion as - // members in Texture2DCopySplit::CopyInfo. + // members in TextureCopySubresource::CopyInfo. const D3D12_TEXTURE_COPY_LOCATION bufferLocation = ComputeBufferLocationForCopyTextureRegion(texture, buffer->GetD3D12Resource(), info.bufferSize, offset, @@ -309,28 +311,30 @@ namespace dawn_native { namespace d3d12 { const uint64_t bytesPerSlice = bufferCopy.bytesPerRow * bufferCopy.rowsPerImage; - // copySplits.copies2D[1] is always calculated for the second copy slice with + // copySplits.copySubresources[1] is always calculated for the second copy slice with // extra "bytesPerSlice" copy offset compared with the first copy slice. So // here we use an array bufferOffsetsForNextSlice to record the extra offsets // for each copy slice: bufferOffsetsForNextSlice[0] is the extra offset for - // the next copy slice that uses copySplits.copies2D[0], and + // the next copy slice that uses copySplits.copySubresources[0], and // bufferOffsetsForNextSlice[1] is the extra offset for the next copy slice - // that uses copySplits.copies2D[1]. - std::array<uint64_t, TextureCopySplits::kMaxTextureCopySplits> bufferOffsetsForNextSlice = { - {0u, 0u}}; - for (uint32_t copySlice = 0; copySlice < copySize.depthOrArrayLayers; ++copySlice) { - const uint32_t splitIndex = copySlice % copySplits.copies2D.size(); - - const Texture2DCopySplit& copySplitPerLayerBase = copySplits.copies2D[splitIndex]; + // that uses copySplits.copySubresources[1]. + std::array<uint64_t, TextureCopySplits::kMaxTextureCopySubresources> + bufferOffsetsForNextSlice = {{0u, 0u}}; + for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) { + const uint32_t splitIndex = copyLayer % copySplits.copySubresources.size(); + + const TextureCopySubresource& copySplitPerLayerBase = + copySplits.copySubresources[splitIndex]; const uint64_t bufferOffsetForNextSlice = bufferOffsetsForNextSlice[splitIndex]; - const uint32_t copyTextureLayer = copySlice + textureCopy.origin.z; + const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z; RecordCopyTextureToBufferFromTextureCopySplit( commandList, copySplitPerLayerBase, buffer, bufferOffsetForNextSlice, bufferCopy.bytesPerRow, texture, textureCopy.mipLevel, copyTextureLayer, textureCopy.aspect); - bufferOffsetsForNextSlice[splitIndex] += bytesPerSlice * copySplits.copies2D.size(); + bufferOffsetsForNextSlice[splitIndex] += + bytesPerSlice * copySplits.copySubresources.size(); } } @@ -349,9 +353,9 @@ namespace dawn_native { namespace d3d12 { ComputeTextureCopySplits(textureCopy.origin, copySize, blockInfo, bufferCopy.offset, bufferCopy.bytesPerRow, bufferCopy.rowsPerImage, true); - RecordCopyTextureToBufferFromTextureCopySplit( - commandList, copySplits.copies2D[0], buffer, 0, bufferCopy.bytesPerRow, texture, - textureCopy.mipLevel, textureCopy.origin.z, textureCopy.aspect); + RecordCopyTextureToBufferFromTextureCopySplit(commandList, copySplits.copySubresources[0], + buffer, 0, bufferCopy.bytesPerRow, texture, + textureCopy.mipLevel, 0, textureCopy.aspect); } void RecordCopyTextureToBuffer(ID3D12GraphicsCommandList* commandList, |