diff --git a/docs/reference/gtk/running.md b/docs/reference/gtk/running.md index 06ea540d12..0163dc2bd5 100644 --- a/docs/reference/gtk/running.md +++ b/docs/reference/gtk/running.md @@ -366,6 +366,9 @@ does not support them. `sync` :GL_ARB_sync +`base-instance` +:GL_EXT_base_instance + ### `GDK_VULKAN_DEVICE` This variable can be set to the index of a Vulkan device to override @@ -473,9 +476,6 @@ disable certain optimizations of the "ngl" and "vulkan" renderer. `mipmap` : Avoid creating mipmaps -`gl-baseinstance` -: Assume no ARB/EXT_base_instance support - The special value `all` can be used to turn on all values. The special value `help` can be used to obtain a list of all supported values. diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index 8a56464dc6..ee5e0ab6c8 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -108,6 +108,7 @@ static const GdkDebugKey gdk_gl_feature_keys[] = { { "unpack-subimage", GDK_GL_FEATURE_UNPACK_SUBIMAGE, "GL_EXT_unpack_subimage" }, { "half-float", GDK_GL_FEATURE_VERTEX_HALF_FLOAT, "GL_OES_vertex_half_float" }, { "sync", GDK_GL_FEATURE_SYNC, "GL_ARB_sync" }, + { "base-instance", GDK_GL_FEATURE_BASE_INSTANCE, "GL_ARB_base_instance" }, }; typedef struct _GdkGLContextPrivate GdkGLContextPrivate; @@ -1697,6 +1698,11 @@ gdk_gl_context_check_features (GdkGLContext *context) epoxy_has_gl_extension ("GL_APPLE_sync")) features |= GDK_GL_FEATURE_SYNC; + if (gdk_gl_context_check_version (context, "4.2", "9.9") || + epoxy_has_gl_extension ("GL_EXT_base_instance") || + epoxy_has_gl_extension ("GL_ARB_base_instance")) + features |= GDK_GL_FEATURE_BASE_INSTANCE; + return features; } diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h index 895580c1fa..87636970c7 100644 --- a/gdk/gdkglcontextprivate.h +++ b/gdk/gdkglcontextprivate.h @@ -32,6 +32,7 @@ typedef enum { GDK_GL_FEATURE_UNPACK_SUBIMAGE = 1 << 1, GDK_GL_FEATURE_VERTEX_HALF_FLOAT = 1 << 2, GDK_GL_FEATURE_SYNC = 1 << 3, + GDK_GL_FEATURE_BASE_INSTANCE = 1 << 4, } GdkGLFeatures; typedef enum { diff --git a/gsk/gpu/gskgpurenderer.c b/gsk/gpu/gskgpurenderer.c index 986a07544c..ee16ebacbe 100644 --- a/gsk/gpu/gskgpurenderer.c +++ b/gsk/gpu/gskgpurenderer.c @@ -30,8 +30,6 @@ static const GdkDebugKey gsk_gpu_optimization_keys[] = { { "blit", GSK_GPU_OPTIMIZE_BLIT, "Use shaders instead of vkCmdBlit()/glBlitFramebuffer()" }, { "gradients", GSK_GPU_OPTIMIZE_GRADIENTS, "Don't supersample gradients" }, { "mipmap", GSK_GPU_OPTIMIZE_MIPMAP, "Avoid creating mipmaps" }, - - { "gl-baseinstance", GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE, "Assume no ARB/EXT_base_instance support" }, }; typedef struct _GskGpuRendererPrivate GskGpuRendererPrivate; diff --git a/gsk/gpu/gskgpushaderop.c b/gsk/gpu/gskgpushaderop.c index 5b076c429d..828ec88b41 100644 --- a/gsk/gpu/gskgpushaderop.c +++ b/gsk/gpu/gskgpushaderop.c @@ -13,6 +13,8 @@ #include "gskvulkandeviceprivate.h" #endif +#include "gdkglcontextprivate.h" + /* maximum number of ops to merge into one call * If this number is too high, the command may take too long * causing the driver to kill us. @@ -191,7 +193,8 @@ gsk_gpu_shader_op_gl_command_n (GskGpuOp *op, for (i = 0; i < n_ops; i += max_ops_per_draw) { - if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE)) + if (gdk_gl_context_has_feature (GDK_GL_CONTEXT (gsk_gpu_frame_get_context (frame)), + GDK_GL_FEATURE_BASE_INSTANCE)) { glDrawArraysInstancedBaseInstance (GL_TRIANGLES, 0, diff --git a/gsk/gpu/gskgputypesprivate.h b/gsk/gpu/gskgputypesprivate.h index 55e85fccda..bbd98d2a7c 100644 --- a/gsk/gpu/gskgputypesprivate.h +++ b/gsk/gpu/gskgputypesprivate.h @@ -118,7 +118,5 @@ typedef enum { GSK_GPU_OPTIMIZE_BLIT = 1 << 3, GSK_GPU_OPTIMIZE_GRADIENTS = 1 << 4, GSK_GPU_OPTIMIZE_MIPMAP = 1 << 5, - /* These require hardware support */ - GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE = 1 << 6, } GskGpuOptimizations; diff --git a/gsk/gpu/gsknglrenderer.c b/gsk/gpu/gsknglrenderer.c index 5c2653d941..4c692662e7 100644 --- a/gsk/gpu/gsknglrenderer.c +++ b/gsk/gpu/gsknglrenderer.c @@ -72,11 +72,6 @@ gsk_ngl_renderer_create_context (GskGpuRenderer *renderer, */ *supported &= ~GSK_GPU_OPTIMIZE_UBER; - if (!gdk_gl_context_check_version (context, "4.2", "9.9") && - !epoxy_has_gl_extension ("GL_EXT_base_instance") && - !epoxy_has_gl_extension ("GL_ARB_base_instance")) - *supported &= ~GSK_GPU_OPTIMIZE_GL_BASE_INSTANCE; - return GDK_DRAW_CONTEXT (context); }