[Mesa-dev] [PATCH 14/92] gallium: add PIPE_STRUCT_CAP_NIR_LOWER_TEX_OPTIONS

Nicolai Hähnle nhaehnle at gmail.com
Mon Jun 26 14:09:53 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Allow the driver to configure the state tracker's nir_lower_tex pass when
using NIR.
---
 src/gallium/docs/source/screen.rst               | 20 ++++++++++++++++++++
 src/gallium/drivers/freedreno/freedreno_screen.c | 14 ++++++++++++++
 src/gallium/drivers/vc4/vc4_screen.c             | 15 +++++++++++++++
 src/gallium/include/pipe/p_defines.h             |  6 ++++++
 src/gallium/include/pipe/p_screen.h              | 11 +++++++++++
 5 files changed, 66 insertions(+)

diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index 32da228..f18109a 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -494,20 +494,33 @@ to be 0.
 * ``PIPE_SHADER_CAP_MAX_SHADER_IMAGES``: Maximum number of image units.
 * ``PIPE_SHADER_CAP_LOWER_IF_THRESHOLD``: IF and ELSE branches with a lower
   cost than this value should be lowered by the state tracker for better
   performance. This is a tunable for the GLSL compiler and the behavior is
   specific to the compiler.
 * ``PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS``: Whether the merge registers
   TGSI pass is skipped. This might reduce code size and register pressure if
   the underlying driver has a real backend compiler.
 
 
+.. _pipe_struct_cap:
+
+PIPE_STRUCT_CAP_*
+^^^^^^^^^^^^^^^^^^
+
+Struct-valued capabilities and options. They can be queried using
+pipe_screen::get_struct_param.
+
+* ``PIPE_CAP_NIR_LOWER_TEX_OPTIONS``: struct nir_lower_tex_options-valued
+  parameter that indicates which texture lowerings the state tracker should
+  apply to NIR shaders. Can be NULL to indicate that no lowering is needed.
+
+
 .. _pipe_compute_cap:
 
 PIPE_COMPUTE_CAP_*
 ^^^^^^^^^^^^^^^^^^
 
 Compute-specific capabilities. They can be queried using
 pipe_screen::get_compute_param.
 
 * ``PIPE_COMPUTE_CAP_IR_TARGET``: A description of the target of the form
   ``processor-arch-manufacturer-os`` that will be passed on to the compiler.
@@ -657,20 +670,27 @@ Get an integer/boolean screen parameter.
 
 .. _get_paramf:
 
 get_paramf
 ^^^^^^^^^^
 
 Get a floating-point screen parameter.
 
 **param** is one of the :ref:`PIPE_CAP` names.
 
+get_struct_param
+^^^^^^^^^^^^^^^^
+
+Get a struct-valued screen parameter.
+
+**param** is one of the :ref:`PIPE_STRUCT_CAP` names.
+
 context_create
 ^^^^^^^^^^^^^^
 
 Create a pipe_context.
 
 **priv** is private data of the caller, which may be put to various
 unspecified uses, typically to do with implementing swapbuffers
 and/or front-buffer rendering.
 
 is_format_supported
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
index b1c2c03..2a6c320 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -664,20 +664,33 @@ fd_get_compiler_options(struct pipe_screen *pscreen,
 		enum pipe_shader_ir ir, unsigned shader)
 {
 	struct fd_screen *screen = fd_screen(pscreen);
 
 	if (is_ir3(screen))
 		return ir3_get_compiler_options(screen->compiler);
 
 	return NULL;
 }
 
+static const void *
+fd_get_struct_param(struct pipe_screen *pscreen,
+                    enum pipe_struct_cap param)
+{
+   switch (param) {
+   case PIPE_STRUCT_CAP_NIR_LOWER_TEX_OPTIONS:
+      return NULL;
+   default:
+      assert(false);
+      return NULL;
+   }
+}
+
 boolean
 fd_screen_bo_get_handle(struct pipe_screen *pscreen,
 		struct fd_bo *bo,
 		unsigned stride,
 		struct winsys_handle *whandle)
 {
 	whandle->stride = stride;
 
 	if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
 		return fd_bo_get_name(bo, &whandle->handle) == 0;
@@ -848,20 +861,21 @@ fd_screen_create(struct fd_device *dev)
 	fd_bc_init(&screen->batch_cache);
 
 	(void) mtx_init(&screen->lock, mtx_plain);
 
 	pscreen->destroy = fd_screen_destroy;
 	pscreen->get_param = fd_screen_get_param;
 	pscreen->get_paramf = fd_screen_get_paramf;
 	pscreen->get_shader_param = fd_screen_get_shader_param;
 	pscreen->get_compute_param = fd_get_compute_param;
 	pscreen->get_compiler_options = fd_get_compiler_options;
+        pscreen->get_struct_param = fd_get_struct_param;
 
 	fd_resource_screen_init(pscreen);
 	fd_query_screen_init(pscreen);
 
 	pscreen->get_name = fd_screen_get_name;
 	pscreen->get_vendor = fd_screen_get_vendor;
 	pscreen->get_device_vendor = fd_screen_get_device_vendor;
 
 	pscreen->get_timestamp = fd_screen_get_timestamp;
 
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c
index cbeb683..4cea36d 100644
--- a/src/gallium/drivers/vc4/vc4_screen.c
+++ b/src/gallium/drivers/vc4/vc4_screen.c
@@ -598,32 +598,47 @@ vc4_get_chip_info(struct vc4_screen *screen)
                 fprintf(stderr,
                         "V3D %d.%d not supported by this version of Mesa.\n",
                         screen->v3d_ver / 10,
                         screen->v3d_ver % 10);
                 return false;
         }
 
         return true;
 }
 
