Dual source blending RHI support

#rb Rolando.Caloca
[FYI] Sebastien.Hillaire


#ROBOMERGE-SOURCE: CL 8635684 via CL 8649754
#ROBOMERGE-BOT: (v412-8640799)

[CL 8649919 by josie yang in Main branch]
This commit is contained in:
josie yang
2019-09-12 02:05:37 -04:00
parent efc608be38
commit 9ededec7d6
6 changed files with 38 additions and 4 deletions

View File

@@ -103,6 +103,10 @@ static mtlpp::BlendFactor TranslateBlendFactor(EBlendFactor BlendFactor)
case BF_InverseDestAlpha: return mtlpp::BlendFactor::OneMinusDestinationAlpha;
case BF_DestColor: return mtlpp::BlendFactor::DestinationColor;
case BF_InverseDestColor: return mtlpp::BlendFactor::OneMinusDestinationColor;
case BF_Source1Color: return mtlpp::BlendFactor::Source1Color;
case BF_InverseSource1Color: return mtlpp::BlendFactor::OneMinusSource1Color;
case BF_Source1Alpha: return mtlpp::BlendFactor::Source1Alpha;
case BF_InverseSource1Alpha: return mtlpp::BlendFactor::OneMinusSource1Alpha;
default: return mtlpp::BlendFactor::Zero;
};
}
@@ -143,6 +147,10 @@ static EBlendFactor TranslateBlendFactor(MTLBlendFactor BlendFactor)
case MTLBlendFactorOneMinusDestinationAlpha: return BF_InverseDestAlpha;
case MTLBlendFactorDestinationColor: return BF_DestColor;
case MTLBlendFactorOneMinusDestinationColor: return BF_InverseDestColor;
case MTLBlendFactorSource1Color: return BF_Source1Color;
case MTLBlendFactorOneMinusSource1Color: return BF_InverseSource1Color;
case MTLBlendFactorSource1Alpha: return BF_Source1Alpha;
case MTLBlendFactorOneMinusSource1Alpha: return BF_InverseSource1Alpha;
case MTLBlendFactorZero: default: return BF_Zero;
};
}

View File

@@ -172,6 +172,10 @@ static D3D12_BLEND TranslateBlendFactor(EBlendFactor BlendFactor)
case BF_InverseDestColor: return D3D12_BLEND_INV_DEST_COLOR;
case BF_ConstantBlendFactor: return D3D12_BLEND_BLEND_FACTOR;
case BF_InverseConstantBlendFactor: return D3D12_BLEND_INV_BLEND_FACTOR;
case BF_Source1Color: return D3D12_BLEND_SRC1_COLOR;
case BF_InverseSource1Color: return D3D12_BLEND_INV_SRC1_COLOR;
case BF_Source1Alpha: return D3D12_BLEND_SRC1_ALPHA;
case BF_InverseSource1Alpha: return D3D12_BLEND_INV_SRC1_ALPHA;
default: return D3D12_BLEND_ZERO;
};
}
@@ -191,6 +195,10 @@ static EBlendFactor ReverseTranslateBlendFactor(D3D12_BLEND BlendFactor)
case D3D12_BLEND_INV_DEST_COLOR: return BF_InverseDestColor;
case D3D12_BLEND_BLEND_FACTOR: return BF_ConstantBlendFactor;
case D3D12_BLEND_INV_BLEND_FACTOR: return BF_InverseConstantBlendFactor;
case D3D12_BLEND_SRC1_COLOR: return BF_Source1Color;
case D3D12_BLEND_INV_SRC1_COLOR: return BF_InverseSource1Color;
case D3D12_BLEND_SRC1_ALPHA: return BF_Source1Alpha;
case D3D12_BLEND_INV_SRC1_ALPHA: return BF_InverseSource1Alpha;
default: return BF_Zero;
};
}

View File

@@ -403,6 +403,10 @@ enum EBlendFactor
BF_InverseDestColor,
BF_ConstantBlendFactor,
BF_InverseConstantBlendFactor,
BF_Source1Color,
BF_InverseSource1Color,
BF_Source1Alpha,
BF_InverseSource1Alpha,
EBlendFactor_Num,
EBlendFactor_NumBits = 4,
@@ -1209,6 +1213,11 @@ inline bool RHISupportsShaderPipelines(EShaderPlatform Platform)
return !IsMobilePlatform(Platform);
}
inline bool RHISupportsDualSourceBlending(EShaderPlatform Platform)
{
// For now only enable support for SM5
return IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM5) && (IsD3DPlatform(Platform, true) || IsPS4Platform(Platform) || IsVulkanPlatform(Platform) || IsMetalPlatform(Platform));
}
// Return what the expected number of samplers will be supported by a feature level
// Note that since the Feature Level is pretty orthogonal to the RHI/HW, this is not going to be perfect

View File

@@ -106,6 +106,10 @@ static inline VkBlendFactor BlendFactorToVulkan(EBlendFactor InFactor)
case BF_InverseDestColor: return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
case BF_ConstantBlendFactor: return VK_BLEND_FACTOR_CONSTANT_COLOR;
case BF_InverseConstantBlendFactor: return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
case BF_Source1Color: return VK_BLEND_FACTOR_SRC1_COLOR;
case BF_InverseSource1Color: return VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR;
case BF_Source1Alpha: return VK_BLEND_FACTOR_SRC1_ALPHA;
case BF_InverseSource1Alpha: return VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA;
default:
break;
}

View File

@@ -120,6 +120,11 @@ static D3D11_BLEND TranslateBlendFactor(EBlendFactor BlendFactor)
case BF_InverseDestColor: return D3D11_BLEND_INV_DEST_COLOR;
case BF_ConstantBlendFactor: return D3D11_BLEND_BLEND_FACTOR;
case BF_InverseConstantBlendFactor: return D3D11_BLEND_INV_BLEND_FACTOR;
case BF_Source1Color: return D3D11_BLEND_SRC1_COLOR;
case BF_InverseSource1Color: return D3D11_BLEND_INV_SRC1_COLOR;
case BF_Source1Alpha: return D3D11_BLEND_SRC1_ALPHA;
case BF_InverseSource1Alpha: return D3D11_BLEND_INV_SRC1_ALPHA;
default: return D3D11_BLEND_ZERO;
};
}

View File

@@ -93,10 +93,10 @@ namespace mtlpp
OneMinusBlendColor = 12,
BlendAlpha = 13,
OneMinusBlendAlpha = 14,
Source1Color MTLPP_AVAILABLE_MAC(10_12) = 15,
OneMinusSource1Color MTLPP_AVAILABLE_MAC(10_12) = 16,
Source1Alpha MTLPP_AVAILABLE_MAC(10_12) = 17,
OneMinusSource1Alpha MTLPP_AVAILABLE_MAC(10_12) = 18,
Source1Color MTLPP_AVAILABLE(10_12, 8_0) = 15,
OneMinusSource1Color MTLPP_AVAILABLE(10_12, 8_0) = 16,
Source1Alpha MTLPP_AVAILABLE(10_12, 8_0) = 17,
OneMinusSource1Alpha MTLPP_AVAILABLE(10_12, 8_0) = 18,
}
MTLPP_AVAILABLE(10_11, 8_0);