vk: Simplify manual heap flush for shadowed blocks

This commit is contained in:
kd-11 2026-04-25 23:15:48 +03:00 committed by kd-11
parent 278daddd2a
commit cbbf52878a
4 changed files with 35 additions and 35 deletions

View file

@ -8,6 +8,14 @@ namespace vk::data_heap_manager
{
std::unordered_set<vk::data_heap*> g_managed_heaps;
rsx::simple_array<vk::data_heap*> to_list()
{
rsx::simple_array<vk::data_heap*> result;
result.resize(::size32(g_managed_heaps));
std::copy(g_managed_heaps.begin(), g_managed_heaps.end(), result.begin());
return result;
}
void register_ring_buffer(vk::data_heap& heap)
{
g_managed_heaps.insert(&heap);

View file

@ -1,6 +1,7 @@
#pragma once
#include <util/types.hpp>
#include "Emu/RSX/Common/simple_array.hpp"
#include <unordered_map>
@ -29,5 +30,8 @@ namespace vk
// Cleanup
void reset();
// Retrieve as list
rsx::simple_array<vk::data_heap*> to_list();
}
}

View file

@ -535,6 +535,8 @@ VKGSRender::VKGSRender(utils::serial* ar) noexcept : GSRender(ar)
std::ref(m_instancing_buffer_ring_info)
});
m_flushable_data_heaps = vk::data_heap_manager::to_list().filter(FN(x->has_shadow()));
const auto shadermode = g_cfg.video.shadermode.get();
if (shadermode == shader_mode::async_with_interpreter || shadermode == shader_mode::interpreter_only)
@ -2297,32 +2299,16 @@ void VKGSRender::close_and_submit_command_buffer(vk::fence* pFence, VkSemaphore
if (vk::test_status_interrupt(vk::heap_dirty))
{
if (m_attrib_ring_info.is_dirty() ||
m_fragment_env_ring_info.is_dirty() ||
m_vertex_env_ring_info.is_dirty() ||
m_fragment_texture_params_ring_info.is_dirty() ||
m_vertex_layout_ring_info.is_dirty() ||
m_fragment_constants_ring_info.is_dirty() ||
m_index_buffer_ring_info.is_dirty() ||
m_transform_constants_ring_info.is_dirty() ||
m_texture_upload_buffer_ring_info.is_dirty() ||
m_raster_env_ring_info.is_dirty() ||
m_instancing_buffer_ring_info.is_dirty())
if (const auto dirty_list = m_flushable_data_heaps.filter(FN(x->is_dirty()));
!dirty_list.empty())
{
auto secondary_command_buffer = m_secondary_cb_list.next();
secondary_command_buffer->begin();
m_attrib_ring_info.sync(*secondary_command_buffer);
m_fragment_env_ring_info.sync(*secondary_command_buffer);
m_vertex_env_ring_info.sync(*secondary_command_buffer);
m_fragment_texture_params_ring_info.sync(*secondary_command_buffer);
m_vertex_layout_ring_info.sync(*secondary_command_buffer);
m_fragment_constants_ring_info.sync(*secondary_command_buffer);
m_index_buffer_ring_info.sync(*secondary_command_buffer);
m_transform_constants_ring_info.sync(*secondary_command_buffer);
m_texture_upload_buffer_ring_info.sync(*secondary_command_buffer);
m_raster_env_ring_info.sync(*secondary_command_buffer);
m_instancing_buffer_ring_info.sync(*secondary_command_buffer);
for (auto& heap : dirty_list)
{
heap->sync(*secondary_command_buffer);
}
secondary_command_buffer->end();

View file

@ -122,20 +122,22 @@ private:
u64 m_last_heap_sync_time = 0;
u32 m_texbuffer_view_size = 0;
vk::data_heap m_attrib_ring_info; // Vertex data
vk::data_heap m_fragment_constants_ring_info; // Fragment program constants
vk::data_heap m_transform_constants_ring_info; // Transform program constants
vk::data_heap m_fragment_env_ring_info; // Fragment environment params
vk::data_heap m_vertex_env_ring_info; // Vertex environment params
vk::data_heap m_fragment_texture_params_ring_info; // Fragment texture params
vk::data_heap m_vertex_layout_ring_info; // Vertex layout structure
vk::data_heap m_index_buffer_ring_info; // Index data
vk::data_heap m_texture_upload_buffer_ring_info; // Texture upload heap
vk::data_heap m_raster_env_ring_info; // Raster control such as polygon and line stipple
vk::data_heap m_instancing_buffer_ring_info; // Instanced rendering data (constants indirection table + instanced constants)
vk::data_heap m_attrib_ring_info; // Vertex data
vk::data_heap m_fragment_constants_ring_info; // Fragment program constants
vk::data_heap m_transform_constants_ring_info; // Transform program constants
vk::data_heap m_fragment_env_ring_info; // Fragment environment params
vk::data_heap m_vertex_env_ring_info; // Vertex environment params
vk::data_heap m_fragment_texture_params_ring_info; // Fragment texture params
vk::data_heap m_vertex_layout_ring_info; // Vertex layout structure
vk::data_heap m_index_buffer_ring_info; // Index data
vk::data_heap m_texture_upload_buffer_ring_info; // Texture upload heap
vk::data_heap m_raster_env_ring_info; // Raster control such as polygon and line stipple
vk::data_heap m_instancing_buffer_ring_info; // Instanced rendering data (constants indirection table + instanced constants)
vk::data_heap m_fragment_instructions_buffer;
vk::data_heap m_vertex_instructions_buffer;
vk::data_heap m_fragment_instructions_buffer; // Interpreter FP block
vk::data_heap m_vertex_instructions_buffer; // Interpreter VP block
rsx::simple_array<vk::data_heap*> m_flushable_data_heaps; // List of heaps that can be 'dirty' and need manual flush
VkDescriptorBufferInfoEx m_vertex_env_buffer_info {};
VkDescriptorBufferInfoEx m_fragment_env_buffer_info {};