+static const void *
+vc4_screen_get_struct_param(struct pipe_screen *pscreen,
+                            enum pipe_struct_cap param)
+{
+   switch (param) {
+   case PIPE_STRUCT_CAP_NIR_LOWER_TEX_OPTIONS:
+      return NULL;
+
+   default:
+      assert(false);
+      return NULL;
+   }
+}
+
 struct pipe_screen *
 vc4_screen_create(int fd, struct renderonly *ro)
 {
         struct vc4_screen *screen = rzalloc(NULL, struct vc4_screen);
         struct pipe_screen *pscreen;
 
         pscreen = &screen->base;
 
         pscreen->destroy = vc4_screen_destroy;
         pscreen->get_param = vc4_screen_get_param;
         pscreen->get_paramf = vc4_screen_get_paramf;
         pscreen->get_shader_param = vc4_screen_get_shader_param;
+        pscreen->get_struct_param = vc4_screen_get_struct_param;
         pscreen->context_create = vc4_context_create;
         pscreen->is_format_supported = vc4_screen_is_format_supported;
 
         screen->fd = fd;
         if (ro) {
                 screen->ro = renderonly_dup(ro);
                 if (!screen->ro) {
                         fprintf(stderr, "Failed to dup renderonly object\n");
                         ralloc_free(screen);
                         return NULL;
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 2ccdf44..89add9d 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -844,20 +844,26 @@ enum pipe_shader_cap
    PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED,
    PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE,
    PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT,
    PIPE_SHADER_CAP_MAX_SHADER_BUFFERS,
    PIPE_SHADER_CAP_SUPPORTED_IRS,
    PIPE_SHADER_CAP_MAX_SHADER_IMAGES,
    PIPE_SHADER_CAP_LOWER_IF_THRESHOLD,
    PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS,
 };
 
+/** Struct-values capabilities/options */
+enum pipe_struct_cap
+{
+   PIPE_STRUCT_CAP_NIR_LOWER_TEX_OPTIONS,
+};
+
 /**
  * Shader intermediate representation.
  *
  * Note that if the driver requests something other than TGSI, it must
  * always be prepared to receive TGSI in addition to its preferred IR.
  * If the driver requests TGSI as its preferred IR, it will *always*
  * get TGSI.
  *
  * Note that PIPE_SHADER_IR_TGSI should be zero for backwards compat with
  * state trackers that only understand TGSI.
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 65e954a..14d9e96 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -94,20 +94,31 @@ struct pipe_screen {
    float (*get_paramf)( struct pipe_screen *, enum pipe_capf param );
 
    /**
     * Query a per-shader-stage integer-valued capability/parameter/limit
     * \param param  one of PIPE_CAP_x
     */
    int (*get_shader_param)( struct pipe_screen *, enum pipe_shader_type shader,
                             enum pipe_shader_cap param );
 
    /**
+    * Query a struct-valued capability/parameter/limit.
+    *
+    * The lifetime of the returned struct must be at least the lifetime of the
+    * screen.
+    *
+    * \param param  one of PIPE_CAP_x
+    */
+   const void *(*get_struct_param)( struct pipe_screen *,
+                                    enum pipe_struct_cap param );
+
+   /**
     * Query an integer-valued capability/parameter/limit for a codec/profile
     * \param param  one of PIPE_VIDEO_CAP_x
     */
    int (*get_video_param)( struct pipe_screen *,
 			   enum pipe_video_profile profile,
 			   enum pipe_video_entrypoint entrypoint,
 			   enum pipe_video_cap param );
 
    /**
     * Query a compute-specific capability/parameter/limit.
-- 
2.9.3



More information about the mesa-dev mailing list