Skip to content

Commit

Permalink
Add BLEND_MODE_NONE
Browse files Browse the repository at this point in the history
  • Loading branch information
RenfengLiu committed Aug 15, 2024
1 parent 87ba0b1 commit 3073906
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion include/ppx/grfx/grfx_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ struct BlendAttachmentState
grfx::ColorComponentFlags colorWriteMask = grfx::ColorComponentFlags::RGBA();

// These are best guesses based on random formulas off of the internet.
// Correct later when authorative literature is found.
// Correct later when authoritative literature is found.
//
static grfx::BlendAttachmentState BlendModeNone();
static grfx::BlendAttachmentState BlendModeAdditive();
static grfx::BlendAttachmentState BlendModeAlpha();
static grfx::BlendAttachmentState BlendModeOver();
Expand Down
24 changes: 17 additions & 7 deletions src/ppx/grfx/grfx_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ namespace grfx {
// -------------------------------------------------------------------------------------------------
// BlendAttachmentState
// -------------------------------------------------------------------------------------------------
grfx::BlendAttachmentState BlendAttachmentState::BlendModeNone()
{
grfx::BlendAttachmentState state = {};
state.blendEnable = false;
state.colorWriteMask = grfx::ColorComponentFlags::RGBA();

return state;
}

grfx::BlendAttachmentState BlendAttachmentState::BlendModeAdditive()
{
grfx::BlendAttachmentState state = {};
Expand Down Expand Up @@ -103,12 +112,6 @@ grfx::BlendAttachmentState BlendAttachmentState::BlendModeDisableOutput()
{
grfx::BlendAttachmentState state = {};
state.blendEnable = false;
state.srcColorBlendFactor = grfx::BLEND_FACTOR_ONE;
state.dstColorBlendFactor = grfx::BLEND_FACTOR_ONE;
state.colorBlendOp = grfx::BLEND_OP_ADD;
state.srcAlphaBlendFactor = grfx::BLEND_FACTOR_ONE;
state.dstAlphaBlendFactor = grfx::BLEND_FACTOR_ONE;
state.alphaBlendOp = grfx::BLEND_OP_ADD;
state.colorWriteMask = grfx::ColorComponentFlags(0);

return state;
Expand Down Expand Up @@ -171,7 +174,7 @@ void FillOutGraphicsPipelineCreateInfo(
for (uint32_t i = 0; i < pDstCreateInfo->colorBlendState.blendAttachmentCount; ++i) {
switch (pSrcCreateInfo->blendModes[i]) {
case grfx::BLEND_MODE_NONE: {
pDstCreateInfo->colorBlendState.blendAttachments[i].colorWriteMask = grfx::ColorComponentFlags::RGBA();
pDstCreateInfo->colorBlendState.blendAttachments[i] = grfx::BlendAttachmentState::BlendModeNone();
break;
}

Expand All @@ -194,8 +197,15 @@ void FillOutGraphicsPipelineCreateInfo(
case grfx::BLEND_MODE_PREMULT_ALPHA: {
pDstCreateInfo->colorBlendState.blendAttachments[i] = grfx::BlendAttachmentState::BlendModePremultAlpha();
} break;

case grfx::BLEND_MODE_DISABLE_OUTPUT: {
pDstCreateInfo->colorBlendState.blendAttachments[i] = grfx::BlendAttachmentState::BlendModeDisableOutput();
break;
}

default: {
PPX_ASSERT_MSG(false, "Unknown BlendMode");
break;
}
}
}
Expand Down

0 comments on commit 3073906

Please sign in to comment.