[Mesa-dev] [PATCH v3] mesa: enable enums for OES_geometry_shader

Ilia Mirkin imirkin at alum.mit.edu
Tue Dec 1 07:53:04 PST 2015


On Tue, Dec 1, 2015 at 10:37 AM, Marta Lofstedt
<marta.lofstedt at linux.intel.com> wrote:
> From: Marta Lofstedt <marta.lofstedt at intel.com>
>
> Enable GL_OES_geometry_shader enums for OpenGL ES 3.1.
>
> Signed-off-by: Marta Lofstedt <marta.lofstedt at linux.intel.com>
> ---
>  src/mesa/main/get.c              | 64 ++++++++++++++++++++++++++++++++++------
>  src/mesa/main/get_hash_params.py | 53 +++++++++++++++++++--------------
>  2 files changed, 86 insertions(+), 31 deletions(-)
>
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index c6a2e5b..7be7971 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -147,11 +147,14 @@ enum value_extra {
>     EXTRA_VALID_CLIP_DISTANCE,
>     EXTRA_FLUSH_CURRENT,
>     EXTRA_GLSL_130,
> -   EXTRA_EXT_UBO_GS4,
> -   EXTRA_EXT_ATOMICS_GS4,
> -   EXTRA_EXT_SHADER_IMAGE_GS4,
> +   EXTRA_EXT_UBO_GS,
> +   EXTRA_EXT_ATOMICS_GS,
> +   EXTRA_EXT_SHADER_IMAGE_GS,
>     EXTRA_EXT_ATOMICS_TESS,
>     EXTRA_EXT_SHADER_IMAGE_TESS,
> +   EXTRA_EXT_SSBO_GS,
> +   EXTRA_EXT_GPU5_GS,
> +   EXTRA_EXT_FB_NO_ATTACH_GS,
>  };
>
>  #define NO_EXTRA NULL
> @@ -308,7 +311,7 @@ static const int extra_ARB_transform_feedback2_api_es3[] = {
>  };
>
>  static const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = {
> -   EXTRA_EXT_UBO_GS4,
> +   EXTRA_EXT_UBO_GS,
>     EXTRA_END
>  };
>
> @@ -343,12 +346,12 @@ static const int extra_EXT_texture_array_es3[] = {
>  };
>
>  static const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = {
> -   EXTRA_EXT_ATOMICS_GS4,
> +   EXTRA_EXT_ATOMICS_GS,
>     EXTRA_END
>  };
>
>  static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
> -   EXTRA_EXT_SHADER_IMAGE_GS4,
> +   EXTRA_EXT_SHADER_IMAGE_GS,
>     EXTRA_END
>  };
>
> @@ -375,6 +378,27 @@ static const int extra_ARB_shader_storage_buffer_object_es31[] = {
>     EXTRA_END
>  };
>
> +static const int extra_ARB_gpu_shader5_and_geometry_shader[] = {
> +   EXTRA_EXT_GPU5_GS,
> +   EXTRA_END
> +};
> +
> +static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader[] = {
> +   EXTRA_EXT_SSBO_GS,
> +   EXTRA_END
> +};
> +
> +static const int extra_ARB_viewport_array_or_geometry_shader[] = {
> +   EXT(ARB_viewport_array),
> +   EXT(OES_geometry_shader),
> +   EXTRA_END
> +};

This won't do what you want... unless drivers only ever set
OES_geometry_shader to true in ES contexts, which is not the way it's
usually done in mesa. That said they *are* careful about only setting
ARB_viewport_array in core contexts (due to the GS dependency).

