Browse Source

NG ragebound workaround via LoadOverrides + vk_rasterizer UpdateBlending TouchBlendequations Rework

Added kleidis and crueter instructions
added in vk's fixed_pipeline_state Refresh() to cover EDS=0 case
pull/2934/head
Allison Cunha 4 months ago
committed by crueter
parent
commit
a055ea723b
  1. 3
      src/common/settings.cpp
  2. 3
      src/common/settings.h
  3. 13
      src/core/core.cpp
  4. 8
      src/video_core/renderer_opengl/gl_rasterizer.cpp
  5. 14
      src/video_core/renderer_vulkan/fixed_pipeline_state.cpp
  6. 47
      src/video_core/renderer_vulkan/vk_rasterizer.cpp

3
src/common/settings.cpp

@ -359,6 +359,9 @@ void RestoreGlobalState(bool is_powered_on) {
for (const auto& reset : values.linkage.restore_functions) {
reset();
}
// Reset per-game flags
values.use_squashed_iterated_blend = false;
}
static bool configuring_global = true;

3
src/common/settings.h

@ -759,6 +759,9 @@ struct Values {
// Add-Ons
std::map<u64, std::vector<std::string>> disabled_addons;
// Per-game overrides
bool use_squashed_iterated_blend;
};
extern Values values;

13
src/core/core.cpp

