Remove parameter layer and use origin.z in MACROs

This change removes layer and use origin.z in MACROs
EXPECT_TEXTURE_FLOAT_EQ and EXPECT_TEXTURE_EQ.

It also removes parameter layer in MACROs' implementation
functions AddTextureExpectation and AddTextureExpectationImpl
and use origin.z instead in these functions.

BUG: dawn:747

Change-Id: I0103524074c6c250fa2f85bf9c3abda8c8cd2197
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He 2021-04-07 16:57:11 +00:00 committed by Commit Bot service account
parent 4c4cec93b3
commit ff55b2f217
8 changed files with 36 additions and 43 deletions

View File

@ -1005,7 +1005,6 @@ std::ostringstream& DawnTestBase::AddTextureExpectationImpl(const char* file,
wgpu::Origin3D origin,
wgpu::Extent3D extent,
uint32_t level,
uint32_t layer,
wgpu::TextureAspect aspect,
uint32_t dataSize,
uint32_t bytesPerRow) {
@ -1026,8 +1025,8 @@ std::ostringstream& DawnTestBase::AddTextureExpectationImpl(const char* file,
// We need to enqueue the copy immediately because by the time we resolve the expectation,
// the texture might have been modified.
wgpu::ImageCopyTexture imageCopyTexture = utils::CreateImageCopyTexture(
texture, level, {origin.x, origin.y, origin.z + layer}, aspect);
wgpu::ImageCopyTexture imageCopyTexture =
utils::CreateImageCopyTexture(texture, level, origin, aspect);
wgpu::ImageCopyBuffer imageCopyBuffer =
utils::CreateImageCopyBuffer(readback.buffer, readback.offset, bytesPerRow, rowsPerImage);

View File

@ -74,9 +74,9 @@
#define EXPECT_PIXEL_FLOAT_EQ(expected, texture, x, y) \
AddTextureExpectation(__FILE__, __LINE__, expected, texture, {x, y})
#define EXPECT_TEXTURE_FLOAT_EQ(expected, texture, x, y, width, height, level, layer) \
AddTextureExpectation(__FILE__, __LINE__, expected, texture, {x, y}, {width, height}, level, \
layer)
#define EXPECT_TEXTURE_FLOAT_EQ(expected, texture, origin, extent, level) \
AddTextureExpectation(__FILE__, __LINE__, expected, texture, utils::MakeOrigin origin, \
utils::MakeExtent extent, level)
#define EXPECT_PIXEL_RGBA8_BETWEEN(color0, color1, texture, x, y) \
AddTextureBetweenColorsExpectation(__FILE__, __LINE__, color0, color1, texture, x, y)
@ -327,14 +327,13 @@ class DawnTestBase {
wgpu::Origin3D origin,
wgpu::Extent3D extent,
uint32_t level = 0,
uint32_t layer = 0,
wgpu::TextureAspect aspect = wgpu::TextureAspect::All,
uint32_t bytesPerRow = 0) {
return AddTextureExpectationImpl(
file, line,
new detail::ExpectEq<T>(expectedData,
extent.width * extent.height * extent.depthOrArrayLayers),
texture, origin, extent, level, layer, aspect, sizeof(T), bytesPerRow);
texture, origin, extent, level, aspect, sizeof(T), bytesPerRow);
}
template <typename T>
@ -344,12 +343,10 @@ class DawnTestBase {
const wgpu::Texture& texture,
wgpu::Origin3D origin,
uint32_t level = 0,
uint32_t layer = 0,
wgpu::TextureAspect aspect = wgpu::TextureAspect::All,
uint32_t bytesPerRow = 0) {
return AddTextureExpectationImpl(file, line, new detail::ExpectEq<T>(expectedData), texture,
origin, {1, 1}, level, layer, aspect, sizeof(T),
bytesPerRow);
origin, {1, 1}, level, aspect, sizeof(T), bytesPerRow);
}
template <typename T>
@ -362,12 +359,11 @@ class DawnTestBase {
uint32_t x,
uint32_t y,
uint32_t level = 0,
uint32_t layer = 0,
wgpu::TextureAspect aspect = wgpu::TextureAspect::All,
uint32_t bytesPerRow = 0) {
return AddTextureExpectationImpl(
file, line, new detail::ExpectBetweenColors<T>(color0, color1), texture, {x, y}, {1, 1},
level, layer, aspect, sizeof(T), bytesPerRow);
level, aspect, sizeof(T), bytesPerRow);
}
void WaitABit();
@ -401,7 +397,6 @@ class DawnTestBase {
wgpu::Origin3D origin,
wgpu::Extent3D extent,
uint32_t level,
uint32_t layer,
wgpu::TextureAspect aspect,
uint32_t dataSize,
uint32_t bytesPerRow);

