refactor(vulkan): Remove redundant query cache segment notifications

- Remove NotifySegment(true) from PrepareDraw, DrawTexture, and Clear
- Remove NotifySegment(false) from AccelerateDisplay
- Add state tracking for transform feedback to avoid redundant CounterEnable calls
- Only call CounterEnable when transform feedback enable state changes

This prevents double resume/pause operations and state management conflicts.

Co-authored-by: Maufeat <maufeat@eden-emu.dev>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2025-12-08 16:18:27 +10:00
parent 220c06b5e7
commit d5efa255ee
2 changed files with 10 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm> #include <algorithm>
@@ -214,8 +215,6 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
FlushWork(); FlushWork();
gpu_memory->FlushCaching(); gpu_memory->FlushCaching();
query_cache.NotifySegment(true);
GraphicsPipeline* const pipeline{pipeline_cache.CurrentGraphicsPipeline()}; GraphicsPipeline* const pipeline{pipeline_cache.CurrentGraphicsPipeline()};
if (!pipeline) { if (!pipeline) {
return; return;
@@ -307,8 +306,6 @@ void RasterizerVulkan::DrawTexture() {
}; };
FlushWork(); FlushWork();
query_cache.NotifySegment(true);
std::scoped_lock l{texture_cache.mutex}; std::scoped_lock l{texture_cache.mutex};
texture_cache.SynchronizeGraphicsDescriptors(); texture_cache.SynchronizeGraphicsDescriptors();
texture_cache.UpdateRenderTargets(false); texture_cache.UpdateRenderTargets(false);
@@ -355,7 +352,6 @@ void RasterizerVulkan::Clear(u32 layer_count) {
FlushWork(); FlushWork();
gpu_memory->FlushCaching(); gpu_memory->FlushCaching();
query_cache.NotifySegment(true);
query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64, query_cache.CounterEnable(VideoCommon::QueryType::ZPassPixelCount64,
maxwell3d->regs.zpass_pixel_count_enable); maxwell3d->regs.zpass_pixel_count_enable);
@@ -875,7 +871,6 @@ std::optional<FramebufferTextureInfo> RasterizerVulkan::AccelerateDisplay(
if (!image_view) { if (!image_view) {
return {}; return {};
} }
query_cache.NotifySegment(false);
const auto& resolution = Settings::values.resolution_info; const auto& resolution = Settings::values.resolution_info;
@@ -1028,9 +1023,14 @@ void RasterizerVulkan::HandleTransformFeedback() {
}); });
return; return;
} }
query_cache.CounterEnable(VideoCommon::QueryType::StreamingByteCount, // Only update counter state when transform feedback enable state changes
regs.transform_feedback_enabled); const bool transform_feedback_enabled = regs.transform_feedback_enabled != 0;
if (regs.transform_feedback_enabled != 0) { if (last_transform_feedback_enabled != transform_feedback_enabled) {
query_cache.CounterEnable(VideoCommon::QueryType::StreamingByteCount,
transform_feedback_enabled);
last_transform_feedback_enabled = transform_feedback_enabled;
}
if (transform_feedback_enabled) {
UNIMPLEMENTED_IF(regs.IsShaderConfigEnabled(Maxwell::ShaderType::TessellationInit) || UNIMPLEMENTED_IF(regs.IsShaderConfigEnabled(Maxwell::ShaderType::TessellationInit) ||
regs.IsShaderConfigEnabled(Maxwell::ShaderType::Tessellation)); regs.IsShaderConfigEnabled(Maxwell::ShaderType::Tessellation));
} }

View File

@@ -219,6 +219,7 @@ private:
boost::container::static_vector<VkSampler, MAX_TEXTURES> sampler_handles; boost::container::static_vector<VkSampler, MAX_TEXTURES> sampler_handles;
u32 draw_counter = 0; u32 draw_counter = 0;
bool last_transform_feedback_enabled = false;
}; };
} // namespace Vulkan } // namespace Vulkan