mesa: Add PrimitiveRestartFixedIndex to gl_constants
authorNeil Roberts <nroberts@igalia.com>
Thu, 18 Jun 2020 13:48:12 +0000 (15:48 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 22 Jun 2020 12:41:56 +0000 (12:41 +0000)
This is a fine-grained subset of the NV_primitive_restart extension that
only uses the fixed indices provided by GLES 3.0. There’s no public
extension to advertise this behaviour so the bool is added to
gl_constants instead of gl_extensions.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed by: Erik Faye-Lund <erik.faye-lund@collabora.com>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5559>

src/mesa/drivers/dri/i965/intel_extensions.c
src/mesa/main/mtypes.h
src/mesa/main/version.c
src/mesa/state_tracker/st_extensions.c

index 276f7aa3d079ef052b1d6ab196baaf9f0e4ce04f..ce2989fa86bf8908cb505cfa444e770df922be0e 100644 (file)
@@ -389,4 +389,6 @@ intelInitExtensions(struct gl_context *ctx)
    ctx->Extensions.ANGLE_texture_compression_dxt = true;
 
    ctx->Extensions.EXT_demote_to_helper_invocation = true;
+
+   ctx->Const.PrimitiveRestartFixedIndex = true;
 }
index eff6f496eb663cd53a5d596214878ccedd41940c..b74f81ee06da5748dc35c20b7df8a9585c66f94f 100644 (file)
@@ -4180,6 +4180,13 @@ struct gl_constants
    /** Whether to allow the fast path for frequently updated VAOs. */
    bool AllowDynamicVAOFastPath;
 
+   /** Whether the driver can support primitive restart with a fixed index.
+    * This is essentially a subset of NV_primitive_restart with enough support
+    * to be able to enable GLES 3.1. Some hardware can support this but not the
+    * full NV extension with arbitrary restart indices.
+    */
+   bool PrimitiveRestartFixedIndex;
+
    /** GL_ARB_gl_spirv */
    struct spirv_supported_capabilities SpirVCapabilities;
 
index 7e51bb534393f9c0ea3963b911f2d32d8fac0a37..3517bfe8f644386f34cc6e3cced4bf34b6efbe7a 100644 (file)
@@ -524,7 +524,8 @@ compute_version_es2(const struct gl_extensions *extensions,
                          extensions->ARB_draw_instanced &&
                          extensions->ARB_uniform_buffer_object &&
                          extensions->EXT_texture_snorm &&
-                         extensions->NV_primitive_restart &&
+                         (extensions->NV_primitive_restart ||
+                          consts->PrimitiveRestartFixedIndex) &&
                          extensions->OES_depth_texture_cube_map &&
                          extensions->EXT_texture_type_2_10_10_10_REV);
    const bool es31_compute_shader =
index 461d197a041cf8f7f9a51c5cf485ea5fcf37cef7..0efd16bfd4a64d89b4319e082a2f3345f61877b3 100644 (file)
@@ -1132,6 +1132,9 @@ void st_init_extensions(struct pipe_screen *screen,
 
    consts->AllowGLSLCrossStageInterpolationMismatch = options->allow_glsl_cross_stage_interpolation_mismatch;
 
+   consts->PrimitiveRestartFixedIndex =
+      screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX);
+
    /* Technically we are turning on the EXT_gpu_shader5 extension,
     * ARB_gpu_shader5 does not exist in GLES, but this flag is what
     * switches on EXT_gpu_shader5:
@@ -1505,7 +1508,8 @@ void st_init_extensions(struct pipe_screen *screen,
     */
    if (GLSLVersion >= 130 &&
        extensions->ARB_uniform_buffer_object &&
-       extensions->NV_primitive_restart &&
+       (extensions->NV_primitive_restart ||
+        consts->PrimitiveRestartFixedIndex) &&
        screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
                                 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS) >= 16 &&
        /* Requirements for ETC2 emulation. */