Refactor CopySplitTests.cpp in unittest D3D12
The log output code snippet duplicates again and again in this test. So this change put it into a function and all tests can call that function without duplicated code. It names the new function as DoTest(), which calls DoTest2D() (the original DoTest()). The new function can add DoTest3D() into the test in order to test 3D texture splitter if needed and all tests don't need to change anything. It also removes TexelBlockInfo instance in DoTest2D(), which provide no new info, just as Origin3D instance (for origin) and Extent3D instance (for copySize). Bug: dawn:547 Change-Id: I668682c5bdbae56dcdc8cf0e232f27233e17b883 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/54221 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
parent
f8a0f82fad
commit
74f0c02044
|
@ -348,16 +348,25 @@ namespace {
|
|||
|
||||
class CopySplitTest : public testing::Test {
|
||||
protected:
|
||||
TextureCopySubresource DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) {
|
||||
void DoTest(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) {
|
||||
TextureCopySubresource copySplit = DoTest2D(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
TextureCopySubresource DoTest2D(const TextureSpec& textureSpec, const BufferSpec& bufferSpec) {
|
||||
ASSERT(textureSpec.width % textureSpec.blockWidth == 0 &&
|
||||
textureSpec.height % textureSpec.blockHeight == 0);
|
||||
dawn_native::TexelBlockInfo blockInfo = {};
|
||||
blockInfo.width = textureSpec.blockWidth;
|
||||
blockInfo.height = textureSpec.blockHeight;
|
||||
blockInfo.byteSize = textureSpec.texelBlockSizeInBytes;
|
||||
TextureCopySubresource copySplit = Compute2DTextureCopySubresource(
|
||||
{textureSpec.x, textureSpec.y, textureSpec.z},
|
||||
{textureSpec.width, textureSpec.height, textureSpec.depthOrArrayLayers}, blockInfo,
|
||||
{textureSpec.width, textureSpec.height, textureSpec.depthOrArrayLayers},
|
||||
{textureSpec.texelBlockSizeInBytes, textureSpec.blockWidth, textureSpec.blockHeight},
|
||||
bufferSpec.offset, bufferSpec.bytesPerRow);
|
||||
ValidateCopySplit(textureSpec, bufferSpec, copySplit);
|
||||
return copySplit;
|
||||
|
@ -367,14 +376,7 @@ class CopySplitTest : public testing::Test {
|
|||
TEST_F(CopySplitTest, General) {
|
||||
for (TextureSpec textureSpec : kBaseTextureSpecs) {
|
||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -387,14 +389,7 @@ TEST_F(CopySplitTest, TextureWidth) {
|
|||
}
|
||||
textureSpec.width = val;
|
||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -408,14 +403,7 @@ TEST_F(CopySplitTest, TextureHeight) {
|
|||
}
|
||||
textureSpec.height = val;
|
||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -426,14 +414,7 @@ TEST_F(CopySplitTest, TextureX) {
|
|||
for (uint32_t val : kCheckValues) {
|
||||
textureSpec.x = val;
|
||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -444,14 +425,7 @@ TEST_F(CopySplitTest, TextureY) {
|
|||
for (uint32_t val : kCheckValues) {
|
||||
textureSpec.y = val;
|
||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -462,14 +436,7 @@ TEST_F(CopySplitTest, TexelSize) {
|
|||
for (uint32_t texelSize : {4, 8, 16, 32, 64}) {
|
||||
textureSpec.texelBlockSizeInBytes = texelSize;
|
||||
for (BufferSpec bufferSpec : BaseBufferSpecs(textureSpec)) {
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -481,14 +448,7 @@ TEST_F(CopySplitTest, BufferOffset) {
|
|||
for (uint32_t val : kCheckValues) {
|
||||
bufferSpec.offset = textureSpec.texelBlockSizeInBytes * val;
|
||||
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -501,14 +461,7 @@ TEST_F(CopySplitTest, RowPitch) {
|
|||
for (uint32_t i = 0; i < 5; ++i) {
|
||||
bufferSpec.bytesPerRow = baseRowPitch + i * 256;
|
||||
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,14 +474,7 @@ TEST_F(CopySplitTest, ImageHeight) {
|
|||
for (uint32_t i = 0; i < 5; ++i) {
|
||||
bufferSpec.rowsPerImage = baseImageHeight + i * 256;
|
||||
|
||||
TextureCopySubresource copySplit = DoTest(textureSpec, bufferSpec);
|
||||
if (HasFatalFailure()) {
|
||||
std::ostringstream message;
|
||||
message << "Failed generating splits: " << textureSpec << ", " << bufferSpec
|
||||
<< std::endl
|
||||
<< copySplit << std::endl;
|
||||
FAIL() << message.str();
|
||||
}
|
||||
DoTest(textureSpec, bufferSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue