Replace BlendState builder via BlendState descriptor.

This change also removes BlendState object.

Bug=dawn:32

Change-Id: I8bf4ff7531e7504efb17b6bae3ca01f1f2b4131e
Reviewed-on: https://dawn-review.googlesource.com/c/3042
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He
2018-12-27 06:32:31 +00:00
committed by Commit Bot service account
parent cb71ba7b3a
commit 92700bfccd
43 changed files with 489 additions and 1043 deletions

View File

@@ -326,16 +326,17 @@ TEST_F(WireTests, CStringArgument) {
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _))
.WillOnce(Return(apiVsModule));
// Create the blend state
dawnBlendStateBuilder blendStateBuilder = dawnDeviceCreateBlendStateBuilder(device);
dawnBlendStateBuilder apiBlendStateBuilder = api.GetNewBlendStateBuilder();
EXPECT_CALL(api, DeviceCreateBlendStateBuilder(apiDevice))
.WillOnce(Return(apiBlendStateBuilder));
dawnBlendState blendState = dawnBlendStateBuilderGetResult(blendStateBuilder);
dawnBlendState apiBlendState = api.GetNewBlendState();
EXPECT_CALL(api, BlendStateBuilderGetResult(apiBlendStateBuilder))
.WillOnce(Return(apiBlendState));
// Create the blend state descriptor
dawnBlendDescriptor blendDescriptor;
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD;
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE;
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
dawnBlendStateDescriptor blendStateDescriptor;
blendStateDescriptor.nextInChain = nullptr;
blendStateDescriptor.blendEnabled = false;
blendStateDescriptor.alphaBlend = blendDescriptor;
blendStateDescriptor.colorBlend = blendDescriptor;
blendStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
// Create the input state
dawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
@@ -397,7 +398,7 @@ TEST_F(WireTests, CStringArgument) {
pipelineDescriptor.attachmentsState = &attachmentsState;
pipelineDescriptor.numBlendStates = 1;
pipelineDescriptor.blendStates = &blendState;
pipelineDescriptor.blendStates = &blendStateDescriptor;
pipelineDescriptor.sampleCount = 1;
pipelineDescriptor.layout = layout;

View File

@@ -1,88 +0,0 @@
// Copyright 2017 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 BlendStateValidationTest : public ValidationTest {
};
// Test cases where creation should succeed
TEST_F(BlendStateValidationTest, CreationSuccess) {
// Success for setting all properties
{
dawn::BlendDescriptor blend;
blend.operation = dawn::BlendOperation::Add;
blend.srcFactor = dawn::BlendFactor::One;
blend.dstFactor = dawn::BlendFactor::One;
dawn::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
.SetBlendEnabled(true)
.SetAlphaBlend(&blend)
.SetColorBlend(&blend)
.SetColorWriteMask(dawn::ColorWriteMask::Red)
.GetResult();
}
// Success for empty builder
{
dawn::BlendState state = AssertWillBeSuccess(device.CreateBlendStateBuilder())
.GetResult();
}
}
// Test creation failure when specifying properties multiple times
TEST_F(BlendStateValidationTest, CreationDuplicates) {
// Test failure when specifying blend enabled multiple times
{
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetBlendEnabled(true)
.SetBlendEnabled(false)
.GetResult();
}
dawn::BlendDescriptor blend1;
blend1.operation = dawn::BlendOperation::Add;
blend1.srcFactor = dawn::BlendFactor::One;
blend1.dstFactor = dawn::BlendFactor::One;
dawn::BlendDescriptor blend2;
blend2.operation = dawn::BlendOperation::Add;
blend2.srcFactor = dawn::BlendFactor::Zero;
blend2.dstFactor = dawn::BlendFactor::Zero;
// Test failure when specifying alpha blend multiple times
{
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetAlphaBlend(&blend1)
.SetAlphaBlend(&blend2)
.GetResult();
}
// Test failure when specifying color blend multiple times
{
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetColorBlend(&blend1)
.SetColorBlend(&blend2)
.GetResult();
}
// Test failure when specifying color write mask multiple times
{
dawn::BlendState state = AssertWillBeError(device.CreateBlendStateBuilder())
.SetColorWriteMask(dawn::ColorWriteMask::Red)
.SetColorWriteMask(dawn::ColorWriteMask::Green)
.GetResult();
}
}