rsx: Fix race on clearing native_ui vs emu_requested flag

This commit is contained in:
eladash 2019-04-03 16:42:33 +03:00 committed by Ivan
parent 67f098627a
commit 6f76e34104
11 changed files with 25 additions and 19 deletions

View File

@ -251,13 +251,12 @@ error_code sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64
//hle protection //hle protection
if (render->isHLE) if (render->isHLE)
return 0; return CELL_OK;
auto m_sysrsx = fxm::get<SysRsxConfig>(); auto m_sysrsx = fxm::get<SysRsxConfig>();
if (!m_sysrsx) if (!m_sysrsx)
{ {
sys_rsx.error("sys_rsx_context_attribute called before sys_rsx_context_allocate: context_id=0x%x, package_id=0x%x, a3=0x%llx, a4=0x%llx, a5=0x%llx, a6=0x%llx)", context_id, package_id, a3, a4, a5, a6);
return CELL_EINVAL; return CELL_EINVAL;
} }

View File

@ -524,7 +524,7 @@ bool is_flip_surface_in_global_memory(rsx::surface_target color_target)
} }
} }
void D3D12GSRender::flip(int buffer) void D3D12GSRender::flip(int buffer, bool emu_flip)
{ {
ID3D12Resource *resource_to_flip; ID3D12Resource *resource_to_flip;
float viewport_w, viewport_h; float viewport_w, viewport_h;

View File

@ -177,7 +177,7 @@ protected:
virtual void do_local_task(rsx::FIFO_state state) override; virtual void do_local_task(rsx::FIFO_state state) override;
virtual bool do_method(u32 cmd, u32 arg) override; virtual bool do_method(u32 cmd, u32 arg) override;
virtual void end() override; virtual void end() override;
virtual void flip(int buffer) override; virtual void flip(int buffer, bool emu_flip = false) override;
virtual bool on_access_violation(u32 address, bool is_writing) override; virtual bool on_access_violation(u32 address, bool is_writing) override;

View File

@ -1564,7 +1564,7 @@ void GLGSRender::update_draw_state()
m_begin_time += (u32)std::chrono::duration_cast<std::chrono::microseconds>(now - then).count(); m_begin_time += (u32)std::chrono::duration_cast<std::chrono::microseconds>(now - then).count();
} }
void GLGSRender::flip(int buffer) void GLGSRender::flip(int buffer, bool emu_flip)
{ {
if (skip_frame) if (skip_frame)
{ {
@ -1789,7 +1789,7 @@ void GLGSRender::flip(int buffer)
} }
m_frame->flip(m_context); m_frame->flip(m_context);
rsx::thread::flip(buffer); rsx::thread::flip(buffer, emu_flip);
// Cleanup // Cleanup
m_gl_texture_cache.on_frame_end(); m_gl_texture_cache.on_frame_end();
@ -1910,7 +1910,7 @@ void GLGSRender::do_local_task(rsx::FIFO_state state)
{ {
if (!in_begin_end && async_flip_requested & flip_request::native_ui) if (!in_begin_end && async_flip_requested & flip_request::native_ui)
{ {
flip((s32)current_display_buffer); flip((s32)current_display_buffer, false);
} }
} }
} }

View File

@ -393,7 +393,7 @@ protected:
void on_init_thread() override; void on_init_thread() override;
void on_exit() override; void on_exit() override;
bool do_method(u32 id, u32 arg) override; bool do_method(u32 id, u32 arg) override;
void flip(int buffer) override; void flip(int buffer, bool emu_flip = false) override;
void do_local_task(rsx::FIFO_state state) override; void do_local_task(rsx::FIFO_state state) override;

View File

