mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-08 20:58:41 +00:00
renderer_vulkan: Ignore blend parameters when disabled. (#3485)
This commit is contained in:
@@ -210,7 +210,7 @@ vk::BlendFactor BlendFactor(Liverpool::BlendControl::BlendFactor factor) {
|
||||
case BlendFactor::OneMinusConstantAlpha:
|
||||
return vk::BlendFactor::eOneMinusConstantAlpha;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
UNREACHABLE_MSG("Unknown blend factor: {}", static_cast<u32>(factor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ vk::BlendOp BlendOp(Liverpool::BlendControl::BlendFunc func) {
|
||||
case BlendFunc::ReverseSubtract:
|
||||
return vk::BlendOp::eReverseSubtract;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
UNREACHABLE_MSG("Unknown blend op: {}", static_cast<u32>(func));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,23 +274,40 @@ GraphicsPipeline::GraphicsPipeline(
|
||||
std::array<vk::PipelineColorBlendAttachmentState, Liverpool::NumColorBuffers> attachments;
|
||||
for (u32 i = 0; i < key.num_color_attachments; i++) {
|
||||
const auto& control = key.blend_controls[i];
|
||||
|
||||
const auto src_color = LiverpoolToVK::BlendFactor(control.color_src_factor);
|
||||
const auto dst_color = LiverpoolToVK::BlendFactor(control.color_dst_factor);
|
||||
const auto color_blend = LiverpoolToVK::BlendOp(control.color_func);
|
||||
|
||||
const auto src_alpha = control.separate_alpha_blend
|
||||
? LiverpoolToVK::BlendFactor(control.alpha_src_factor)
|
||||
: src_color;
|
||||
const auto dst_alpha = control.separate_alpha_blend
|
||||
? LiverpoolToVK::BlendFactor(control.alpha_dst_factor)
|
||||
: dst_color;
|
||||
const auto alpha_blend =
|
||||
control.separate_alpha_blend ? LiverpoolToVK::BlendOp(control.alpha_func) : color_blend;
|
||||
|
||||
const auto color_scaled_min_max =
|
||||
(color_blend == vk::BlendOp::eMin || color_blend == vk::BlendOp::eMax) &&
|
||||
(src_color != vk::BlendFactor::eOne || dst_color != vk::BlendFactor::eOne);
|
||||
const auto alpha_scaled_min_max =
|
||||
(alpha_blend == vk::BlendOp::eMin || alpha_blend == vk::BlendOp::eMax) &&
|
||||
(src_alpha != vk::BlendFactor::eOne || dst_alpha != vk::BlendFactor::eOne);
|
||||
if (color_scaled_min_max || alpha_scaled_min_max) {
|
||||
LOG_WARNING(
|
||||
Render_Vulkan,
|
||||
"Unimplemented use of min/max blend op with blend factor not equal to one.");
|
||||
}
|
||||
|
||||
attachments[i] = vk::PipelineColorBlendAttachmentState{
|
||||
.blendEnable = control.enable,
|
||||
.srcColorBlendFactor = src_color,
|
||||
.dstColorBlendFactor = dst_color,
|
||||
.colorBlendOp = color_blend,
|
||||
.srcAlphaBlendFactor = control.separate_alpha_blend
|
||||
? LiverpoolToVK::BlendFactor(control.alpha_src_factor)
|
||||
: src_color,
|
||||
.dstAlphaBlendFactor = control.separate_alpha_blend
|
||||
? LiverpoolToVK::BlendFactor(control.alpha_dst_factor)
|
||||
: dst_color,
|
||||
.alphaBlendOp = control.separate_alpha_blend
|
||||
? LiverpoolToVK::BlendOp(control.alpha_func)
|
||||
: color_blend,
|
||||
.srcAlphaBlendFactor = src_alpha,
|
||||
.dstAlphaBlendFactor = dst_alpha,
|
||||
.alphaBlendOp = alpha_blend,
|
||||
.colorWriteMask =
|
||||
instance.IsDynamicColorWriteMaskSupported()
|
||||
? vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG |
|
||||
|
||||
@@ -168,13 +168,17 @@ const Shader::RuntimeInfo& PipelineCache::BuildRuntimeInfo(Stage stage, LogicalS
|
||||
const auto& ps_inputs = regs.ps_inputs;
|
||||
info.fs_info.num_inputs = regs.num_interp;
|
||||
const auto& cb0_blend = regs.blend_control[0];
|
||||
info.fs_info.dual_source_blending =
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_dst_factor) ||
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_src_factor);
|
||||
if (cb0_blend.separate_alpha_blend) {
|
||||
info.fs_info.dual_source_blending |=
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.alpha_dst_factor) ||
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.alpha_src_factor);
|
||||
if (cb0_blend.enable) {
|
||||
info.fs_info.dual_source_blending =
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_dst_factor) ||
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_src_factor);
|
||||
if (cb0_blend.separate_alpha_blend) {
|
||||
info.fs_info.dual_source_blending |=
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.alpha_dst_factor) ||
|
||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.alpha_src_factor);
|
||||
}
|
||||
} else {
|
||||
info.fs_info.dual_source_blending = false;
|
||||
}
|
||||
for (u32 i = 0; i < regs.num_interp; i++) {
|
||||
info.fs_info.inputs[i] = {
|
||||
@@ -344,9 +348,9 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||
};
|
||||
|
||||
// Fill color blending information
|
||||
key.blend_controls[cb] = regs.blend_control[cb];
|
||||
key.blend_controls[cb].enable.Assign(regs.blend_control[cb].enable &&
|
||||
!col_buf.info.blend_bypass);
|
||||
if (regs.blend_control[cb].enable && !col_buf.info.blend_bypass) {
|
||||
key.blend_controls[cb] = regs.blend_control[cb];
|
||||
}
|
||||
|
||||
// Apply swizzle to target mask
|
||||
key.write_masks[cb] =
|
||||
|
||||
Reference in New Issue
Block a user