gl: Move GL_ARB_base_instance check

It's a GLContext feature check, not a GpuRenderer thing.

So put it there.
This commit is contained in:
Benjamin Otte 2024-03-16 13:33:13 +01:00
parent cfbe3709bf
commit f725bdad25
7 changed files with 14 additions and 13 deletions

View File

@ -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.

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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);
}