@ -50,7 +50,7 @@ void GSRender::on_exit()
rsx::thread::on_exit(); rsx::thread::on_exit();
} }
void GSRender::flip(int buffer) void GSRender::flip(int buffer, bool emu_flip)
{ {
if (m_frame) if (m_frame)
{ {

View File

@ -172,7 +172,7 @@ public:
void on_init_thread() override; void on_init_thread() override;
void on_exit() override; void on_exit() override;
void flip(int buffer) override; void flip(int buffer, bool emu_flip = false) override;
GSFrameBase* get_frame() { return m_frame; }; GSFrameBase* get_frame() { return m_frame; };
}; };

View File

@ -2094,7 +2094,7 @@ namespace rsx
} }
} }
void thread::flip(int buffer) void thread::flip(int buffer, bool emu_flip)
{ {
if (!(async_flip_requested & flip_request::any)) if (!(async_flip_requested & flip_request::any))
{ {
@ -2135,7 +2135,14 @@ namespace rsx
m_flattener.force_disable(); m_flattener.force_disable();
} }
async_flip_requested.clear(); if (emu_flip)
{
async_flip_requested.clear(flip_request::emu_requested);
}
else
{
async_flip_requested.clear(flip_request::native_ui);
}
} }
if (!skip_frame) if (!skip_frame)
@ -2462,7 +2469,7 @@ namespace rsx
int_flip_index++; int_flip_index++;
current_display_buffer = buffer; current_display_buffer = buffer;
flip(buffer); flip(buffer, true);
last_flip_time = get_system_time() - 1000000; last_flip_time = get_system_time() - 1000000;
flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_DONE; flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_DONE;

View File

@ -623,7 +623,7 @@ namespace rsx
virtual void on_init_rsx() = 0; virtual void on_init_rsx() = 0;
virtual void on_init_thread() = 0; virtual void on_init_thread() = 0;
virtual bool do_method(u32 /*cmd*/, u32 /*value*/) { return false; } virtual bool do_method(u32 /*cmd*/, u32 /*value*/) { return false; }
virtual void flip(int buffer) = 0; virtual void flip(int buffer, bool emu_flip = false) = 0;
virtual u64 timestamp(); virtual u64 timestamp();
virtual bool on_access_violation(u32 /*address*/, bool /*is_writing*/) { return false; } virtual bool on_access_violation(u32 /*address*/, bool /*is_writing*/) { return false; }
virtual void on_invalidate_memory_range(const address_range & /*range*/) {} virtual void on_invalidate_memory_range(const address_range & /*range*/) {}

View File

@ -2488,7 +2488,7 @@ void VKGSRender::do_local_task(rsx::FIFO_state state)
if (!in_begin_end && async_flip_requested & flip_request::native_ui) if (!in_begin_end && async_flip_requested & flip_request::native_ui)
{ {
flush_command_queue(true); flush_command_queue(true);
flip((s32)current_display_buffer); flip((s32)current_display_buffer, false);
} }
} }
} }
@ -3194,12 +3194,12 @@ void VKGSRender::reinitialize_swapchain()
renderer_unavailable = false; renderer_unavailable = false;
} }
void VKGSRender::flip(int buffer) void VKGSRender::flip(int buffer, bool emu_flip)
{ {
if (skip_frame || renderer_unavailable) if (skip_frame || renderer_unavailable)
{ {
m_frame->flip(m_context); m_frame->flip(m_context);
rsx::thread::flip(buffer); rsx::thread::flip(buffer, emu_flip);
if (!skip_frame) if (!skip_frame)
{ {
@ -3537,7 +3537,7 @@ void VKGSRender::flip(int buffer)
//NOTE:Resource destruction is handled within the real swap handler //NOTE:Resource destruction is handled within the real swap handler
m_frame->flip(m_context); m_frame->flip(m_context);
rsx::thread::flip(buffer); rsx::thread::flip(buffer, emu_flip);
//Do not reset perf counters if we are skipping the next frame //Do not reset perf counters if we are skipping the next frame
if (skip_frame) return; if (skip_frame) return;

View File

@ -466,7 +466,7 @@ protected:
void on_init_thread() override; void on_init_thread() override;
void on_exit() override; void on_exit() override;
bool do_method(u32 id, u32 arg) override; bool do_method(u32 id, u32 arg) override;
void flip(int buffer) override; void flip(int buffer, bool emu_flip = false) override;
void do_local_task(rsx::FIFO_state state) override; void do_local_task(rsx::FIFO_state state) override;
bool scaled_image_from_memory(rsx::blit_src_info& src, rsx::blit_dst_info& dst, bool interpolate) override; bool scaled_image_from_memory(rsx::blit_src_info& src, rsx::blit_dst_info& dst, bool interpolate) override;