mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-01 09:49:07 +00:00
This patch removes RenderPassDescriptorBuilder completely from Dawn. With this patch, RenderPassDescriptor is a structure instead of a Dawn object, and all the checks in RenderPassDescriptorBuilder are moved into CommandEncoder.cpp. This patch also updates the helper functions and structures related to RenderPassDescriptor because RenderPassDescriptor is no longer an object but a structure with members in pointers. BUG=dawn:6 Change-Id: Ic6d015582031891f35ffef912f0e460a9c010f81 Reviewed-on: https://dawn-review.googlesource.com/c/4902 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
120 lines
3.7 KiB
C++
120 lines
3.7 KiB
C++
// Copyright 2018 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "tests/unittests/validation/ValidationTest.h"
|
|
|
|
class SetScissorRectTest : public ValidationTest {
|
|
};
|
|
|
|
// Test to check basic use of SetScissor
|
|
TEST_F(SetScissorRectTest, Success) {
|
|
DummyRenderPass renderPass(device);
|
|
|
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
|
pass.SetScissorRect(0, 0, 1, 1);
|
|
pass.EndPass();
|
|
}
|
|
encoder.Finish();
|
|
}
|
|
|
|
// Test to check that an empty scissor is allowed
|
|
TEST_F(SetScissorRectTest, EmptyScissor) {
|
|
DummyRenderPass renderPass(device);
|
|
|
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
|
pass.SetScissorRect(0, 0, 0, 0);
|
|
pass.EndPass();
|
|
}
|
|
encoder.Finish();
|
|
}
|
|
|
|
// Test to check that a scissor larger than the framebuffer is allowed
|
|
// TODO(cwallez@chromium.org): scissor values seem to be integers in all APIs do the same
|
|
// and test negative values?
|
|
TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) {
|
|
DummyRenderPass renderPass(device);
|
|
|
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
|
pass.SetScissorRect(0, 0, renderPass.width + 1, renderPass.height + 1);
|
|
pass.EndPass();
|
|
}
|
|
encoder.Finish();
|
|
}
|
|
|
|
class SetBlendColorTest : public ValidationTest {
|
|
};
|
|
|
|
// Test to check basic use of SetBlendColor
|
|
TEST_F(SetBlendColorTest, Success) {
|
|
DummyRenderPass renderPass(device);
|
|
|
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
|
constexpr dawn::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
|
|
pass.SetBlendColor(&kTransparentBlack);
|
|
pass.EndPass();
|
|
}
|
|
encoder.Finish();
|
|
}
|
|
|
|
// Test that SetBlendColor allows any value, large, small or negative
|
|
TEST_F(SetBlendColorTest, AnyValueAllowed) {
|
|
DummyRenderPass renderPass(device);
|
|
|
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
|
constexpr dawn::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
|
|
pass.SetBlendColor(&kAnyColorValue);
|
|
pass.EndPass();
|
|
}
|
|
encoder.Finish();
|
|
}
|
|
|
|
class SetStencilReferenceTest : public ValidationTest {
|
|
};
|
|
|
|
// Test to check basic use of SetStencilReferenceTest
|
|
TEST_F(SetStencilReferenceTest, Success) {
|
|
DummyRenderPass renderPass(device);
|
|
|
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
|
pass.SetStencilReference(0);
|
|
pass.EndPass();
|
|
}
|
|
encoder.Finish();
|
|
}
|
|
|
|
// Test that SetStencilReference allows any bit to be set
|
|
TEST_F(SetStencilReferenceTest, AllBitsAllowed) {
|
|
DummyRenderPass renderPass(device);
|
|
|
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
|
{
|
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
|
pass.SetStencilReference(0xFFFFFFFF);
|
|
pass.EndPass();
|
|
}
|
|
encoder.Finish();
|
|
}
|