chromium/third_party/dawn/src/dawn/tests/unittests/validation/CopyCommandsValidationTests.cpp

// Copyright 2017 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <tuple>
#include <vector>

#include "dawn/common/Assert.h"
#include "dawn/common/Constants.h"
#include "dawn/common/Math.h"
#include "dawn/tests/unittests/validation/ValidationTest.h"
#include "dawn/utils/TestUtils.h"
#include "dawn/utils/TextureUtils.h"
#include "dawn/utils/WGPUHelpers.h"

namespace dawn {
namespace {

class CopyCommandTest : public ValidationTest {};

// Test copies between buffer and multiple array layers of an uncompressed texture
TEST_F(CopyCommandTest, CopyToMultipleArrayLayers) {}

class CopyCommandTest_B2B : public CopyCommandTest {};

// TODO([email protected]): Test that copies are forbidden inside renderpasses

// Test a successfull B2B copy
TEST_F(CopyCommandTest_B2B, Success) {}

// Test a successful B2B copy where the last external reference is dropped.
// This is a regression test for crbug.com/1217741 where submitting a command
// buffer with dropped resources when the copy size is 0 was a use-after-free.
TEST_F(CopyCommandTest_B2B, DroppedBuffer) {}

// Test B2B copies with OOB
TEST_F(CopyCommandTest_B2B, OutOfBounds) {}

// Test B2B copies with incorrect buffer usage
TEST_F(CopyCommandTest_B2B, BadUsage) {}

// Test B2B copies with unaligned data size
TEST_F(CopyCommandTest_B2B, UnalignedSize) {}

// Test B2B copies with unaligned offset
TEST_F(CopyCommandTest_B2B, UnalignedOffset) {}

// Test B2B copies with buffers in error state cause errors.
TEST_F(CopyCommandTest_B2B, BuffersInErrorState) {}

// Test it is not allowed to do B2B copies within same buffer.
TEST_F(CopyCommandTest_B2B, CopyWithinSameBuffer) {}

class CopyCommandTest_B2T : public CopyCommandTest {};

// Test a successfull B2T copy
TEST_F(CopyCommandTest_B2T, Success) {}

// Test OOB conditions on the buffer
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnBuffer) {}

// Test OOB conditions on the texture
TEST_F(CopyCommandTest_B2T, OutOfBoundsOnTexture) {}

// Test that we force Depth=1 on copies to 2D textures
TEST_F(CopyCommandTest_B2T, DepthConstraintFor2DTextures) {}

// Test B2T copies with incorrect buffer usage
TEST_F(CopyCommandTest_B2T, IncorrectUsage) {}

TEST_F(CopyCommandTest_B2T, BytesPerRowConstraints) {}

TEST_F(CopyCommandTest_B2T, RowsPerImageConstraints) {}

// Test B2T copies with incorrect buffer offset usage for color texture
TEST_F(CopyCommandTest_B2T, IncorrectBufferOffsetForColorTexture) {}

// Test B2T copies with incorrect buffer offset usage for depth-stencil texture
TEST_F(CopyCommandTest_B2T, IncorrectBufferOffsetForDepthStencilTexture) {}

// Test multisampled textures cannot be used in B2T copies.
TEST_F(CopyCommandTest_B2T, CopyToMultisampledTexture) {}

// Test B2T copies with buffer or texture in error state causes errors.
TEST_F(CopyCommandTest_B2T, BufferOrTextureInErrorState) {}

// Regression tests for a bug in the computation of texture copy buffer size in Dawn.
TEST_F(CopyCommandTest_B2T, TextureCopyBufferSizeLastRowComputation) {}

// Test copy from buffer to mip map of non square texture
TEST_F(CopyCommandTest_B2T, CopyToMipmapOfNonSquareTexture) {}

// Test whether or not it is valid to copy to a depth texture
TEST_F(CopyCommandTest_B2T, CopyToDepthAspect) {}

// Test copy to only the stencil aspect of a texture
TEST_F(CopyCommandTest_B2T, CopyToStencilAspect) {}

// Test that CopyB2T throws an error when requiredBytesInCopy overflows uint64_t
TEST_F(CopyCommandTest_B2T, RequiredBytesInCopyOverflow) {}

class CopyCommandTest_T2B : public CopyCommandTest {};

// Test a successfull T2B copy
TEST_F(CopyCommandTest_T2B, Success) {}

// Edge cases around requiredBytesInCopy computation for empty copies
TEST_F(CopyCommandTest_T2B, Empty) {}

// Test OOB conditions on the texture
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnTexture) {}

// Test OOB conditions on the buffer
TEST_F(CopyCommandTest_T2B, OutOfBoundsOnBuffer) {}

// Test that we force Depth=1 on copies from to 2D textures
TEST_F(CopyCommandTest_T2B, DepthConstraintFor2DTextures) {}

// Test T2B copies with incorrect buffer usage
TEST_F(CopyCommandTest_T2B, IncorrectUsage) {}

TEST_F(CopyCommandTest_T2B, BytesPerRowConstraints) {}

TEST_F(CopyCommandTest_T2B, RowsPerImageConstraints) {}

// Test T2B copies with incorrect buffer offset usage for color texture
TEST_F(CopyCommandTest_T2B, IncorrectBufferOffsetForColorTexture) {}