> +
> +static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader[] = {
> +   EXTRA_EXT_FB_NO_ATTACH_GS,
> +   EXTRA_END
> +};
> +
>  EXTRA_EXT(ARB_texture_cube_map);
>  EXTRA_EXT(EXT_texture_array);
>  EXTRA_EXT(NV_fog_distance);
> @@ -423,6 +447,7 @@ EXTRA_EXT(ARB_framebuffer_no_attachments);
>  EXTRA_EXT(ARB_tessellation_shader);
>  EXTRA_EXT(ARB_shader_subroutine);
>  EXTRA_EXT(ARB_shader_storage_buffer_object);
> +EXTRA_EXT(OES_geometry_shader);
>
>  static const int
>  extra_ARB_color_buffer_float_or_glcore[] = {
> @@ -454,6 +479,12 @@ static const int extra_gl32_es3[] = {
>      EXTRA_END,
>  };
>
> +static const int extra_version_32_OES_geometry_shader[] = {
> +    EXTRA_VERSION_32,
> +    EXT(OES_geometry_shader),
> +    EXTRA_END
> +};
> +
>  static const int extra_gl40_ARB_sample_shading[] = {
>     EXTRA_VERSION_40,
>     EXT(ARB_sample_shading),
> @@ -1149,17 +1180,17 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
>           if (ctx->Const.GLSLVersion >= 130)
>              api_found = GL_TRUE;
>          break;
> -      case EXTRA_EXT_UBO_GS4:
> +      case EXTRA_EXT_UBO_GS:
>           api_check = GL_TRUE;
>           api_found = (ctx->Extensions.ARB_uniform_buffer_object &&
>                        _mesa_has_geometry_shaders(ctx));
>           break;
> -      case EXTRA_EXT_ATOMICS_GS4:
> +      case EXTRA_EXT_ATOMICS_GS:
>           api_check = GL_TRUE;
>           api_found = (ctx->Extensions.ARB_shader_atomic_counters &&
>                        _mesa_has_geometry_shaders(ctx));
>           break;
> -      case EXTRA_EXT_SHADER_IMAGE_GS4:
> +      case EXTRA_EXT_SHADER_IMAGE_GS:
>           api_check = GL_TRUE;
>           api_found = (ctx->Extensions.ARB_shader_image_load_store &&
>                        _mesa_has_geometry_shaders(ctx));
> @@ -1174,6 +1205,21 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
>           api_found = ctx->Extensions.ARB_shader_image_load_store &&
>                       _mesa_has_tessellation(ctx);
>           break;
> +      case EXTRA_EXT_GPU5_GS:
> +         api_check = GL_TRUE;
> +         api_found = (ctx->Extensions.ARB_gpu_shader5 &&
> +                      _mesa_has_geometry_shaders(ctx));

Can't have gs5 without geometry shaders.

> +         break;
> +      case EXTRA_EXT_SSBO_GS:
> +         api_check = GL_TRUE;
> +         api_found = (ctx->Extensions.ARB_shader_storage_buffer_object &&
> +                      _mesa_has_geometry_shaders(ctx));
> +         break;
> +      case EXTRA_EXT_FB_NO_ATTACH_GS:
> +         api_check = GL_TRUE;
> +         api_found = (ctx->Extensions.ARB_framebuffer_no_attachments &&
> +                      _mesa_has_geometry_shaders(ctx));
> +         break;
>        case EXTRA_END:
>          break;
>        default: /* *e is a offset into the extension struct */
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index 0c58b30..151f7f8 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -499,6 +499,37 @@ descriptor=[
>  { "apis": ["GL_CORE", "GLES31"], "params": [
>  # GL_ARB_draw_indirect / GLES 3.1
>    [ "DRAW_INDIRECT_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_draw_indirect" ],
> +
> +# GL 3.2 / GL OES_geometry_shader
> +  [ "MAX_GEOMETRY_INPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents), extra_version_32_OES_geometry_shader" ],
> +  [ "MAX_GEOMETRY_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents), extra_version_32_OES_geometry_shader" ],
> +  [ "MAX_GEOMETRY_TEXTURE_IMAGE_UNITS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits), extra_version_32_OES_geometry_shader" ],
> +  [ "MAX_GEOMETRY_OUTPUT_VERTICES", "CONTEXT_INT(Const.MaxGeometryOutputVertices), extra_version_32_OES_geometry_shader" ],
> +  [ "MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.MaxGeometryTotalOutputComponents), extra_version_32_OES_geometry_shader" ],
> +  [ "MAX_GEOMETRY_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformComponents), extra_version_32_OES_geometry_shader" ],
> +
> +# GL_ARB_shader_image_load_store / GL_OES_geometry_shader
> +  [ "MAX_GEOMETRY_IMAGE_UNIFORMS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxImageUniforms), extra_ARB_shader_image_load_store_and_geometry_shader" ],
> +
> +# GL_ARB_shader_atomic_counters / GL_OES_geometry_shader
> +  [ "MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers), extra_ARB_shader_atomic_counters_and_geometry_shader " ],
> +  [ "MAX_GEOMETRY_ATOMIC_COUNTERS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters), extra_ARB_shader_atomic_counters_and_geometry_shader" ],
> +
> +# GL_ARB_shader_storage_buffer_object /  GL_OES_geometry_shader
> +  [ "MAX_GEOMETRY_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object_and_geometry_shader" ],
> +
> +# GL_ARB_uniform_buffer_object / GL_OES_geometry_shader
> +  [ "MAX_GEOMETRY_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
> +  [ "MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
> +
> +# GL_ARB_gpu_shader5 / GL_OES_geometry_shader
> +  [ "MAX_GEOMETRY_SHADER_INVOCATIONS", "CONST(MAX_GEOMETRY_SHADER_INVOCATIONS), extra_ARB_gpu_shader5_and_geometry_shader" ],

I guess the assumption being that if you have OES_geometry_shader then
you also must have ARB_gpu_shader5? Seems a little strong, esp given
all the random junk that ARB_gs5 includes. I'd rather have a custom
enum here, EXTRA_EXT_INVOCATIONS or something, which checks for

core && gs5 || es && oes_geometry_shader

> +
> +# GL_ARB_viewport_array / GL_OES_geometry_shader
> +  [ "LAYER_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array_or_geometry_shader" ],
> +
> +# GL_ARB_framebuffer_no_attachments / GL_OES_geometry_shader
> +  ["MAX_FRAMEBUFFER_LAYERS", "CONTEXT_INT(Const.MaxFramebufferLayers), extra_ARB_framebuffer_no_attachments_and_geometry_shader"],
>  ]},
>
>  # Remaining enums are only in OpenGL
> @@ -790,21 +821,10 @@ descriptor=[
>
>  # GL 3.2
>    [ "CONTEXT_PROFILE_MASK", "CONTEXT_INT(Const.ProfileMask), extra_version_32" ],
> -  [ "MAX_GEOMETRY_INPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents), extra_version_32" ],
> -  [ "MAX_GEOMETRY_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents), extra_version_32" ],
> -  [ "MAX_GEOMETRY_TEXTURE_IMAGE_UNITS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits), extra_version_32" ],
> -  [ "MAX_GEOMETRY_OUTPUT_VERTICES", "CONTEXT_INT(Const.MaxGeometryOutputVertices), extra_version_32" ],
> -  [ "MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.MaxGeometryTotalOutputComponents), extra_version_32" ],
> -  [ "MAX_GEOMETRY_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformComponents), extra_version_32" ],
>
>  # GL_ARB_robustness
>    [ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA" ],
>
> -
> -# GL_ARB_uniform_buffer_object
> -  [ "MAX_GEOMETRY_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
> -  [ "MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
> -
>  # GL_ARB_timer_query
>    [ "TIMESTAMP", "LOC_CUSTOM, TYPE_INT64, 0, extra_ARB_timer_query" ],
>
> @@ -817,23 +837,14 @@ descriptor=[
>  # GL_ARB_texture_gather
>    [ "MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB", "CONTEXT_INT(Const.MaxProgramTextureGatherComponents), extra_ARB_texture_gather"],
>
> -# GL_ARB_shader_atomic_counters
> -  [ "MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers), extra_ARB_shader_atomic_counters_and_geometry_shader" ],
> -  [ "MAX_GEOMETRY_ATOMIC_COUNTERS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters), extra_ARB_shader_atomic_counters_and_geometry_shader" ],
> -
>  # GL_ARB_shader_image_load_store
>    [ "MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS", "CONTEXT_INT(Const.MaxCombinedShaderOutputResources), extra_ARB_shader_image_load_store" ],
>    [ "MAX_IMAGE_SAMPLES", "CONTEXT_INT(Const.MaxImageSamples), extra_ARB_shader_image_load_store" ],
> -  [ "MAX_GEOMETRY_IMAGE_UNIFORMS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxImageUniforms), extra_ARB_shader_image_load_store_and_geometry_shader"],
> -
> -# GL_ARB_framebuffer_no_attachments
> -  ["MAX_FRAMEBUFFER_LAYERS", "CONTEXT_INT(Const.MaxFramebufferLayers), extra_ARB_framebuffer_no_attachments"],
>
>  # GL_EXT_polygon_offset_clamp
>    [ "POLYGON_OFFSET_CLAMP_EXT", "CONTEXT_FLOAT(Polygon.OffsetClamp), extra_EXT_polygon_offset_clamp" ],
>
>  # GL_ARB_shader_storage_buffer_object
> -  [ "MAX_GEOMETRY_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object" ],
>    [ "MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object" ],
>    [ "MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object" ],
>  ]},
> @@ -847,11 +858,9 @@ descriptor=[
>    [ "MAX_VIEWPORTS", "CONTEXT_INT(Const.MaxViewports), extra_ARB_viewport_array" ],
>    [ "VIEWPORT_SUBPIXEL_BITS", "CONTEXT_INT(Const.ViewportSubpixelBits), extra_ARB_viewport_array" ],
>    [ "VIEWPORT_BOUNDS_RANGE", "CONTEXT_FLOAT2(Const.ViewportBounds), extra_ARB_viewport_array" ],
> -  [ "LAYER_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ],
>    [ "VIEWPORT_INDEX_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ],
>
>  # GL_ARB_gpu_shader5
> -  [ "MAX_GEOMETRY_SHADER_INVOCATIONS", "CONST(MAX_GEOMETRY_SHADER_INVOCATIONS), extra_ARB_gpu_shader5" ],
>    [ "MIN_FRAGMENT_INTERPOLATION_OFFSET", "CONTEXT_FLOAT(Const.MinFragmentInterpolationOffset), extra_ARB_gpu_shader5" ],
>    [ "MAX_FRAGMENT_INTERPOLATION_OFFSET", "CONTEXT_FLOAT(Const.MaxFragmentInterpolationOffset), extra_ARB_gpu_shader5" ],
>    [ "FRAGMENT_INTERPOLATION_OFFSET_BITS", "CONST(FRAGMENT_INTERPOLATION_OFFSET_BITS), extra_ARB_gpu_shader5" ],
> --
> 2.5.0
>


More information about the mesa-dev mailing list