rsx: Fix zombie image references from inside the texture cache

- Do not add locked orphans to the flush_always cache! They will not remove their cache entries as they are not bound
This commit is contained in:
kd-11 2019-05-15 15:55:14 +03:00 committed by kd-11
parent 214bb3ec87
commit 05eb1e9193
4 changed files with 30 additions and 18 deletions

View File

@ -1252,7 +1252,7 @@ namespace rsx
}
template <typename ...FlushArgs, typename ...Args>
void lock_memory_region(commandbuffer_type& cmd, image_storage_type* image, const address_range &rsx_range, u32 width, u32 height, u32 pitch, Args&&... extras)
void lock_memory_region(commandbuffer_type& cmd, image_storage_type* image, const address_range &rsx_range, bool is_active_surface, u32 width, u32 height, u32 pitch, Args&&... extras)
{
AUDIT(g_cfg.video.write_color_buffers || g_cfg.video.write_depth_buffer); // this method is only called when either WCB or WDB are enabled
@ -1297,15 +1297,18 @@ namespace rsx
region.set_dirty(false);
region.touch(m_cache_update_tag);
// Add to flush always cache
if (region.get_memory_read_flags() != memory_read_flags::flush_always)
if (is_active_surface)
{
region.set_memory_read_flags(memory_read_flags::flush_always, false);
update_flush_always_cache(region, true);
}
else
{
AUDIT(m_flush_always_cache.find(region.get_section_range()) != m_flush_always_cache.end());
// Add to flush always cache
if (region.get_memory_read_flags() != memory_read_flags::flush_always)
{
region.set_memory_read_flags(memory_read_flags::flush_always, false);
update_flush_always_cache(region, true);
}
else
{
AUDIT(m_flush_always_cache.find(region.get_section_range()) != m_flush_always_cache.end());
}
}
update_cache_tag();

View File

@ -398,7 +398,9 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
if (g_cfg.video.write_color_buffers)
{
// Mark buffer regions as NO_ACCESS on Cell-visible side
m_gl_texture_cache.lock_memory_region(cmd, std::get<1>(m_rtts.m_bound_render_targets[i]), surface_range, m_surface_info[i].width, m_surface_info[i].height, m_surface_info[i].pitch,
m_gl_texture_cache.lock_memory_region(
cmd, m_rtts.m_bound_render_targets[i].second, surface_range, true,
m_surface_info[i].width, m_surface_info[i].height, m_surface_info[i].pitch,
color_format.format, color_format.type, color_format.swap_bytes);
}
else
@ -413,7 +415,9 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
if (g_cfg.video.write_depth_buffer)
{
const auto depth_format_gl = rsx::internals::surface_depth_format_to_gl(layout.depth_format);
m_gl_texture_cache.lock_memory_region(cmd, std::get<1>(m_rtts.m_bound_depth_stencil), surface_range, m_depth_surface_info.width, m_depth_surface_info.height, m_depth_surface_info.pitch,
m_gl_texture_cache.lock_memory_region(
cmd, m_rtts.m_bound_depth_stencil.second, surface_range, true,
m_depth_surface_info.width, m_depth_surface_info.height, m_depth_surface_info.pitch,
depth_format_gl.format, depth_format_gl.type, true);
}
else
@ -451,7 +455,8 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
swap_bytes = color_format_gl.swap_bytes;
}
m_gl_texture_cache.lock_memory_region(cmd, surface, surface->get_memory_range(),
m_gl_texture_cache.lock_memory_region(
cmd, surface, surface->get_memory_range(), false,
surface->get_surface_width(), surface->get_surface_height(), surface->get_rsx_pitch(),
format, type, swap_bytes);
}
@ -681,7 +686,7 @@ void gl::render_target::memory_barrier(gl::command_context& cmd, bool force_init
if (state_flags & rsx::surface_state_flags::erase_bkgnd)
{
const auto area = old_contents.dst_rect();
if (area.x1 > 0 || area.y1 > 0 || area.x2 < width() || area.y2 < height())
if (area.x1 > 0 || area.y1 > 0 || unsigned(area.x2) < width() || unsigned(area.y2) < height())
{
clear_surface_impl();
}

View File

@ -3083,8 +3083,10 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
const utils::address_range surface_range = m_surface_info[index].get_memory_range();
if (g_cfg.video.write_color_buffers)
{
m_texture_cache.lock_memory_region(*m_current_command_buffer, std::get<1>(m_rtts.m_bound_render_targets[index]), surface_range,
m_surface_info[index].width, m_surface_info[index].height, layout.actual_color_pitch[index], color_fmt_info.first, color_fmt_info.second);
m_texture_cache.lock_memory_region(
*m_current_command_buffer, m_rtts.m_bound_render_targets[index].second, surface_range, true,
m_surface_info[index].width, m_surface_info[index].height, layout.actual_color_pitch[index],
color_fmt_info.first, color_fmt_info.second);
}
else
{
@ -3098,7 +3100,8 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
if (g_cfg.video.write_depth_buffer)
{
const u32 gcm_format = (m_depth_surface_info.depth_format != rsx::surface_depth_format::z16) ? CELL_GCM_TEXTURE_DEPTH16 : CELL_GCM_TEXTURE_DEPTH24_D8;
m_texture_cache.lock_memory_region(*m_current_command_buffer, std::get<1>(m_rtts.m_bound_depth_stencil), surface_range,
m_texture_cache.lock_memory_region(
*m_current_command_buffer, m_rtts.m_bound_depth_stencil.second, surface_range, true,
m_depth_surface_info.width, m_depth_surface_info.height, layout.actual_zeta_pitch, gcm_format, false);
}
else
@ -3132,7 +3135,8 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
swap_bytes = info.second;
}
m_texture_cache.lock_memory_region(*m_current_command_buffer, surface, surface->get_memory_range(),
m_texture_cache.lock_memory_region(
*m_current_command_buffer, surface, surface->get_memory_range(), false,
surface->get_surface_width(), surface->get_surface_height(), surface->get_rsx_pitch(),
gcm_format, swap_bytes);
}

View File

@ -146,7 +146,7 @@ namespace vk
if (state_flags & rsx::surface_state_flags::erase_bkgnd)
{
const auto area = old_contents.dst_rect();
if (area.x1 > 0 || area.y1 > 0 || area.x2 < width() || area.y2 < height())
if (area.x1 > 0 || area.y1 > 0 || unsigned(area.x2) < width() || unsigned(area.y2) < height())
{
clear_surface_impl();
}