mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-11 01:08:39 +12:00
rsx: Track orphaned surfaces' parent addresses
This commit is contained in:
parent
f66eaf8f44
commit
4417701ea7
3 changed files with 80 additions and 80 deletions
|
@ -68,7 +68,7 @@ namespace rsx
|
||||||
std::pair<u32, surface_type> m_bound_depth_stencil = {};
|
std::pair<u32, surface_type> m_bound_depth_stencil = {};
|
||||||
|
|
||||||
// List of sections derived from a section that has been split and invalidated
|
// List of sections derived from a section that has been split and invalidated
|
||||||
std::vector<surface_type> orphaned_surfaces;
|
std::vector<std::pair<u32, surface_type>> orphaned_surfaces;
|
||||||
|
|
||||||
// List of sections that have been wholly inherited and invalidated
|
// List of sections that have been wholly inherited and invalidated
|
||||||
std::vector<surface_type> superseded_surfaces;
|
std::vector<surface_type> superseded_surfaces;
|
||||||
|
@ -156,7 +156,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure(region.target == Traits::get(sink));
|
ensure(region.target == Traits::get(sink));
|
||||||
orphaned_surfaces.push_back(region.target);
|
orphaned_surfaces.push_back({ address, region.target });
|
||||||
data.emplace(region.target->get_memory_range(), std::move(sink));
|
data.emplace(region.target->get_memory_range(), std::move(sink));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -310,6 +310,47 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool /*
|
||||||
m_rtts.superseded_surfaces.clear();
|
m_rtts.superseded_surfaces.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_rtts.orphaned_surfaces.empty())
|
||||||
|
{
|
||||||
|
gl::texture::format format;
|
||||||
|
gl::texture::type type;
|
||||||
|
bool swap_bytes;
|
||||||
|
|
||||||
|
for (auto& [base_addr, surface] : m_rtts.orphaned_surfaces)
|
||||||
|
{
|
||||||
|
const bool lock = surface->is_depth_surface() ? !!g_cfg.video.write_depth_buffer :
|
||||||
|
!!g_cfg.video.write_color_buffers;
|
||||||
|
|
||||||
|
if (!lock) [[likely]]
|
||||||
|
{
|
||||||
|
m_gl_texture_cache.commit_framebuffer_memory_region(cmd, surface->get_memory_range());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (surface->is_depth_surface())
|
||||||
|
{
|
||||||
|
const auto depth_format_gl = rsx::internals::surface_depth_format_to_gl(surface->get_surface_depth_format());
|
||||||
|
format = depth_format_gl.format;
|
||||||
|
type = depth_format_gl.type;
|
||||||
|
swap_bytes = (type != gl::texture::type::uint_24_8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto color_format_gl = rsx::internals::surface_color_format_to_gl(surface->get_surface_color_format());
|
||||||
|
format = color_format_gl.format;
|
||||||
|
type = color_format_gl.type;
|
||||||
|
swap_bytes = color_format_gl.swap_bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_gl_texture_cache.lock_memory_region(
|
||||||
|
cmd, surface, surface->get_memory_range(), false,
|
||||||
|
surface->get_surface_width<rsx::surface_metrics::pixels>(), surface->get_surface_height<rsx::surface_metrics::pixels>(), surface->get_rsx_pitch(),
|
||||||
|
format, type, swap_bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rtts.orphaned_surfaces.clear();
|
||||||
|
}
|
||||||
|
|
||||||
const auto color_format = rsx::internals::surface_color_format_to_gl(m_framebuffer_layout.color_format);
|
const auto color_format = rsx::internals::surface_color_format_to_gl(m_framebuffer_layout.color_format);
|
||||||
for (u8 i = 0; i < rsx::limits::color_buffers_count; ++i)
|
for (u8 i = 0; i < rsx::limits::color_buffers_count; ++i)
|
||||||
{
|
{
|
||||||
|
@ -347,47 +388,6 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool /*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_rtts.orphaned_surfaces.empty())
|
|
||||||
{
|
|
||||||
gl::texture::format format;
|
|
||||||
gl::texture::type type;
|
|
||||||
bool swap_bytes;
|
|
||||||
|
|
||||||
for (auto& surface : m_rtts.orphaned_surfaces)
|
|
||||||
{
|
|
||||||
const bool lock = surface->is_depth_surface() ? !!g_cfg.video.write_depth_buffer :
|
|
||||||
!!g_cfg.video.write_color_buffers;
|
|
||||||
|
|
||||||
if (!lock) [[likely]]
|
|
||||||
{
|
|
||||||
m_gl_texture_cache.commit_framebuffer_memory_region(cmd, surface->get_memory_range());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surface->is_depth_surface())
|
|
||||||
{
|
|
||||||
const auto depth_format_gl = rsx::internals::surface_depth_format_to_gl(surface->get_surface_depth_format());
|
|
||||||
format = depth_format_gl.format;
|
|
||||||
type = depth_format_gl.type;
|
|
||||||
swap_bytes = (type != gl::texture::type::uint_24_8);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto color_format_gl = rsx::internals::surface_color_format_to_gl(surface->get_surface_color_format());
|
|
||||||
format = color_format_gl.format;
|
|
||||||
type = color_format_gl.type;
|
|
||||||
swap_bytes = color_format_gl.swap_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_gl_texture_cache.lock_memory_region(
|
|
||||||
cmd, surface, surface->get_memory_range(), false,
|
|
||||||
surface->get_surface_width<rsx::surface_metrics::pixels>(), surface->get_surface_height<rsx::surface_metrics::pixels>(), surface->get_rsx_pitch(),
|
|
||||||
format, type, swap_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_rtts.orphaned_surfaces.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_gl_texture_cache.get_ro_tex_invalidate_intr())
|
if (m_gl_texture_cache.get_ro_tex_invalidate_intr())
|
||||||
{
|
{
|
||||||
// Invalidate cached sampler state
|
// Invalidate cached sampler state
|
||||||
|
|
|
@ -2416,6 +2416,43 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
|
||||||
m_rtts.superseded_surfaces.clear();
|
m_rtts.superseded_surfaces.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_rtts.orphaned_surfaces.empty())
|
||||||
|
{
|
||||||
|
u32 gcm_format;
|
||||||
|
bool swap_bytes;
|
||||||
|
|
||||||
|
for (auto& [base_addr, surface] : m_rtts.orphaned_surfaces)
|
||||||
|
{
|
||||||
|
const bool lock = surface->is_depth_surface() ? !!g_cfg.video.write_depth_buffer :
|
||||||
|
!!g_cfg.video.write_color_buffers;
|
||||||
|
|
||||||
|
if (!lock) [[likely]]
|
||||||
|
{
|
||||||
|
m_texture_cache.commit_framebuffer_memory_region(*m_current_command_buffer, surface->get_memory_range());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (surface->is_depth_surface())
|
||||||
|
{
|
||||||
|
gcm_format = (surface->get_surface_depth_format() != rsx::surface_depth_format::z16) ? CELL_GCM_TEXTURE_DEPTH16 : CELL_GCM_TEXTURE_DEPTH24_D8;
|
||||||
|
swap_bytes = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto info = get_compatible_gcm_format(surface->get_surface_color_format());
|
||||||
|
gcm_format = info.first;
|
||||||
|
swap_bytes = info.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_texture_cache.lock_memory_region(
|
||||||
|
*m_current_command_buffer, surface, surface->get_memory_range(), false,
|
||||||
|
surface->get_surface_width<rsx::surface_metrics::pixels>(), surface->get_surface_height<rsx::surface_metrics::pixels>(), surface->get_rsx_pitch(),
|
||||||
|
gcm_format, swap_bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_rtts.orphaned_surfaces.clear();
|
||||||
|
}
|
||||||
|
|
||||||
const auto color_fmt_info = get_compatible_gcm_format(m_framebuffer_layout.color_format);
|
const auto color_fmt_info = get_compatible_gcm_format(m_framebuffer_layout.color_format);
|
||||||
for (u8 index : m_draw_buffers)
|
for (u8 index : m_draw_buffers)
|
||||||
{
|
{
|
||||||
|
@ -2451,43 +2488,6 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_rtts.orphaned_surfaces.empty())
|
|
||||||
{
|
|
||||||
u32 gcm_format;
|
|
||||||
bool swap_bytes;
|
|
||||||
|
|
||||||
for (auto& surface : m_rtts.orphaned_surfaces)
|
|
||||||
{
|
|
||||||
const bool lock = surface->is_depth_surface() ? !!g_cfg.video.write_depth_buffer :
|
|
||||||
!!g_cfg.video.write_color_buffers;
|
|
||||||
|
|
||||||
if (!lock) [[likely]]
|
|
||||||
{
|
|
||||||
m_texture_cache.commit_framebuffer_memory_region(*m_current_command_buffer, surface->get_memory_range());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surface->is_depth_surface())
|
|
||||||
{
|
|
||||||
gcm_format = (surface->get_surface_depth_format() != rsx::surface_depth_format::z16) ? CELL_GCM_TEXTURE_DEPTH16 : CELL_GCM_TEXTURE_DEPTH24_D8;
|
|
||||||
swap_bytes = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto info = get_compatible_gcm_format(surface->get_surface_color_format());
|
|
||||||
gcm_format = info.first;
|
|
||||||
swap_bytes = info.second;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_texture_cache.lock_memory_region(
|
|
||||||
*m_current_command_buffer, surface, surface->get_memory_range(), false,
|
|
||||||
surface->get_surface_width<rsx::surface_metrics::pixels>(), surface->get_surface_height<rsx::surface_metrics::pixels>(), surface->get_rsx_pitch(),
|
|
||||||
gcm_format, swap_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_rtts.orphaned_surfaces.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_current_renderpass_key = vk::get_renderpass_key(m_fbo_images);
|
m_current_renderpass_key = vk::get_renderpass_key(m_fbo_images);
|
||||||
m_cached_renderpass = vk::get_renderpass(*m_device, m_current_renderpass_key);
|
m_cached_renderpass = vk::get_renderpass(*m_device, m_current_renderpass_key);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue