mesa: Implement glGet*(GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED).
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 21 May 2016 03:59:33 +0000 (20:59 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 23 May 2016 23:44:22 +0000 (16:44 -0700)
Technically, this was introduced with GL 4.4.  However, I believe it
was intended to be retroactive.  As far as I know, AMD has never
supported primitive restart with patches, while NVidia and Intel do.
This necessitated the need for a query which would allow applications
to figure out whether this was usable or not.

I decided to expose it everywhere ARB_tessellation_shader is exposed.
(It's also in both OES and EXT_tessellation_shader.)

Enable this for i965 and Gallium drivers which expose the capability.

v2: Fix a bug in the state_tracker code (caught by Ilia Mirkin).

Bugzilla: https://cvs.khronos.org/bugzilla/show_bug.cgi?id=10364
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mapi/glapi/gen/ARB_tessellation_shader.xml
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/main/context.c
src/mesa/main/get_hash_params.py
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_extensions.c

index 77f2228ae3b08d411b57fe71545c450aa7b741da..5ffc2bad3189317f90f07e94cf41ffe49726211c 100644 (file)
@@ -48,6 +48,7 @@
     <enum value="0x8E88" name="TESS_CONTROL_SHADER"/>
     <enum value="0x8E89" name="MAX_TESS_CONTROL_UNIFORM_BLOCKS"/>
     <enum value="0x8E8A" name="MAX_TESS_EVALUATION_UNIFORM_BLOCKS"/>
+    <enum value="0x8221" name="PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED"/>
 
     <function name="PatchParameteri">
         <param name="pname" type="GLenum"/>
index 1ab02ae3d0f5923f110a8214a76c1593984422b3..552e5ec8925febcfd3eff6afe010b86f2159de8c 100644 (file)
@@ -565,6 +565,7 @@ brw_initialize_context_constants(struct brw_context *brw)
       ctx->Const.MaxClipPlanes = 8;
 
    ctx->Const.LowerTessLevel = true;
+   ctx->Const.PrimitiveRestartForPatches = true;
 
    ctx->Const.Program[MESA_SHADER_VERTEX].MaxNativeInstructions = 16 * 1024;
    ctx->Const.Program[MESA_SHADER_VERTEX].MaxAluInstructions = 0;
index f6907991c75358ef1ffe2bfd503024d2a5d34bc6..7c0a6ef340a4648f3afc99afe761735ba1b6ced0 100644 (file)
@@ -725,6 +725,7 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
    consts->Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
    consts->MaxTessPatchComponents = MAX_TESS_PATCH_COMPONENTS;
    consts->MaxTessControlTotalOutputComponents = MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS;
+   consts->PrimitiveRestartForPatches = false;
 }
 
 
index 8f693acdc7c9de1fb64f0610ca0871dc8d83db3e..2124072ca0c0c361027e7ac906f4b582ae57bb8b 100644 (file)
@@ -912,6 +912,7 @@ descriptor=[
   [ "MAX_TESS_EVALUATION_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxUniformBlocks), extra_ARB_tessellation_shader" ],
   [ "MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxCombinedUniformComponents), extra_ARB_tessellation_shader" ],
   [ "MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxCombinedUniformComponents), extra_ARB_tessellation_shader" ],
+  [ "PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED", "CONTEXT_BOOL(Const.PrimitiveRestartForPatches), extra_ARB_tessellation_shader" ],
 # Dependencies on GL_ARB_tessellation_shader
   [ "MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxAtomicBuffers), extra_ARB_shader_atomic_counters_and_tessellation" ],
   [ "MAX_TESS_CONTROL_ATOMIC_COUNTERS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxAtomicCounters), extra_ARB_shader_atomic_counters_and_tessellation" ],
index f6c6d9733e13d35c6a341a2e8b6b7ad827fe2dc1..6cd30e8c10c67a19e06b70b0b5ee711c536ac4a4 100644 (file)
@@ -3727,6 +3727,7 @@ struct gl_constants
    GLuint MaxTessPatchComponents;
    GLuint MaxTessControlTotalOutputComponents;
    bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
+   bool PrimitiveRestartForPatches;
 };
 
 
index ea60e41acdc3d18eb9204941506953991a83842b..ef061e9d756540813343141f6b0173b1b73fc8cb 100644 (file)
@@ -314,6 +314,8 @@ void st_init_limits(struct pipe_screen *screen,
    }
 
    c->LowerTessLevel = true;
+   c->PrimitiveRestartForPatches =
+      screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES);
 
    c->MaxCombinedTextureImageUnits =
          _min(c->Program[MESA_SHADER_VERTEX].MaxTextureImageUnits +