mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-09 13:19:00 +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:
|
case BlendFactor::OneMinusConstantAlpha:
|
||||||
return vk::BlendFactor::eOneMinusConstantAlpha;
|
return vk::BlendFactor::eOneMinusConstantAlpha;
|
||||||
default:
|
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:
|
case BlendFunc::ReverseSubtract:
|
||||||
return vk::BlendOp::eReverseSubtract;
|
return vk::BlendOp::eReverseSubtract;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE_MSG("Unknown blend op: {}", static_cast<u32>(func));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -274,23 +274,40 @@ GraphicsPipeline::GraphicsPipeline(
|
|||||||
std::array<vk::PipelineColorBlendAttachmentState, Liverpool::NumColorBuffers> attachments;
|
std::array<vk::PipelineColorBlendAttachmentState, Liverpool::NumColorBuffers> attachments;
|
||||||
for (u32 i = 0; i < key.num_color_attachments; i++) {
|
for (u32 i = 0; i < key.num_color_attachments; i++) {
|
||||||
const auto& control = key.blend_controls[i];
|
const auto& control = key.blend_controls[i];
|
||||||
|
|
||||||
const auto src_color = LiverpoolToVK::BlendFactor(control.color_src_factor);
|
const auto src_color = LiverpoolToVK::BlendFactor(control.color_src_factor);
|
||||||
const auto dst_color = LiverpoolToVK::BlendFactor(control.color_dst_factor);
|
const auto dst_color = LiverpoolToVK::BlendFactor(control.color_dst_factor);
|
||||||
const auto color_blend = LiverpoolToVK::BlendOp(control.color_func);
|
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{
|
attachments[i] = vk::PipelineColorBlendAttachmentState{
|
||||||
.blendEnable = control.enable,
|
.blendEnable = control.enable,
|
||||||
.srcColorBlendFactor = src_color,
|
.srcColorBlendFactor = src_color,
|
||||||
.dstColorBlendFactor = dst_color,
|
.dstColorBlendFactor = dst_color,
|
||||||
.colorBlendOp = color_blend,
|
.colorBlendOp = color_blend,
|
||||||
.srcAlphaBlendFactor = control.separate_alpha_blend
|
.srcAlphaBlendFactor = src_alpha,
|
||||||
? LiverpoolToVK::BlendFactor(control.alpha_src_factor)
|
.dstAlphaBlendFactor = dst_alpha,
|
||||||
: src_color,
|
.alphaBlendOp = alpha_blend,
|
||||||
.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,
|
|
||||||
.colorWriteMask =
|
.colorWriteMask =
|
||||||
instance.IsDynamicColorWriteMaskSupported()
|
instance.IsDynamicColorWriteMaskSupported()
|
||||||
? vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG |
|
? 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;
|
const auto& ps_inputs = regs.ps_inputs;
|
||||||
info.fs_info.num_inputs = regs.num_interp;
|
info.fs_info.num_inputs = regs.num_interp;
|
||||||
const auto& cb0_blend = regs.blend_control[0];
|
const auto& cb0_blend = regs.blend_control[0];
|
||||||
info.fs_info.dual_source_blending =
|
if (cb0_blend.enable) {
|
||||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_dst_factor) ||
|
info.fs_info.dual_source_blending =
|
||||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_src_factor);
|
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_dst_factor) ||
|
||||||
if (cb0_blend.separate_alpha_blend) {
|
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.color_src_factor);
|
||||||
info.fs_info.dual_source_blending |=
|
if (cb0_blend.separate_alpha_blend) {
|
||||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.alpha_dst_factor) ||
|
info.fs_info.dual_source_blending |=
|
||||||
LiverpoolToVK::IsDualSourceBlendFactor(cb0_blend.alpha_src_factor);
|
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++) {
|
for (u32 i = 0; i < regs.num_interp; i++) {
|
||||||
info.fs_info.inputs[i] = {
|
info.fs_info.inputs[i] = {
|
||||||
@@ -344,9 +348,9 @@ bool PipelineCache::RefreshGraphicsKey() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Fill color blending information
|
// Fill color blending information
|
||||||
key.blend_controls[cb] = regs.blend_control[cb];
|
if (regs.blend_control[cb].enable && !col_buf.info.blend_bypass) {
|
||||||
key.blend_controls[cb].enable.Assign(regs.blend_control[cb].enable &&
|
key.blend_controls[cb] = regs.blend_control[cb];
|
||||||
!col_buf.info.blend_bypass);
|
}
|
||||||
|
|
||||||
// Apply swizzle to target mask
|
// Apply swizzle to target mask
|
||||||
key.write_masks[cb] =
|
key.write_masks[cb] =
|
||||||
|
|||||||
Reference in New Issue
Block a user