rsx: Optimize thread self-tests

This commit is contained in:
kd-11 2021-09-25 02:01:27 +03:00 committed by kd-11
parent ba2a8ebf2e
commit 2e22a0d9bb
4 changed files with 14 additions and 8 deletions

View File

@ -917,7 +917,7 @@ void GLGSRender::update_vertex_env(const gl::vertex_upload_info& upload_info)
bool GLGSRender::on_access_violation(u32 address, bool is_writing)
{
const bool can_flush = (std::this_thread::get_id() == m_rsx_thread);
const bool can_flush = is_current_thread();
const rsx::invalidation_cause cause =
is_writing ? (can_flush ? rsx::invalidation_cause::write : rsx::invalidation_cause::deferred_write)
: (can_flush ? rsx::invalidation_cause::read : rsx::invalidation_cause::deferred_read);

View File

@ -16,7 +16,7 @@ namespace rsx
atomic_t<u64> m_processed_count = 0;
transport_packet* m_current_job = nullptr;
std::thread::id m_thread_id;
thread_base* current_thread_ = nullptr;
void operator ()()
{
@ -26,7 +26,8 @@ namespace rsx
return;
}
m_thread_id = std::this_thread::get_id();
current_thread_ = thread_ctrl::get_current();
ensure(current_thread_);
if (g_cfg.core.thread_scheduler != thread_scheduler_mode::os)
{
@ -147,7 +148,12 @@ namespace rsx
// Synchronization
bool dma_manager::is_current_thread()
{
return std::this_thread::get_id() == g_fxo->get<dma_thread>().m_thread_id;
if (auto cpu = thread_ctrl::get_current())
{
return g_fxo->get<dma_thread>().current_thread_ == cpu;
}
return false;
}
bool dma_manager::sync() const

View File

@ -576,8 +576,6 @@ namespace rsx
void thread::on_task()
{
m_rsx_thread = std::this_thread::get_id();
g_tls_log_prefix = []
{
const auto rsx = get_current_renderer();

View File

@ -602,7 +602,6 @@ namespace rsx
void cpu_task() override;
protected:
std::thread::id m_rsx_thread;
atomic_t<bool> m_rsx_thread_exiting{ true };
std::array<push_buffer_vertex_info, 16> vertex_push_buffers;
@ -963,7 +962,10 @@ namespace rsx
u32 get_load();
// Returns true if the current thread is the active RSX thread
bool is_current_thread() const { return std::this_thread::get_id() == m_rsx_thread; }
inline bool is_current_thread() const
{
return !!cpu_thread::get_current<rsx::thread>();
}
};
inline thread* get_current_renderer()