mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-10 15:15:58 +00:00
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:
parent
67a73bd9fa
commit
7775258f98
2
BUILD.gn
2
BUILD.gn
@ -998,8 +998,8 @@ test("dawn_end2end_tests") {
|
||||
"src/tests/DawnTest.h",
|
||||
"src/tests/end2end/BasicTests.cpp",
|
||||
"src/tests/end2end/BindGroupTests.cpp",
|
||||
"src/tests/end2end/BlendStateTests.cpp",
|
||||
"src/tests/end2end/BufferTests.cpp",
|
||||
"src/tests/end2end/ColorStateTests.cpp",
|
||||
"src/tests/end2end/ComputeCopyStorageBufferTests.cpp",
|
||||
"src/tests/end2end/CopyTests.cpp",
|
||||
"src/tests/end2end/DepthStencilStateTests.cpp",
|
||||
|
@ -151,13 +151,13 @@ namespace dawn_native {
|
||||
mDepthStencilState->stencilFront.passOp != dawn::StencilOperation::Keep;
|
||||
}
|
||||
|
||||
bool BlendEnabled(const ColorStateDescriptor* 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;
|
||||
bool BlendEnabled(const ColorStateDescriptor* mColorState) {
|
||||
return mColorState->alphaBlend.operation != dawn::BlendOperation::Add ||
|
||||
mColorState->alphaBlend.srcFactor != dawn::BlendFactor::One ||
|
||||
mColorState->alphaBlend.dstFactor != dawn::BlendFactor::Zero ||
|
||||
mColorState->colorBlend.operation != dawn::BlendOperation::Add ||
|
||||
mColorState->colorBlend.srcFactor != dawn::BlendFactor::One ||
|
||||
mColorState->colorBlend.dstFactor != dawn::BlendFactor::Zero;
|
||||
}
|
||||
|
||||
// RenderPipelineBase
|
||||
|
@ -30,7 +30,7 @@ namespace dawn_native {
|
||||
MaybeError ValidateRenderPipelineDescriptor(DeviceBase* device,
|
||||
const RenderPipelineDescriptor* descriptor);
|
||||
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState);
|
||||
bool BlendEnabled(const ColorStateDescriptor* mBlendState);
|
||||
bool BlendEnabled(const ColorStateDescriptor* mColorState);
|
||||
|
||||
class RenderPipelineBase : public PipelineBase {
|
||||
public:
|
||||
|
@ -127,7 +127,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
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;
|
||||
blendDesc.BlendEnable = BlendEnabled(descriptor);
|
||||
blendDesc.SrcBlend = D3D12Blend(descriptor->colorBlend.srcFactor);
|
||||
@ -287,7 +287,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
|
||||
descriptorD3D12.RTVFormats[i] = D3D12TextureFormat(GetColorAttachmentFormat(i));
|
||||
descriptorD3D12.BlendState.RenderTarget[i] =
|
||||
ComputeBlendDesc(GetColorStateDescriptor(i));
|
||||
ComputeColorDesc(GetColorStateDescriptor(i));
|
||||
}
|
||||
descriptorD3D12.NumRenderTargets = static_cast<uint32_t>(GetColorAttachmentsMask().count());
|
||||
|
||||
|
@ -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)) {
|
||||
glEnablei(GL_BLEND, attachment);
|
||||
glBlendEquationSeparatei(attachment, GLBlendMode(descriptor->colorBlend.operation),
|
||||
@ -196,7 +196,7 @@ namespace dawn_native { namespace opengl {
|
||||
ApplyDepthStencilState(GetDepthStencilStateDescriptor(), &persistentPipelineState);
|
||||
|
||||
for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) {
|
||||
ApplyBlendState(attachmentSlot, GetColorStateDescriptor(attachmentSlot));
|
||||
ApplyColorState(attachmentSlot, GetColorStateDescriptor(attachmentSlot));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace dawn_native { namespace vulkan {
|
||||
return static_cast<VkColorComponentFlagBits>(mask);
|
||||
}
|
||||
|
||||
VkPipelineColorBlendAttachmentState ComputeBlendDesc(
|
||||
VkPipelineColorBlendAttachmentState ComputeColorDesc(
|
||||
const ColorStateDescriptor* descriptor) {
|
||||
VkPipelineColorBlendAttachmentState attachment;
|
||||
attachment.blendEnable = BlendEnabled(descriptor) ? VK_TRUE : VK_FALSE;
|
||||
@ -199,10 +199,6 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
RenderPipeline::RenderPipeline(Device* device, const RenderPipelineDescriptor* 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];
|
||||
{
|
||||
shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
@ -283,11 +279,11 @@ namespace dawn_native { namespace vulkan {
|
||||
ComputeDepthStencilDesc(GetDepthStencilStateDescriptor());
|
||||
|
||||
// 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;
|
||||
for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
|
||||
const ColorStateDescriptor* descriptor = GetColorStateDescriptor(i);
|
||||
colorBlendAttachments[i] = ComputeBlendDesc(descriptor);
|
||||
colorBlendAttachments[i] = ComputeColorDesc(descriptor);
|
||||
}
|
||||
VkPipelineColorBlendStateCreateInfo colorBlend;
|
||||
colorBlend.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -51,8 +51,7 @@ TEST_F(RenderPipelineValidationTest, CreationSuccess) {
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
|
||||
TEST_F(RenderPipelineValidationTest, BlendState) {
|
||||
|
||||
TEST_F(RenderPipelineValidationTest, ColorState) {
|
||||
{
|
||||
// This one succeeds because attachment 0 is the color attachment
|
||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||
@ -72,4 +71,3 @@ TEST_F(RenderPipelineValidationTest, BlendState) {
|
||||
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user