mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
nv2a/gl: Move GPU property check context creation to main thread
GL context must be created from main thread on macOS.
This commit is contained in:
@@ -333,14 +333,11 @@ static void determine_triangle_winding_order(uint8_t *pixels, int width,
|
||||
props->geom_shader_winding.tri_fan = (fan_rot + 2) % 3;
|
||||
}
|
||||
|
||||
void pgraph_gl_determine_gpu_properties(NV2AState *d)
|
||||
void pgraph_gl_determine_gpu_properties(void)
|
||||
{
|
||||
const int width = 640;
|
||||
const int height = 480;
|
||||
|
||||
GloContext *g_context = glo_context_create();
|
||||
glo_set_current(g_context);
|
||||
|
||||
uint8_t *pixels = render_geom_shader_triangles(width, height);
|
||||
determine_triangle_winding_order(pixels, width, height,
|
||||
&pgraph_gl_gpu_properties);
|
||||
@@ -351,9 +348,6 @@ void pgraph_gl_determine_gpu_properties(NV2AState *d)
|
||||
pgraph_gl_gpu_properties.geom_shader_winding.tri_strip0,
|
||||
pgraph_gl_gpu_properties.geom_shader_winding.tri_strip1,
|
||||
pgraph_gl_gpu_properties.geom_shader_winding.tri_fan);
|
||||
|
||||
glo_context_destroy(g_context);
|
||||
glo_set_current(g_nv2a_context_render);
|
||||
}
|
||||
|
||||
GPUProperties *pgraph_gl_get_gpu_properties(void)
|
||||
|
||||
@@ -31,6 +31,15 @@ static void early_context_init(void)
|
||||
{
|
||||
g_nv2a_context_render = glo_context_create();
|
||||
g_nv2a_context_display = glo_context_create();
|
||||
|
||||
// Note: Due to use of shared contexts, this must happen after some other
|
||||
// context is created so the temporary context will not become the thread
|
||||
// context. After destroying the context, some a durable context should be
|
||||
// selected.
|
||||
GloContext *context = glo_context_create();
|
||||
pgraph_gl_determine_gpu_properties();
|
||||
glo_context_destroy(context);
|
||||
glo_set_current(g_nv2a_context_display);
|
||||
}
|
||||
|
||||
static void pgraph_gl_init(NV2AState *d, Error **errp)
|
||||
@@ -69,8 +78,6 @@ static void pgraph_gl_init(NV2AState *d, Error **errp)
|
||||
|
||||
r->supported_extensions.texture_filter_anisotropic =
|
||||
glo_check_extension("GL_EXT_texture_filter_anisotropic");
|
||||
|
||||
pgraph_gl_determine_gpu_properties(d);
|
||||
}
|
||||
|
||||
static void pgraph_gl_finalize(NV2AState *d)
|
||||
|
||||
@@ -291,7 +291,8 @@ void pgraph_gl_shader_write_cache_reload_list(PGRAPHState *pg);
|
||||
void pgraph_gl_set_surface_scale_factor(NV2AState *d, unsigned int scale);
|
||||
unsigned int pgraph_gl_get_surface_scale_factor(NV2AState *d);
|
||||
int pgraph_gl_get_framebuffer_surface(NV2AState *d);
|
||||
void pgraph_gl_determine_gpu_properties(NV2AState *d);
|
||||
/** Note: The caller must set up a clean GL context before invoking. */
|
||||
void pgraph_gl_determine_gpu_properties(void);
|
||||
GPUProperties *pgraph_gl_get_gpu_properties(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user