rsx: Optimize hash_struct; vk cleanup

This commit is contained in:
kd-11 2018-07-24 23:41:45 +03:00 committed by kd-11
parent d0165290b6
commit 1200ca8172
3 changed files with 32 additions and 16 deletions

View File

@ -9,19 +9,43 @@ namespace rpcs3
return static_cast<size_t>(value);
}
template<typename T>
static size_t hash_struct(const T& value)
template<typename T, typename U>
static size_t hash_struct_base(const T& value)
{
// FNV 64-bit
size_t result = 14695981039346656037ull;
const unsigned char *bytes = reinterpret_cast<const unsigned char*>(&value);
const U *bits = reinterpret_cast<const U*>(&value);
for (size_t n = 0; n < sizeof(T); ++n)
for (size_t n = 0; n < (sizeof(T) / sizeof(U)); ++n)
{
result ^= bytes[n];
result ^= bits[n];
result *= 1099511628211ull;
}
return result;
}
template<typename T>
static size_t hash_struct(const T& value)
{
// TODO: use c++17 if constexpr
static constexpr auto block_sz = sizeof(T);
if ((block_sz & 0x7) == 0)
{
return hash_struct_base<T, u64>(value);
}
if ((block_sz & 0x3) == 0)
{
return hash_struct_base<T, u32>(value);
}
if ((block_sz & 0x1) == 0)
{
return hash_struct_base<T, u16>(value);
}
return hash_struct_base<T, u8>(value);
}
}

View File

@ -1884,7 +1884,7 @@ namespace rsx
block.base_offset = base_address;
block.attribute_stride = info.stride();
block.memory_location = info.offset() >> 31;
block.locations.reserve(4);
block.locations.reserve(8);
block.locations.push_back(index);
block.min_divisor = info.frequency();
block.all_modulus = !!(frequency_divider_mask & (1 << index));

View File

@ -2671,7 +2671,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
//Search old framebuffers for this same configuration
bool framebuffer_found = false;
const auto fbo_width = rsx::apply_resolution_scale(layout.width, true);
const auto fbo_width = rsx::apply_resolution_scale(layout.width, true);
const auto fbo_height = rsx::apply_resolution_scale(layout.height, true);
for (auto &fbo : m_framebuffers_to_clean)
@ -3140,15 +3140,7 @@ void VKGSRender::end_occlusion_query(rsx::reports::occlusion_query_info* query)
m_occlusion_query_active = false;
m_active_query_info = nullptr;
//Avoid stalling later if this query is already tied to a report
if (query->num_draws && query->owned && !m_flush_requests.pending())
{
if (0)//m_current_command_buffer->flags & cb_has_occlusion_task)
{
m_flush_requests.post(false);
m_flush_requests.remove_one();
}
}
// NOTE: flushing the queue is very expensive, do not flush just because query stopped
}
bool VKGSRender::check_occlusion_query_status(rsx::reports::occlusion_query_info* query)