rsx: Modify find_cached_texture to respect gcm_format. Can pass 0 for "dont care"

This commit is contained in:
kd-11 2019-09-09 19:14:57 +03:00 committed by kd-11
parent cb66d05693
commit 75fcfac00e
4 changed files with 14 additions and 15 deletions

View file

@ -10,6 +10,8 @@
extern u64 get_system_time(); extern u64 get_system_time();
#define RSX_GCM_FORMAT_IGNORED 0
namespace rsx namespace rsx
{ {
template <typename derived_type, typename _traits> template <typename derived_type, typename _traits>
@ -1092,7 +1094,7 @@ namespace rsx
return nullptr; return nullptr;
} }
section_storage_type* find_cached_texture(const address_range &range, bool create_if_not_found, bool confirm_dimensions, u16 width = 0, u16 height = 0, u16 depth = 0, u16 mipmaps = 0) section_storage_type* find_cached_texture(const address_range &range, u32 gcm_format, bool create_if_not_found, bool confirm_dimensions, u16 width = 0, u16 height = 0, u16 depth = 0, u16 mipmaps = 0)
{ {
auto &block = m_storage.block_for(range); auto &block = m_storage.block_for(range);
@ -1110,7 +1112,7 @@ namespace rsx
{ {
if (!tex.is_dirty()) if (!tex.is_dirty())
{ {
if (!confirm_dimensions || tex.matches_dimensions(width, height, depth, mipmaps)) if (!confirm_dimensions || tex.matches(gcm_format, width, height, depth, mipmaps))
{ {
#ifndef TEXTURE_CACHE_DEBUG #ifndef TEXTURE_CACHE_DEBUG
return &tex; return &tex;
@ -1202,7 +1204,7 @@ namespace rsx
std::lock_guard lock(m_cache_mutex); std::lock_guard lock(m_cache_mutex);
// Find a cached section to use // Find a cached section to use
section_storage_type& region = *find_cached_texture(rsx_range, true, true, width, height); section_storage_type& region = *find_cached_texture(rsx_range, RSX_GCM_FORMAT_IGNORED, true, true, width, height);
// Prepare and initialize fbo region // Prepare and initialize fbo region
if (region.exists() && region.get_context() != texture_upload_context::framebuffer_storage) if (region.exists() && region.get_context() != texture_upload_context::framebuffer_storage)
@ -1278,7 +1280,7 @@ namespace rsx
{ {
std::lock_guard lock(m_cache_mutex); std::lock_guard lock(m_cache_mutex);
auto* region_ptr = find_cached_texture(memory_range, false, false); auto* region_ptr = find_cached_texture(memory_range, RSX_GCM_FORMAT_IGNORED, false, false);
if (region_ptr == nullptr) if (region_ptr == nullptr)
{ {
AUDIT(m_flush_always_cache.find(memory_range) == m_flush_always_cache.end()); AUDIT(m_flush_always_cache.find(memory_range) == m_flush_always_cache.end());

View file

@ -1646,11 +1646,14 @@ namespace rsx
return valid_range() && rsx::buffered_section::matches(memory_range); return valid_range() && rsx::buffered_section::matches(memory_range);
} }
bool matches_dimensions(u32 width, u32 height, u32 depth, u32 mipmaps) bool matches(u32 format, u32 width, u32 height, u32 depth, u32 mipmaps)
{ {
if (!valid_range()) if (!valid_range())
return false; return false;
if ((gcm_format & format) != format)
return false;
if (!width && !height && !depth && !mipmaps) if (!width && !height && !depth && !mipmaps)
return true; return true;
@ -1677,10 +1680,7 @@ namespace rsx
if (rsx_address != get_section_base()) if (rsx_address != get_section_base())
return false; return false;
if ((gcm_format & format) != format) return matches(format, width, height, depth, mipmaps);
return false;
return matches_dimensions(width, height, depth, mipmaps);
} }
bool matches(const address_range& memory_range, u32 format, u32 width, u32 height, u32 depth, u32 mipmaps) bool matches(const address_range& memory_range, u32 format, u32 width, u32 height, u32 depth, u32 mipmaps)
@ -1691,10 +1691,7 @@ namespace rsx
if (!rsx::buffered_section::matches(memory_range)) if (!rsx::buffered_section::matches(memory_range))
return false; return false;
if ((gcm_format & format) != format) return matches(format, width, height, depth, mipmaps);
return false;
return matches_dimensions(width, height, depth, mipmaps);
} }

View file

@ -831,7 +831,7 @@ namespace gl
const auto swizzle = get_component_mapping(gcm_format, flags); const auto swizzle = get_component_mapping(gcm_format, flags);
image->set_native_component_layout(swizzle); image->set_native_component_layout(swizzle);
auto& cached = *find_cached_texture(rsx_range, true, true, width, height, depth, mipmaps); auto& cached = *find_cached_texture(rsx_range, gcm_format, true, true, width, height, depth, mipmaps);
ASSERT(!cached.is_locked()); ASSERT(!cached.is_locked());
// Prepare section // Prepare section

View file

@ -1020,7 +1020,7 @@ namespace vk
change_image_layout(cmd, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, { aspect_flags, 0, mipmaps, 0, layer }); change_image_layout(cmd, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, { aspect_flags, 0, mipmaps, 0, layer });
cached_texture_section& region = *find_cached_texture(rsx_range, true, true, width, height, section_depth); cached_texture_section& region = *find_cached_texture(rsx_range, gcm_format, true, true, width, height, section_depth);
ASSERT(!region.is_locked()); ASSERT(!region.is_locked());
// New section, we must prepare it // New section, we must prepare it