[Mesa-dev] [PATCH v2] mesa: add NV_image_formats extension support
Ilia Mirkin
imirkin at alum.mit.edu
Thu Nov 17 20:29:51 UTC 2016
I believe the bit in src/mesa/main/mtypes.h can be removed. Otherwise, this is
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
It is customary to also include a note in relnotes/version.html that
the ext was added.
On Tue, Nov 15, 2016 at 6:16 AM, Lionel Landwerlin
<llandwerlin at gmail.com> wrote:
> v2: Replace helper function by qualifier struct field (Ilia)
> Enable NV_image_formats using ARB_shader_image_load_store (Ilia)
>
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98480
> Cc: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/compiler/glsl/glsl_parser.yy | 86 +++++++++++++++++---------------
> src/compiler/glsl/glsl_parser_extras.cpp | 2 +
> src/compiler/glsl/glsl_parser_extras.h | 2 +
> src/mesa/main/extensions_table.h | 1 +
> src/mesa/main/mtypes.h | 1 +
> src/mesa/main/shaderimage.c | 22 +++++---
> 6 files changed, 67 insertions(+), 47 deletions(-)
>
> diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
> index 7d709c7..a48dc68 100644
> --- a/src/compiler/glsl/glsl_parser.yy
> +++ b/src/compiler/glsl/glsl_parser.yy
> @@ -1296,51 +1296,55 @@ layout_qualifier_id:
> unsigned required_glsl;
> /** Minimum GLSL ES version required for the image format. */
> unsigned required_essl;
> + /* NV_image_formats */
> + bool nv_image_formats;
> } map[] = {
> - { "rgba32f", GL_RGBA32F, GLSL_TYPE_FLOAT, 130, 310 },
> - { "rgba16f", GL_RGBA16F, GLSL_TYPE_FLOAT, 130, 310 },
> - { "rg32f", GL_RG32F, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rg16f", GL_RG16F, GLSL_TYPE_FLOAT, 130, 0 },
> - { "r11f_g11f_b10f", GL_R11F_G11F_B10F, GLSL_TYPE_FLOAT, 130, 0 },
> - { "r32f", GL_R32F, GLSL_TYPE_FLOAT, 130, 310 },
> - { "r16f", GL_R16F, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rgba32ui", GL_RGBA32UI, GLSL_TYPE_UINT, 130, 310 },
> - { "rgba16ui", GL_RGBA16UI, GLSL_TYPE_UINT, 130, 310 },
> - { "rgb10_a2ui", GL_RGB10_A2UI, GLSL_TYPE_UINT, 130, 0 },
> - { "rgba8ui", GL_RGBA8UI, GLSL_TYPE_UINT, 130, 310 },
> - { "rg32ui", GL_RG32UI, GLSL_TYPE_UINT, 130, 0 },
> - { "rg16ui", GL_RG16UI, GLSL_TYPE_UINT, 130, 0 },
> - { "rg8ui", GL_RG8UI, GLSL_TYPE_UINT, 130, 0 },
> - { "r32ui", GL_R32UI, GLSL_TYPE_UINT, 130, 310 },
> - { "r16ui", GL_R16UI, GLSL_TYPE_UINT, 130, 0 },
> - { "r8ui", GL_R8UI, GLSL_TYPE_UINT, 130, 0 },
> - { "rgba32i", GL_RGBA32I, GLSL_TYPE_INT, 130, 310 },
> - { "rgba16i", GL_RGBA16I, GLSL_TYPE_INT, 130, 310 },
> - { "rgba8i", GL_RGBA8I, GLSL_TYPE_INT, 130, 310 },
> - { "rg32i", GL_RG32I, GLSL_TYPE_INT, 130, 0 },
> - { "rg16i", GL_RG16I, GLSL_TYPE_INT, 130, 0 },
> - { "rg8i", GL_RG8I, GLSL_TYPE_INT, 130, 0 },
> - { "r32i", GL_R32I, GLSL_TYPE_INT, 130, 310 },
> - { "r16i", GL_R16I, GLSL_TYPE_INT, 130, 0 },
> - { "r8i", GL_R8I, GLSL_TYPE_INT, 130, 0 },
> - { "rgba16", GL_RGBA16, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rgb10_a2", GL_RGB10_A2, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rgba8", GL_RGBA8, GLSL_TYPE_FLOAT, 130, 310 },
> - { "rg16", GL_RG16, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rg8", GL_RG8, GLSL_TYPE_FLOAT, 130, 0 },
> - { "r16", GL_R16, GLSL_TYPE_FLOAT, 130, 0 },
> - { "r8", GL_R8, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rgba16_snorm", GL_RGBA16_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rgba8_snorm", GL_RGBA8_SNORM, GLSL_TYPE_FLOAT, 130, 310 },
> - { "rg16_snorm", GL_RG16_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
> - { "rg8_snorm", GL_RG8_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
> - { "r16_snorm", GL_R16_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
> - { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT, 130, 0 }
> + { "rgba32f", GL_RGBA32F, GLSL_TYPE_FLOAT, 130, 310, false },
> + { "rgba16f", GL_RGBA16F, GLSL_TYPE_FLOAT, 130, 310, false },
> + { "rg32f", GL_RG32F, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "rg16f", GL_RG16F, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "r11f_g11f_b10f", GL_R11F_G11F_B10F, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "r32f", GL_R32F, GLSL_TYPE_FLOAT, 130, 310, false },
> + { "r16f", GL_R16F, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "rgba32ui", GL_RGBA32UI, GLSL_TYPE_UINT, 130, 310, false },
> + { "rgba16ui", GL_RGBA16UI, GLSL_TYPE_UINT, 130, 310, false },
> + { "rgb10_a2ui", GL_RGB10_A2UI, GLSL_TYPE_UINT, 130, 0, true },
> + { "rgba8ui", GL_RGBA8UI, GLSL_TYPE_UINT, 130, 310, false },
> + { "rg32ui", GL_RG32UI, GLSL_TYPE_UINT, 130, 0, true },
> + { "rg16ui", GL_RG16UI, GLSL_TYPE_UINT, 130, 0, true },
> + { "rg8ui", GL_RG8UI, GLSL_TYPE_UINT, 130, 0, true },
> + { "r32ui", GL_R32UI, GLSL_TYPE_UINT, 130, 310, false },
> + { "r16ui", GL_R16UI, GLSL_TYPE_UINT, 130, 0, true },
> + { "r8ui", GL_R8UI, GLSL_TYPE_UINT, 130, 0, true },
> + { "rgba32i", GL_RGBA32I, GLSL_TYPE_INT, 130, 310, false },
> + { "rgba16i", GL_RGBA16I, GLSL_TYPE_INT, 130, 310, false },
> + { "rgba8i", GL_RGBA8I, GLSL_TYPE_INT, 130, 310, false },
> + { "rg32i", GL_RG32I, GLSL_TYPE_INT, 130, 0, true },
> + { "rg16i", GL_RG16I, GLSL_TYPE_INT, 130, 0, true },
> + { "rg8i", GL_RG8I, GLSL_TYPE_INT, 130, 0, true },
> + { "r32i", GL_R32I, GLSL_TYPE_INT, 130, 310, false },
> + { "r16i", GL_R16I, GLSL_TYPE_INT, 130, 0, true },
> + { "r8i", GL_R8I, GLSL_TYPE_INT, 130, 0, true },
> + { "rgba16", GL_RGBA16, GLSL_TYPE_FLOAT, 130, 0, false },
> + { "rgb10_a2", GL_RGB10_A2, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "rgba8", GL_RGBA8, GLSL_TYPE_FLOAT, 130, 310, false },
> + { "rg16", GL_RG16, GLSL_TYPE_FLOAT, 130, 0, false },
> + { "rg8", GL_RG8, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "r16", GL_R16, GLSL_TYPE_FLOAT, 130, 0, false },
> + { "r8", GL_R8, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "rgba16_snorm", GL_RGBA16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
> + { "rgba8_snorm", GL_RGBA8_SNORM, GLSL_TYPE_FLOAT, 130, 310, false },
> + { "rg16_snorm", GL_RG16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
> + { "rg8_snorm", GL_RG8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true },
> + { "r16_snorm", GL_R16_SNORM, GLSL_TYPE_FLOAT, 130, 0, false },
> + { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT, 130, 0, true }
> };
>
> for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
> - if (state->is_version(map[i].required_glsl,
> - map[i].required_essl) &&
> + if ((state->is_version(map[i].required_glsl,
> + map[i].required_essl) ||
> + (state->NV_image_formats_enable &&
> + map[i].nv_image_formats)) &&
> match_layout_qualifier($1, map[i].name, state) == 0) {
> $$.flags.q.explicit_image_format = 1;
> $$.image_format = map[i].format;
> diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
> index 0cb3c12..1f3ba2c 100644
> --- a/src/compiler/glsl/glsl_parser_extras.cpp
> +++ b/src/compiler/glsl/glsl_parser_extras.cpp
> @@ -28,6 +28,7 @@
> #include "main/core.h" /* for struct gl_context */
> #include "main/context.h"
> #include "main/debug_output.h"
> +#include "main/formats.h"
> #include "main/shaderobj.h"
> #include "util/u_atomic.h" /* for p_atomic_cmpxchg */
> #include "util/ralloc.h"
> @@ -687,6 +688,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
> EXT_AEP(EXT_texture_buffer),
> EXT_AEP(EXT_texture_cube_map_array),
> EXT(MESA_shader_integer_functions),
> + EXT(NV_image_formats),
> };
>
> #undef EXT
> diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
> index 53abbbc..d757c1d 100644
> --- a/src/compiler/glsl/glsl_parser_extras.h
> +++ b/src/compiler/glsl/glsl_parser_extras.h
> @@ -765,6 +765,8 @@ struct _mesa_glsl_parse_state {
> bool MESA_shader_framebuffer_fetch_non_coherent_warn;
> bool MESA_shader_integer_functions_enable;
> bool MESA_shader_integer_functions_warn;
> + bool NV_image_formats_enable;
> + bool NV_image_formats_warn;
> /*@}*/
>
> /** Extensions supported by the OpenGL implementation. */
> diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
> index 036e62b..d3ec551 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -315,6 +315,7 @@ EXT(NV_depth_clamp , ARB_depth_clamp
> EXT(NV_draw_buffers , dummy_true , x , x , x , ES2, 2011)
> EXT(NV_fbo_color_attachments , dummy_true , x , x , x , ES2, 2010)
> EXT(NV_fog_distance , NV_fog_distance , GLL, x , x , x , 2001)
> +EXT(NV_image_formats , ARB_shader_image_load_store , x , x , x , 31, 2014)
> EXT(NV_light_max_exponent , dummy_true , GLL, x , x , x , 1999)
> EXT(NV_packed_depth_stencil , dummy_true , GLL, GLC, x , x , 2000)
> EXT(NV_point_sprite , NV_point_sprite , GLL, GLC, x , x , 2001)
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 5e98040..150aa0c 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3921,6 +3921,7 @@ struct gl_extensions
> GLboolean MESA_ycbcr_texture;
> GLboolean NV_conditional_render;
> GLboolean NV_fog_distance;
> + GLboolean NV_image_formats;
> GLboolean NV_point_sprite;
> GLboolean NV_primitive_restart;
> GLboolean NV_texture_barrier;
> diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
> index db36e3b..5cce3ac 100644
> --- a/src/mesa/main/shaderimage.c
> +++ b/src/mesa/main/shaderimage.c
> @@ -401,7 +401,7 @@ _mesa_is_shader_image_format_supported(const struct gl_context *ctx,
>
> /* Formats supported on unextended desktop GL and the original
> * ARB_shader_image_load_store extension, c.f. table 3.21 of the OpenGL 4.2
> - * specification.
> + * specification or by GLES 3.1 with GL_NV_image_formats extension.
> */
> case GL_RG32F:
> case GL_RG16F:
> @@ -418,17 +418,27 @@ _mesa_is_shader_image_format_supported(const struct gl_context *ctx,
> case GL_RG8I:
> case GL_R16I:
> case GL_R8I:
> - case GL_RGBA16:
> case GL_RGB10_A2:
> - case GL_RG16:
> case GL_RG8:
> - case GL_R16:
> case GL_R8:
> + case GL_RG8_SNORM:
> + case GL_R8_SNORM:
> + return true;
> +
> + /* Formats supported on unextended desktop GL and the original
> + * ARB_shader_image_load_store extension, c.f. table 3.21 of the OpenGL 4.2
> + * specification.
> + *
> + * These can be supported by GLES 3.1 with GL_NV_image_formats &
> + * GL_EXT_texture_norm16 extensions but we don't have support for the
> + * latter in Mesa yet.
> + */
> + case GL_RGBA16:
> case GL_RGBA16_SNORM:
> + case GL_RG16:
> case GL_RG16_SNORM:
> - case GL_RG8_SNORM:
> + case GL_R16:
> case GL_R16_SNORM:
> - case GL_R8_SNORM:
> return _mesa_is_desktop_gl(ctx);
>
> default:
> --
> 2.10.2
More information about the mesa-dev
mailing list