gallium: plumb context priority through to driver
authorRob Clark <robdclark@gmail.com>
Wed, 23 Aug 2017 18:39:55 +0000 (14:39 -0400)
committerRob Clark <robdclark@gmail.com>
Tue, 19 Dec 2017 21:36:10 +0000 (16:36 -0500)
Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Andres Rodriguez <andresx7@gmail.com>
Reviewed-by: Wladimir J. van der Laan <laanwj@gmail.com>
22 files changed:
src/gallium/docs/source/screen.rst
src/gallium/drivers/etnaviv/etnaviv_screen.c
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nouveau/nv30/nv30_screen.c
src/gallium/drivers/nouveau/nv50/nv50_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeonsi/si_get.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/swr/swr_screen.cpp
src/gallium/drivers/vc4/vc4_screen.c
src/gallium/drivers/vc5/vc5_screen.c
src/gallium/drivers/virgl/virgl_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/state_tracker/st_api.h
src/gallium/state_trackers/dri/dri_context.c
src/gallium/state_trackers/dri/dri_query_renderer.c
src/mesa/state_tracker/st_manager.c

index 519728f188b9477758c2a3f2100e0b015da90bde..3cfa8e3021209310b5d616400d5b168aec60775f 100644 (file)
@@ -417,6 +417,10 @@ The integer capabilities:
 * ``PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET``:
   Whether pipe_vertex_buffer::buffer_offset is treated as signed. The u_vbuf
   module needs this for optimal performance in workstation applications.
+* ``PIPE_CAP_CONTEXT_PRIORITY_MASK``: For drivers that support per-context
+  priorities, this returns a bitmask of PIPE_CONTEXT_PRIORITY_x for the
+  supported priority levels.  A driver that does not support prioritized
+  contexts can return 0.
 
 
 .. _pipe_capf:
index 6d6165e45cee8258766dbd842e318bdd733b2cf8..242ebf8512eddcff101f9a66cdc6ae688c2c9476 100644 (file)
@@ -268,6 +268,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
 
    /* Stream output. */
index 0c3994730bd8907aebebc0706ee58fe12b25e208..cf74c8d621b50436a1730135732fcf1833ca1497 100644 (file)
@@ -339,6 +339,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TILE_RASTER_ORDER:
        case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
        case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+       case PIPE_CAP_CONTEXT_PRIORITY_MASK:
                return 0;
 
        case PIPE_CAP_DRAW_INDIRECT:
index 26d0d804452a449ebdb948cb23f77ce7c018dd0b..663e79333e8b10554850f0e0e4ddf8b21e673419 100644 (file)
@@ -326,6 +326,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
 
    case PIPE_CAP_MAX_VIEWPORTS:
index bd5876994d318e38c481108806bd7bd79cd056ef..9c3d9fbcbd21d8d88bf199ce3c3b51ea6e5a391a 100644 (file)
@@ -364,6 +364,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
    }
    /* should only get here on unhandled cases */
index 37f6cf63453124cb66a11c879a03fd1639e9bac3..f915800023ddff7bb32b4a3f68ace9c34e52723e 100644 (file)
@@ -228,6 +228,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index d9c868cd197d748f1c713270816ade3a28c145b9..d6e06e049b66a77c6a2edf33ea70a50b33045003 100644 (file)
@@ -280,6 +280,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 2e7b4d7afd5e2dd001ca0e5bdc55c16f054eab4e..02562dd4eb2a8cc816d86c846020ccc480ec1e48 100644 (file)
@@ -309,6 +309,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 99d63021da5f9afea45109a983480837d7d7ec2f..f341a403432e9d00a5ad4d74bac96f0785d6c75f 100644 (file)
@@ -250,6 +250,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_TILE_RASTER_ORDER:
         case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
         case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+        case PIPE_CAP_CONTEXT_PRIORITY_MASK:
             return 0;
 
         /* SWTCL-only features. */
index 29cffe9c7e2ab89484436e101fb4df70e38cc752..95aa2e5383f48a08d491d9d86905fc475b616392 100644 (file)
@@ -411,6 +411,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
        case PIPE_CAP_TILE_RASTER_ORDER:
        case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+       case PIPE_CAP_CONTEXT_PRIORITY_MASK:
                return 0;
 
        case PIPE_CAP_DOUBLES:
