diff --git a/hw/xbox/nv2a/pgraph/gl/gpuprops.c b/hw/xbox/nv2a/pgraph/gl/gpuprops.c index 58b195e8c3..54614e0dac 100644 --- a/hw/xbox/nv2a/pgraph/gl/gpuprops.c +++ b/hw/xbox/nv2a/pgraph/gl/gpuprops.c @@ -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) diff --git a/hw/xbox/nv2a/pgraph/gl/renderer.c b/hw/xbox/nv2a/pgraph/gl/renderer.c index de7fa9db81..e9e2109779 100644 --- a/hw/xbox/nv2a/pgraph/gl/renderer.c +++ b/hw/xbox/nv2a/pgraph/gl/renderer.c @@ -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) diff --git a/hw/xbox/nv2a/pgraph/gl/renderer.h b/hw/xbox/nv2a/pgraph/gl/renderer.h index 5623683842..9b9d9bfb02 100644 --- a/hw/xbox/nv2a/pgraph/gl/renderer.h +++ b/hw/xbox/nv2a/pgraph/gl/renderer.h @@ -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