Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsx: Conditional render sync optimization #6285

Merged
merged 1 commit into from Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions rpcs3/Emu/RSX/RSXThread.cpp
Expand Up @@ -3095,5 +3095,16 @@ namespace rsx
update(ptimer, sync_address);
}
}

occlusion_query_info* ZCULL_control::find_query(vm::addr_t sink_address)
{
for (auto &writer : m_pending_writes)
{
if (writer.sink == sink_address)
return writer.query;
}

return nullptr;
}
}
}
5 changes: 4 additions & 1 deletion rpcs3/Emu/RSX/RSXThread.h
Expand Up @@ -397,6 +397,9 @@ namespace rsx
// Check for pending writes
bool has_pending() const { return !m_pending_writes.empty(); }

// Search for query synchronized at address
occlusion_query_info* find_query(vm::addr_t sink_address);

// Backend methods (optional, will return everything as always visible by default)
virtual void begin_occlusion_query(occlusion_query_info* /*query*/) {}
virtual void end_occlusion_query(occlusion_query_info* /*query*/) {}
Expand Down Expand Up @@ -614,7 +617,7 @@ namespace rsx
// sync
void sync();
void read_barrier(u32 memory_address, u32 memory_range);
virtual void sync_hint(FIFO_hint /*hint*/) {}
virtual void sync_hint(FIFO_hint /*hint*/, u32 /*arg*/) {}

gsl::span<const gsl::byte> get_raw_index_array(const draw_clause& draw_indexed_clause) const;
gsl::span<const gsl::byte> get_raw_vertex_buffer(const rsx::data_array_format_info&, u32 base_offset, const draw_clause& draw_array_clause) const;
Expand Down
19 changes: 15 additions & 4 deletions rpcs3/Emu/RSX/VK/VKGSRender.cpp
Expand Up @@ -2157,15 +2157,26 @@ void VKGSRender::flush_command_queue(bool hard_sync)
open_command_buffer();
}

void VKGSRender::sync_hint(rsx::FIFO_hint hint)
void VKGSRender::sync_hint(rsx::FIFO_hint hint, u32 arg)
{
// Occlusion test result evaluation is coming up, avoid a hard sync
if (hint == rsx::FIFO_hint::hint_conditional_render_eval)
{
if (m_current_command_buffer->flags & vk::command_buffer::cb_has_occlusion_task)
// Occlusion queries not enabled, do nothing
if (!(m_current_command_buffer->flags & vk::command_buffer::cb_has_occlusion_task))
return;

// If a flush request is already enqueued, do nothing
if (m_flush_requests.pending())
return;

// Check if the required report is synced to this CB
if (auto occlusion_info = zcull_ctrl->find_query(vm::cast(arg)))
{
// Occlusion test result evaluation is coming up, avoid a hard sync
if (!m_flush_requests.pending())
auto& data = m_occlusion_map[occlusion_info->driver_handle];
if (data.command_buffer_to_wait == m_current_command_buffer && !data.indices.empty())
{
// Confirmed hard sync coming up, post a sync request
m_flush_requests.post(false);
m_flush_requests.remove_one();
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/VK/VKGSRender.h
Expand Up @@ -463,7 +463,7 @@ class VKGSRender : public GSRender, public ::rsx::reports::ZCULL_control
void set_scissor(bool clip_viewport);
void bind_viewport();

void sync_hint(rsx::FIFO_hint hint) override;
void sync_hint(rsx::FIFO_hint hint, u32 arg) override;

void begin_occlusion_query(rsx::reports::occlusion_query_info* query) override;
void end_occlusion_query(rsx::reports::occlusion_query_info* query) override;
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/rsx_methods.cpp
Expand Up @@ -581,7 +581,7 @@ namespace rsx
}

// Defer conditional render evaluation
rsx->sync_hint(FIFO_hint::hint_conditional_render_eval);
rsx->sync_hint(FIFO_hint::hint_conditional_render_eval, address_ptr);
rsx->conditional_render_test_address = address_ptr;
rsx->conditional_render_test_failed = false;
}
Expand Down