d3d12: Make TextureCopySplitter public API use strong types
Also update UtilsD3D12 private implementation to use strong types.
Bug: 424536624
Change-Id: I9579bf5c88b02d3cab799fb81ce79783795349ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/248374
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/BlockInfo.h b/src/dawn/native/BlockInfo.h
index d199269..153307b 100644
--- a/src/dawn/native/BlockInfo.h
+++ b/src/dawn/native/BlockInfo.h
@@ -194,23 +194,23 @@
}
// Convert from TexelOrigin3D to BlockOrigin3D
- BlockOrigin3D ToBlock(const TexelOrigin3D& origin) {
+ BlockOrigin3D ToBlock(const TexelOrigin3D& origin) const {
return {ToBlockWidth(origin.x), ToBlockHeight(origin.y), ToBlockDepth(origin.z)};
}
// Convert from TexelExtent3D to BlockExtent3D
- BlockExtent3D ToBlock(const TexelExtent3D& extent) {
+ BlockExtent3D ToBlock(const TexelExtent3D& extent) const {
return {ToBlockWidth(extent.width), ToBlockHeight(extent.height),
ToBlockDepth(extent.depthOrArrayLayers)};
}
// Convert from BlockOrigin3D to TexelOrigin3D
- TexelOrigin3D ToTexel(const BlockOrigin3D& origin) {
+ TexelOrigin3D ToTexel(const BlockOrigin3D& origin) const {
return {ToTexelWidth(origin.x), ToTexelHeight(origin.y), ToTexelDepth(origin.z)};
}
// Convert from BlockExtent3D to TexelExtent3D
- TexelExtent3D ToTexel(const BlockExtent3D& extent) {
+ TexelExtent3D ToTexel(const BlockExtent3D& extent) const {
return {ToTexelWidth(extent.width), ToTexelHeight(extent.height),
ToTexelDepth(extent.depthOrArrayLayers)};
}
diff --git a/src/dawn/native/d3d12/TextureCopySplitter.cpp b/src/dawn/native/d3d12/TextureCopySplitter.cpp
index 5ec90658..8620215 100644
--- a/src/dawn/native/d3d12/TextureCopySplitter.cpp
+++ b/src/dawn/native/d3d12/TextureCopySplitter.cpp
@@ -251,16 +251,11 @@
return &this->copies[this->count++];
}
-TextureCopySubresource Compute2DTextureCopySubresource(Origin3D origin_in,
- Extent3D copySize_in,
- const TexelBlockInfo& blockInfo_in,
+TextureCopySubresource Compute2DTextureCopySubresource(BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow_in) {
- TypedTexelBlockInfo blockInfo{blockInfo_in};
- BlockOrigin3D origin = blockInfo.ToBlock(origin_in);
- BlockExtent3D copySize = blockInfo.ToBlock(copySize_in);
- BlockCount blocksPerRow = blockInfo.BytesToBlocks(bytesPerRow_in);
-
+ BlockCount blocksPerRow) {
TextureCopySubresource copy;
// The copies must be 512-aligned. To do this, we calculate the first 512-aligned address
@@ -420,16 +415,14 @@
return copy;
}
-TextureCopySplits Compute2DTextureCopySplits(Origin3D origin,
- Extent3D copySize,
- const TexelBlockInfo& blockInfo,
+TextureCopySplits Compute2DTextureCopySplits(BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow,
- uint32_t rowsPerImage) {
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage) {
TextureCopySplits copies;
- const uint64_t bytesPerLayer = bytesPerRow * rowsPerImage;
-
// The function Compute2DTextureCopySubresource() decides how to split the copy based on:
// - the alignment of the buffer offset with D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT (512)
// - the alignment of the buffer offset with D3D12_TEXTURE_DATA_PITCH_ALIGNMENT (256)
@@ -441,20 +434,21 @@
// layer. Moreover, if "rowsPerImage" is even, both the first and second copy layers can
// share the same copy split, so in this situation we just need to compute copy split once
// and reuse it for all the layers.
- Extent3D copyOneLayerSize = copySize;
- Origin3D copyFirstLayerOrigin = origin;
- copyOneLayerSize.depthOrArrayLayers = 1;
- copyFirstLayerOrigin.z = 0;
+ BlockExtent3D copyOneLayerSize = copySize;
+ BlockOrigin3D copyFirstLayerOrigin = origin;
+ copyOneLayerSize.depthOrArrayLayers = BlockCount{1};
+ copyFirstLayerOrigin.z = BlockCount{0};
copies.copySubresources[0] = Compute2DTextureCopySubresource(
- copyFirstLayerOrigin, copyOneLayerSize, blockInfo, offset, bytesPerRow);
+ copyFirstLayerOrigin, copyOneLayerSize, blockInfo, offset, blocksPerRow);
// When the copy only refers one texture 2D array layer,
// copies.copySubresources[1] will never be used so we can safely early return here.
- if (copySize.depthOrArrayLayers == 1) {
+ if (copySize.depthOrArrayLayers == BlockCount{1}) {
return copies;
}
+ const uint64_t bytesPerLayer = blockInfo.ToBytes(blocksPerRow * rowsPerImage);
if (bytesPerLayer % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0) {
copies.copySubresources[1] = copies.copySubresources[0];
uint64_t alignedOffset0 =
@@ -466,24 +460,18 @@
} else {
const uint64_t bufferOffsetNextLayer = offset + bytesPerLayer;
copies.copySubresources[1] = Compute2DTextureCopySubresource(
- copyFirstLayerOrigin, copyOneLayerSize, blockInfo, bufferOffsetNextLayer, bytesPerRow);
+ copyFirstLayerOrigin, copyOneLayerSize, blockInfo, bufferOffsetNextLayer, blocksPerRow);
}
return copies;
}
-TextureCopySubresource Compute3DTextureCopySplits(Origin3D origin_in,
- Extent3D copySize_in,
- const TexelBlockInfo& blockInfo_in,
+TextureCopySubresource Compute3DTextureCopySplits(BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow,
- uint32_t rowsPerImage_in) {
- TypedTexelBlockInfo blockInfo{blockInfo_in};
- BlockOrigin3D origin = blockInfo.ToBlock(origin_in);
- BlockExtent3D copySize = blockInfo.ToBlock(copySize_in);
- BlockCount blocksPerRow = blockInfo.BytesToBlocks(bytesPerRow);
- BlockCount rowsPerImage{rowsPerImage_in};
-
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage) {
// To compute the copy region(s) for 3D textures, we call Compute2DTextureCopySubresource
// and get copy region(s) for the first slice of the copy, then extend to all depth slices
// and become a 3D copy. However, this doesn't work as easily as that due to some corner
@@ -498,9 +486,8 @@
// Call Compute2DTextureCopySubresource and get copy regions. This function has already
// forwarded "copySize.depthOrArrayLayers" to all depth slices.
- TextureCopySubresource copySubresource = Compute2DTextureCopySubresource(
- blockInfo.ToTexel(origin).ToOrigin3D(), blockInfo.ToTexel(copySize).ToExtent3D(),
- blockInfo.ToTexelBlockInfo(), offset, bytesPerRow);
+ TextureCopySubresource copySubresource =
+ Compute2DTextureCopySubresource(origin, copySize, blockInfo, offset, blocksPerRow);
DAWN_ASSERT(copySubresource.count <= 2);
// If copySize.depthOrArrayLayers is 1, we can return copySubresource. Because we don't need to
@@ -535,6 +522,7 @@
// bytesPerRow is definitely 256, and it is definitely a full copy on height.
// Otherwise, bufferHeight won't be greater than rowsPerImage and there won't be
// an empty row at the beginning of this copy region.
+ uint64_t bytesPerRow = blockInfo.ToBytes(blocksPerRow);
DAWN_ASSERT(bytesPerRow == D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
DAWN_ASSERT(copySize.height == rowsPerImage);
@@ -564,14 +552,11 @@
}
TextureCopySubresource Compute2DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- Origin3D origin_in,
- Extent3D copySize_in,
- const TexelBlockInfo& blockInfo_in,
+ BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t /*bytesPerRow*/) {
- TypedTexelBlockInfo blockInfo{blockInfo_in};
- BlockOrigin3D origin = blockInfo.ToBlock(origin_in);
- BlockExtent3D copySize = blockInfo.ToBlock(copySize_in);
+ BlockCount /*blocksPerRow*/) {
TextureCopySubresource copy;
auto* copyInfo = copy.AddCopy();
@@ -596,20 +581,13 @@
}
TextureCopySubresource Compute3DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- Origin3D origin_in,
- Extent3D copySize_in,
- const TexelBlockInfo& blockInfo_in,
+ BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow_in,
- uint32_t rowsPerImage_in) {
- TypedTexelBlockInfo blockInfo{blockInfo_in};
- BlockOrigin3D origin = blockInfo.ToBlock(origin_in);
- BlockExtent3D copySize = blockInfo.ToBlock(copySize_in);
- BlockCount rowsPerImage{rowsPerImage_in};
- BlockCount blocksPerRow = blockInfo.BytesToBlocks(bytesPerRow_in);
-
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage) {
TextureCopySubresource copy;
-
BlockOrigin3D bufferOffset{BlockCount{0}, BlockCount{0}, BlockCount{0}};
// You can visualize the data in the buffer (bufferLocation) like the inline comments.
diff --git a/src/dawn/native/d3d12/TextureCopySplitter.h b/src/dawn/native/d3d12/TextureCopySplitter.h
index 3f7a020..4cdd99e 100644
--- a/src/dawn/native/d3d12/TextureCopySplitter.h
+++ b/src/dawn/native/d3d12/TextureCopySplitter.h
@@ -92,44 +92,44 @@
// - Copy region(s) combined should exactly be equivalent to the texture region to be copied.
// - Every pixel accessed by every copy region should not be out of the bound of the copied
// texture and buffer.
-TextureCopySubresource Compute2DTextureCopySubresource(Origin3D origin,
- Extent3D copySize,
- const TexelBlockInfo& blockInfo,
+TextureCopySubresource Compute2DTextureCopySubresource(BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow);
+ BlockCount blocksPerRow);
-TextureCopySplits Compute2DTextureCopySplits(Origin3D origin,
- Extent3D copySize,
- const TexelBlockInfo& blockInfo,
+TextureCopySplits Compute2DTextureCopySplits(BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow,
- uint32_t rowsPerImage);
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage);
-TextureCopySubresource Compute3DTextureCopySplits(Origin3D origin,
- Extent3D copySize,
- const TexelBlockInfo& blockInfo,
+TextureCopySubresource Compute3DTextureCopySplits(BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow,
- uint32_t rowsPerImage);
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage);
// Compute the `TextureCopySubresource` for one subresource of a 2D texture with relaxed row pitch
// and offset.
TextureCopySubresource Compute2DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- Origin3D origin,
- Extent3D copySize,
- const TexelBlockInfo& blockInfo,
+ BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow);
+ BlockCount blocksPerRow);
// Compute the `TextureCopySubresource` for one subresource of a 3D texture with relaxed row pitch
// and offset.
TextureCopySubresource Compute3DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- Origin3D origin,
- Extent3D copySize,
- const TexelBlockInfo& blockInfo,
+ BlockOrigin3D origin,
+ BlockExtent3D copySize,
+ const TypedTexelBlockInfo& blockInfo,
uint64_t offset,
- uint32_t bytesPerRow,
- uint32_t rowsPerImage);
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage);
} // namespace dawn::native::d3d12
diff --git a/src/dawn/native/d3d12/UtilsD3D12.cpp b/src/dawn/native/d3d12/UtilsD3D12.cpp
index 7d828ee..382c4d4 100644
--- a/src/dawn/native/d3d12/UtilsD3D12.cpp
+++ b/src/dawn/native/d3d12/UtilsD3D12.cpp
@@ -32,6 +32,7 @@
#include <utility>
#include "dawn/common/Assert.h"
+#include "dawn/common/Range.h"
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Format.h"
#include "dawn/native/d3d/D3DError.h"
@@ -192,16 +193,16 @@
const TextureCopySubresource& baseCopySplit,
ID3D12Resource* bufferResource,
uint64_t baseOffset,
- uint64_t bufferBytesPerRow,
- const TexelBlockInfo& blockInfo_in,
+ BlockCount bufferBlocksPerRow,
+ const TypedTexelBlockInfo& blockInfo,
TextureBase* textureBase,
uint32_t textureMiplevel,
- uint32_t textureLayer,
+ BlockCount textureLayer,
Aspect aspect) {
Texture* texture = ToBackend(textureBase);
- TypedTexelBlockInfo blockInfo{blockInfo_in};
- const D3D12_TEXTURE_COPY_LOCATION textureLocation =
- ComputeTextureCopyLocationForTexture(texture, textureMiplevel, textureLayer, aspect);
+ const D3D12_TEXTURE_COPY_LOCATION textureLocation = ComputeTextureCopyLocationForTexture(
+ texture, textureMiplevel, static_cast<uint32_t>(textureLayer), aspect);
+ uint64_t bufferBytesPerRow = blockInfo.ToBytes(bufferBlocksPerRow);
for (uint32_t i = 0; i < baseCopySplit.count; ++i) {
const TextureCopySubresource::CopyInfo& info = baseCopySplit.copies[i];
@@ -236,17 +237,18 @@
void Record2DBufferTextureCopyWithSplit(BufferTextureCopyDirection direction,
ID3D12GraphicsCommandList* commandList,
ID3D12Resource* bufferResource,
- const uint64_t offset,
- const uint32_t bytesPerRow,
- const uint32_t rowsPerImage,
+ uint64_t offset,
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage,
const TextureCopy& textureCopy,
- const TexelBlockInfo& blockInfo,
- const Extent3D& copySize) {
+ const TypedTexelBlockInfo& blockInfo,
+ const BlockExtent3D& copySize) {
// See comments in Compute2DTextureCopySplits() for more details.
const TextureCopySplits copySplits = Compute2DTextureCopySplits(
- textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
+ blockInfo.ToBlock(textureCopy.origin), copySize, blockInfo.ToTexelBlockInfo(), offset,
+ blocksPerRow, rowsPerImage);
- const uint64_t bytesPerLayer = bytesPerRow * rowsPerImage;
+ const uint64_t bytesPerLayer = blockInfo.ToBytes(blocksPerRow * rowsPerImage);
// copySplits.copySubresources[1] is always calculated for the second copy layer with
// extra "bytesPerLayer" copy offset compared with the first copy layer. So
@@ -258,17 +260,18 @@
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();
+ for (BlockCount copyLayer : Range(copySize.depthOrArrayLayers)) {
+ const uint32_t splitIndex =
+ static_cast<uint32_t>(copyLayer) % copySplits.copySubresources.size();
const TextureCopySubresource& copySplitPerLayerBase =
copySplits.copySubresources[splitIndex];
const uint64_t bufferOffsetForNextLayer = bufferOffsetsForNextLayer[splitIndex];
- const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z;
+ const BlockCount copyTextureLayer = copyLayer + blockInfo.ToBlock(textureCopy.origin).z;
RecordBufferTextureCopyFromSplits(
direction, commandList, copySplitPerLayerBase, bufferResource, bufferOffsetForNextLayer,
- bytesPerRow, blockInfo, textureCopy.texture.Get(), textureCopy.mipLevel,
+ blocksPerRow, blockInfo, textureCopy.texture.Get(), textureCopy.mipLevel,
copyTextureLayer, textureCopy.aspect);
bufferOffsetsForNextLayer[splitIndex] += bytesPerLayer * copySplits.copySubresources.size();
@@ -279,21 +282,21 @@
ID3D12GraphicsCommandList* commandList,
ID3D12Resource* bufferResource,
const uint64_t offset,
- const uint32_t bytesPerRow,
- const uint32_t rowsPerImage,
+ BlockCount blocksPerRow,
+ BlockCount rowsPerImage,
const TextureCopy& textureCopy,
- const TexelBlockInfo& blockInfo,
- const Extent3D& copySize) {
+ const TypedTexelBlockInfo& blockInfo,
+ const BlockExtent3D& copySize) {
TextureCopySubresource copySubresource =
- Compute2DTextureCopySubresourceWithRelaxedRowPitchAndOffset(textureCopy.origin, copySize,
- blockInfo, offset, bytesPerRow);
+ Compute2DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
+ blockInfo.ToBlock(textureCopy.origin), copySize, blockInfo, offset, blocksPerRow);
- uint64_t bytesPerLayer = bytesPerRow * rowsPerImage;
+ uint64_t bytesPerLayer = blockInfo.ToBytes(blocksPerRow * rowsPerImage);
uint64_t bufferOffsetForNextLayer = 0;
- for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) {
- uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z;
+ for (BlockCount copyLayer : Range(copySize.depthOrArrayLayers)) {
+ BlockCount copyTextureLayer = copyLayer + blockInfo.ToBlock(textureCopy.origin).z;
RecordBufferTextureCopyFromSplits(direction, commandList, copySubresource, bufferResource,
- bufferOffsetForNextLayer, bytesPerRow, blockInfo,
+ bufferOffsetForNextLayer, blocksPerRow, blockInfo,
textureCopy.texture.Get(), textureCopy.mipLevel,
copyTextureLayer, textureCopy.aspect);
bufferOffsetForNextLayer += bytesPerLayer;
@@ -305,13 +308,17 @@
ID3D12Resource* bufferResource,
const uint64_t offset,
const uint32_t bytesPerRow,
- const uint32_t rowsPerImage,
+ const uint32_t rowsPerImage_in,
const TextureCopy& textureCopy,
- const Extent3D& copySize) {
+ const Extent3D& copySize_in) {
DAWN_ASSERT(HasOneBit(textureCopy.aspect));
TextureBase* texture = textureCopy.texture.Get();
- const TexelBlockInfo& blockInfo = texture->GetFormat().GetAspectInfo(textureCopy.aspect).block;
+ const TypedTexelBlockInfo& blockInfo =
+ texture->GetFormat().GetAspectInfo(textureCopy.aspect).block;
+ BlockCount blocksPerRow = blockInfo.BytesToBlocks(bytesPerRow);
+ BlockCount rowsPerImage{rowsPerImage_in};
+ BlockExtent3D copySize = blockInfo.ToBlock(copySize_in);
bool useRelaxedRowPitchAndOffset = texture->GetDevice()->IsToggleEnabled(
Toggle::D3D12RelaxBufferTextureCopyPitchAndOffsetAlignment);
@@ -327,14 +334,16 @@
TextureCopySubresource copyRegions;
if (useRelaxedRowPitchAndOffset) {
copyRegions = Compute2DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- textureCopy.origin, copySize, blockInfo, offset, bytesPerRow);
+ blockInfo.ToBlock(textureCopy.origin), copySize, blockInfo, offset,
+ blocksPerRow);
} else {
- copyRegions = Compute2DTextureCopySubresource(textureCopy.origin, copySize,
- blockInfo, offset, bytesPerRow);
+ copyRegions =
+ Compute2DTextureCopySubresource(blockInfo.ToBlock(textureCopy.origin), copySize,
+ blockInfo, offset, blocksPerRow);
}
- RecordBufferTextureCopyFromSplits(direction, commandList, copyRegions, bufferResource,
- 0, bytesPerRow, blockInfo, texture,
- textureCopy.mipLevel, 0, textureCopy.aspect);
+ RecordBufferTextureCopyFromSplits(
+ direction, commandList, copyRegions, bufferResource, 0, blocksPerRow, blockInfo,
+ texture, textureCopy.mipLevel, BlockCount{0}, textureCopy.aspect);
break;
}
@@ -342,13 +351,14 @@
// layers since each require their own set of copies.
case wgpu::TextureDimension::e2D:
if (useRelaxedRowPitchAndOffset) {
+ // This function calls RecordBufferTextureCopyFromSplits
Record2DBufferTextureCopyWithRelaxedOffsetAndPitch(
- direction, commandList, bufferResource, offset, bytesPerRow, rowsPerImage,
- textureCopy, blockInfo, copySize);
+ direction, commandList, bufferResource, offset, blocksPerRow,
+ BlockCount{rowsPerImage}, textureCopy, blockInfo, copySize);
} else {
Record2DBufferTextureCopyWithSplit(direction, commandList, bufferResource, offset,
- bytesPerRow, rowsPerImage, textureCopy,
- blockInfo, copySize);
+ blocksPerRow, BlockCount{rowsPerImage},
+ textureCopy, blockInfo, copySize);
}
break;
@@ -356,15 +366,17 @@
TextureCopySubresource copyRegions;
if (useRelaxedRowPitchAndOffset) {
copyRegions = Compute3DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage);
+ blockInfo.ToBlock(textureCopy.origin), copySize, blockInfo, offset,
+ blocksPerRow, BlockCount{rowsPerImage});
} else {
// See comments in Compute3DTextureCopySplits() for more details.
- copyRegions = Compute3DTextureCopySplits(textureCopy.origin, copySize, blockInfo,
- offset, bytesPerRow, rowsPerImage);
+ copyRegions = Compute3DTextureCopySplits(blockInfo.ToBlock(textureCopy.origin),
+ copySize, blockInfo, offset, blocksPerRow,
+ BlockCount{rowsPerImage});
}
- RecordBufferTextureCopyFromSplits(direction, commandList, copyRegions, bufferResource,
- 0, bytesPerRow, blockInfo, texture,
- textureCopy.mipLevel, 0, textureCopy.aspect);
+ RecordBufferTextureCopyFromSplits(
+ direction, commandList, copyRegions, bufferResource, 0, blocksPerRow, blockInfo,
+ texture, textureCopy.mipLevel, BlockCount{0}, textureCopy.aspect);
break;
}
}
diff --git a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp
index a972bb4..a7cfc43 100644
--- a/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp
+++ b/src/dawn/tests/unittests/d3d12/CopySplitTests.cpp
@@ -87,6 +87,14 @@
return TexelExtent3D{textureSpec.width, textureSpec.height, textureSpec.depthOrArrayLayers};
}
+BlockOrigin3D ToBlockOrigin3D(const TextureSpec& textureSpec) {
+ return ToTypedTexelBlockInfo(textureSpec).ToBlock(ToTexelOrigin3D(textureSpec));
+}
+
+BlockExtent3D ToBlockExtent3D(const TextureSpec& textureSpec) {
+ return ToTypedTexelBlockInfo(textureSpec).ToBlock(ToTexelExtent3D(textureSpec));
+}
+
// Check that each copy region fits inside the buffer footprint
void ValidateFootprints(const TextureSpec& textureSpec,
const BufferSpec& bufferSpec,
@@ -760,43 +768,41 @@
trace << textureSpec << ", " << bufferSpec;
SCOPED_TRACE(trace.str());
+ TypedTexelBlockInfo blockInfo = ToTypedTexelBlockInfo(textureSpec);
+ BlockCount blocksPerRow = blockInfo.BytesToBlocks(bufferSpec.bytesPerRow);
+ BlockCount rowsPerImage{bufferSpec.rowsPerImage};
+
TextureCopySubresource copySplit;
switch (dimension) {
case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e2D: {
// Skip test cases that are clearly for 3D. Validation would catch
// these cases before reaching the TextureCopySplitter.
+ // TODO(425944899): Test Compute2DTextureCopySplits to cover e2D and
+ // depthOrArrayLayers>1
if (textureSpec.z > 0_tc || textureSpec.depthOrArrayLayers > 1_tc) {
return;
}
if (relaxed) {
copySplit = Compute2DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- ToTexelOrigin3D(textureSpec).ToOrigin3D(),
- ToTexelExtent3D(textureSpec).ToExtent3D(),
- ToTypedTexelBlockInfo(textureSpec).ToTexelBlockInfo(), bufferSpec.offset,
- bufferSpec.bytesPerRow);
+ ToBlockOrigin3D(textureSpec), ToBlockExtent3D(textureSpec), blockInfo,
+ bufferSpec.offset, blocksPerRow);
} else {
copySplit = Compute2DTextureCopySubresource(
- ToTexelOrigin3D(textureSpec).ToOrigin3D(),
- ToTexelExtent3D(textureSpec).ToExtent3D(),
- ToTypedTexelBlockInfo(textureSpec).ToTexelBlockInfo(), bufferSpec.offset,
- bufferSpec.bytesPerRow);
+ ToBlockOrigin3D(textureSpec), ToBlockExtent3D(textureSpec), blockInfo,
+ bufferSpec.offset, blocksPerRow);
}
break;
}
case wgpu::TextureDimension::e3D: {
if (relaxed) {
copySplit = Compute3DTextureCopySubresourceWithRelaxedRowPitchAndOffset(
- ToTexelOrigin3D(textureSpec).ToOrigin3D(),
- ToTexelExtent3D(textureSpec).ToExtent3D(),
- ToTypedTexelBlockInfo(textureSpec).ToTexelBlockInfo(), bufferSpec.offset,
- bufferSpec.bytesPerRow, static_cast<uint32_t>(bufferSpec.rowsPerImage));
+ ToBlockOrigin3D(textureSpec), ToBlockExtent3D(textureSpec), blockInfo,
+ bufferSpec.offset, blocksPerRow, rowsPerImage);
} else {
copySplit = Compute3DTextureCopySplits(
- ToTexelOrigin3D(textureSpec).ToOrigin3D(),
- ToTexelExtent3D(textureSpec).ToExtent3D(),
- ToTypedTexelBlockInfo(textureSpec).ToTexelBlockInfo(), bufferSpec.offset,
- bufferSpec.bytesPerRow, static_cast<uint32_t>(bufferSpec.rowsPerImage));
+ ToBlockOrigin3D(textureSpec), ToBlockExtent3D(textureSpec), blockInfo,
+ bufferSpec.offset, blocksPerRow, rowsPerImage);
}
break;
}