chromium/third_party/dawn/src/dawn/tests/end2end/ColorStateTests.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 <algorithm>
#include <array>
#include <cmath>
#include <utility>
#include <vector>

#include "dawn/common/Assert.h"
#include "dawn/common/Constants.h"
#include "dawn/tests/DawnTest.h"
#include "dawn/utils/ComboRenderPipelineDescriptor.h"
#include "dawn/utils/WGPUHelpers.h"

namespace dawn {
namespace {

constexpr static unsigned int kRTSize =;

class ColorStateTest : public DawnTest {};

namespace {
// Add two colors and clamp
constexpr utils::RGBA8 operator+(const utils::RGBA8& col1, const utils::RGBA8& col2) {}

// Subtract two colors and clamp
constexpr utils::RGBA8 operator-(const utils::RGBA8& col1, const utils::RGBA8& col2) {}

// Get the component-wise minimum of two colors
utils::RGBA8 min(const utils::RGBA8& col1, const utils::RGBA8& col2) {}

// Get the component-wise maximum of two colors
utils::RGBA8 max(const utils::RGBA8& col1, const utils::RGBA8& col2) {}

// Blend two RGBA8 color values parameterized by the provided factors in the range [0.f, 1.f]
utils::RGBA8 mix(const utils::RGBA8& col1, const utils::RGBA8& col2, std::array<float, 4> fac) {}

// Blend two RGBA8 color values parameterized by the provided RGBA8 factor
utils::RGBA8 mix(const utils::RGBA8& col1, const utils::RGBA8& col2, const utils::RGBA8& fac) {}

constexpr std::array<utils::RGBA8, 8> kColors =;
}  // namespace

// Test compilation and usage of the fixture
TEST_P(ColorStateTest, Basic) {}

// The following tests check test that the blend operation works
TEST_P(ColorStateTest, BlendOperationAdd) {}

TEST_P(ColorStateTest, BlendOperationSubtract) {}

TEST_P(ColorStateTest, BlendOperationReverseSubtract) {}

TEST_P(ColorStateTest, BlendOperationMin) {}

TEST_P(ColorStateTest, BlendOperationMax) {}

// The following tests check that the Source blend factor works
TEST_P(ColorStateTest, SrcBlendFactorZero) {}

TEST_P(ColorStateTest, SrcBlendFactorOne) {}

TEST_P(ColorStateTest, SrcBlendFactorSrc) {}

TEST_P(ColorStateTest, SrcBlendFactorOneMinusSrc) {}

TEST_P(ColorStateTest, SrcBlendFactorSrcAlpha) {}

TEST_P(ColorStateTest, SrcBlendFactorOneMinusSrcAlpha) {}

TEST_P(ColorStateTest, SrcBlendFactorDst) {}

TEST_P(ColorStateTest, SrcBlendFactorOneMinusDst) {}

TEST_P(ColorStateTest, SrcBlendFactorDstAlpha) {}

TEST_P(ColorStateTest, SrcBlendFactorOneMinusDstAlpha) {}

TEST_P(ColorStateTest, SrcBlendFactorSrcAlphaSaturated) {}

TEST_P(ColorStateTest, SrcBlendFactorConstant) {}

TEST_P(ColorStateTest, SrcBlendFactorOneMinusConstant) {}

// The following tests check that the Destination blend factor works
TEST_P(ColorStateTest, DstBlendFactorZero) {}

TEST_P(ColorStateTest, DstBlendFactorOne) {}

TEST_P(ColorStateTest, DstBlendFactorSrc) {}

TEST_P(ColorStateTest, DstBlendFactorOneMinusSrc) {}

TEST_P(ColorStateTest, DstBlendFactorSrcAlpha) {}

TEST_P(ColorStateTest, DstBlendFactorOneMinusSrcAlpha) {}

TEST_P(ColorStateTest, DstBlendFactorDst) {}

TEST_P(ColorStateTest, DstBlendFactorOneMinusDst) {}

TEST_P(ColorStateTest, DstBlendFactorDstAlpha) {}

TEST_P(ColorStateTest, DstBlendFactorOneMinusDstAlpha) {}

TEST_P(ColorStateTest, DstBlendFactorSrcAlphaSaturated) {}

TEST_P(ColorStateTest, DstBlendFactorConstant) {}

TEST_P(ColorStateTest, DstBlendFactorOneMinusConstant) {}

// Check that the color write mask works
TEST_P(ColorStateTest, ColorWriteMask) {}

// Check that the color write mask works when blending is disabled
TEST_P(ColorStateTest, ColorWriteMaskBlendingDisabled) {}

// Test that independent color states on render targets works
TEST_P(ColorStateTest, IndependentColorState) {}

// Test that the default blend color is correctly set at the beginning of every subpass
TEST_P(ColorStateTest, DefaultBlendColor) {}

// This tests a problem in the OpenGL backend where a previous color write mask
// persisted and prevented a render pass loadOp from fully clearing the output
// attachment.
TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {}

TEST_P(ColorStateTest, SparseAttachmentsDifferentColorMask) {}

// This is a regression test against an Intel driver issue about using DstAlpha as
// SrcBlendFactor for both color and alpha blend factors.
TEST_P(ColorStateTest, SrcBlendFactorDstAlphaDstBlendFactorZero) {}

DAWN_INSTANTIATE_TEST(ColorStateTest,
                      D3D11Backend(),
                      D3D12Backend(),
                      MetalBackend(),
                      OpenGLBackend(),
                      OpenGLESBackend(),
                      VulkanBackend());

}  // anonymous namespace
}  // namespace dawn