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

// Copyright 2018 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 <vector>

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

namespace dawn {
namespace {

constexpr wgpu::TextureFormat kNonRenderableColorFormats[] =;

wgpu::TextureDimension kDimensions[] =;

class TextureValidationTest : public ValidationTest {};

// Test the validation of non-zero texture usage
TEST_F(TextureValidationTest, UsageNonZero) {}

// Test the validation of sample count
TEST_F(TextureValidationTest, SampleCount) {}

// Test the validation of the mip level count
TEST_F(TextureValidationTest, MipLevelCount) {}

// Test the validation of array layer count
TEST_F(TextureValidationTest, ArrayLayerCount) {}

// Test the validation of 1D texture size
TEST_F(TextureValidationTest, 1DTextureSize) {}

// Test the validation of 2D texture size
TEST_F(TextureValidationTest, 2DTextureSize) {}

// Test the validation of 3D texture size
TEST_F(TextureValidationTest, 3DTextureSize) {}

// Test that depth/stencil formats are invalid for 1D and 3D texture
TEST_F(TextureValidationTest, DepthStencilFormatsFor1DAnd3D) {}

// Test that it is valid to destroy a texture
TEST_F(TextureValidationTest, DestroyTexture) {}

// Test that it's valid to destroy a destroyed texture
TEST_F(TextureValidationTest, DestroyDestroyedTexture) {}

// Test that it's invalid to submit a destroyed texture in a queue
// in the case of destroy, encode, submit
TEST_F(TextureValidationTest, DestroyEncodeSubmit) {}

// Test that it's invalid to submit a destroyed texture in a queue
// in the case of encode, destroy, submit
TEST_F(TextureValidationTest, EncodeDestroySubmit) {}

// Test it is an error to create an RenderAttachment texture with a non-renderable format.
TEST_F(TextureValidationTest, NonRenderableAndRenderAttachment) {}

// Test it is an error to create a Storage texture with any format that doesn't support
// TextureUsage::StorageBinding texture usages.
TEST_F(TextureValidationTest, TextureFormatNotSupportTextureUsageStorage) {}

// Test it is an error to create a RenderAttachment texture with the texture dimensions that
// doesn't support TextureUsage::RenderAttachment texture usages.
TEST_F(TextureValidationTest, TextureDimensionNotSupportRenderAttachment) {}

// Test it is an error to create a texture with format "Undefined".
TEST_F(TextureValidationTest, TextureFormatUndefined) {}

// Test that the creation of a texture with depth32float-stencil8 will fail when the feature
// Depth32FloatStencil8 is not enabled.
TEST_F(TextureValidationTest, UseD32S8FormatWithoutEnablingFeature) {}

// Test that the creation of a texture with BC format will fail when the feature
// textureCompressionBC is not enabled.
TEST_F(TextureValidationTest, UseBCFormatWithoutEnablingFeature) {}

// Test that the creation of a texture with ETC2 format will fail when the feature
// textureCompressionETC2 is not enabled.
TEST_F(TextureValidationTest, UseETC2FormatWithoutEnablingFeature) {}

// Test that the creation of a texture with ASTC format will fail when the feature
// textureCompressionASTC is not enabled.
TEST_F(TextureValidationTest, UseASTCFormatWithoutEnablingFeature) {}

class D32S8TextureFormatsValidationTests : public TextureValidationTest {};

// Test that depth32float-stencil8 format is invalid for 3D texture
TEST_F(D32S8TextureFormatsValidationTests, DepthStencilFormatsFor3D) {}

class CompressedTextureFormatsValidationTests : public TextureValidationTest {};

// Test that only CopySrc, CopyDst and Sampled are accepted as usage in compressed formats.
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {}

// Test that using various MipLevelCount is allowed for compressed formats.
TEST_F(CompressedTextureFormatsValidationTests, MipLevelCount) {}

// Test that it is invalid to specify SampleCount>1 in compressed formats.
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {}

// Test that it is allowed to create a 2D texture with depth>1 in compressed formats.
TEST_F(CompressedTextureFormatsValidationTests, 2DArrayTexture) {}

// Test that it is not allowed to create a 1D texture in compressed formats.
TEST_F(CompressedTextureFormatsValidationTests, 1DTexture) {}

// Test that it is not allowed to create a 3D texture in compressed formats.
TEST_F(CompressedTextureFormatsValidationTests, 3DTexture) {}

// Test that it is invalid to use numbers for a texture's width/height that are not multiples
// of the compressed block sizes.
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {}

class RG11B10UfloatTextureFormatsValidationTests : public TextureValidationTest {};

// Test that RG11B10Ufloat format is valid as render attachment and also it allows
// multisampling if "rg11b10ufloat-renderable" feature is enabled
TEST_F(RG11B10UfloatTextureFormatsValidationTests, RenderableFeature) {}

class BGRA8UnormTextureFormatsValidationTests : public TextureValidationTest {};

// Test that BGRA8Unorm format is valid as storage texture if 'bgra8unorm-storage' is enabled.
TEST_F(BGRA8UnormTextureFormatsValidationTests, StorageFeature) {}

class Unorm16TextureFormatsValidationTests : public TextureValidationTest {};

// Test that Norm16 formats are valid as renderable and sample-able texture if
// 'norm16-texture-formats' is enabled.
TEST_F(Unorm16TextureFormatsValidationTests, RenderAndSample) {}

class Snorm16TextureFormatsValidationTests : public TextureValidationTest {};

// Test that Norm16 formats are valid as renderable and sample-able texture if
// 'norm16-texture-formats' is enabled.
TEST_F(Snorm16TextureFormatsValidationTests, RenderAndSample) {}

// Test that the Norm16 formats are not available even for just TextureBinding when the optional
// feature is not specified.
TEST_F(TextureValidationTest, Norm16NotAvailableWithoutExtension) {}

static void CheckTextureMatchesDescriptor(const wgpu::Texture& tex,
                                          const wgpu::TextureDescriptor& desc) {}

// Test that the texture creation parameters are correctly reflected for succesfully created
// textures.
TEST_F(TextureValidationTest, CreationParameterReflectionForValidTextures) {}

// Test that the texture creation parameters are correctly reflected for error textures.
TEST_F(TextureValidationTest, CreationParameterReflectionForErrorTextures) {}

// Test that CreateErrorTexture creates an invalid texture but doesn't produce an error.
TEST_F(TextureValidationTest, CreateErrorTexture) {}

// Test that the texture creation parameters are correctly reflected for textures created via
// CreateErrorTexture
TEST_F(TextureValidationTest, CreationParameterReflectionForCreateErrorTexture) {}

// A tiny test that Device::ValidateTextureDescriptor works, under the assumption that all the
// texture validation logic is implemented through it (so there is no need to re-test every possible
// failure case).
TEST_F(TextureValidationTest, APIValidateTextureDescriptor) {}

// Tests that specification of the transient attachment on an unsupported device
// causes an error.
TEST_F(TextureValidationTest, TransientAttachmentOnUnsupportedDevice) {}

class TransientAttachmentValidationTest : public TextureValidationTest {};

// Tests that specification of the transient attachment with supported usage on
// a supported device does not raise a validation error.
TEST_F(TransientAttachmentValidationTest, Success) {}

// Tests that specification of the transient attachment without specification of
// the render attachment causes an error.
TEST_F(TransientAttachmentValidationTest, NoRenderAttachment) {}

// Tests that specification of the transient attachment with flags beyond just
// render attachment causes an error.
TEST_F(TransientAttachmentValidationTest, FlagsBeyondRenderAttachment) {}

}  // anonymous namespace
}  // namespace dawn