mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
gl: Fix async shader compiler
- Removes glFinish hack. - Adds proper server-side synchronization. - Adds primary context detection to allow worker threads to be identified.
This commit is contained in:
parent
dc5cdb3bb4
commit
b301fecfd8
@ -50,7 +50,7 @@ namespace gl
|
||||
|
||||
m_program.create();
|
||||
m_program.attach(m_shader);
|
||||
m_program.make();
|
||||
m_program.link();
|
||||
|
||||
compiled = true;
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ void GLGSRender::on_init_thread()
|
||||
|
||||
// Bind primary context to main RSX thread
|
||||
m_frame->set_current(m_context);
|
||||
gl::set_primary_context_thread();
|
||||
|
||||
zcull_ctrl.reset(static_cast<::rsx::reports::ZCULL_control*>(this));
|
||||
|
||||
@ -625,6 +626,11 @@ bool GLGSRender::load_program()
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
verify(HERE), m_program;
|
||||
m_program->sync();
|
||||
}
|
||||
|
||||
return m_program != nullptr;
|
||||
}
|
||||
@ -946,13 +952,5 @@ void GLGSRender::on_decompiler_exit()
|
||||
|
||||
bool GLGSRender::on_decompiler_task()
|
||||
{
|
||||
const auto result = m_prog_buffer.async_update(8);
|
||||
if (result.second)
|
||||
{
|
||||
// TODO: Proper synchronization with renderer
|
||||
// Finish works well enough for now but it is not a proper soulution
|
||||
glFinish();
|
||||
}
|
||||
|
||||
return result.first;
|
||||
return m_prog_buffer.async_update(8).first;
|
||||
}
|
||||
|
@ -11,6 +11,18 @@ namespace gl
|
||||
capabilities g_driver_caps;
|
||||
const fbo screen{};
|
||||
|
||||
thread_local bool tls_primary_context_thread = false;
|
||||
|
||||
void set_primary_context_thread()
|
||||
{
|
||||
tls_primary_context_thread = true;
|
||||
}
|
||||
|
||||
bool is_primary_context_thread()
|
||||
{
|
||||
return tls_primary_context_thread;
|
||||
}
|
||||
|
||||
GLenum draw_mode(rsx::primitive_type in)
|
||||
{
|
||||
switch (in)
|
||||
|
@ -86,6 +86,9 @@ namespace gl
|
||||
bool is_primitive_native(rsx::primitive_type in);
|
||||
GLenum draw_mode(rsx::primitive_type in);
|
||||
|
||||
void set_primary_context_thread();
|
||||
bool is_primary_context_thread();
|
||||
|
||||
// Texture helpers
|
||||
std::array<GLenum, 4> apply_swizzle_remap(const std::array<GLenum, 4>& swizzle_remap, const std::pair<std::array<u8, 4>, std::array<u8, 4>>& decoded_remap);
|
||||
|
||||
@ -391,6 +394,12 @@ namespace gl
|
||||
|
||||
return signaled;
|
||||
}
|
||||
|
||||
void server_wait_sync() const
|
||||
{
|
||||
verify(HERE), m_value != nullptr;
|
||||
glWaitSync(m_value, 0, GL_TIMEOUT_IGNORED);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type, uint BindId, uint GetStateId>
|
||||
@ -2533,6 +2542,7 @@ public:
|
||||
class program
|
||||
{
|
||||
GLuint m_id = 0;
|
||||
fence m_fence;
|
||||
|
||||
public:
|
||||
class uniform_t
|
||||
@ -2717,6 +2727,15 @@ public:
|
||||
|
||||
rsx_log.fatal("Linkage failed: %s", error_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fence.create();
|
||||
|
||||
if (!is_primary_context_thread())
|
||||
{
|
||||
glFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void validate()
|
||||
@ -2743,11 +2762,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void make()
|
||||
{
|
||||
link();
|
||||
}
|
||||
|
||||
uint id() const
|
||||
{
|
||||
return m_id;
|
||||
@ -2764,6 +2778,14 @@ public:
|
||||
return m_id != 0;
|
||||
}
|
||||
|
||||
void sync()
|
||||
{
|
||||
if (!m_fence.check_signaled())
|
||||
{
|
||||
m_fence.server_wait_sync();
|
||||
}
|
||||
}
|
||||
|
||||
explicit operator bool() const
|
||||
{
|
||||
return created();
|
||||
|
@ -66,7 +66,7 @@ namespace gl
|
||||
program_handle.create();
|
||||
program_handle.attach(vs);
|
||||
program_handle.attach(fs);
|
||||
program_handle.make();
|
||||
program_handle.link();
|
||||
|
||||
fbo.create();
|
||||
|
||||
|
@ -217,6 +217,7 @@ OPENGL_PROC(PFNGLBUFFERSTORAGEPROC, BufferStorage);
|
||||
// ARB_sync
|
||||
OPENGL_PROC(PFNGLFENCESYNCPROC, FenceSync);
|
||||
OPENGL_PROC(PFNGLCLIENTWAITSYNCPROC, ClientWaitSync);
|
||||
OPENGL_PROC(PFNGLWAITSYNCPROC, WaitSync);
|
||||
OPENGL_PROC(PFNGLGETSYNCIVPROC, GetSynciv);
|
||||
OPENGL_PROC(PFNGLDELETESYNCPROC, DeleteSync);
|
||||
|
||||
|
@ -42,7 +42,7 @@ struct GLTraits
|
||||
.bind_fragment_data_location("ocol1", 1)
|
||||
.bind_fragment_data_location("ocol2", 2)
|
||||
.bind_fragment_data_location("ocol3", 3)
|
||||
.make();
|
||||
.link();
|
||||
|
||||
// Progam locations are guaranteed to not change after linking
|
||||
// Texture locations are simply bound to the TIUs so this can be done once
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "GLHelpers.h"
|
||||
@ -63,7 +63,7 @@ namespace gl
|
||||
m_program.create();
|
||||
m_program.attach(m_vs);
|
||||
m_program.attach(m_fs);
|
||||
m_program.make();
|
||||
m_program.link();
|
||||
}
|
||||
|
||||
void load_program(float scale_x, float scale_y, float *offsets, size_t nb_offsets, color4f color)
|
||||
|
Loading…
Reference in New Issue
Block a user