index 1c84a252ef3aeea9014793a022b1d0742e971c5e..fd42adbcae75bdd916edac3ec4ce812289d577e5 100644 (file)
@@ -274,6 +274,7 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_POST_DEPTH_COVERAGE:
        case PIPE_CAP_TILE_RASTER_ORDER:
        case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
+       case PIPE_CAP_CONTEXT_PRIORITY_MASK:
                return 0;
 
        case PIPE_CAP_NATIVE_FENCE_FD:
index 08efd14fbe0f22b1e94a24b1bc6f7c32b16407a3..5b29e23438bd282919b055dadfd5b93e0aeb08d2 100644 (file)
@@ -315,6 +315,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
    case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
       return 4;
index 2f68466c13fb19bb47e0df0c1e7976f687d35d3a..534e94ab22bd13662596acfe61af0141f6dd02a3 100644 (file)
@@ -459,6 +459,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
    }
 
index 71a07ebe8d21e303a56e241acd9f68adfb56f080..ce30da4169d6024846eef4cb470ad5634ed6d43c 100644 (file)
@@ -346,6 +346,7 @@ swr_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 74dd9d5767e38dbc461b6f9d0cf707e8a29b3e64..be8fc2f5f168fdf1137fd96f924bfe54fd95226c 100644 (file)
@@ -288,6 +288,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
         case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
         case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+        case PIPE_CAP_CONTEXT_PRIORITY_MASK:
                 return 0;
 
                 /* Stream output. */
index 36e34dedd59f9edd96c3da0fed440c23bd1d6616..7c1d855a2667d6a133115c7e18c76cd6ec9df2a5 100644 (file)
@@ -248,6 +248,7 @@ vc5_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_TILE_RASTER_ORDER:
         case PIPE_CAP_STREAM_OUTPUT_INTERLEAVE_BUFFERS:
         case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
+        case PIPE_CAP_CONTEXT_PRIORITY_MASK:
                 return 0;
 
                 /* Geometry shader output, unsupported. */
index 725f7dbed440bc27350ca58c8742481534bcb3b8..65eab20586820f3cb7f441ba7310cc93b83ce648 100644 (file)
@@ -273,6 +273,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TILE_RASTER_ORDER:
    case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
    case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
+   case PIPE_CAP_CONTEXT_PRIORITY_MASK:
       return 0;
    case PIPE_CAP_VENDOR_ID:
       return 0x1af4;
index e4d0d63066d7bcfdd4004aa429ff5bc027b1db4a..42aff60ac4b0c5e566a9edda9dd95e0ec5bed55c 100644 (file)
@@ -391,6 +391,15 @@ enum pipe_flush_flags
  */
 #define PIPE_CONTEXT_PREFER_THREADED   (1 << 3)
 
+/**
+ * Create a high priority context.
+ */
+#define PIPE_CONTEXT_HIGH_PRIORITY     (1 << 4)
+
+/**
+ * Create a low priority context.
+ */
+#define PIPE_CONTEXT_LOW_PRIORITY      (1 << 5)
 
 /**
  * Flags for pipe_context::memory_barrier.
@@ -785,8 +794,20 @@ enum pipe_cap
    PIPE_CAP_TILE_RASTER_ORDER,
    PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES,
    PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET,
+   PIPE_CAP_CONTEXT_PRIORITY_MASK,
 };
 
+/**
+ * Possible bits for PIPE_CAP_CONTEXT_PRIORITY_MASK param, which should
+ * return a bitmask of the supported priorities.  If the driver does not
+ * support prioritized contexts, it can return 0.
+ *
+ * Note that these match __DRI2_RENDER_HAS_CONTEXT_PRIORITY_*
+ */
+#define PIPE_CONTEXT_PRIORITY_LOW     (1 << 0)
+#define PIPE_CONTEXT_PRIORITY_MEDIUM  (1 << 1)
+#define PIPE_CONTEXT_PRIORITY_HIGH    (1 << 2)
+
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600 (1 << 1)
 