View File

@ -162,7 +162,7 @@ TEST_P(DepthBiasTests, PositiveBiasOnFloat) {
0.5, 0.5, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -182,7 +182,7 @@ TEST_P(DepthBiasTests, PositiveBiasOnFloatWithClamp) {
0.375, 0.375, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -204,7 +204,7 @@ TEST_P(DepthBiasTests, NegativeBiasOnFloat) {
0.0, 0.0, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -224,7 +224,7 @@ TEST_P(DepthBiasTests, NegativeBiasOnFloatWithClamp) {
0.125, 0.125, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -243,7 +243,7 @@ TEST_P(DepthBiasTests, PositiveInfinitySlopeBiasOnFloat) {
1.0, 1.0, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -262,7 +262,7 @@ TEST_P(DepthBiasTests, NegativeInfinityBiasOnFloat) {
0.0, 0.0, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -277,7 +277,7 @@ TEST_P(DepthBiasTests, NoBiasTiltedXOnFloat) {
0.125, 0.125, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -292,7 +292,7 @@ TEST_P(DepthBiasTests, PositiveSlopeBiasOnFloat) {
0.375, 0.375, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -307,7 +307,7 @@ TEST_P(DepthBiasTests, NegativeHalfSlopeBiasOnFloat) {
0.0, 0.0, //
};
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0, 0,
EXPECT_TEXTURE_EQ(expected.data(), mDepthTexture, {0, 0}, {kRTSize, kRTSize}, 0,
wgpu::TextureAspect::DepthOnly);
}

View File

@ -300,7 +300,7 @@ class DepthStencilCopyTests : public DawnTest {
queue.Submit(1, &commands);
std::vector<uint32_t> colorData(width * height, 1u);
EXPECT_TEXTURE_EQ(colorData.data(), colorTexture, {0, 0}, {width, height}, 0, 0);
EXPECT_TEXTURE_EQ(colorData.data(), colorTexture, {0, 0}, {width, height});
}
wgpu::ShaderModule mVertexModule;
@ -323,7 +323,7 @@ TEST_P(DepthStencilCopyTests, FromDepthAspect) {
0.3, 0.3, 0.0, 0.0, //
0.3, 0.3, 0.0, 0.0, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), depthTexture, {0, 0}, {kWidth, kHeight}, 0, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), depthTexture, {0, 0}, {kWidth, kHeight}, 0,
wgpu::TextureAspect::DepthOnly);
}
@ -348,7 +348,7 @@ TEST_P(DepthStencilCopyTests, FromStencilAspect) {
1u, 1u, 0u, 0u, //
1u, 1u, 0u, 0u, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), depthStencilTexture, {0, 0}, {kWidth, kHeight}, 0, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), depthStencilTexture, {0, 0}, {kWidth, kHeight}, 0,
wgpu::TextureAspect::StencilOnly);
}
@ -373,7 +373,7 @@ TEST_P(DepthStencilCopyTests, FromNonZeroMipStencilAspect) {
1u, 1u, 0u, 0u, //
1u, 1u, 0u, 0u, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), depthStencilTexture, {0, 0}, {4, 4}, 1, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), depthStencilTexture, {0, 0}, {4, 4}, 1,
wgpu::TextureAspect::StencilOnly);
}
@ -391,7 +391,7 @@ TEST_P(DepthStencilCopyTests, FromNonZeroMipDepthAspect) {
0.4, 0.4, 0.0, 0.0, //
0.4, 0.4, 0.0, 0.0, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), depthTexture, {0, 0}, {4, 4}, 1, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), depthTexture, {0, 0}, {4, 4}, 1,
wgpu::TextureAspect::DepthOnly);
}
@ -420,7 +420,7 @@ TEST_P(DepthStencilCopyTests, T2TBothAspectsThenCopyStencil) {
3u, 3u, 1u, 1u, //
3u, 3u, 1u, 1u, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0,
wgpu::TextureAspect::StencilOnly);
}
@ -443,7 +443,7 @@ TEST_P(DepthStencilCopyTests, T2TBothAspectsThenCopyNonRenderableStencil) {
3u, 3u, 1u, 1u, //
3u, 3u, 1u, 1u, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0,
wgpu::TextureAspect::StencilOnly);
}
@ -469,7 +469,7 @@ TEST_P(DepthStencilCopyTests, T2TBothAspectsThenCopyNonRenderableNonZeroMipStenc
3u, 3u, 1u, 1u, //
3u, 3u, 1u, 1u, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {4, 4}, 1, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {4, 4}, 1,
wgpu::TextureAspect::StencilOnly);
}
@ -525,7 +525,7 @@ TEST_P(DepthStencilCopyTests, T2TBothAspectsThenCopyStencilThenDepth) {
3u, 3u, 1u, 1u, //
3u, 3u, 1u, 1u, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0,
wgpu::TextureAspect::StencilOnly);
// Check the depth
@ -574,7 +574,7 @@ TEST_P(DepthStencilCopyTests, T2TBothAspectsThenCopyDepthThenStencil) {
3u, 3u, 1u, 1u, //
3u, 3u, 1u, 1u, //
};
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0, 0,
EXPECT_TEXTURE_EQ(expectedData.data(), texture, {0, 0}, {kWidth, kHeight}, 0,
wgpu::TextureAspect::StencilOnly);
}
@ -673,7 +673,7 @@ TEST_P(DepthStencilCopyTests, ToStencilAspect) {
// Copy back the stencil data and check it is correct.
EXPECT_TEXTURE_EQ(expectedStencilData.data(), depthStencilTexture, {0, 0}, {kWidth, kHeight}, 0,
0, wgpu::TextureAspect::StencilOnly);
wgpu::TextureAspect::StencilOnly);
ExpectDepthData(depthStencilTexture, wgpu::TextureFormat::Depth24PlusStencil8, kWidth, kHeight,
0,

View File

@ -64,7 +64,7 @@ TEST_P(NonzeroTextureCreationTests, Depth32TextureCreationDepthClears) {
// TODO(crbug.com/dawn/145): Test other formats via sampling.
wgpu::Texture texture = device.CreateTexture(&descriptor);
std::vector<float> expected(kSize * kSize, 1.f);
EXPECT_TEXTURE_EQ(expected.data(), texture, {0, 0}, {kSize, kSize}, 0, 0);
EXPECT_TEXTURE_EQ(expected.data(), texture, {0, 0}, {kSize, kSize});
}
// Test that non-zero mip level clears 0xFF because toggle is enabled.

View File

@ -85,8 +85,8 @@ class SubresourceRenderAttachmentTest : public DawnTest {
}
case Type::Depth: {
std::vector<float> expected(renderTargetSize * renderTargetSize, expectedDepth);
EXPECT_TEXTURE_FLOAT_EQ(expected.data(), renderTarget, 0, 0, renderTargetSize,
renderTargetSize, baseMipLevel, baseArrayLayer);
EXPECT_TEXTURE_FLOAT_EQ(expected.data(), renderTarget, (0, 0, baseArrayLayer),
(renderTargetSize, renderTargetSize), baseMipLevel);
break;
}
case Type::Stencil:

View File

@ -663,7 +663,7 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilLoadAfterDiscard) {
std::vector<uint8_t> expected(kSize * kSize, 2);
EXPECT_LAZY_CLEAR(
0u, EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0}, {kSize, kSize},
0, 0, wgpu::TextureAspect::StencilOnly));
0, wgpu::TextureAspect::StencilOnly));
}
}
@ -736,7 +736,7 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilLoadAfterDiscard) {
std::vector<uint8_t> expected(kSize * kSize, 0);
EXPECT_LAZY_CLEAR(
0u, EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0}, {kSize, kSize},
0, 0, wgpu::TextureAspect::StencilOnly));
0, wgpu::TextureAspect::StencilOnly));
}
}
}
@ -779,9 +779,8 @@ TEST_P(TextureZeroInitTest, IndependentDepthStencilCopyAfterDiscard) {
// Check by copy that the stencil data is lazily cleared to 0.
std::vector<uint8_t> expected(kSize * kSize, 0);
EXPECT_LAZY_CLEAR(
1u, EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0}, {kSize, kSize}, 0, 0,
wgpu::TextureAspect::StencilOnly));
EXPECT_LAZY_CLEAR(1u, EXPECT_TEXTURE_EQ(expected.data(), depthStencilTexture, {0, 0},
{kSize, kSize}, 0, wgpu::TextureAspect::StencilOnly));
// Everything is initialized now
EXPECT_EQ(true, dawn_native::IsTextureSubresourceInitialized(depthStencilTexture.Get(), 0, 1, 0,

View File

@ -144,7 +144,7 @@ class ViewportTest : public DawnTest {
(maxDepth + minDepth) / 2,
minDepth,
};
EXPECT_TEXTURE_EQ(expected.data(), depthTexture, {0, 0}, {3, 1}, 0, 0);
EXPECT_TEXTURE_EQ(expected.data(), depthTexture, {0, 0}, {3, 1});
}
};