Rename STRIDE_UNDEFINED to COPY_STRIDE_UNDEFINED
Per https://github.com/webgpu-native/webgpu-headers/pull/71 Keeps but deprecates WGPU_STRIDE_UNDEFINED/wgpu::kStrideUndefined. Bug: dawn:520 Change-Id: Ied162ec39454fac3d16a3782c9ed6d2f68c1d41d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/34926 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
fea4c14580
commit
cf820d79ef
|
@ -1731,8 +1731,8 @@
|
|||
"extensible": true,
|
||||
"members": [
|
||||
{"name": "offset", "type": "uint64_t", "default": 0},
|
||||
{"name": "bytes per row", "type": "uint32_t", "default": "WGPU_STRIDE_UNDEFINED"},
|
||||
{"name": "rows per image", "type": "uint32_t", "default": "WGPU_STRIDE_UNDEFINED"}
|
||||
{"name": "bytes per row", "type": "uint32_t", "default": "WGPU_COPY_STRIDE_UNDEFINED"},
|
||||
{"name": "rows per image", "type": "uint32_t", "default": "WGPU_COPY_STRIDE_UNDEFINED"}
|
||||
]
|
||||
},
|
||||
"texture descriptor": {
|
||||
|
|
|
@ -74,7 +74,9 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL)
|
||||
// TODO(crbug.com/520): Remove WGPU_STRIDE_UNDEFINED in favor of WGPU_COPY_STRIDE_UNDEFINED.
|
||||
#define WGPU_STRIDE_UNDEFINED (0xffffffffUL)
|
||||
#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL)
|
||||
|
||||
typedef uint32_t WGPUFlags;
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
namespace wgpu {
|
||||
|
||||
static constexpr uint64_t kWholeSize = WGPU_WHOLE_SIZE;
|
||||
// TODO(crbug.com/520): Remove kStrideUndefined in favor of kCopyStrideUndefined.
|
||||
static constexpr uint32_t kStrideUndefined = WGPU_STRIDE_UNDEFINED;
|
||||
static constexpr uint32_t kCopyStrideUndefined = WGPU_COPY_STRIDE_UNDEFINED;
|
||||
|
||||
{% for type in by_category["enum"] %}
|
||||
enum class {{as_cppType(type.name)}} : uint32_t {
|
||||
|
|
|
@ -416,8 +416,8 @@ namespace dawn_native {
|
|||
//
|
||||
// This means that if the computation of depth * bytesPerImage doesn't overflow, none of the
|
||||
// computations for requiredBytesInCopy will. (and it's not a very pessimizing check)
|
||||
ASSERT(copySize.depth <= 1 ||
|
||||
(bytesPerRow != wgpu::kStrideUndefined && rowsPerImage != wgpu::kStrideUndefined));
|
||||
ASSERT(copySize.depth <= 1 || (bytesPerRow != wgpu::kCopyStrideUndefined &&
|
||||
rowsPerImage != wgpu::kCopyStrideUndefined));
|
||||
uint64_t bytesPerImage = Safe32x32(bytesPerRow, rowsPerImage);
|
||||
if (bytesPerImage > std::numeric_limits<uint64_t>::max() / copySize.depth) {
|
||||
return DAWN_VALIDATION_ERROR("requiredBytesInCopy is too large.");
|
||||
|
@ -425,7 +425,7 @@ namespace dawn_native {
|
|||
|
||||
uint64_t requiredBytesInCopy = bytesPerImage * (copySize.depth - 1);
|
||||
if (heightInBlocks > 0) {
|
||||
ASSERT(heightInBlocks <= 1 || bytesPerRow != wgpu::kStrideUndefined);
|
||||
ASSERT(heightInBlocks <= 1 || bytesPerRow != wgpu::kCopyStrideUndefined);
|
||||
uint64_t bytesInLastImage = Safe32x32(bytesPerRow, heightInBlocks - 1) + bytesInLastRow;
|
||||
requiredBytesInCopy += bytesInLastImage;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ namespace dawn_native {
|
|||
device->EmitDeprecationWarning(
|
||||
"rowsPerImage soon must be non-zero or unspecified if copy depth == 1 (it will "
|
||||
"no longer default to the copy height).");
|
||||
layout.rowsPerImage = wgpu::kStrideUndefined;
|
||||
layout.rowsPerImage = wgpu::kCopyStrideUndefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,12 +478,13 @@ namespace dawn_native {
|
|||
device->EmitDeprecationWarning(
|
||||
"Soon, even if copy height == 1, bytesPerRow must be >= the byte size of each row "
|
||||
"or left unspecified.");
|
||||
layout.bytesPerRow = wgpu::kStrideUndefined;
|
||||
layout.bytesPerRow = wgpu::kCopyStrideUndefined;
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
// Replace wgpu::kStrideUndefined with real values, so backends don't have to think about it.
|
||||
// Replace wgpu::kCopyStrideUndefined with real values, so backends don't have to think about
|
||||
// it.
|
||||
void ApplyDefaultTextureDataLayoutOptions(TextureDataLayout* layout,
|
||||
const TexelBlockInfo& blockInfo,
|
||||
const Extent3D& copyExtent) {
|
||||
|
@ -491,7 +492,7 @@ namespace dawn_native {
|
|||
ASSERT(copyExtent.height % blockInfo.height == 0);
|
||||
uint32_t heightInBlocks = copyExtent.height / blockInfo.height;
|
||||
|
||||
if (layout->bytesPerRow == wgpu::kStrideUndefined) {
|
||||
if (layout->bytesPerRow == wgpu::kCopyStrideUndefined) {
|
||||
ASSERT(copyExtent.width % blockInfo.width == 0);
|
||||
uint32_t widthInBlocks = copyExtent.width / blockInfo.width;
|
||||
uint32_t bytesInLastRow = widthInBlocks * blockInfo.byteSize;
|
||||
|
@ -499,7 +500,7 @@ namespace dawn_native {
|
|||
ASSERT(heightInBlocks <= 1 && copyExtent.depth <= 1);
|
||||
layout->bytesPerRow = Align(bytesInLastRow, kTextureBytesPerRowAlignment);
|
||||
}
|
||||
if (layout->rowsPerImage == wgpu::kStrideUndefined) {
|
||||
if (layout->rowsPerImage == wgpu::kCopyStrideUndefined) {
|
||||
ASSERT(copyExtent.depth <= 1);
|
||||
layout->rowsPerImage = heightInBlocks;
|
||||
}
|
||||
|
@ -512,12 +513,12 @@ namespace dawn_native {
|
|||
ASSERT(copyExtent.height % blockInfo.height == 0);
|
||||
uint32_t heightInBlocks = copyExtent.height / blockInfo.height;
|
||||
|
||||
if (copyExtent.depth > 1 && (layout.bytesPerRow == wgpu::kStrideUndefined ||
|
||||
layout.rowsPerImage == wgpu::kStrideUndefined)) {
|
||||
if (copyExtent.depth > 1 && (layout.bytesPerRow == wgpu::kCopyStrideUndefined ||
|
||||
layout.rowsPerImage == wgpu::kCopyStrideUndefined)) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"If copy depth > 1, bytesPerRow and rowsPerImage must be specified.");
|
||||
}
|
||||
if (heightInBlocks > 1 && layout.bytesPerRow == wgpu::kStrideUndefined) {
|
||||
if (heightInBlocks > 1 && layout.bytesPerRow == wgpu::kCopyStrideUndefined) {
|
||||
return DAWN_VALIDATION_ERROR("If heightInBlocks > 1, bytesPerRow must be specified.");
|
||||
}
|
||||
|
||||
|
@ -528,12 +529,14 @@ namespace dawn_native {
|
|||
std::numeric_limits<uint32_t>::max());
|
||||
uint32_t bytesInLastRow = widthInBlocks * blockInfo.byteSize;
|
||||
|
||||
// These != wgpu::kStrideUndefined checks are technically redundant with the > checks, but
|
||||
// they should get optimized out.
|
||||
if (layout.bytesPerRow != wgpu::kStrideUndefined && bytesInLastRow > layout.bytesPerRow) {
|
||||
// These != wgpu::kCopyStrideUndefined checks are technically redundant with the > checks,
|
||||
// but they should get optimized out.
|
||||
if (layout.bytesPerRow != wgpu::kCopyStrideUndefined &&
|
||||
bytesInLastRow > layout.bytesPerRow) {
|
||||
return DAWN_VALIDATION_ERROR("The byte size of each row must be <= bytesPerRow.");
|
||||
}
|
||||
if (layout.rowsPerImage != wgpu::kStrideUndefined && heightInBlocks > layout.rowsPerImage) {
|
||||
if (layout.rowsPerImage != wgpu::kCopyStrideUndefined &&
|
||||
heightInBlocks > layout.rowsPerImage) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"The height of each image, in blocks, must be <= rowsPerImage.");
|
||||
}
|
||||
|
@ -559,7 +562,7 @@ namespace dawn_native {
|
|||
MaybeError ValidateBufferCopyView(DeviceBase const* device,
|
||||
const BufferCopyView& bufferCopyView) {
|
||||
DAWN_TRY(device->ValidateObject(bufferCopyView.buffer));
|
||||
if (bufferCopyView.layout.bytesPerRow != wgpu::kStrideUndefined) {
|
||||
if (bufferCopyView.layout.bytesPerRow != wgpu::kCopyStrideUndefined) {
|
||||
if (bufferCopyView.layout.bytesPerRow % kTextureBytesPerRowAlignment != 0) {
|
||||
return DAWN_VALIDATION_ERROR("bytesPerRow must be a multiple of 256");
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ struct CopyConfig {
|
|||
uint32_t viewMipmapLevel = 0;
|
||||
uint32_t bufferOffset = 0;
|
||||
uint32_t bytesPerRowAlignment = kTextureBytesPerRowAlignment;
|
||||
uint32_t rowsPerImage = wgpu::kStrideUndefined;
|
||||
uint32_t rowsPerImage = wgpu::kCopyStrideUndefined;
|
||||
};
|
||||
|
||||
class CompressedTextureBCFormatTest : public DawnTest {
|
||||
|
@ -60,7 +60,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
|
|||
utils::GetTexelBlockSizeInBytes(copyConfig.textureDescriptor.format);
|
||||
}
|
||||
uint32_t copyRowsPerImage = copyConfig.rowsPerImage;
|
||||
if (copyRowsPerImage == wgpu::kStrideUndefined) {
|
||||
if (copyRowsPerImage == wgpu::kCopyStrideUndefined) {
|
||||
copyRowsPerImage = copyHeightInBlock;
|
||||
}
|
||||
uint32_t copyBytesPerImage = copyBytesPerRow * copyRowsPerImage;
|
||||
|
|
|
@ -61,7 +61,7 @@ class CopyTests : public DawnTest {
|
|||
|
||||
static BufferSpec MinimumBufferSpec(uint32_t width, uint32_t height, uint32_t depth = 1) {
|
||||
return MinimumBufferSpec({width, height, depth}, kStrideComputeDefault,
|
||||
depth == 1 ? wgpu::kStrideUndefined : kStrideComputeDefault);
|
||||
depth == 1 ? wgpu::kCopyStrideUndefined : kStrideComputeDefault);
|
||||
}
|
||||
|
||||
static BufferSpec MinimumBufferSpec(wgpu::Extent3D copyExtent,
|
||||
|
@ -722,7 +722,7 @@ TEST_P(CopyTests_T2B, BytesPerRowWithOneRowCopy) {
|
|||
EXPECT_DEPRECATION_WARNING(DoTest(textureSpec, bufferSpec, {5, 1, 1}));
|
||||
|
||||
// bytesPerRow undefined
|
||||
bufferSpec.bytesPerRow = wgpu::kStrideUndefined;
|
||||
bufferSpec.bytesPerRow = wgpu::kCopyStrideUndefined;
|
||||
DoTest(textureSpec, bufferSpec, {5, 1, 1});
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,8 @@ TEST_P(CopyTests_T2B, StrideSpecialCases) {
|
|||
// bytesPerRow undefined
|
||||
for (const wgpu::Extent3D copyExtent :
|
||||
{wgpu::Extent3D{2, 1, 1}, {2, 0, 1}, {2, 1, 0}, {2, 0, 0}}) {
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, wgpu::kStrideUndefined, 2), copyExtent);
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, wgpu::kCopyStrideUndefined, 2),
|
||||
copyExtent);
|
||||
}
|
||||
|
||||
// rowsPerImage 0
|
||||
|
@ -761,7 +762,8 @@ TEST_P(CopyTests_T2B, StrideSpecialCases) {
|
|||
|
||||
// rowsPerImage undefined
|
||||
for (const wgpu::Extent3D copyExtent : {wgpu::Extent3D{2, 2, 1}, {2, 2, 0}}) {
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, 256, wgpu::kStrideUndefined), copyExtent);
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, 256, wgpu::kCopyStrideUndefined),
|
||||
copyExtent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1209,7 +1211,7 @@ TEST_P(CopyTests_B2T, BytesPerRowWithOneRowCopy) {
|
|||
EXPECT_DEPRECATION_WARNING(DoTest(textureSpec, bufferSpec, {5, 1, 1}));
|
||||
|
||||
// bytesPerRow undefined
|
||||
bufferSpec.bytesPerRow = wgpu::kStrideUndefined;
|
||||
bufferSpec.bytesPerRow = wgpu::kCopyStrideUndefined;
|
||||
DoTest(textureSpec, bufferSpec, {5, 1, 1});
|
||||
}
|
||||
|
||||
|
@ -1237,7 +1239,8 @@ TEST_P(CopyTests_B2T, StrideSpecialCases) {
|
|||
// bytesPerRow undefined
|
||||
for (const wgpu::Extent3D copyExtent :
|
||||
{wgpu::Extent3D{2, 1, 1}, {2, 0, 1}, {2, 1, 0}, {2, 0, 0}}) {
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, wgpu::kStrideUndefined, 2), copyExtent);
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, wgpu::kCopyStrideUndefined, 2),
|
||||
copyExtent);
|
||||
}
|
||||
|
||||
// rowsPerImage 0
|
||||
|
@ -1248,7 +1251,8 @@ TEST_P(CopyTests_B2T, StrideSpecialCases) {
|
|||
|
||||
// rowsPerImage undefined
|
||||
for (const wgpu::Extent3D copyExtent : {wgpu::Extent3D{2, 2, 1}, {2, 2, 0}}) {
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, 256, wgpu::kStrideUndefined), copyExtent);
|
||||
DoTest(textureSpec, MinimumBufferSpec(copyExtent, 256, wgpu::kCopyStrideUndefined),
|
||||
copyExtent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ class QueueWriteTextureTests : public DawnTest {
|
|||
textureSpec.textureSize.height >> textureSpec.level,
|
||||
textureSpec.textureSize.depth};
|
||||
uint32_t bytesPerRow = dataSpec.bytesPerRow;
|
||||
if (bytesPerRow == wgpu::kStrideUndefined) {
|
||||
if (bytesPerRow == wgpu::kCopyStrideUndefined) {
|
||||
bytesPerRow = mipSize.width * bytesPerTexel;
|
||||
}
|
||||
uint32_t alignedBytesPerRow = Align(bytesPerRow, bytesPerTexel);
|
||||
|
@ -526,7 +526,7 @@ TEST_P(QueueWriteTextureTests, BytesPerRowWithOneRowCopy) {
|
|||
EXPECT_DEPRECATION_WARNING(DoTest(textureSpec, dataSpec, copyExtent));
|
||||
|
||||
// bytesPerRow undefined
|
||||
dataSpec.bytesPerRow = wgpu::kStrideUndefined;
|
||||
dataSpec.bytesPerRow = wgpu::kCopyStrideUndefined;
|
||||
DoTest(textureSpec, dataSpec, copyExtent);
|
||||
}
|
||||
|
||||
|
@ -586,7 +586,7 @@ TEST_P(QueueWriteTextureTests, StrideSpecialCases) {
|
|||
// bytesPerRow undefined
|
||||
for (const wgpu::Extent3D copyExtent :
|
||||
{wgpu::Extent3D{2, 1, 1}, {2, 0, 1}, {2, 1, 0}, {2, 0, 0}}) {
|
||||
DoTest(textureSpec, MinimumDataSpec(copyExtent, wgpu::kStrideUndefined, 2), copyExtent);
|
||||
DoTest(textureSpec, MinimumDataSpec(copyExtent, wgpu::kCopyStrideUndefined, 2), copyExtent);
|
||||
}
|
||||
|
||||
// rowsPerImage 0
|
||||
|
@ -597,7 +597,8 @@ TEST_P(QueueWriteTextureTests, StrideSpecialCases) {
|
|||
|
||||
// rowsPerImage undefined
|
||||
for (const wgpu::Extent3D copyExtent : {wgpu::Extent3D{2, 2, 1}, {2, 2, 0}}) {
|
||||
DoTest(textureSpec, MinimumDataSpec(copyExtent, 256, wgpu::kStrideUndefined), copyExtent);
|
||||
DoTest(textureSpec, MinimumDataSpec(copyExtent, 256, wgpu::kCopyStrideUndefined),
|
||||
copyExtent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ TEST_F(CopyCommandTest_B2T, Success) {
|
|||
TestB2TCopy(utils::Expectation::Success, source, bufferSize - 4, 256, 1, destination, 0,
|
||||
{0, 0, 0}, {1, 1, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, bufferSize - 4, 256,
|
||||
wgpu::kStrideUndefined, destination, 0, {0, 0, 0}, {1, 1, 1});
|
||||
wgpu::kCopyStrideUndefined, destination, 0, {0, 0, 0}, {1, 1, 1});
|
||||
}
|
||||
|
||||
// Copies with a 256-byte aligned bytes per row but unaligned texture region
|
||||
|
@ -397,15 +397,15 @@ TEST_F(CopyCommandTest_B2T, Success) {
|
|||
|
||||
// bytesPerRow is undefined
|
||||
{
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kStrideUndefined, 2, destination,
|
||||
0, {0, 0, 0}, {1, 1, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kStrideUndefined, 2, destination,
|
||||
0, {0, 0, 0}, {3, 1, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kCopyStrideUndefined, 2,
|
||||
destination, 0, {0, 0, 0}, {1, 1, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kCopyStrideUndefined, 2,
|
||||
destination, 0, {0, 0, 0}, {3, 1, 1});
|
||||
// Fail because height or depth is greater than 1:
|
||||
TestB2TCopy(utils::Expectation::Failure, source, 0, wgpu::kStrideUndefined, 2, destination,
|
||||
0, {0, 0, 0}, {1, 2, 1});
|
||||
TestB2TCopy(utils::Expectation::Failure, source, 0, wgpu::kStrideUndefined, 2, destination,
|
||||
0, {0, 0, 0}, {1, 1, 2});
|
||||
TestB2TCopy(utils::Expectation::Failure, source, 0, wgpu::kCopyStrideUndefined, 2,
|
||||
destination, 0, {0, 0, 0}, {1, 2, 1});
|
||||
TestB2TCopy(utils::Expectation::Failure, source, 0, wgpu::kCopyStrideUndefined, 2,
|
||||
destination, 0, {0, 0, 0}, {1, 1, 2});
|
||||
}
|
||||
|
||||
// Empty copies are valid
|
||||
|
@ -413,23 +413,23 @@ TEST_F(CopyCommandTest_B2T, Success) {
|
|||
// An empty copy
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, 0, 0, destination, 0, {0, 0, 0},
|
||||
{0, 0, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kStrideUndefined, 0, destination,
|
||||
0, {0, 0, 0}, {0, 0, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kCopyStrideUndefined, 0,
|
||||
destination, 0, {0, 0, 0}, {0, 0, 1});
|
||||
// An empty copy with depth = 0
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, 0, 0, destination, 0, {0, 0, 0},
|
||||
{0, 0, 0});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kStrideUndefined, 0, destination,
|
||||
0, {0, 0, 0}, {0, 0, 0});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kCopyStrideUndefined, 0,
|
||||
destination, 0, {0, 0, 0}, {0, 0, 0});
|
||||
// An empty copy touching the end of the buffer
|
||||
TestB2TCopy(utils::Expectation::Success, source, bufferSize, 0, 0, destination, 0,
|
||||
{0, 0, 0}, {0, 0, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, bufferSize, wgpu::kStrideUndefined, 0,
|
||||
TestB2TCopy(utils::Expectation::Success, source, bufferSize, wgpu::kCopyStrideUndefined, 0,
|
||||
destination, 0, {0, 0, 0}, {0, 0, 1});
|
||||
// An empty copy touching the side of the texture
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, 0, 0, destination, 0, {16, 16, 0},
|
||||
{0, 0, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kStrideUndefined, 0, destination,
|
||||
0, {16, 16, 0}, {0, 0, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, wgpu::kCopyStrideUndefined, 0,
|
||||
destination, 0, {16, 16, 0}, {0, 0, 1});
|
||||
|
||||
// An empty copy with depth = 1 and bytesPerRow > 0
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, kTextureBytesPerRowAlignment, 0,
|
||||
|
@ -599,11 +599,11 @@ TEST_F(CopyCommandTest_B2T, RowsPerImageConstraints) {
|
|||
destination, 0, {0, 0, 0}, {4, 4, 1}));
|
||||
|
||||
// rowsPerImage is undefined
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, 256, wgpu::kStrideUndefined, destination, 0,
|
||||
{0, 0, 0}, {4, 4, 1});
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, 256, wgpu::kCopyStrideUndefined,
|
||||
destination, 0, {0, 0, 0}, {4, 4, 1});
|
||||
// Fail because depth > 1:
|
||||
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, wgpu::kStrideUndefined, destination, 0,
|
||||
{0, 0, 0}, {4, 4, 2});
|
||||
TestB2TCopy(utils::Expectation::Failure, source, 0, 256, wgpu::kCopyStrideUndefined,
|
||||
destination, 0, {0, 0, 0}, {4, 4, 2});
|
||||
|
||||
// rowsPerImage is equal to copy height (Valid)
|
||||
TestB2TCopy(utils::Expectation::Success, source, 0, 256, 4, destination, 0, {0, 0, 0},
|
||||
|
@ -942,7 +942,7 @@ TEST_F(CopyCommandTest_T2B, Success) {
|
|||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, bufferSize - 4,
|
||||
256, 1, {1, 1, 1});
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, bufferSize - 4,
|
||||
256, wgpu::kStrideUndefined, {1, 1, 1});
|
||||
256, wgpu::kCopyStrideUndefined, {1, 1, 1});
|
||||
}
|
||||
|
||||
// Copies with a 256-byte aligned bytes per row but unaligned texture region
|
||||
|
@ -961,14 +961,14 @@ TEST_F(CopyCommandTest_T2B, Success) {
|
|||
// bytesPerRow is undefined
|
||||
{
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
|
||||
wgpu::kStrideUndefined, 2, {1, 1, 1});
|
||||
wgpu::kCopyStrideUndefined, 2, {1, 1, 1});
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
|
||||
wgpu::kStrideUndefined, 2, {3, 1, 1});
|
||||
wgpu::kCopyStrideUndefined, 2, {3, 1, 1});
|
||||
// Fail because height or depth is greater than 1:
|
||||
TestT2BCopy(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
|
||||
wgpu::kStrideUndefined, 2, {1, 2, 1});
|
||||
wgpu::kCopyStrideUndefined, 2, {1, 2, 1});
|
||||
TestT2BCopy(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0,
|
||||
wgpu::kStrideUndefined, 2, {1, 1, 2});
|
||||
wgpu::kCopyStrideUndefined, 2, {1, 1, 2});
|
||||
}
|
||||
|
||||
// Empty copies are valid
|
||||
|
@ -977,22 +977,22 @@ TEST_F(CopyCommandTest_T2B, Success) {
|
|||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, 0, 0,
|
||||
{0, 0, 1});
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
|
||||
wgpu::kStrideUndefined, 0, {0, 0, 1});
|
||||
wgpu::kCopyStrideUndefined, 0, {0, 0, 1});
|
||||
// An empty copy with depth = 0
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, 0, 0,
|
||||
{0, 0, 0});
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
|
||||
wgpu::kStrideUndefined, 0, {0, 0, 0});
|
||||
wgpu::kCopyStrideUndefined, 0, {0, 0, 0});
|
||||
// An empty copy touching the end of the buffer
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, bufferSize, 0,
|
||||
0, {0, 0, 1});
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, bufferSize,
|
||||
wgpu::kStrideUndefined, 0, {0, 0, 1});
|
||||
wgpu::kCopyStrideUndefined, 0, {0, 0, 1});
|
||||
// An empty copy touching the side of the texture
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {16, 16, 0}, destination, 0, 0, 0,
|
||||
{0, 0, 1});
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {16, 16, 0}, destination, 0,
|
||||
wgpu::kStrideUndefined, 0, {0, 0, 1});
|
||||
wgpu::kCopyStrideUndefined, 0, {0, 0, 1});
|
||||
|
||||
// An empty copy with depth = 1 and bytesPerRow > 0
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0,
|
||||
|
@ -1191,10 +1191,10 @@ TEST_F(CopyCommandTest_T2B, RowsPerImageConstraints) {
|
|||
|
||||
// rowsPerImage is undefined
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, 256,
|
||||
wgpu::kStrideUndefined, {4, 4, 1});
|
||||
wgpu::kCopyStrideUndefined, {4, 4, 1});
|
||||
// Fail because depth > 1:
|
||||
TestT2BCopy(utils::Expectation::Failure, source, 0, {0, 0, 0}, destination, 0, 256,
|
||||
wgpu::kStrideUndefined, {4, 4, 2});
|
||||
wgpu::kCopyStrideUndefined, {4, 4, 2});
|
||||
|
||||
// rowsPerImage is equal to copy height (Valid)
|
||||
TestT2BCopy(utils::Expectation::Success, source, 0, {0, 0, 0}, destination, 0, 256, 4,
|
||||
|
|
|
@ -106,8 +106,8 @@ namespace {
|
|||
TestWriteTexture(dataSize, 0, 256, 4, destination, 2, {0, 0, 0}, {4, 4, 1});
|
||||
// Copy with a data offset
|
||||
TestWriteTexture(dataSize, dataSize - 4, 256, 1, destination, 0, {0, 0, 0}, {1, 1, 1});
|
||||
TestWriteTexture(dataSize, dataSize - 4, 256, wgpu::kStrideUndefined, destination, 0,
|
||||
{0, 0, 0}, {1, 1, 1});
|
||||
TestWriteTexture(dataSize, dataSize - 4, 256, wgpu::kCopyStrideUndefined, destination,
|
||||
0, {0, 0, 0}, {1, 1, 1});
|
||||
}
|
||||
|
||||
// Copies with a 256-byte aligned bytes per row but unaligned texture region
|
||||
|
@ -124,27 +124,27 @@ namespace {
|
|||
{
|
||||
// An empty copy
|
||||
TestWriteTexture(dataSize, 0, 0, 0, destination, 0, {0, 0, 0}, {0, 0, 1});
|
||||
TestWriteTexture(dataSize, 0, 0, wgpu::kStrideUndefined, destination, 0, {0, 0, 0},
|
||||
TestWriteTexture(dataSize, 0, 0, wgpu::kCopyStrideUndefined, destination, 0, {0, 0, 0},
|
||||
{0, 0, 1});
|
||||
// An empty copy with depth = 0
|
||||
TestWriteTexture(dataSize, 0, 0, 0, destination, 0, {0, 0, 0}, {0, 0, 0});
|
||||
TestWriteTexture(dataSize, 0, 0, wgpu::kStrideUndefined, destination, 0, {0, 0, 0},
|
||||
TestWriteTexture(dataSize, 0, 0, wgpu::kCopyStrideUndefined, destination, 0, {0, 0, 0},
|
||||
{0, 0, 0});
|
||||
// An empty copy touching the end of the data
|
||||
TestWriteTexture(dataSize, dataSize, 0, 0, destination, 0, {0, 0, 0}, {0, 0, 1});
|
||||
TestWriteTexture(dataSize, dataSize, 0, wgpu::kStrideUndefined, destination, 0,
|
||||
TestWriteTexture(dataSize, dataSize, 0, wgpu::kCopyStrideUndefined, destination, 0,
|
||||
{0, 0, 0}, {0, 0, 1});
|
||||
// An empty copy touching the side of the texture
|
||||
TestWriteTexture(dataSize, 0, 0, 0, destination, 0, {16, 16, 0}, {0, 0, 1});
|
||||
TestWriteTexture(dataSize, 0, 0, wgpu::kStrideUndefined, destination, 0, {16, 16, 0},
|
||||
{0, 0, 1});
|
||||
TestWriteTexture(dataSize, 0, 0, wgpu::kCopyStrideUndefined, destination, 0,
|
||||
{16, 16, 0}, {0, 0, 1});
|
||||
// An empty copy with depth = 1 and bytesPerRow > 0
|
||||
TestWriteTexture(dataSize, 0, 256, 0, destination, 0, {0, 0, 0}, {0, 0, 1});
|
||||
TestWriteTexture(dataSize, 0, 256, wgpu::kStrideUndefined, destination, 0, {0, 0, 0},
|
||||
{0, 0, 1});
|
||||
TestWriteTexture(dataSize, 0, 256, wgpu::kCopyStrideUndefined, destination, 0,
|
||||
{0, 0, 0}, {0, 0, 1});
|
||||
// An empty copy with height > 0, depth = 0, bytesPerRow > 0 and rowsPerImage > 0
|
||||
TestWriteTexture(dataSize, 0, 256, wgpu::kStrideUndefined, destination, 0, {0, 0, 0},
|
||||
{0, 1, 0});
|
||||
TestWriteTexture(dataSize, 0, 256, wgpu::kCopyStrideUndefined, destination, 0,
|
||||
{0, 0, 0}, {0, 1, 0});
|
||||
TestWriteTexture(dataSize, 0, 256, 1, destination, 0, {0, 0, 0}, {0, 1, 0});
|
||||
TestWriteTexture(dataSize, 0, 256, 16, destination, 0, {0, 0, 0}, {0, 1, 0});
|
||||
}
|
||||
|
@ -237,27 +237,27 @@ namespace {
|
|||
wgpu::Texture destination = Create2DTexture({3, 7, 2}, 1, wgpu::TextureFormat::RGBA8Unorm,
|
||||
wgpu::TextureUsage::CopyDst);
|
||||
|
||||
// bytesPerRow = 0 or wgpu::kStrideUndefined
|
||||
// bytesPerRow = 0 or wgpu::kCopyStrideUndefined
|
||||
{
|
||||
// copyHeight > 1
|
||||
ASSERT_DEVICE_ERROR(
|
||||
TestWriteTexture(128, 0, 0, 7, destination, 0, {0, 0, 0}, {3, 7, 1}));
|
||||
TestWriteTexture(128, 0, 0, 7, destination, 0, {0, 0, 0}, {0, 7, 1});
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(128, 0, wgpu::kStrideUndefined, 7, destination, 0,
|
||||
{0, 0, 0}, {0, 7, 1}));
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(128, 0, wgpu::kCopyStrideUndefined, 7, destination,
|
||||
0, {0, 0, 0}, {0, 7, 1}));
|
||||
|
||||
// copyDepth > 1
|
||||
ASSERT_DEVICE_ERROR(
|
||||
TestWriteTexture(128, 0, 0, 1, destination, 0, {0, 0, 0}, {3, 1, 2}));
|
||||
TestWriteTexture(128, 0, 0, 1, destination, 0, {0, 0, 0}, {0, 1, 2});
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(128, 0, wgpu::kStrideUndefined, 1, destination, 0,
|
||||
{0, 0, 0}, {0, 1, 2}));
|
||||
ASSERT_DEVICE_ERROR(TestWriteTexture(128, 0, wgpu::kCopyStrideUndefined, 1, destination,
|
||||
0, {0, 0, 0}, {0, 1, 2}));
|
||||
|
||||
// copyHeight = 1 and copyDepth = 1
|
||||
// TODO(crbug.com/dawn/520): Change to ASSERT_DEVICE_ERROR.
|
||||
EXPECT_DEPRECATION_WARNING(
|
||||
TestWriteTexture(128, 0, 0, 1, destination, 0, {0, 0, 0}, {3, 1, 1}));
|
||||
TestWriteTexture(128, 0, wgpu::kStrideUndefined, 1, destination, 0, {0, 0, 0},
|
||||
TestWriteTexture(128, 0, wgpu::kCopyStrideUndefined, 1, destination, 0, {0, 0, 0},
|
||||
{3, 1, 1});
|
||||
}
|
||||
|
||||
|
@ -298,8 +298,8 @@ namespace {
|
|||
wgpu::Texture destination = Create2DTexture({16, 16, 2}, 1, wgpu::TextureFormat::RGBA8Unorm,
|
||||
wgpu::TextureUsage::CopyDst);
|
||||
|
||||
// rowsPerImage is wgpu::kStrideUndefined
|
||||
TestWriteTexture(dataSize, 0, 256, wgpu::kStrideUndefined, destination, 0, {0, 0, 0},
|
||||
// rowsPerImage is wgpu::kCopyStrideUndefined
|
||||
TestWriteTexture(dataSize, 0, 256, wgpu::kCopyStrideUndefined, destination, 0, {0, 0, 0},
|
||||
{4, 4, 1});
|
||||
|
||||
// rowsPerImage is equal to copy height (Valid)
|
||||
|
@ -532,7 +532,7 @@ namespace {
|
|||
{4, 4, 1}, 1, wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
wgpu::TextureUsage::CopyDst);
|
||||
|
||||
TestWriteTexture(dataSize, 0, bytesPerRow, wgpu::kStrideUndefined, destination, 0,
|
||||
TestWriteTexture(dataSize, 0, bytesPerRow, wgpu::kCopyStrideUndefined, destination, 0,
|
||||
{0, 0, 0}, {4, 4, 1}, wgpu::TextureAspect::StencilOnly);
|
||||
|
||||
// And that it fails if the buffer is one byte too small
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace utils {
|
|||
|
||||
layout.bytesPerRow = GetMinimumBytesPerRow(format, layout.mipSize.width);
|
||||
|
||||
if (rowsPerImage == wgpu::kStrideUndefined) {
|
||||
if (rowsPerImage == wgpu::kCopyStrideUndefined) {
|
||||
rowsPerImage = layout.mipSize.height;
|
||||
}
|
||||
layout.rowsPerImage = rowsPerImage;
|
||||
|
@ -125,7 +125,7 @@ namespace utils {
|
|||
|
||||
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
|
||||
wgpu::TextureDataLayout textureDataLayout =
|
||||
utils::CreateTextureDataLayout(0, wgpu::kStrideUndefined);
|
||||
utils::CreateTextureDataLayout(0, wgpu::kCopyStrideUndefined);
|
||||
wgpu::Extent3D copyExtent = {1, 1, 1};
|
||||
|
||||
// WriteTexture with exactly 1 byte of data.
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace utils {
|
|||
wgpu::TextureFormat format,
|
||||
wgpu::Extent3D textureSizeAtLevel0,
|
||||
uint32_t mipmapLevel,
|
||||
uint32_t rowsPerImage = wgpu::kStrideUndefined);
|
||||
uint32_t rowsPerImage = wgpu::kCopyStrideUndefined);
|
||||
|
||||
uint64_t RequiredBytesInCopy(uint64_t bytesPerRow,
|
||||
uint64_t rowsPerImage,
|
||||
|
|
|
@ -53,15 +53,16 @@ namespace utils {
|
|||
wgpu::BufferCopyView CreateBufferCopyView(wgpu::Buffer buffer,
|
||||
uint64_t offset,
|
||||
uint32_t bytesPerRow,
|
||||
uint32_t rowsPerImage = wgpu::kStrideUndefined);
|
||||
uint32_t rowsPerImage = wgpu::kCopyStrideUndefined);
|
||||
wgpu::TextureCopyView CreateTextureCopyView(
|
||||
wgpu::Texture texture,
|
||||
uint32_t level,
|
||||
wgpu::Origin3D origin,
|
||||
wgpu::TextureAspect aspect = wgpu::TextureAspect::All);
|
||||
wgpu::TextureDataLayout CreateTextureDataLayout(uint64_t offset,
|
||||
wgpu::TextureDataLayout CreateTextureDataLayout(
|
||||
uint64_t offset,
|
||||
uint32_t bytesPerRow,
|
||||
uint32_t rowsPerImage = wgpu::kStrideUndefined);
|
||||
uint32_t rowsPerImage = wgpu::kCopyStrideUndefined);
|
||||
|
||||
struct ComboRenderPassDescriptor : public wgpu::RenderPassDescriptor {
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue