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:
Erik Abair
2025-10-28 11:39:19 -07:00
committed by GitHub
parent 5eb603b28d
commit dc672ab87b
3 changed files with 12 additions and 10 deletions
+1 -7
View File
@@ -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)
+9 -2
View File
@@ -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)
+2 -1
View File
@@ -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