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 <apinheiro@igalia.com> [v1]
parent dccd179b
......@@ -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;
......
......@@ -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:
......
......@@ -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,
};
/**
......
......@@ -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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment