Rename some data structures in TextureCopySplitter

The change renames Texture2DCopySplit and copies2D to
TextureCopySubresource and copySubresources respectively.
Because they are not used for 2D only.

I didn't change Texture2DCopySplit to TextureCopySplit in order
to reflect its meaning and distinguish it from TextureCopySplits.
TextureCopySubresource is a collection of copy regions for either a
single layer of a 1D/2D texture or all depth slices on the same
mip level of a 3D texture (They are exactly what subresources are).

It also renames function ComputeTextureCopySplit to
ComputeTextureCopySubresource, and a couple similar renaming.

Bug: dawn:547
Change-Id: I17f8b349e209af0ed1ccaee4634be1e8235a63b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/50920
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Yunchao He 2021-05-17 10:35:57 +00:00 committed by Commit Bot service account
parent 75de553398
commit e8c271dab7
6 changed files with 78 additions and 73 deletions

View File

@ -33,13 +33,13 @@ namespace dawn_native { namespace d3d12 {
} }
} // namespace } // namespace
Texture2DCopySplit ComputeTextureCopySplit(Origin3D origin, TextureCopySubresource ComputeTextureCopySubresource(Origin3D origin,
Extent3D copySize, Extent3D copySize,
const TexelBlockInfo& blockInfo, const TexelBlockInfo& blockInfo,
uint64_t offset, uint64_t offset,
uint32_t bytesPerRow, uint32_t bytesPerRow,
uint32_t rowsPerImage) { uint32_t rowsPerImage) {
Texture2DCopySplit copy; TextureCopySubresource copy;
ASSERT(bytesPerRow % blockInfo.byteSize == 0); ASSERT(bytesPerRow % blockInfo.byteSize == 0);
@ -215,7 +215,7 @@ namespace dawn_native { namespace d3d12 {
const uint64_t bytesPerSlice = bytesPerRow * rowsPerImage; const uint64_t bytesPerSlice = bytesPerRow * rowsPerImage;
// The function ComputeTextureCopySplit() decides how to split the copy based on: // The function ComputeTextureCopySubresource() 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_PLACEMENT_ALIGNMENT (512)
// - the alignment of the buffer offset with D3D12_TEXTURE_DATA_PITCH_ALIGNMENT (256) // - the alignment of the buffer offset with D3D12_TEXTURE_DATA_PITCH_ALIGNMENT (256)
// Each slice of a 2D array or 3D copy might need to be split, but because of the WebGPU // Each slice of a 2D array or 3D copy might need to be split, but because of the WebGPU
@ -233,22 +233,22 @@ namespace dawn_native { namespace d3d12 {
copyFirstLayerOrigin.z = 0; copyFirstLayerOrigin.z = 0;
} }
copies.copies2D[0] = ComputeTextureCopySplit(copyFirstLayerOrigin, copyOneLayerSize, copies.copySubresources[0] = ComputeTextureCopySubresource(
blockInfo, offset, bytesPerRow, rowsPerImage); copyFirstLayerOrigin, copyOneLayerSize, blockInfo, offset, bytesPerRow, rowsPerImage);
// When the copy only refers one texture 2D array layer or a 3D texture, copies.copies2D[1] // When the copy only refers one texture 2D array layer or a 3D texture,
// will never be used so we can safely early return here. // copies.copySubresources[1] will never be used so we can safely early return here.
if (copySize.depthOrArrayLayers == 1 || is3DTexture) { if (copySize.depthOrArrayLayers == 1 || is3DTexture) {
return copies; return copies;
} }
if (bytesPerSlice % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0) { if (bytesPerSlice % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT == 0) {
copies.copies2D[1] = copies.copies2D[0]; copies.copySubresources[1] = copies.copySubresources[0];
copies.copies2D[1].offset += bytesPerSlice; copies.copySubresources[1].offset += bytesPerSlice;
} else { } else {
const uint64_t bufferOffsetNextLayer = offset + bytesPerSlice; const uint64_t bufferOffsetNextLayer = offset + bytesPerSlice;
copies.copies2D[1] = copies.copySubresources[1] =
ComputeTextureCopySplit(copyFirstLayerOrigin, copyOneLayerSize, blockInfo, ComputeTextureCopySubresource(copyFirstLayerOrigin, copyOneLayerSize, blockInfo,
bufferOffsetNextLayer, bytesPerRow, rowsPerImage); bufferOffsetNextLayer, bytesPerRow, rowsPerImage);
} }

View File

@ -27,7 +27,7 @@ namespace dawn_native {
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
struct Texture2DCopySplit { struct TextureCopySubresource {
static constexpr unsigned int kMaxTextureCopyRegions = 2; static constexpr unsigned int kMaxTextureCopyRegions = 2;
struct CopyInfo { struct CopyInfo {
@ -44,12 +44,12 @@ namespace dawn_native { namespace d3d12 {
}; };
struct TextureCopySplits { struct TextureCopySplits {
static constexpr uint32_t kMaxTextureCopySplits = 2; static constexpr uint32_t kMaxTextureCopySubresources = 2;
std::array<Texture2DCopySplit, kMaxTextureCopySplits> copies2D; std::array<TextureCopySubresource, kMaxTextureCopySubresources> copySubresources;
}; };
Texture2DCopySplit ComputeTextureCopySplit(Origin3D origin, TextureCopySubresource ComputeTextureCopySubresource(Origin3D origin,
Extent3D copySize, Extent3D copySize,
const TexelBlockInfo& blockInfo, const TexelBlockInfo& blockInfo,
uint64_t offset, uint64_t offset,

View File

@ -967,7 +967,7 @@ namespace dawn_native { namespace d3d12 {
Extent3D copySize = GetMipLevelPhysicalSize(level); Extent3D copySize = GetMipLevelPhysicalSize(level);
uint32_t rowsPerImage = GetHeight() / blockInfo.height; uint32_t rowsPerImage = GetHeight() / blockInfo.height;
Texture2DCopySplit copySplit = ComputeTextureCopySplit( TextureCopySubresource copySplit = ComputeTextureCopySubresource(
{0, 0, 0}, copySize, blockInfo, uploadHandle.startOffset, bytesPerRow, {0, 0, 0}, copySize, blockInfo, uploadHandle.startOffset, bytesPerRow,
rowsPerImage); rowsPerImage);

View File

@ -143,7 +143,7 @@ namespace dawn_native { namespace d3d12 {
} }
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList, void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
const Texture2DCopySplit& baseCopySplit, const TextureCopySubresource& baseCopySplit,
ID3D12Resource* bufferResource, ID3D12Resource* bufferResource,
uint64_t baseOffset, uint64_t baseOffset,
uint64_t bufferBytesPerRow, uint64_t bufferBytesPerRow,
@ -158,10 +158,10 @@ namespace dawn_native { namespace d3d12 {
const uint64_t offsetBytes = baseCopySplit.offset + baseOffset; 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 TextureCopySubresource::CopyInfo& info = baseCopySplit.copies[i];
// TODO(jiawei.shao@intel.com): pre-compute bufferLocation and sourceRegion as // 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 = const D3D12_TEXTURE_COPY_LOCATION bufferLocation =
ComputeBufferLocationForCopyTextureRegion(texture, bufferResource, info.bufferSize, ComputeBufferLocationForCopyTextureRegion(texture, bufferResource, info.bufferSize,
offsetBytes, bufferBytesPerRow, aspect); offsetBytes, bufferBytesPerRow, aspect);
@ -191,20 +191,21 @@ namespace dawn_native { namespace d3d12 {
const uint64_t bytesPerSlice = bytesPerRow * rowsPerImage; 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 // extra "bytesPerSlice" copy offset compared with the first copy slice. So
// here we use an array bufferOffsetsForNextSlice to record the extra offsets // here we use an array bufferOffsetsForNextSlice to record the extra offsets
// for each copy slice: bufferOffsetsForNextSlice[0] is the extra offset for // 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 // bufferOffsetsForNextSlice[1] is the extra offset for the next copy slice
// that uses copySplits.copies2D[1]. // that uses copySplits.copySubresources[1].
std::array<uint64_t, TextureCopySplits::kMaxTextureCopySplits> bufferOffsetsForNextSlice = { std::array<uint64_t, TextureCopySplits::kMaxTextureCopySubresources>
{0u, 0u}}; bufferOffsetsForNextSlice = {{0u, 0u}};
for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) { for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) {
const uint32_t splitIndex = copyLayer % copySplits.copies2D.size(); 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 uint64_t bufferOffsetForNextSlice = bufferOffsetsForNextSlice[splitIndex];
const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z; const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z;
@ -213,7 +214,8 @@ namespace dawn_native { namespace d3d12 {
bufferOffsetForNextSlice, bytesPerRow, texture, textureCopy.mipLevel, bufferOffsetForNextSlice, bytesPerRow, texture, textureCopy.mipLevel,
copyTextureLayer, aspect); copyTextureLayer, aspect);
bufferOffsetsForNextSlice[splitIndex] += bytesPerSlice * copySplits.copies2D.size(); bufferOffsetsForNextSlice[splitIndex] +=
bytesPerSlice * copySplits.copySubresources.size();
} }
} }
@ -233,7 +235,7 @@ namespace dawn_native { namespace d3d12 {
textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage, true); textureCopy.origin, copySize, blockInfo, offset, bytesPerRow, rowsPerImage, true);
RecordCopyBufferToTextureFromTextureCopySplit( RecordCopyBufferToTextureFromTextureCopySplit(
commandContext->GetCommandList(), copySplits.copies2D[0], bufferResource, 0, commandContext->GetCommandList(), copySplits.copySubresources[0], bufferResource, 0,
bytesPerRow, texture, textureCopy.mipLevel, 0, aspect); bytesPerRow, texture, textureCopy.mipLevel, 0, aspect);
} }
@ -261,7 +263,7 @@ namespace dawn_native { namespace d3d12 {
} }
void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList, void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
const Texture2DCopySplit& baseCopySplit, const TextureCopySubresource& baseCopySplit,
Buffer* buffer, Buffer* buffer,
uint64_t baseOffset, uint64_t baseOffset,
uint64_t bufferBytesPerRow, uint64_t bufferBytesPerRow,
@ -275,10 +277,10 @@ namespace dawn_native { namespace d3d12 {
const uint64_t offset = baseCopySplit.offset + baseOffset; const uint64_t offset = 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 TextureCopySubresource::CopyInfo& info = baseCopySplit.copies[i];
// TODO(jiawei.shao@intel.com): pre-compute bufferLocation and sourceRegion as // 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 = const D3D12_TEXTURE_COPY_LOCATION bufferLocation =
ComputeBufferLocationForCopyTextureRegion(texture, buffer->GetD3D12Resource(), ComputeBufferLocationForCopyTextureRegion(texture, buffer->GetD3D12Resource(),
info.bufferSize, offset, info.bufferSize, offset,
@ -309,19 +311,20 @@ namespace dawn_native { namespace d3d12 {
const uint64_t bytesPerSlice = bufferCopy.bytesPerRow * bufferCopy.rowsPerImage; 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 // extra "bytesPerSlice" copy offset compared with the first copy slice. So
// here we use an array bufferOffsetsForNextSlice to record the extra offsets // here we use an array bufferOffsetsForNextSlice to record the extra offsets
// for each copy slice: bufferOffsetsForNextSlice[0] is the extra offset for // 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 // bufferOffsetsForNextSlice[1] is the extra offset for the next copy slice
// that uses copySplits.copies2D[1]. // that uses copySplits.copySubresources[1].
std::array<uint64_t, TextureCopySplits::kMaxTextureCopySplits> bufferOffsetsForNextSlice = { std::array<uint64_t, TextureCopySplits::kMaxTextureCopySubresources>
{0u, 0u}}; bufferOffsetsForNextSlice = {{0u, 0u}};
for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) { for (uint32_t copyLayer = 0; copyLayer < copySize.depthOrArrayLayers; ++copyLayer) {
const uint32_t splitIndex = copyLayer % copySplits.copies2D.size(); 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 uint64_t bufferOffsetForNextSlice = bufferOffsetsForNextSlice[splitIndex];
const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z; const uint32_t copyTextureLayer = copyLayer + textureCopy.origin.z;
@ -330,7 +333,8 @@ namespace dawn_native { namespace d3d12 {
bufferCopy.bytesPerRow, texture, textureCopy.mipLevel, copyTextureLayer, bufferCopy.bytesPerRow, texture, textureCopy.mipLevel, copyTextureLayer,
textureCopy.aspect); textureCopy.aspect);
bufferOffsetsForNextSlice[splitIndex] += bytesPerSlice * copySplits.copies2D.size(); bufferOffsetsForNextSlice[splitIndex] +=
bytesPerSlice * copySplits.copySubresources.size();
} }
} }
@ -349,8 +353,8 @@ namespace dawn_native { namespace d3d12 {
ComputeTextureCopySplits(textureCopy.origin, copySize, blockInfo, bufferCopy.offset, ComputeTextureCopySplits(textureCopy.origin, copySize, blockInfo, bufferCopy.offset,
bufferCopy.bytesPerRow, bufferCopy.rowsPerImage, true); bufferCopy.bytesPerRow, bufferCopy.rowsPerImage, true);
RecordCopyTextureToBufferFromTextureCopySplit(commandList, copySplits.copies2D[0], buffer, RecordCopyTextureToBufferFromTextureCopySplit(commandList, copySplits.copySubresources[0],
0, bufferCopy.bytesPerRow, texture, buffer, 0, bufferCopy.bytesPerRow, texture,
textureCopy.mipLevel, 0, textureCopy.aspect); textureCopy.mipLevel, 0, textureCopy.aspect);
} }

View File

@ -45,7 +45,7 @@ namespace dawn_native { namespace d3d12 {
bool IsTypeless(DXGI_FORMAT format); bool IsTypeless(DXGI_FORMAT format);
void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList, void RecordCopyBufferToTextureFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
const Texture2DCopySplit& baseCopySplit, const TextureCopySubresource& baseCopySplit,
ID3D12Resource* bufferResource, ID3D12Resource* bufferResource,
uint64_t baseOffset, uint64_t baseOffset,
uint64_t bufferBytesPerRow, uint64_t bufferBytesPerRow,
@ -65,7 +65,7 @@ namespace dawn_native { namespace d3d12 {
Aspect aspect); Aspect aspect);
void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList, void RecordCopyTextureToBufferFromTextureCopySplit(ID3D12GraphicsCommandList* commandList,
const Texture2DCopySplit& baseCopySplit, const TextureCopySubresource& baseCopySplit,
Buffer* buffer, Buffer* buffer,
uint64_t baseOffset, uint64_t baseOffset,
uint64_t bufferBytesPerRow, uint64_t bufferBytesPerRow,

View File

@ -44,7 +44,7 @@ namespace {
}; };
// Check that each copy region fits inside the buffer footprint // Check that each copy region fits inside the buffer footprint
void ValidateFootprints(const Texture2DCopySplit& copySplit) { void ValidateFootprints(const TextureCopySubresource& copySplit) {
for (uint32_t i = 0; i < copySplit.count; ++i) { for (uint32_t i = 0; i < copySplit.count; ++i) {
const auto& copy = copySplit.copies[i]; const auto& copy = copySplit.copies[i];
ASSERT_LE(copy.bufferOffset.x + copy.copySize.width, copy.bufferSize.width); ASSERT_LE(copy.bufferOffset.x + copy.copySize.width, copy.bufferSize.width);
@ -55,7 +55,7 @@ namespace {
} }
// Check that the offset is aligned // Check that the offset is aligned
void ValidateOffset(const Texture2DCopySplit& copySplit) { void ValidateOffset(const TextureCopySubresource& copySplit) {
ASSERT_TRUE(Align(copySplit.offset, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT) == ASSERT_TRUE(Align(copySplit.offset, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT) ==
copySplit.offset); copySplit.offset);
} }
@ -65,7 +65,7 @@ namespace {
} }
// Check that no pair of copy regions intersect each other // Check that no pair of copy regions intersect each other
void ValidateDisjoint(const Texture2DCopySplit& copySplit) { void ValidateDisjoint(const TextureCopySubresource& copySplit) {
for (uint32_t i = 0; i < copySplit.count; ++i) { for (uint32_t i = 0; i < copySplit.count; ++i) {
const auto& a = copySplit.copies[i]; const auto& a = copySplit.copies[i];
for (uint32_t j = i + 1; j < copySplit.count; ++j) { for (uint32_t j = i + 1; j < copySplit.count; ++j) {
@ -86,7 +86,7 @@ namespace {
// Check that the union of the copy regions exactly covers the texture region // Check that the union of the copy regions exactly covers the texture region
void ValidateTextureBounds(const TextureSpec& textureSpec, void ValidateTextureBounds(const TextureSpec& textureSpec,
const Texture2DCopySplit& copySplit) { const TextureCopySubresource& copySplit) {
ASSERT_TRUE(copySplit.count > 0); ASSERT_TRUE(copySplit.count > 0);
uint32_t minX = copySplit.copies[0].textureOffset.x; uint32_t minX = copySplit.copies[0].textureOffset.x;
@ -117,7 +117,8 @@ namespace {
// Validate that the number of pixels copied is exactly equal to the number of pixels in the // Validate that the number of pixels copied is exactly equal to the number of pixels in the
// texture region // texture region
void ValidatePixelCount(const TextureSpec& textureSpec, const Texture2DCopySplit& copySplit) { void ValidatePixelCount(const TextureSpec& textureSpec,
const TextureCopySubresource& copySplit) {
uint32_t count = 0; uint32_t count = 0;
for (uint32_t i = 0; i < copySplit.count; ++i) { for (uint32_t i = 0; i < copySplit.count; ++i) {
const auto& copy = copySplit.copies[i]; const auto& copy = copySplit.copies[i];
@ -129,7 +130,7 @@ namespace {
// Check that every buffer offset is at the correct pixel location // Check that every buffer offset is at the correct pixel location
void ValidateBufferOffset(const TextureSpec& textureSpec, void ValidateBufferOffset(const TextureSpec& textureSpec,
const BufferSpec& bufferSpec, const BufferSpec& bufferSpec,
const Texture2DCopySplit& copySplit) { const TextureCopySubresource& copySplit) {
ASSERT_TRUE(copySplit.count > 0); ASSERT_TRUE(copySplit.count > 0);
uint32_t texelsPerBlock = textureSpec.blockWidth * textureSpec.blockHeight; uint32_t texelsPerBlock = textureSpec.blockWidth * textureSpec.blockHeight;
@ -165,7 +166,7 @@ namespace {
void ValidateCopySplit(const TextureSpec& textureSpec, void ValidateCopySplit(const TextureSpec& textureSpec,
const BufferSpec& bufferSpec, const BufferSpec& bufferSpec,
const Texture2DCopySplit& copySplit) { const TextureCopySubresource& copySplit) {
ValidateFootprints(copySplit); ValidateFootprints(copySplit);
ValidateOffset(copySplit); ValidateOffset(copySplit);
ValidateDisjoint(copySplit); ValidateDisjoint(copySplit);
@ -188,7 +189,7 @@ namespace {
return os; return os;
} }
std::ostream& operator<<(std::ostream& os, const Texture2DCopySplit& copySplit) { std::ostream& operator<<(std::ostream& os, const TextureCopySubresource& copySplit) {
os << "CopySplit" << std::endl; os << "CopySplit" << std::endl;
for (uint32_t i = 0; i < copySplit.count; ++i) { for (uint32_t i = 0; i < copySplit.count; ++i) {
const auto& copy = copySplit.copies[i]; const auto& copy = copySplit.copies[i];
@ -294,14 +295,14 @@ namespace {
class CopySplitTest : public testing::Test { class CopySplitTest : public testing::Test {
protected: protected:
Texture2DCopySplit DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) { TextureCopySubresource DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) {
ASSERT(textureSpec.width % textureSpec.blockWidth == 0 && ASSERT(textureSpec.width % textureSpec.blockWidth == 0 &&
textureSpec.height % textureSpec.blockHeight == 0); textureSpec.height % textureSpec.blockHeight == 0);
dawn_native::TexelBlockInfo blockInfo = {}; dawn_native::TexelBlockInfo blockInfo = {};
blockInfo.width = textureSpec.blockWidth; blockInfo.width = textureSpec.blockWidth;
blockInfo.height = textureSpec.blockHeight; blockInfo.height = textureSpec.blockHeight;
blockInfo.byteSize = textureSpec.texelBlockSizeInBytes; blockInfo.byteSize = textureSpec.texelBlockSizeInBytes;
Texture2DCopySplit copySplit = ComputeTextureCopySplit( TextureCopySubresource copySplit = ComputeTextureCopySubresource(
{textureSpec.x, textureSpec.y, textureSpec.z}, {textureSpec.x, textureSpec.y, textureSpec.z},
{textureSpec.width, textureSpec.height, textureSpec.depth}, blockInfo, {textureSpec.width, textureSpec.height, textureSpec.depth}, blockInfo,
bufferSpec.offset, bufferSpec.bytesPerRow, bufferSpec.rowsPerImage); bufferSpec.offset, bufferSpec.bytesPerRow, bufferSpec.rowsPerImage);
@ -313,7 +314,7 @@ class CopySplitTest : public testing::Test {
TEST_F(CopySplitTest, General) { TEST_F(CopySplitTest, General) {
for (TextureSpec textureSpec : kBaseTextureSpecs) { for (TextureSpec textureSpec : kBaseTextureSpecs) {
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) { for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -333,7 +334,7 @@ TEST_F(CopySplitTest, TextureWidth) {
} }
textureSpec.width = val; textureSpec.width = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) { for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -354,7 +355,7 @@ TEST_F(CopySplitTest, TextureHeight) {
} }
textureSpec.height = val; textureSpec.height = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) { for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -372,7 +373,7 @@ TEST_F(CopySplitTest, TextureX) {
for (uint32_t val : kCheckValues) { for (uint32_t val : kCheckValues) {
textureSpec.x = val; textureSpec.x = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) { for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -390,7 +391,7 @@ TEST_F(CopySplitTest, TextureY) {
for (uint32_t val : kCheckValues) { for (uint32_t val : kCheckValues) {
textureSpec.y = val; textureSpec.y = val;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) { for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -408,7 +409,7 @@ TEST_F(CopySplitTest, TexelSize) {
for (uint32_t texelSize : {4, 8, 16, 32, 64}) { for (uint32_t texelSize : {4, 8, 16, 32, 64}) {
textureSpec.texelBlockSizeInBytes = texelSize; textureSpec.texelBlockSizeInBytes = texelSize;
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) { for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -427,7 +428,7 @@ TEST_F(CopySplitTest, BufferOffset) {
for (uint32_t val : kCheckValues) { for (uint32_t val : kCheckValues) {
bufferSpec.offset = textureSpec.texelBlockSizeInBytes * val; bufferSpec.offset = textureSpec.texelBlockSizeInBytes * val;
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -447,7 +448,7 @@ TEST_F(CopySplitTest, RowPitch) {
for (uint32_t i = 0; i < 5; ++i) { for (uint32_t i = 0; i < 5; ++i) {
bufferSpec.bytesPerRow = baseRowPitch + i * 256; bufferSpec.bytesPerRow = baseRowPitch + i * 256;
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
@ -467,7 +468,7 @@ TEST_F(CopySplitTest, ImageHeight) {
for (uint32_t i = 0; i < 5; ++i) { for (uint32_t i = 0; i < 5; ++i) {
bufferSpec.rowsPerImage = baseImageHeight + i * 256; bufferSpec.rowsPerImage = baseImageHeight + i * 256;
Texture2DCopySplit copySplit = DoTest(textureSpec, bufferSpec); TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
if (HasFatalFailure()) { if (HasFatalFailure()) {
std::ostringstream message; std::ostringstream message;
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec message << "Failed generating splits: " << textureSpec << ", " << bufferSpec