Remove blendEnabled in BlendStateDescriptor, in order to match web idl

BUG=dawn:32

Change-Id: I7225d919ca1a9c1c848050ad3b9e8832725f0af6
Reviewed-on: https://dawn-review.googlesource.com/c/4460
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Yunchao He 2019-02-12 00:32:13 +00:00 committed by Commit Bot service account
parent 393d555a0e
commit 5987c4e839
12 changed files with 14 additions and 18 deletions

View File

@ -124,7 +124,6 @@
"category": "structure",
"extensible": true,
"members": [
{"name": "blend enabled", "type": "bool"},
{"name": "alpha blend", "type": "blend descriptor"},
{"name": "color blend", "type": "blend descriptor"},
{"name": "color write mask", "type": "color write mask"}

View File

@ -93,7 +93,6 @@ void init() {
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;

View File

@ -169,6 +169,15 @@ namespace dawn_native {
mDepthStencilState->stencilFront.passOp != dawn::StencilOperation::Keep;
}
bool BlendEnabled(const BlendStateDescriptor* mBlendState) {
return mBlendState->alphaBlend.operation != dawn::BlendOperation::Add ||
mBlendState->alphaBlend.srcFactor != dawn::BlendFactor::One ||
mBlendState->alphaBlend.dstFactor != dawn::BlendFactor::Zero ||
mBlendState->colorBlend.operation != dawn::BlendOperation::Add ||
mBlendState->colorBlend.srcFactor != dawn::BlendFactor::One ||
mBlendState->colorBlend.dstFactor != dawn::BlendFactor::Zero;
}
// RenderPipelineBase
RenderPipelineBase::RenderPipelineBase(DeviceBase* device,

View File

@ -30,6 +30,7 @@ namespace dawn_native {
MaybeError ValidateRenderPipelineDescriptor(DeviceBase* device,
const RenderPipelineDescriptor* descriptor);
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState);
bool BlendEnabled(const BlendStateDescriptor* mBlendState);
class RenderPipelineBase : public PipelineBase {
public:

View File

@ -129,7 +129,7 @@ namespace dawn_native { namespace d3d12 {
D3D12_RENDER_TARGET_BLEND_DESC ComputeBlendDesc(const BlendStateDescriptor* descriptor) {
D3D12_RENDER_TARGET_BLEND_DESC blendDesc;
blendDesc.BlendEnable = descriptor->blendEnabled;
blendDesc.BlendEnable = BlendEnabled(descriptor);
blendDesc.SrcBlend = D3D12Blend(descriptor->colorBlend.srcFactor);
blendDesc.DestBlend = D3D12Blend(descriptor->colorBlend.dstFactor);
blendDesc.BlendOp = D3D12BlendOperation(descriptor->colorBlend.operation);

View File

@ -130,7 +130,7 @@ namespace dawn_native { namespace metal {
void ComputeBlendDesc(MTLRenderPipelineColorAttachmentDescriptor* attachment,
const BlendStateDescriptor* descriptor) {
attachment.blendingEnabled = descriptor->blendEnabled;
attachment.blendingEnabled = BlendEnabled(descriptor);
attachment.sourceRGBBlendFactor =
MetalBlendFactor(descriptor->colorBlend.srcFactor, false);
attachment.destinationRGBBlendFactor =

View File

@ -91,7 +91,7 @@ namespace dawn_native { namespace opengl {
}
void ApplyBlendState(uint32_t attachment, const BlendStateDescriptor* descriptor) {
if (descriptor->blendEnabled) {
if (BlendEnabled(descriptor)) {
glEnablei(GL_BLEND, attachment);
glBlendEquationSeparatei(attachment, GLBlendMode(descriptor->colorBlend.operation),
GLBlendMode(descriptor->alphaBlend.operation));

View File

@ -115,7 +115,7 @@ namespace dawn_native { namespace vulkan {
VkPipelineColorBlendAttachmentState ComputeBlendDesc(
const BlendStateDescriptor* descriptor) {
VkPipelineColorBlendAttachmentState attachment;
attachment.blendEnable = descriptor->blendEnabled ? VK_TRUE : VK_FALSE;
attachment.blendEnable = BlendEnabled(descriptor) ? VK_TRUE : VK_FALSE;
attachment.srcColorBlendFactor = VulkanBlendFactor(descriptor->colorBlend.srcFactor);
attachment.dstColorBlendFactor = VulkanBlendFactor(descriptor->colorBlend.dstFactor);
attachment.colorBlendOp = VulkanBlendOperation(descriptor->colorBlend.operation);

View File

@ -136,7 +136,6 @@ class BlendStateTest : public DawnTest {
blend.dstFactor = dawn::BlendFactor::One;
dawn::BlendStateDescriptor descriptor;
descriptor.blendEnabled = true;
descriptor.alphaBlend = blend;
descriptor.colorBlend = blend;
descriptor.colorWriteMask = dawn::ColorWriteMask::All;
@ -161,7 +160,6 @@ class BlendStateTest : public DawnTest {
alphaBlend.dstFactor = alphaDstFactor;
dawn::BlendStateDescriptor descriptor;
descriptor.blendEnabled = true;
descriptor.colorBlend = colorBlend;
descriptor.alphaBlend = alphaBlend;
descriptor.colorWriteMask = dawn::ColorWriteMask::All;
@ -281,7 +279,6 @@ TEST_P(BlendStateTest, Basic) {
blend.srcFactor = dawn::BlendFactor::One;
blend.dstFactor = dawn::BlendFactor::Zero;
dawn::BlendStateDescriptor descriptor;
descriptor.blendEnabled = false;
descriptor.alphaBlend = blend;
descriptor.colorBlend = blend;
descriptor.colorWriteMask = dawn::ColorWriteMask::All;
@ -637,7 +634,6 @@ TEST_P(BlendStateTest, ColorWriteMask) {
blend.dstFactor = dawn::BlendFactor::One;
dawn::BlendStateDescriptor descriptor;
descriptor.blendEnabled = true;
descriptor.colorBlend = blend;
descriptor.alphaBlend = blend;
{
@ -687,7 +683,6 @@ TEST_P(BlendStateTest, ColorWriteMaskBlendingDisabled) {
descriptor.alphaBlend = blend;
descriptor.colorBlend = blend;
descriptor.blendEnabled = false;
descriptor.colorWriteMask = dawn::ColorWriteMask::Red;
SetupSingleSourcePipelines(descriptor);
@ -799,15 +794,12 @@ TEST_P(BlendStateTest, IndependentBlendState) {
blend3.srcFactor = dawn::BlendFactor::One;
blend3.dstFactor = dawn::BlendFactor::One;
testDescriptor.cBlendStates[0].blendEnabled = true;
testDescriptor.cBlendStates[0].colorBlend = blend1;
testDescriptor.cBlendStates[0].alphaBlend = blend1;
testDescriptor.cBlendStates[1].blendEnabled = true;
testDescriptor.cBlendStates[1].colorBlend = blend2;
testDescriptor.cBlendStates[1].alphaBlend = blend2;
testDescriptor.cBlendStates[3].blendEnabled = true;
testDescriptor.cBlendStates[3].colorBlend = blend3;
testDescriptor.cBlendStates[3].alphaBlend = blend3;
@ -881,7 +873,6 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
blend.operation = dawn::BlendOperation::Add;
blend.srcFactor = dawn::BlendFactor::BlendColor;
blend.dstFactor = dawn::BlendFactor::One;
testDescriptor.cBlendStates[0].blendEnabled = true;
testDescriptor.cBlendStates[0].colorBlend = blend;
testDescriptor.cBlendStates[0].alphaBlend = blend;

View File

@ -195,7 +195,6 @@ class PushConstantTest: public DawnTest {
blend.operation = dawn::BlendOperation::Add;
blend.srcFactor = dawn::BlendFactor::One;
blend.dstFactor = dawn::BlendFactor::One;
descriptor.cBlendStates[0].blendEnabled = true;
descriptor.cBlendStates[0].alphaBlend = blend;
descriptor.cBlendStates[0].colorBlend = blend;

View File

@ -347,7 +347,6 @@ TEST_F(WireTests, CStringArgument) {
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;

View File

@ -61,7 +61,6 @@ namespace utils {
blend.srcFactor = dawn::BlendFactor::One;
blend.dstFactor = dawn::BlendFactor::Zero;
dawn::BlendStateDescriptor blendStateDescriptor;
blendStateDescriptor.blendEnabled = false;
blendStateDescriptor.alphaBlend = blend;
blendStateDescriptor.colorBlend = blend;
blendStateDescriptor.colorWriteMask = dawn::ColorWriteMask::All;