chromium/third_party/dawn/src/dawn/tests/unittests/validation/ComputeValidationTests.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 <string>
#include <vector>

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

namespace dawn {
namespace {

class ComputePipelineValidationTest : public ValidationTest {};

// Test that creating a compute pipeline with basic shader module and pipeline layout succeeds.
TEST_F(ComputePipelineValidationTest, Success) {}

// Test that creating a compute pipeline with mismatched entry point name fails.
TEST_F(ComputePipelineValidationTest, EntryPointNameMismatched) {}

// Test that creating a compute pipeline with chained DawnComputePipelineFullSubgroups on a device
// that don't enable ChromiumExperimentalSubgroups feature fails.
TEST_F(ComputePipelineValidationTest, UnexpectedDawnComputePipelineFullSubgroups) {}

// Tests that requiring ChromiumExperimentalSubgroups feature, for DawnComputePipelineFullSubgroups
// testing.
// TODO(349125474): Revisit these tests when removing deprecated ChromiumExperimentalSubgroups.
class ComputePipelineValidationTestWithChromiumExperimentalSubgroupsFeatureEnabled
    : public ComputePipelineValidationTest {};

// Test that creating a compute pipeline with basic shader module and chained
// DawnComputePipelineFullSubgroups not requiring fullSubgroups succeeds.
TEST_F(ComputePipelineValidationTestWithChromiumExperimentalSubgroupsFeatureEnabled,
       DawnComputePipelineFullSubgroupsNotRequired) {}

// Test that creating a compute pipeline with basic shader module and chained
// DawnComputePipelineFullSubgroups requiring fullSubgroups fails if x dimension of workgroup size
// is not a multiple of maxSubgroupSize. Note that ValidationTest use Null backend, which assume a
// maxSubgroupSize of 128.
TEST_F(ComputePipelineValidationTestWithChromiumExperimentalSubgroupsFeatureEnabled,
       DawnComputePipelineFullSubgroupsRequired_WorkgroupSizeInvalid) {}

// Test that creating a compute pipeline with basic shader module and chained
// DawnComputePipelineFullSubgroups requiring fullSubgroups succeeds if x dimension of workgroup
// size is a multiple of maxSubgroupSize. Note that ValidationTest use Null backend, which assume a
// maxSubgroupSize of 128.
TEST_F(ComputePipelineValidationTestWithChromiumExperimentalSubgroupsFeatureEnabled,
       DawnComputePipelineFullSubgroupsRequired_WorkgroupSizeValid) {}

// Test that creating a compute pipeline with override workgroup size shader module and chained
// DawnComputePipelineFullSubgroups requiring fullSubgroups fails if x dimension of workgroup size
// is not a multiple of maxSubgroupSize. Note that ValidationTest use Null backend, which assume a
// maxSubgroupSize of 128.
TEST_F(ComputePipelineValidationTestWithChromiumExperimentalSubgroupsFeatureEnabled,
       DawnComputePipelineFullSubgroupsRequired_OverrideWorkgroupSizeInvalid) {}

// Test that creating a compute pipeline with override workgroup size shader module and chained
// DawnComputePipelineFullSubgroups requiring fullSubgroups succeeds if x dimension of workgroup
// size is a multiple of maxSubgroupSize. Note that ValidationTest use Null backend, which assume a
// maxSubgroupSize of 128.
TEST_F(ComputePipelineValidationTestWithChromiumExperimentalSubgroupsFeatureEnabled,
       DawnComputePipelineFullSubgroupsRequired_OverrideWorkgroupSizeValid) {}

// TODO([email protected]): Add a regression test for Disptach validation trying to access the
// input state.

class ComputeDispatchValidationTest : public ValidationTest {};

// Check that 1x1x1 dispatch is OK.
TEST_F(ComputeDispatchValidationTest, PerDimensionDispatchSizeLimits_SmallestValid) {}

// Check that the largest allowed dispatch is OK.
TEST_F(ComputeDispatchValidationTest, PerDimensionDispatchSizeLimits_LargestValid) {}

// Check that exceeding the maximum on the X dimension results in validation failure.
TEST_F(ComputeDispatchValidationTest, PerDimensionDispatchSizeLimits_InvalidX) {}

// Check that exceeding the maximum on the Y dimension results in validation failure.
TEST_F(ComputeDispatchValidationTest, PerDimensionDispatchSizeLimits_InvalidY) {}

// Check that exceeding the maximum on the Z dimension results in validation failure.
TEST_F(ComputeDispatchValidationTest, PerDimensionDispatchSizeLimits_InvalidZ) {}

// Check that exceeding the maximum on all dimensions results in validation failure.
TEST_F(ComputeDispatchValidationTest, PerDimensionDispatchSizeLimits_InvalidAll) {}

class ComputeValidationEntryPointTest : public ValidationTest {};

// Check that entry points are optional.
TEST_F(ComputeValidationEntryPointTest, EntryPointNameOptional) {}

// Check that entry points are required if module has multiple entry points.
TEST_F(ComputeValidationEntryPointTest, EntryPointNameRequiredIfMultipleEntryPoints) {}

// Check that entry points are required if module has no compatible entry points.
TEST_F(ComputeValidationEntryPointTest, EntryPointNameRequiredIfNoCompatibleEntryPoints) {}

}  // anonymous namespace
}  // namespace dawn