@ -297,6 +297,9 @@ struct System::Impl {
std::string vendor = gpu_core->Renderer().GetDeviceVendor();
LOG_INFO(Core, "GPU Vendor: {}", vendor);
// Reset all per-game flags
Settings::values.use_squashed_iterated_blend = false;
// Insert PC overrides here
#ifdef ANDROID
@ -322,6 +325,13 @@ struct System::Impl {
#endif
// Ninja Gaiden Ragebound
constexpr u64 ngr = 0x0100781020710000ULL;
if (programId == ngr) {
LOG_INFO(Core, "Enabling game specifc override: use_squashed_iterated_blend");
Settings::values.use_squashed_iterated_blend = true;
}
}
SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window,
@ -425,6 +435,9 @@ struct System::Impl {
void ShutdownMainProcess() {
SetShuttingDown(true);
// Reset per-game flags
Settings::values.use_squashed_iterated_blend = false;
is_powered_on = false;
exit_locked = false;
exit_requested = false;

8
src/video_core/renderer_opengl/gl_rasterizer.cpp

@ -1142,6 +1142,14 @@ void RasterizerOpenGL::SyncBlendState() {
glDisable(GL_BLEND);
return;
}
// Temporary workaround for games that use iterated blending
if (regs.iterated_blend.enable && Settings::values.use_squashed_iterated_blend) {
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ONE_MINUS_SRC_COLOR, GL_ZERO);
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
return;
}
glEnable(GL_BLEND);
glBlendFuncSeparate(MaxwellToGL::BlendFunc(regs.blend.color_source),
MaxwellToGL::BlendFunc(regs.blend.color_dest),

14
src/video_core/renderer_vulkan/fixed_pipeline_state.cpp

@ -11,6 +11,7 @@
#include <ranges>
#include "common/cityhash.h"
#include "common/common_types.h"
#include "common/settings.h"
#include "video_core/engines/draw_manager.h"
#include "video_core/renderer_vulkan/fixed_pipeline_state.h"
#include "video_core/renderer_vulkan/vk_state_tracker.h"
@ -201,6 +202,19 @@ void FixedPipelineState::BlendingAttachment::Refresh(const Maxwell& regs, size_t
};
if (!regs.blend_per_target_enabled) {
// Temporary workaround for games that use iterated blending
// even when dynamic blending is off so overrides work with EDS = 0 as well
if (regs.iterated_blend.enable && Settings::values.use_squashed_iterated_blend) {
equation_rgb.Assign(PackBlendEquation(Maxwell::Blend::Equation::Add_GL));
equation_a.Assign(PackBlendEquation(Maxwell::Blend::Equation::Add_GL));
factor_source_rgb.Assign(PackBlendFactor(Maxwell::Blend::Factor::One_GL));
factor_dest_rgb.Assign(PackBlendFactor(Maxwell::Blend::Factor::One_GL));
factor_source_a.Assign(
PackBlendFactor(Maxwell::Blend::Factor::OneMinusSourceColor_GL));
factor_dest_a.Assign(PackBlendFactor(Maxwell::Blend::Factor::Zero_GL));
enable.Assign(1);
return;
}
setup_blend(regs.blend);
return;
}

47
src/video_core/renderer_vulkan/vk_rasterizer.cpp

@ -1557,22 +1557,41 @@ void RasterizerVulkan::UpdateBlending(Tegra::Engines::Maxwell3D::Regs& regs) {
if (state_tracker.TouchBlendEquations()) {
std::array<VkColorBlendEquationEXT, Maxwell::NumRenderTargets> setup_blends{};
for (size_t index = 0; index < Maxwell::NumRenderTargets; index++) {
const auto blend_setup = [&]<typename T>(const T& guest_blend) {
auto& host_blend = setup_blends[index];
host_blend.srcColorBlendFactor = MaxwellToVK::BlendFactor(guest_blend.color_source);
host_blend.dstColorBlendFactor = MaxwellToVK::BlendFactor(guest_blend.color_dest);
host_blend.colorBlendOp = MaxwellToVK::BlendEquation(guest_blend.color_op);
host_blend.srcAlphaBlendFactor = MaxwellToVK::BlendFactor(guest_blend.alpha_source);
host_blend.dstAlphaBlendFactor = MaxwellToVK::BlendFactor(guest_blend.alpha_dest);
host_blend.alphaBlendOp = MaxwellToVK::BlendEquation(guest_blend.alpha_op);
};
if (!regs.blend_per_target_enabled) {
blend_setup(regs.blend);
continue;
const auto blend_setup = [&](auto& host_blend, const auto& guest_blend) {
host_blend.srcColorBlendFactor = MaxwellToVK::BlendFactor(guest_blend.color_source);
host_blend.dstColorBlendFactor = MaxwellToVK::BlendFactor(guest_blend.color_dest);
host_blend.colorBlendOp = MaxwellToVK::BlendEquation(guest_blend.color_op);
host_blend.srcAlphaBlendFactor = MaxwellToVK::BlendFactor(guest_blend.alpha_source);
host_blend.dstAlphaBlendFactor = MaxwellToVK::BlendFactor(guest_blend.alpha_dest);
host_blend.alphaBlendOp = MaxwellToVK::BlendEquation(guest_blend.alpha_op);
};
// Single blend equation for all targets
if (!regs.blend_per_target_enabled) {
// Temporary workaround for games that use iterated blending
if (regs.iterated_blend.enable && Settings::values.use_squashed_iterated_blend) {
setup_blends[0].srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
setup_blends[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
setup_blends[0].colorBlendOp = VK_BLEND_OP_ADD;
setup_blends[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
setup_blends[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
setup_blends[0].alphaBlendOp = VK_BLEND_OP_ADD;
} else {
blend_setup(setup_blends[0], regs.blend);
}
// Copy first blend state to all other targets
for (size_t index = 1; index < Maxwell::NumRenderTargets; index++) {
setup_blends[index] = setup_blends[0];
}
} else {
// Per-target blending
for (size_t index = 0; index < Maxwell::NumRenderTargets; index++) {
blend_setup(setup_blends[index], regs.blend_per_target[index]);
}
blend_setup(regs.blend_per_target[index]);
}
scheduler.Record([setup_blends](vk::CommandBuffer cmdbuf) {
cmdbuf.SetColorBlendEquationEXT(0, setup_blends);
});

Loading…
Cancel
Save