Rename BlendState to ColorState, in order to match web idl

BUG=dawn:106

Change-Id: Id2cb1788becfacd09bd7f420d6525d22f96d1fe2
Reviewed-on: https://dawn-review.googlesource.com/c/4781
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Yunchao He 2019-02-16 02:27:30 +00:00 committed by Commit Bot service account
parent 67a73bd9fa
commit 7775258f98
8 changed files with 440 additions and 385 deletions

View File

@ -998,8 +998,8 @@ test("dawn_end2end_tests") {
"src/tests/DawnTest.h", "src/tests/DawnTest.h",
"src/tests/end2end/BasicTests.cpp", "src/tests/end2end/BasicTests.cpp",
"src/tests/end2end/BindGroupTests.cpp", "src/tests/end2end/BindGroupTests.cpp",
"src/tests/end2end/BlendStateTests.cpp",
"src/tests/end2end/BufferTests.cpp", "src/tests/end2end/BufferTests.cpp",
"src/tests/end2end/ColorStateTests.cpp",
"src/tests/end2end/ComputeCopyStorageBufferTests.cpp", "src/tests/end2end/ComputeCopyStorageBufferTests.cpp",
"src/tests/end2end/CopyTests.cpp", "src/tests/end2end/CopyTests.cpp",
"src/tests/end2end/DepthStencilStateTests.cpp", "src/tests/end2end/DepthStencilStateTests.cpp",

View File

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

View File

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

View File

@ -127,7 +127,7 @@ namespace dawn_native { namespace d3d12 {
return static_cast<uint8_t>(colorWriteMask); return static_cast<uint8_t>(colorWriteMask);
} }
D3D12_RENDER_TARGET_BLEND_DESC ComputeBlendDesc(const ColorStateDescriptor* descriptor) { D3D12_RENDER_TARGET_BLEND_DESC ComputeColorDesc(const ColorStateDescriptor* descriptor) {
D3D12_RENDER_TARGET_BLEND_DESC blendDesc; D3D12_RENDER_TARGET_BLEND_DESC blendDesc;
blendDesc.BlendEnable = BlendEnabled(descriptor); blendDesc.BlendEnable = BlendEnabled(descriptor);
blendDesc.SrcBlend = D3D12Blend(descriptor->colorBlend.srcFactor); blendDesc.SrcBlend = D3D12Blend(descriptor->colorBlend.srcFactor);
@ -287,7 +287,7 @@ namespace dawn_native { namespace d3d12 {
for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) { for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
descriptorD3D12.RTVFormats[i] = D3D12TextureFormat(GetColorAttachmentFormat(i)); descriptorD3D12.RTVFormats[i] = D3D12TextureFormat(GetColorAttachmentFormat(i));
descriptorD3D12.BlendState.RenderTarget[i] = descriptorD3D12.BlendState.RenderTarget[i] =
ComputeBlendDesc(GetColorStateDescriptor(i)); ComputeColorDesc(GetColorStateDescriptor(i));
} }
descriptorD3D12.NumRenderTargets = static_cast<uint32_t>(GetColorAttachmentsMask().count()); descriptorD3D12.NumRenderTargets = static_cast<uint32_t>(GetColorAttachmentsMask().count());

View File

@ -90,7 +90,7 @@ namespace dawn_native { namespace opengl {
} }
} }
void ApplyBlendState(uint32_t attachment, const ColorStateDescriptor* descriptor) { void ApplyColorState(uint32_t attachment, const ColorStateDescriptor* descriptor) {
if (BlendEnabled(descriptor)) { if (BlendEnabled(descriptor)) {
glEnablei(GL_BLEND, attachment); glEnablei(GL_BLEND, attachment);
glBlendEquationSeparatei(attachment, GLBlendMode(descriptor->colorBlend.operation), glBlendEquationSeparatei(attachment, GLBlendMode(descriptor->colorBlend.operation),
@ -196,7 +196,7 @@ namespace dawn_native { namespace opengl {
ApplyDepthStencilState(GetDepthStencilStateDescriptor(), &persistentPipelineState); ApplyDepthStencilState(GetDepthStencilStateDescriptor(), &persistentPipelineState);
for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) { for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) {
ApplyBlendState(attachmentSlot, GetColorStateDescriptor(attachmentSlot)); ApplyColorState(attachmentSlot, GetColorStateDescriptor(attachmentSlot));
} }
} }

View File

@ -111,7 +111,7 @@ namespace dawn_native { namespace vulkan {
return static_cast<VkColorComponentFlagBits>(mask); return static_cast<VkColorComponentFlagBits>(mask);
} }
VkPipelineColorBlendAttachmentState ComputeBlendDesc( VkPipelineColorBlendAttachmentState ComputeColorDesc(
const ColorStateDescriptor* descriptor) { const ColorStateDescriptor* descriptor) {
VkPipelineColorBlendAttachmentState attachment; VkPipelineColorBlendAttachmentState attachment;
attachment.blendEnable = BlendEnabled(descriptor) ? VK_TRUE : VK_FALSE; attachment.blendEnable = BlendEnabled(descriptor) ? VK_TRUE : VK_FALSE;
@ -199,10 +199,6 @@ namespace dawn_native { namespace vulkan {
RenderPipeline::RenderPipeline(Device* device, const RenderPipelineDescriptor* descriptor) RenderPipeline::RenderPipeline(Device* device, const RenderPipelineDescriptor* descriptor)
: RenderPipelineBase(device, descriptor) { : RenderPipelineBase(device, descriptor) {
// Eventually a bunch of the structures that need to be chained in the create info will be
// held by objects such as the BlendState. They aren't implemented yet so we initialize
// everything here.
VkPipelineShaderStageCreateInfo shaderStages[2]; VkPipelineShaderStageCreateInfo shaderStages[2];
{ {
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@ -283,11 +279,11 @@ namespace dawn_native { namespace vulkan {
ComputeDepthStencilDesc(GetDepthStencilStateDescriptor()); ComputeDepthStencilDesc(GetDepthStencilStateDescriptor());
// Initialize the "blend state info" that will be chained in the "create info" from the data // Initialize the "blend state info" that will be chained in the "create info" from the data
// pre-computed in the BlendState // pre-computed in the ColorState
std::array<VkPipelineColorBlendAttachmentState, kMaxColorAttachments> colorBlendAttachments; std::array<VkPipelineColorBlendAttachmentState, kMaxColorAttachments> colorBlendAttachments;
for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) { for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
const ColorStateDescriptor* descriptor = GetColorStateDescriptor(i); const ColorStateDescriptor* descriptor = GetColorStateDescriptor(i);
colorBlendAttachments[i] = ComputeBlendDesc(descriptor); colorBlendAttachments[i] = ComputeColorDesc(descriptor);
} }
VkPipelineColorBlendStateCreateInfo colorBlend; VkPipelineColorBlendStateCreateInfo colorBlend;
colorBlend.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; colorBlend.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;

View File

@ -51,8 +51,7 @@ TEST_F(RenderPipelineValidationTest, CreationSuccess) {
device.CreateRenderPipeline(&descriptor); device.CreateRenderPipeline(&descriptor);
} }
TEST_F(RenderPipelineValidationTest, BlendState) { TEST_F(RenderPipelineValidationTest, ColorState) {
{ {
// This one succeeds because attachment 0 is the color attachment // This one succeeds because attachment 0 is the color attachment
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor descriptor(device);
@ -72,4 +71,3 @@ TEST_F(RenderPipelineValidationTest, BlendState) {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
} }
} }