rsx: Simplify ZCULL logic a bit

This commit is contained in:
kd-11 2022-05-10 00:09:13 +03:00 committed by kd-11
parent 850eef0c1a
commit 0b7e013fbe
3 changed files with 27 additions and 42 deletions

View File

@ -102,9 +102,9 @@ namespace rsx
{
rsx_log.error("ZCULL queue interrupted by data type change!");
// Stop+start the current setup
set_active(ptimer, false, false);
set_active(ptimer, true, false);
// Stop+start the current setup
set_active(ptimer, false, false);
set_active(ptimer, true, false);
}
}
}
@ -134,7 +134,7 @@ namespace rsx
if (m_pending_writes.empty())
{
// No need to queue this if there is no pending request in the pipeline anyway
write(sink, ptimer->timestamp(), type, m_statistics_map[m_statistics_tag_id]);
write(sink, ptimer->timestamp(), type, m_statistics_map[m_statistics_tag_id].result);
return;
}
@ -168,7 +168,7 @@ namespace rsx
ptimer->async_tasks_pending++;
if (m_statistics_map[m_statistics_tag_id] != 0)
if (m_statistics_map[m_statistics_tag_id].result != 0)
{
// Flush guaranteed results; only one positive is needed
update(ptimer);
@ -256,7 +256,7 @@ namespace rsx
}
m_statistics_tag_id++;
m_statistics_map[m_statistics_tag_id] = 0;
m_statistics_map[m_statistics_tag_id] = {};
}
void ZCULL_control::on_draw()
@ -326,7 +326,7 @@ namespace rsx
if (!writer->forwarder)
{
// No other queries in the chain, write result
const auto value = (writer->type == CELL_GCM_ZPASS_PIXEL_CNT) ? m_statistics_map[writer->counter_tag] : result;
const auto value = (writer->type == CELL_GCM_ZPASS_PIXEL_CNT) ? m_statistics_map[writer->counter_tag].result : result;
write(writer, ptimer->timestamp(), value);
}
@ -379,38 +379,30 @@ namespace rsx
break;
auto query = writer.query;
u32 result = m_statistics_map[writer.counter_tag];
auto& counter = m_statistics_map[writer.counter_tag];
if (query)
{
ensure(query->pending);
const bool implemented = (writer.type == CELL_GCM_ZPASS_PIXEL_CNT || writer.type == CELL_GCM_ZCULL_STATS3);
const bool have_result = result && !g_cfg.video.precise_zpass_count;
const bool have_result = counter.result && !g_cfg.video.precise_zpass_count;
if (implemented && !have_result && query->num_draws)
{
get_occlusion_query_result(query);
if (query->result)
{
result += query->result;
if (query->data_type & CELL_GCM_ZPASS_PIXEL_CNT)
{
m_statistics_map[writer.counter_tag] += query->result;
}
}
counter.result += query->result;
}
else
{
//Already have a hit, no need to retest
// Already have a hit, no need to retest
discard_occlusion_query(query);
}
free_query(query);
}
retire(ptimer, &writer, result);
retire(ptimer, &writer, counter.result);
processed++;
}
@ -526,7 +518,7 @@ namespace rsx
}
auto query = writer.query;
u32 result = m_statistics_map[writer.counter_tag];
auto& counter = m_statistics_map[writer.counter_tag];
const bool force_read = (sync_address != 0);
if (force_read && writer.sink == sync_address && !writer.forwarder)
@ -540,7 +532,7 @@ namespace rsx
ensure(query->pending);
const bool implemented = (writer.type == CELL_GCM_ZPASS_PIXEL_CNT || writer.type == CELL_GCM_ZCULL_STATS3);
const bool have_result = result && !g_cfg.video.precise_zpass_count;
const bool have_result = counter.result && !g_cfg.video.precise_zpass_count;
if (!implemented || !query->num_draws || have_result)
{
@ -549,15 +541,7 @@ namespace rsx
else if (force_read || check_occlusion_query_status(query))
{
get_occlusion_query_result(query);
if (query->result)
{
result += query->result;
if (query->data_type & CELL_GCM_ZPASS_PIXEL_CNT)
{
m_statistics_map[writer.counter_tag] += query->result;
}
}
counter.result += query->result;
}
else
{
@ -571,7 +555,7 @@ namespace rsx
stat_tag_to_remove = writer.counter_tag;
retire(ptimer, &writer, result);
retire(ptimer, &writer, counter.result);
processed++;
}

View File

@ -45,6 +45,12 @@ namespace rsx
std::vector<occlusion_query_info*> queries;
};
struct query_stat_counter
{
u32 result;
u32 reserved;
};
enum sync_control
{
sync_none = 0,
@ -84,7 +90,7 @@ namespace rsx
u64 m_timer = 0;
std::vector<queued_report_write> m_pending_writes{};
std::unordered_map<u32, u32> m_statistics_map{};
std::unordered_map<u32, query_stat_counter> m_statistics_map{};
// Enables/disables the ZCULL unit
void set_active(class ::rsx::thread* ptimer, bool state, bool flush_queue);

View File

@ -36,15 +36,10 @@ namespace vk
}
case VK_NOT_READY:
{
if (result[0] && (flags & VK_QUERY_RESULT_PARTIAL_BIT))
{
query.any_passed = true;
query.ready = true;
query.data = result[0];
return true;
}
return false;
query.any_passed = !!result[0];
query.ready = query.any_passed && !!(flags & VK_QUERY_RESULT_PARTIAL_BIT);
query.data = result[0];
return query.ready;
}
default:
die_with_error(error);