[Mesa-dev] [PATCH 10/24] spirv_extensions: add GL_ARB_spirv_extensions boilerplate

Ian Romanick idr at freedesktop.org
Mon Nov 27 22:12:30 UTC 2017


On 11/15/2017 05:22 AM, Eduardo Lima Mitev wrote:
> From: Alejandro Piñeiro <apinheiro at igalia.com>
> 
> ---
>  src/mapi/glapi/gen/ARB_spirv_extensions.xml | 13 ++++++++
>  src/mapi/glapi/gen/Makefile.am              |  1 +
>  src/mapi/glapi/gen/gl_API.xml               |  2 ++
>  src/mesa/Makefile.sources                   |  2 ++
>  src/mesa/main/extensions_table.h            |  1 +
>  src/mesa/main/get.c                         |  6 ++++
>  src/mesa/main/get_hash_params.py            |  3 ++
>  src/mesa/main/getstring.c                   |  7 +++++
>  src/mesa/main/mtypes.h                      |  1 +
>  src/mesa/main/spirvextensions.c             | 42 +++++++++++++++++++++++++
>  src/mesa/main/spirvextensions.h             | 49 +++++++++++++++++++++++++++++
>  11 files changed, 127 insertions(+)
>  create mode 100644 src/mapi/glapi/gen/ARB_spirv_extensions.xml
>  create mode 100644 src/mesa/main/spirvextensions.c
>  create mode 100644 src/mesa/main/spirvextensions.h

Could these files be renamed spirv_extensions.[ch]?

