From: Caio Marcelo de Oliveira Filho Date: Mon, 5 Aug 2019 23:25:11 +0000 (-0700) Subject: gallium: Add ARB_gl_spirv support X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eca8032f20d0970184843d98e2bddb688e94a3a9;p=mesa.git gallium: Add ARB_gl_spirv support The PIPE_CAP_GL_SPIRV capability enables ARB_gl_spirv and ARB_spirv_extensions, and will make sure the corresponding SPIR-V capabilities and extensions lists are initialized. The additional PIPE_CAP_GL_SPIRV_VARIABLE_POINTERS capability enables the support for Variable Pointers in SPIR-V shaders. This depends on the driver and is not mandatory for ARB_gl_spirv support. v2: Add a PIPE_CAP for Variable Pointers. (Marek) Reviewed-by: Alejandro PiƱeiro [v1] --- diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 879e49d8d5b..83b1c4df15b 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -376,6 +376,10 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, case PIPE_CAP_TEXTURE_SHADOW_LOD: return 0; + case PIPE_CAP_GL_SPIRV: + case PIPE_CAP_GL_SPIRV_VARIABLE_POINTERS: + return 0; + case PIPE_CAP_DMABUF: #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) return 1; diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 1df04b6c3bf..c4373e72de5 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -552,6 +552,8 @@ The integer capabilities: turn arrays whose contents can be deduced at compile time into constant buffer loads, or false if the driver can handle such arrays itself in a more efficient manner. +* ``PIPE_CAP_GL_SPIRV``: True if the driver supports ARB_gl_spirv extension. +* ``PIPE_CAP_GL_SPIRV_VARIABLE_POINTERS``: True if the driver supports Variable Pointers in SPIR-V shaders. .. _pipe_capf: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 8530994d9ad..0e98af3985d 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -898,6 +898,8 @@ enum pipe_cap PIPE_CAP_SHADER_SAMPLES_IDENTICAL, PIPE_CAP_TGSI_ATOMINC_WRAP, PIPE_CAP_PREFER_IMM_ARRAYS_AS_CONSTBUF, + PIPE_CAP_GL_SPIRV, + PIPE_CAP_GL_SPIRV_VARIABLE_POINTERS, }; /** diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 4da6e559ed5..ed81134f4c5 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -31,6 +31,7 @@ #include "main/imports.h" #include "main/context.h" #include "main/macros.h" +#include "main/spirv_extensions.h" #include "main/version.h" #include "pipe/p_context.h" @@ -708,6 +709,7 @@ void st_init_extensions(struct pipe_screen *screen, { o(ARB_draw_instanced), PIPE_CAP_TGSI_INSTANCEID }, { o(ARB_framebuffer_object), PIPE_CAP_MIXED_FRAMEBUFFER_SIZES }, { o(ARB_gpu_shader_int64), PIPE_CAP_INT64 }, + { o(ARB_gl_spirv), PIPE_CAP_GL_SPIRV }, { o(ARB_indirect_parameters), PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS }, { o(ARB_instanced_arrays), PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR }, { o(ARB_occlusion_query), PIPE_CAP_OCCLUSION_QUERY }, @@ -732,6 +734,7 @@ void st_init_extensions(struct pipe_screen *screen, { o(ARB_shader_texture_image_samples), PIPE_CAP_TGSI_TXQS }, { o(ARB_shader_texture_lod), PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD }, { o(ARB_sparse_buffer), PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE }, + { o(ARB_spirv_extensions), PIPE_CAP_GL_SPIRV }, { o(ARB_texture_buffer_object), PIPE_CAP_TEXTURE_BUFFER_OBJECTS }, { o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY }, { o(ARB_texture_gather), PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS }, @@ -1656,4 +1659,22 @@ void st_init_extensions(struct pipe_screen *screen, pre_snap_triangles && pre_snap_points_lines; } } + + if (extensions->ARB_gl_spirv) { + struct spirv_supported_capabilities *spirv_caps = &consts->SpirVCapabilities; + + spirv_caps->atomic_storage = extensions->ARB_shader_atomic_counters; + spirv_caps->draw_parameters = extensions->ARB_shader_draw_parameters; + spirv_caps->float64 = extensions->ARB_gpu_shader_fp64; + spirv_caps->geometry_streams = extensions->ARB_gpu_shader5; + spirv_caps->image_write_without_format = extensions->ARB_shader_image_load_store; + spirv_caps->int64 = extensions->ARB_gpu_shader_int64; + spirv_caps->tessellation = extensions->ARB_tessellation_shader; + spirv_caps->transform_feedback = extensions->ARB_transform_feedback3; + spirv_caps->variable_pointers = + screen->get_param(screen, PIPE_CAP_GL_SPIRV_VARIABLE_POINTERS); + + consts->SpirVExtensions = CALLOC_STRUCT(spirv_supported_extensions); + _mesa_fill_supported_spirv_extensions(consts->SpirVExtensions, spirv_caps); + } }