gallium: Add ARB_gl_spirv support
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 5 Aug 2019 23:25:11 +0000 (16:25 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 10 Sep 2019 21:36:46 +0000 (14:36 -0700)
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]
src/gallium/auxiliary/util/u_screen.c
src/gallium/docs/source/screen.rst
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_extensions.c

index 879e49d8d5bce9d6b49464dbf636557ac7743afb..83b1c4df15b850a7de9753f48fb9dd85d70db802 100644 (file)
@@ -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;
index 1df04b6c3bf96480f25bdc4c18d573028dd0ed7d..c4373e72de5b2753b81c982e1dde621a2d42d438 100644 (file)
@@ -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:
 
index 8530994d9ad39382edc6f005a681947ca926f913..0e98af3985db421dc3bcc7ae2e31b5c228c239e0 100644 (file)
@@ -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,
 };
 
 /**
index 4da6e559ed5d392f0397b5149ba3ba7b82596cf0..ed81134f4c535a93e3cc19df476d3ee2f0f60271 100644 (file)
@@ -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);
+   }
 }