// Test T2B copies with incorrect buffer offset usage for depth-stencil texture
TEST_F(CopyCommandTest_T2B, IncorrectBufferOffsetForDepthStencilTexture) {}

// Test multisampled textures cannot be used in T2B copies.
TEST_F(CopyCommandTest_T2B, CopyFromMultisampledTexture) {}

// Test T2B copies with buffer or texture in error state cause errors.
TEST_F(CopyCommandTest_T2B, BufferOrTextureInErrorState) {}

// Regression tests for a bug in the computation of texture copy buffer size in Dawn.
TEST_F(CopyCommandTest_T2B, TextureCopyBufferSizeLastRowComputation) {}

// Test copy from mip map of non square texture to buffer
TEST_F(CopyCommandTest_T2B, CopyFromMipmapOfNonSquareTexture) {}

// Test copy from only the depth aspect of a texture
TEST_F(CopyCommandTest_T2B, CopyFromDepthAspect) {}

// Test copy from only the stencil aspect of a texture
TEST_F(CopyCommandTest_T2B, CopyFromStencilAspect) {}

// Test that CopyT2B throws an error when requiredBytesInCopy overflows uint64_t
TEST_F(CopyCommandTest_T2B, RequiredBytesInCopyOverflow) {}

class CopyCommandTest_T2T : public CopyCommandTest {};

TEST_F(CopyCommandTest_T2T, Success) {}

TEST_F(CopyCommandTest_T2T, IncorrectUsage) {}

TEST_F(CopyCommandTest_T2T, OutOfBounds) {}

TEST_F(CopyCommandTest_T2T, 2DTextureDepthStencil) {}

TEST_F(CopyCommandTest_T2T, 2DTextureDepthOnly) {}

TEST_F(CopyCommandTest_T2T, 2DTextureArrayDepthStencil) {}

TEST_F(CopyCommandTest_T2T, FormatsMismatch) {}

// Test copying between textures that have srgb compatible texture formats;
TEST_F(CopyCommandTest_T2T, SrgbFormatsCompatibility) {}

TEST_F(CopyCommandTest_T2T, MultisampledCopies) {}

// Test copy to mip map of non square textures
TEST_F(CopyCommandTest_T2T, CopyToMipmapOfNonSquareTexture) {}

// Test copy within the same texture
TEST_F(CopyCommandTest_T2T, CopyWithinSameTexture) {}

class CopyCommandTest_CompressedTextureFormats : public CopyCommandTest {};

// Tests to verify that bufferOffset must be a multiple of the compressed texture blocks in bytes
// in buffer-to-texture or texture-to-buffer copies with compressed texture formats.
TEST_F(CopyCommandTest_CompressedTextureFormats, BufferOffset) {}

// Tests to verify that bytesPerRow must not be less than (width / blockWidth) * blockSizeInBytes.
// Note that in Dawn we require bytesPerRow be a multiple of 256, which ensures bytesPerRow will
// always be the multiple of compressed texture block width in bytes.
TEST_F(CopyCommandTest_CompressedTextureFormats, BytesPerRow) {}

// rowsPerImage must be >= heightInBlocks.
TEST_F(CopyCommandTest_CompressedTextureFormats, RowsPerImage) {}

// Tests to verify that ImageOffset.x must be a multiple of the compressed texture block width and
// ImageOffset.y must be a multiple of the compressed texture block height in buffer-to-texture,
// texture-to-buffer or texture-to-texture copies with compressed texture formats.
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageOffset) {}

// Tests to verify that ImageExtent.x must be a multiple of the compressed texture block width and
// ImageExtent.y must be a multiple of the compressed texture block height in buffer-to-texture,
// texture-to-buffer or texture-to-texture copies with compressed texture formats.
TEST_F(CopyCommandTest_CompressedTextureFormats, ImageExtent) {}

// Test copies between buffer and multiple array layers of a compressed texture
TEST_F(CopyCommandTest_CompressedTextureFormats, CopyToMultipleArrayLayers) {}

// Test copying between textures that have srgb compatible texture formats;
TEST_F(CopyCommandTest_CompressedTextureFormats, SrgbFormatCompatibility) {}

class CopyCommandTest_ClearBuffer : public CopyCommandTest {};

TEST_F(CopyCommandTest_ClearBuffer, Success) {}

// Test a successful ClearBuffer where the last external reference is dropped.
TEST_F(CopyCommandTest_ClearBuffer, DroppedBuffer) {}

// Test ClearBuffer copies with OOB
TEST_F(CopyCommandTest_ClearBuffer, OutOfBounds) {}

// Test ClearBuffer with incorrect buffer usage
TEST_F(CopyCommandTest_ClearBuffer, BadUsage) {}

// Test ClearBuffer with unaligned data size
TEST_F(CopyCommandTest_ClearBuffer, UnalignedSize) {}

// Test ClearBuffer with unaligned offset
TEST_F(CopyCommandTest_ClearBuffer, UnalignedOffset) {}

// Test ClearBuffer with buffers in error state cause errors.
TEST_F(CopyCommandTest_ClearBuffer, BuffersInErrorState) {}

}  // anonymous namespace
}  // namespace dawn