Skip to content

Commit

Permalink
Disable blending for autogenerated shadow caster blend blocks. Fixed …
Browse files Browse the repository at this point in the history
…Vulkan validation layer errors on Google Pixel 7 Pro, that does not supports VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT for PFG_R32_FLOAT aka VK_FORMAT_R32_SFLOAT, that often used for shadow maps.
  • Loading branch information
eugenegff committed Sep 18, 2024
1 parent efba9f5 commit 6bbe582
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions OgreMain/src/OgreHlmsDatablock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,19 @@ namespace Ogre
if( !casterBlock && overrideCasterBlock )
{
mIgnoreFlushRenderables = true;
if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled )
if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled &&
mBlendblock[0]->mSourceBlendFactor == SBF_ONE &&
mBlendblock[0]->mDestBlendFactor == SBF_ZERO &&
( !mBlendblock[0]->mSeparateBlend ||
( mBlendblock[0]->mSourceBlendFactorAlpha == SBF_ONE &&
mBlendblock[0]->mDestBlendFactorAlpha == SBF_ZERO ) ) )
setBlendblock( mBlendblock[0], true );
else
{
HlmsBlendblock blendblockNoAC = *mBlendblock[0];
blendblockNoAC.mAlphaToCoverage = HlmsBlendblock::A2cDisabled;
setBlendblock( blendblockNoAC, true );
HlmsBlendblock casterBlendblock = *mBlendblock[0];
casterBlendblock.mAlphaToCoverage = HlmsBlendblock::A2cDisabled;
casterBlendblock.setBlendType( SBT_REPLACE );
setBlendblock( casterBlendblock, true );
}
mIgnoreFlushRenderables = false;
}
Expand Down Expand Up @@ -419,13 +425,19 @@ namespace Ogre
if( !casterBlock && overrideCasterBlock )
{
mIgnoreFlushRenderables = true;
if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled )
if( mBlendblock[0]->mAlphaToCoverage == HlmsBlendblock::A2cDisabled &&
mBlendblock[0]->mSourceBlendFactor == SBF_ONE &&
mBlendblock[0]->mDestBlendFactor == SBF_ZERO &&
( !mBlendblock[0]->mSeparateBlend ||
( mBlendblock[0]->mSourceBlendFactorAlpha == SBF_ONE &&
mBlendblock[0]->mDestBlendFactorAlpha == SBF_ZERO ) ) )
setBlendblock( mBlendblock[0], true );
else
{
HlmsBlendblock blendblockNoAC = *mBlendblock[0];
blendblockNoAC.mAlphaToCoverage = HlmsBlendblock::A2cDisabled;
setBlendblock( blendblockNoAC, true );
HlmsBlendblock casterBlendblock = *mBlendblock[0];
casterBlendblock.mAlphaToCoverage = HlmsBlendblock::A2cDisabled;
casterBlendblock.setBlendType( SBT_REPLACE );
setBlendblock( casterBlendblock, true );
}
mIgnoreFlushRenderables = false;
}
Expand Down

0 comments on commit 6bbe582

Please sign in to comment.