index 44d6b474f8f34aaa9bcaf024b89cc64bc9783486..f95f65f15601d28144c3d0d2d4532ba3ec9f38b8 100644 (file)
@@ -92,6 +92,8 @@ enum st_api_feature
 #define ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED (1 << 3)
 #define ST_CONTEXT_FLAG_NO_ERROR            (1 << 4)
 #define ST_CONTEXT_FLAG_RELEASE_NONE       (1 << 5)
+#define ST_CONTEXT_FLAG_HIGH_PRIORITY       (1 << 6)
+#define ST_CONTEXT_FLAG_LOW_PRIORITY        (1 << 7)
 
 /**
  * Reasons that context creation might fail.
index 6e28553146f1391869724fbcbe678a979e00834a..fb307337a90565e55c19b0be13b9ef6ec6f3fd9a 100644 (file)
@@ -57,7 +57,9 @@ dri_create_context(gl_api api, const struct gl_config * visual,
    unsigned allowed_flags = __DRI_CTX_FLAG_DEBUG |
                             __DRI_CTX_FLAG_FORWARD_COMPATIBLE |
                             __DRI_CTX_FLAG_NO_ERROR;
-   unsigned allowed_attribs = __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR;
+   unsigned allowed_attribs =
+      __DRIVER_CONTEXT_ATTRIB_PRIORITY |
+      __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR;
    const __DRIbackgroundCallableExtension *backgroundCallable =
       screen->sPriv->dri2.backgroundCallable;
 
@@ -112,6 +114,19 @@ dri_create_context(gl_api api, const struct gl_config * visual,
    if (ctx_config->flags & __DRI_CTX_FLAG_NO_ERROR)
       attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
 
+   if (ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_PRIORITY) {
+      switch (ctx_config->priority) {
+      case __DRI_CTX_PRIORITY_LOW:
+         attribs.flags |= ST_CONTEXT_FLAG_LOW_PRIORITY;
+         break;
+      case __DRI_CTX_PRIORITY_HIGH:
+         attribs.flags |= ST_CONTEXT_FLAG_HIGH_PRIORITY;
+         break;
+      default:
+         break;
+      }
+   }
+
    if ((ctx_config->attribute_mask & __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR)
        && (ctx_config->release_behavior == __DRI_CTX_RELEASE_BEHAVIOR_NONE))
       attribs.flags |= ST_CONTEXT_FLAG_RELEASE_NONE;
index ea31b6c1e10305bbd3b0628ee2f660a6ddc66f23..80847e3d3149c4208c1189f371755e4de8a9353b 100644 (file)
@@ -55,7 +55,13 @@ dri2_query_renderer_integer(__DRIscreen *_screen, int param,
                                                   PIPE_TEXTURE_2D, 0,
                                                   PIPE_BIND_RENDER_TARGET);
       return 0;
-
+   case __DRI2_RENDERER_HAS_CONTEXT_PRIORITY:
+      value[0] =
+         screen->base.screen->get_param(screen->base.screen,
+                                        PIPE_CAP_CONTEXT_PRIORITY_MASK);
+      if (!value[0])
+         return -1;
+      return 0;
    default:
       return driQueryRendererIntegerCommon(_screen, param, value);
    }
index 380b05c53f513cbe326855fb822c37091ca842ac..d6aa3e7962c269f74b2aa609c86ce41373d3f068 100644 (file)
@@ -880,6 +880,11 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
    if (attribs->flags & ST_CONTEXT_FLAG_NO_ERROR)
       no_error = true;
 
+   if (attribs->flags & ST_CONTEXT_FLAG_LOW_PRIORITY)
+      ctx_flags |= PIPE_CONTEXT_LOW_PRIORITY;
+   else if (attribs->flags & ST_CONTEXT_FLAG_HIGH_PRIORITY)
+      ctx_flags |= PIPE_CONTEXT_HIGH_PRIORITY;
+
    pipe = smapi->screen->context_create(smapi->screen, NULL, ctx_flags);
    if (!pipe) {
       *error = ST_CONTEXT_ERROR_NO_MEMORY;