> 
> diff --git a/src/mapi/glapi/gen/ARB_spirv_extensions.xml b/src/mapi/glapi/gen/ARB_spirv_extensions.xml
> new file mode 100644
> index 00000000000..103393104c2
> --- /dev/null
> +++ b/src/mapi/glapi/gen/ARB_spirv_extensions.xml
> @@ -0,0 +1,13 @@
> +<?xml version="1.0"?>
> +<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
> +
> +<OpenGLAPI>
> +
> +<category name="GL_ARB_spirv_extensions" number="194">
> +
> +    <enum name="SPIR_V_EXTENSIONS" value="0x9553"/>
> +    <enum name="NUM_SPIR_V_EXTENSIONS" value="0x9554"/>
> +
> +</category>
> +
> +</OpenGLAPI>
> diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
> index 35e37e95a9f..9a7a268adbf 100644
> --- a/src/mapi/glapi/gen/Makefile.am
> +++ b/src/mapi/glapi/gen/Makefile.am
> @@ -167,6 +167,7 @@ API_XML = \
>  	ARB_shader_subroutine.xml \
>  	ARB_shader_storage_buffer_object.xml \
>  	ARB_sparse_buffer.xml \
> +	ARB_spirv_extensions.xml \
>  	ARB_sync.xml \
>  	ARB_tessellation_shader.xml \
>  	ARB_texture_barrier.xml \
> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
> index d3594cfe195..6b81160b5a1 100644
> --- a/src/mapi/glapi/gen/gl_API.xml
> +++ b/src/mapi/glapi/gen/gl_API.xml
> @@ -8404,6 +8404,8 @@
>  
>  <xi:include href="ARB_gl_spirv.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
>  
> +<xi:include href="ARB_spirv_extensions.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
> +
>  <!-- Non-ARB extensions sorted by extension number. -->
>  
>  <category name="GL_EXT_blend_color" number="2">
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index e9680bf004c..944c8bcc812 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -203,6 +203,8 @@ MAIN_FILES = \
>  	main/shader_query.cpp \
>  	main/shared.c \
>  	main/shared.h \
> +	main/spirvextensions.c \
> +	main/spirvextensions.h \
>  	main/state.c \
>  	main/state.h \
>  	main/stencil.c \
> diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
> index ab15ceb9414..06deabd0640 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -129,6 +129,7 @@ EXT(ARB_shading_language_420pack            , ARB_shading_language_420pack
>  EXT(ARB_shading_language_packing            , ARB_shading_language_packing           , GLL, GLC,  x ,  x , 2011)
>  EXT(ARB_shadow                              , ARB_shadow                             , GLL,  x ,  x ,  x , 2001)
>  EXT(ARB_sparse_buffer                       , ARB_sparse_buffer                      , GLL, GLC,  x ,  x , 2014)
> +EXT(ARB_spirv_extensions                    , ARB_spirv_extensions                   ,  x,  GLC,  x ,  x , 2016)
>  EXT(ARB_stencil_texturing                   , ARB_stencil_texturing                  , GLL, GLC,  x ,  x , 2012)
>  EXT(ARB_sync                                , ARB_sync                               , GLL, GLC,  x ,  x , 2003)
>  EXT(ARB_tessellation_shader                 , ARB_tessellation_shader                ,  x , GLC,  x ,  x , 2009)
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index ea8d932b182..c97ec9efde9 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -34,6 +34,7 @@
>  #include "get.h"
>  #include "macros.h"
>  #include "mtypes.h"
> +#include "spirvextensions.h"
>  #include "state.h"
>  #include "texcompress.h"
>  #include "texstate.h"
> @@ -1151,6 +1152,11 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
>           }
>        }
>        break;
> +
> +   /* ARB_spirv_extensions */
> +   case GL_NUM_SPIR_V_EXTENSIONS:
> +      v->value_int = _mesa_get_spirv_extension_count(ctx);
> +      break;
>     }
>  }
>  
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index 20ef6e4977a..4378cc1cabe 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -378,6 +378,9 @@ descriptor=[
>  # GL_ARB_sampler_objects / GL 3.3 / GLES 3.0
>    [ "SAMPLER_BINDING", "LOC_CUSTOM, TYPE_INT, GL_SAMPLER_BINDING, NO_EXTRA" ],
>  
> +# GL_ARB_spirv_extensions
> +  [ "NUM_SPIR_V_EXTENSIONS", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
> +
>  # GL_ARB_sync
>    [ "MAX_SERVER_WAIT_TIMEOUT", "CONTEXT_INT64(Const.MaxServerWaitTimeout), extra_ARB_sync" ],
>  
> diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
> index 4c805ca4d51..d87e29c15af 100644
> --- a/src/mesa/main/getstring.c
> +++ b/src/mesa/main/getstring.c
> @@ -32,6 +32,7 @@
>  #include "extensions.h"
>  #include "mtypes.h"
>  #include "macros.h"
> +#include "spirvextensions.h"
>  
>  /**
>   * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query.
> @@ -184,6 +185,12 @@ _mesa_GetStringi(GLenum name, GLuint index)
>           return (const GLubyte *) 0;
>        }
>        return _mesa_get_enabled_extension(ctx, index);
> +   case GL_SPIR_V_EXTENSIONS:
> +      if (index >= _mesa_get_spirv_extension_count(ctx)) {
> +         _mesa_error(ctx, GL_INVALID_VALUE, "glGetStringi(index=%u)", index);
> +         return (const GLubyte *) 0;
> +      }

I agree with Eric about INVALID_ENUM.  Also, we should add a piglit test
that checks that INVALID_ENUM is returned when the extension is not
supported.  That does not need to be at the top of the priority list,
however. :)

> +      return _mesa_get_enabled_spirv_extension(ctx, index);
>     default:
>        _mesa_error(ctx, GL_INVALID_ENUM, "glGetStringi");
>        return (const GLubyte *) 0;
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index bf7c4ddc051..1352ca98800 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -4102,6 +4102,7 @@ struct gl_extensions
>     GLboolean ARB_shadow;
>     GLboolean ARB_sparse_buffer;
>     GLboolean ARB_stencil_texturing;
> +   GLboolean ARB_spirv_extensions;

This should be before ARB_stencil_texturing.

With that and the various other nits fixed, this patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

>     GLboolean ARB_sync;
>     GLboolean ARB_tessellation_shader;
>     GLboolean ARB_texture_border_clamp;
> diff --git a/src/mesa/main/spirvextensions.c b/src/mesa/main/spirvextensions.c
> new file mode 100644
> index 00000000000..6a9fea9fe31
> --- /dev/null
> +++ b/src/mesa/main/spirvextensions.c
> @@ -0,0 +1,42 @@
> +/*
> + * Copyright © 2017 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * on the rights to use, copy, modify, merge, publish, distribute, sub
> + * license, and/or sell copies of the Software, and to permit persons to whom
> + * the Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +/**
> + * \file
> + * \brief SPIRV-V extension handling. See ARB_spirv_extensions
> + */
> +
> +#include "spirvextensions.h"
> +
> +GLuint
> +_mesa_get_spirv_extension_count(struct gl_context *ctx)
> +{
> +   return 0;
> +}
> +
> +const GLubyte *
> +_mesa_get_enabled_spirv_extension(struct gl_context *ctx,
> +                                  GLuint index)
> +{
> +   return (const GLubyte *) 0;
> +}
> diff --git a/src/mesa/main/spirvextensions.h b/src/mesa/main/spirvextensions.h
> new file mode 100644
> index 00000000000..35754f7e53b
> --- /dev/null
> +++ b/src/mesa/main/spirvextensions.h
> @@ -0,0 +1,49 @@
> +/*
> + * Copyright 2017 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * on the rights to use, copy, modify, merge, publish, distribute, sub
> + * license, and/or sell copies of the Software, and to permit persons to whom
> + * the Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
> + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
> + * USE OR OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +/**
> + * \file
> + * \brief SPIRV-V extension handling. See ARB_spirv_extensions
> + */
> +
> +#ifndef _SPIRVEXTENSIONS_H_
> +#define _SPIRVEXTENSIONS_H_
> +
> +#include "mtypes.h"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +extern GLuint
> +_mesa_get_spirv_extension_count(struct gl_context *ctx);
> +
> +extern const GLubyte *
> +_mesa_get_enabled_spirv_extension(struct gl_context *ctx,
> +                                  GLuint index);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* SPIRVEXTENSIONS_H */
> 



More information about the mesa-dev mailing list