mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-12-06 00:32:41 -08:00
refactor(vulkan): remove depth buffer workarounds and excessive logging
- Remove special handling for reversed depth scenarios that were added for Civilization 7 - Remove excessive logging in Vulkan renderer - Update Discord client ID - Update Vulkan-related external dependencies Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
2
externals/Vulkan-Headers
vendored
2
externals/Vulkan-Headers
vendored
Submodule externals/Vulkan-Headers updated: 78c359741d...5ceb9ed481
2
externals/Vulkan-Utility-Libraries
vendored
2
externals/Vulkan-Utility-Libraries
vendored
Submodule externals/Vulkan-Utility-Libraries updated: 0d5b49b80f...4ee0833a3c
2
externals/VulkanMemoryAllocator
vendored
2
externals/VulkanMemoryAllocator
vendored
Submodule externals/VulkanMemoryAllocator updated: 89d3a6a5ea...f378e7b3f1
2
externals/vcpkg
vendored
2
externals/vcpkg
vendored
Submodule externals/vcpkg updated: 64f3d3d620...bc994510d2
@@ -36,7 +36,7 @@ system_
|
||||
DiscordEventHandlers handlers {};
|
||||
// The number is the client ID for citron, it's used for images and the
|
||||
// application name
|
||||
Discord_Initialize("1322413013248118888", & handlers, 1, nullptr);
|
||||
Discord_Initialize("1361252452329848892", & handlers, 1, nullptr);
|
||||
}
|
||||
|
||||
DiscordImpl::~DiscordImpl() {
|
||||
|
||||
@@ -369,9 +369,6 @@ void RasterizerVulkan::Clear(u32 layer_count) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only log the clear depth value - there's no depth or stencil members in ClearSurface
|
||||
LOG_INFO(Render_Vulkan, "Clear depth value: {}", regs.clear_depth);
|
||||
|
||||
std::scoped_lock lock{texture_cache.mutex};
|
||||
texture_cache.UpdateRenderTargets(true);
|
||||
const Framebuffer* const framebuffer = texture_cache.GetFramebuffer();
|
||||
@@ -977,8 +974,7 @@ void RasterizerVulkan::UpdateDynamicStates() {
|
||||
bool hasFloat = std::any_of(
|
||||
regs.vertex_attrib_format.begin(), regs.vertex_attrib_format.end(),
|
||||
[](const auto& attrib) {
|
||||
return attrib.type ==
|
||||
Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type::Float;
|
||||
return attrib.type == Tegra::Engines::Maxwell3D::Regs::VertexAttribute::Type::Float;
|
||||
});
|
||||
|
||||
// For AMD drivers, disable logic_op if a float attribute is present.
|
||||
@@ -1290,33 +1286,8 @@ void RasterizerVulkan::UpdateDepthWriteEnable(Tegra::Engines::Maxwell3D::Regs& r
|
||||
if (!state_tracker.TouchDepthWriteEnable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we're likely in a reversed depth scenario (clear depth near 0)
|
||||
const bool likely_reversed_depth = (regs.clear_depth < 0.5f);
|
||||
|
||||
// Get the original depth write enable state
|
||||
bool depth_write_enable = regs.depth_write_enabled != 0;
|
||||
bool modified = false;
|
||||
|
||||
// Only force enable depth writes when:
|
||||
// 1. We're using reversed depth (clear_depth < 0.5)
|
||||
// 2. Depth testing is enabled
|
||||
// 3. Original depth writes are disabled
|
||||
// This selectively fixes the issue without affecting other games
|
||||
if (likely_reversed_depth && regs.depth_test_enable && !depth_write_enable) {
|
||||
depth_write_enable = true;
|
||||
modified = true;
|
||||
LOG_INFO(Render_Vulkan, "Reversed depth buffer with disabled depth writes detected, "
|
||||
"enabling depth writes for improved visibility");
|
||||
}
|
||||
|
||||
// Log when depth write is being modified
|
||||
LOG_INFO(Render_Vulkan, "Depth write set to: {} ({}){}",
|
||||
depth_write_enable ? "enabled" : "disabled", regs.depth_write_enabled ? "1" : "0",
|
||||
modified ? " -> modified" : "");
|
||||
|
||||
scheduler.Record([depth_write_enable](vk::CommandBuffer cmdbuf) {
|
||||
cmdbuf.SetDepthWriteEnableEXT(depth_write_enable);
|
||||
scheduler.Record([enable = regs.depth_write_enabled](vk::CommandBuffer cmdbuf) {
|
||||
cmdbuf.SetDepthWriteEnableEXT(enable);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1400,27 +1371,7 @@ void RasterizerVulkan::UpdateDepthCompareOp(Tegra::Engines::Maxwell3D::Regs& reg
|
||||
if (!state_tracker.TouchDepthCompareOp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the original depth comparison function requested by the game
|
||||
auto original_func = regs.depth_test_func;
|
||||
auto func_to_use = original_func;
|
||||
|
||||
// Check for clear depth - we'll use this to determine how to handle depth
|
||||
const bool likely_reversed_depth = (regs.clear_depth < 0.5f);
|
||||
|
||||
// For reversed depth (clear_depth near 0), ALWAYS use GREATER_OR_EQUAL
|
||||
// For normal depth (clear_depth near 1), ALWAYS use LESS_OR_EQUAL
|
||||
if (likely_reversed_depth) {
|
||||
func_to_use =
|
||||
Maxwell::ComparisonOp::GreaterEqual_GL; // Maxwell::ComparisonOp::GreaterEqual_GL;
|
||||
LOG_INFO(Render_Vulkan,
|
||||
"Reversed depth buffer detected, using GREATER_OR_EQUAL for improved visibility");
|
||||
} else {
|
||||
func_to_use = regs.depth_test_func;
|
||||
}
|
||||
|
||||
// Use the modified depth comparison function
|
||||
scheduler.Record([func = func_to_use](vk::CommandBuffer cmdbuf) {
|
||||
scheduler.Record([func = regs.depth_test_func](vk::CommandBuffer cmdbuf) {
|
||||
cmdbuf.SetDepthCompareOpEXT(MaxwellToVK::ComparisonOp(func));
|
||||
});
|
||||
}
|
||||
@@ -1525,38 +1476,13 @@ void RasterizerVulkan::UpdateBlending(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||
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) {
|
||||
// Check if we're likely in a reversed depth scenario (clear depth near 0),
|
||||
// which would indicate we're in Civilization 7 where models have transparency
|
||||
// issues
|
||||
const bool likely_reversed_depth = (regs.clear_depth < 0.5f);
|
||||
|
||||
auto& host_blend = setup_blends[index];
|
||||
|
||||
if (likely_reversed_depth) {
|
||||
// For reversed depth scenarios (likely Civilization 7), force ONE/ZERO blend
|
||||
// factors to ensure models render as fully opaque
|
||||
host_blend.srcColorBlendFactor =
|
||||
MaxwellToVK::BlendFactor(guest_blend.color_source);
|
||||
host_blend.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
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);
|
||||
} else {
|
||||
// For normal depth scenarios, use the game's requested blend factors
|
||||
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);
|
||||
}
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user