[Mesa-dev] [PATCH 02/15] gallium: add flags parameter to pipe_screen::context_create

Marek Olšák maraeo at gmail.com
Sun Aug 23 05:04:48 PDT 2015


From: Marek Olšák <marek.olsak at amd.com>

This allows creating compute-only and debug contexts.
---
 src/gallium/auxiliary/util/u_tests.c              |  2 +-
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c      |  2 +-
 src/gallium/drivers/freedreno/a2xx/fd2_context.c  |  2 +-
 src/gallium/drivers/freedreno/a2xx/fd2_context.h  |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_context.c  |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_context.h  |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_context.c  |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_context.h  |  2 +-
 src/gallium/drivers/i915/i915_context.c           |  2 +-
 src/gallium/drivers/i915/i915_context.h           |  2 +-
 src/gallium/drivers/ilo/ilo_context.c             |  2 +-
 src/gallium/drivers/llvmpipe/lp_context.c         |  3 ++-
 src/gallium/drivers/llvmpipe/lp_context.h         |  3 ++-
 src/gallium/drivers/noop/noop_pipe.c              |  3 ++-
 src/gallium/drivers/nouveau/nv30/nv30_context.c   |  2 +-
 src/gallium/drivers/nouveau/nv30/nv30_context.h   |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_context.c   |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_context.h   |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c   |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.h   |  2 +-
 src/gallium/drivers/r300/r300_context.c           |  2 +-
 src/gallium/drivers/r300/r300_context.h           |  2 +-
 src/gallium/drivers/r600/r600_pipe.c              |  5 +++--
 src/gallium/drivers/radeonsi/si_pipe.c            |  5 +++--
 src/gallium/drivers/rbug/rbug_screen.c            |  6 +++---
 src/gallium/drivers/softpipe/sp_context.c         |  4 ++--
 src/gallium/drivers/softpipe/sp_context.h         |  2 +-
 src/gallium/drivers/svga/svga_context.c           |  4 ++--
 src/gallium/drivers/svga/svga_context.h           |  2 +-
 src/gallium/drivers/trace/tr_screen.c             |  7 +++++--
 src/gallium/drivers/vc4/vc4_context.c             |  2 +-
 src/gallium/drivers/vc4/vc4_context.h             |  2 +-
 src/gallium/include/pipe/p_defines.h              | 15 +++++++++++++++
 src/gallium/include/pipe/p_screen.h               | 11 +++++++++--
 src/gallium/state_trackers/clover/core/queue.cpp  |  2 +-
 src/gallium/state_trackers/glx/xlib/xm_st.c       |  2 +-
 src/gallium/state_trackers/nine/device9.c         |  2 +-
 src/gallium/state_trackers/omx/vid_dec.c          |  2 +-
 src/gallium/state_trackers/omx/vid_enc.c          |  4 ++--
 src/gallium/state_trackers/va/context.c           |  3 ++-
 src/gallium/state_trackers/vdpau/device.c         |  2 +-
 src/gallium/state_trackers/xa/xa_context.c        |  2 +-
 src/gallium/state_trackers/xvmc/context.c         |  2 +-
 src/gallium/tests/graw/clear.c                    |  2 +-
 src/gallium/tests/graw/fs-test.c                  |  2 +-
 src/gallium/tests/graw/graw_util.h                |  2 +-
 src/gallium/tests/graw/gs-test.c                  |  2 +-
 src/gallium/tests/graw/quad-sample.c              |  2 +-
 src/gallium/tests/graw/shader-leak.c              |  2 +-
 src/gallium/tests/graw/tri-gs.c                   |  2 +-
 src/gallium/tests/graw/tri-instanced.c            |  2 +-
 src/gallium/tests/graw/vs-test.c                  |  2 +-
 src/gallium/tests/trivial/compute.c               |  2 +-
 src/gallium/tests/trivial/quad-tex.c              |  2 +-
 src/gallium/tests/trivial/tri.c                   |  2 +-
 src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
 src/mesa/state_tracker/st_manager.c               |  2 +-
 57 files changed, 96 insertions(+), 65 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index 6a489d6..a94e5cc 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -457,7 +457,7 @@ null_constant_buffer(struct pipe_context *ctx)
 void
 util_run_tests(struct pipe_screen *screen)
 {
-   struct pipe_context *ctx = screen->context_create(screen, NULL);
+   struct pipe_context *ctx = screen->context_create(screen, NULL, 0);
 
    tgsi_vs_window_space_position(ctx);
    null_sampler_view(ctx, TGSI_TEXTURE_2D);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index b700983..9d0e4a1 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -1120,7 +1120,7 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
 
    dec->base = *templat;
    dec->base.context = context;
-   dec->context = context->screen->context_create(context->screen, NULL);
+   dec->context = context->screen->context_create(context->screen, NULL, 0);
 
    dec->base.destroy = vl_mpeg12_destroy;
    dec->base.begin_frame = vl_mpeg12_begin_frame;
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_context.c b/src/gallium/drivers/freedreno/a2xx/fd2_context.c
index 6089ebc..3bed735 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_context.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_context.c
@@ -86,7 +86,7 @@ static const uint8_t a20x_primtypes[PIPE_PRIM_MAX] = {
 };
 
 struct pipe_context *
-fd2_context_create(struct pipe_screen *pscreen, void *priv)
+fd2_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 {
 	struct fd_screen *screen = fd_screen(pscreen);
 	struct fd2_context *fd2_ctx = CALLOC_STRUCT(fd2_context);
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_context.h b/src/gallium/drivers/freedreno/a2xx/fd2_context.h
index 7414710..eeadf84 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_context.h
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_context.h
@@ -47,6 +47,6 @@ fd2_context(struct fd_context *ctx)
 }
 
 struct pipe_context *
-fd2_context_create(struct pipe_screen *pscreen, void *priv);
+fd2_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);
 
 #endif /* FD2_CONTEXT_H_ */
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.c b/src/gallium/drivers/freedreno/a3xx/fd3_context.c
index dc33783..74cbbf2 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_context.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.c
@@ -98,7 +98,7 @@ static const uint8_t primtypes[PIPE_PRIM_MAX] = {
 };
 
 struct pipe_context *
-fd3_context_create(struct pipe_screen *pscreen, void *priv)
+fd3_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 {
 	struct fd_screen *screen = fd_screen(pscreen);
 	struct fd3_context *fd3_ctx = CALLOC_STRUCT(fd3_context);
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.h b/src/gallium/drivers/freedreno/a3xx/fd3_context.h
index 6e20b2f..250bcf8 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_context.h
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.h
@@ -119,6 +119,6 @@ fd3_context(struct fd_context *ctx)
 }
 
 struct pipe_context *
-fd3_context_create(struct pipe_screen *pscreen, void *priv);
+fd3_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);
 
 #endif /* FD3_CONTEXT_H_ */
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_context.c b/src/gallium/drivers/freedreno/a4xx/fd4_context.c
index e172d35..625512c 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_context.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_context.c
@@ -96,7 +96,7 @@ static const uint8_t primtypes[PIPE_PRIM_MAX] = {
 };
 
 struct pipe_context *
-fd4_context_create(struct pipe_screen *pscreen, void *priv)
+fd4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 {
 	struct fd_screen *screen = fd_screen(pscreen);
 	struct fd4_context *fd4_ctx = CALLOC_STRUCT(fd4_context);
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_context.h b/src/gallium/drivers/freedreno/a4xx/fd4_context.h
index 0b74991..af94756 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_context.h
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_context.h
@@ -97,6 +97,6 @@ fd4_context(struct fd_context *ctx)
 }
 
 struct pipe_context *
-fd4_context_create(struct pipe_screen *pscreen, void *priv);
+fd4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);
 
 #endif /* FD4_CONTEXT_H_ */
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c
index 788381b..05f8e93 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -155,7 +155,7 @@ static void i915_destroy(struct pipe_context *pipe)
 }
 
 struct pipe_context *
-i915_create_context(struct pipe_screen *screen, void *priv)
+i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
 {
    struct i915_context *i915;
 
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index c8c7d64..1ed6851 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -401,7 +401,7 @@ void i915_init_string_functions( struct i915_context *i915 );
  * i915_context.c
  */
 struct pipe_context *i915_create_context(struct pipe_screen *screen,
-					 void *priv);
+					 void *priv, unsigned flags);
 
 
 /***********************************************************************
diff --git a/src/gallium/drivers/ilo/ilo_context.c b/src/gallium/drivers/ilo/ilo_context.c
index b9a16aa..2a00cf1 100644
--- a/src/gallium/drivers/ilo/ilo_context.c
+++ b/src/gallium/drivers/ilo/ilo_context.c
@@ -135,7 +135,7 @@ ilo_context_destroy(struct pipe_context *pipe)
 }
 
 static struct pipe_context *
-ilo_context_create(struct pipe_screen *screen, void *priv)
+ilo_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
 {
    struct ilo_screen *is = ilo_screen(screen);
    struct ilo_context *ilo;
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c
index 80cb657..bd7c0a1 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.c
+++ b/src/gallium/drivers/llvmpipe/lp_context.c
@@ -128,7 +128,8 @@ llvmpipe_render_condition ( struct pipe_context *pipe,
 }
 
 struct pipe_context *
-llvmpipe_create_context( struct pipe_screen *screen, void *priv )
+llvmpipe_create_context(struct pipe_screen *screen, void *priv,
+                        unsigned flags)
 {
    struct llvmpipe_context *llvmpipe;
 
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h
index c273b25..c9a5d67 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -160,7 +160,8 @@ struct llvmpipe_context {
 
 
 struct pipe_context *
-llvmpipe_create_context( struct pipe_screen *screen, void *priv );
+llvmpipe_create_context(struct pipe_screen *screen, void *priv,
+                        unsigned flags);
 
 struct pipe_resource *
 llvmpipe_user_buffer_create(struct pipe_screen *screen,
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c
index aeec677..e644685 100644
--- a/src/gallium/drivers/noop/noop_pipe.c
+++ b/src/gallium/drivers/noop/noop_pipe.c
@@ -260,7 +260,8 @@ static void noop_destroy_context(struct pipe_context *ctx)
 	FREE(ctx);
 }
 
-static struct pipe_context *noop_create_context(struct pipe_screen *screen, void *priv)
+static struct pipe_context *noop_create_context(struct pipe_screen *screen,
+                                                void *priv, unsigned flags)
 {
 	struct pipe_context *ctx = CALLOC_STRUCT(pipe_context);
 
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.c b/src/gallium/drivers/nouveau/nv30/nv30_context.c
index 6e88ed7..46590ee 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_context.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_context.c
@@ -190,7 +190,7 @@ nv30_context_destroy(struct pipe_context *pipe)
    } while(0)
 
 struct pipe_context *
-nv30_context_create(struct pipe_screen *pscreen, void *priv)
+nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 {
    struct nv30_screen *screen = nv30_screen(pscreen);
    struct nv30_context *nv30 = CALLOC_STRUCT(nv30_context);
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.h b/src/gallium/drivers/nouveau/nv30/nv30_context.h
index d5c18bb6..0ab2f95 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_context.h
+++ b/src/gallium/drivers/nouveau/nv30/nv30_context.h
@@ -132,7 +132,7 @@ nv30_context(struct pipe_context *pipe)
 }
 
 struct pipe_context *
-nv30_context_create(struct pipe_screen *pscreen, void *priv);
+nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);
 
 void
 nv30_vbo_init(struct pipe_context *pipe);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c b/src/gallium/drivers/nouveau/nv50/nv50_context.c
index f8d46db..11638dd 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c
@@ -240,7 +240,7 @@ nv50_context_get_sample_position(struct pipe_context *, unsigned, unsigned,
                                  float *);
 
 struct pipe_context *
-nv50_create(struct pipe_screen *pscreen, void *priv)
+nv50_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 {
    struct nv50_screen *screen = nv50_screen(pscreen);
    struct nv50_context *nv50;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.h b/src/gallium/drivers/nouveau/nv50/nv50_context.h
index ce12e71..e7adf47 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.h
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.h
@@ -186,7 +186,7 @@ nv50_context_shader_stage(unsigned pipe)
 }
 
 /* nv50_context.c */
-struct pipe_context *nv50_create(struct pipe_screen *, void *);
+struct pipe_context *nv50_create(struct pipe_screen *, void *, unsigned flags);
 
 void nv50_bufctx_fence(struct nouveau_bufctx *, bool on_flush);
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
index 7a15a11..613cad6 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
@@ -262,7 +262,7 @@ nvc0_context_get_sample_position(struct pipe_context *, unsigned, unsigned,
                                  float *);
 
 struct pipe_context *
-nvc0_create(struct pipe_screen *pscreen, void *priv)
+nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 {
    struct nvc0_screen *screen = nvc0_screen(pscreen);
    struct nvc0_context *nvc0;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
index df1a891..6ed79cf 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h
@@ -214,7 +214,7 @@ nvc0_shader_stage(unsigned pipe)
 
 
 /* nvc0_context.c */
-struct pipe_context *nvc0_create(struct pipe_screen *, void *);
+struct pipe_context *nvc0_create(struct pipe_screen *, void *, unsigned flags);
 void nvc0_bufctx_fence(struct nvc0_context *, struct nouveau_bufctx *,
                        bool on_flush);
 void nvc0_default_kick_notify(struct nouveau_pushbuf *);
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 8c24ad6..b393769 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -363,7 +363,7 @@ static void r300_init_states(struct pipe_context *pipe)
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
-                                         void *priv)
+                                         void *priv, unsigned flags)
 {
     struct r300_context* r300 = CALLOC_STRUCT(r300_context);
     struct r300_screen* r300screen = r300_screen(screen);
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 18ae11a..f298d88 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -705,7 +705,7 @@ r300_get_nonnull_cb(struct pipe_framebuffer_state *fb, unsigned i)
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
-                                         void *priv);
+                                         void *priv, unsigned flags);
 
 /* Context initialization. */
 struct draw_stage* r300_draw_stage(struct r300_context* r300);
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 6ffe561..f6efaa3 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -108,7 +108,8 @@ static void r600_destroy_context(struct pipe_context *context)
 	FREE(rctx);
 }
 
-static struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
+static struct pipe_context *r600_create_context(struct pipe_screen *screen,
+                                                void *priv, unsigned flags)
 {
 	struct r600_context *rctx = CALLOC_STRUCT(r600_context);
 	struct r600_screen* rscreen = (struct r600_screen *)screen;
@@ -624,7 +625,7 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
 	rscreen->global_pool = compute_memory_pool_new(rscreen);
 
 	/* Create the auxiliary context. This must be done last. */
-	rscreen->b.aux_context = rscreen->b.b.context_create(&rscreen->b.b, NULL);
+	rscreen->b.aux_context = rscreen->b.b.context_create(&rscreen->b.b, NULL, 0);
 
 #if 0 /* This is for testing whether aux_context and buffer clearing work correctly. */
 	struct pipe_resource templ = {};
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 473a2e9..029b3cc 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -92,7 +92,8 @@ si_amdgpu_get_reset_status(struct pipe_context *ctx)
 	return sctx->b.ws->ctx_query_reset_status(sctx->b.ctx);
 }
 
-static struct pipe_context *si_create_context(struct pipe_screen *screen, void *priv)
+static struct pipe_context *si_create_context(struct pipe_screen *screen,
+                                              void *priv, unsigned flags)
 {
 	struct si_context *sctx = CALLOC_STRUCT(si_context);
 	struct si_screen* sscreen = (struct si_screen *)screen;
@@ -586,7 +587,7 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 		sscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS;
 
 	/* Create the auxiliary context. This must be done last. */
-	sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL);
+	sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL, 0);
 
 	return &sscreen->b.b;
 }
diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c
index 7da4e81..ac76402 100644
--- a/src/gallium/drivers/rbug/rbug_screen.c
+++ b/src/gallium/drivers/rbug/rbug_screen.c
@@ -129,13 +129,13 @@ rbug_screen_is_format_supported(struct pipe_screen *_screen,
 
 static struct pipe_context *
 rbug_screen_context_create(struct pipe_screen *_screen,
-                           void *priv)
+                           void *priv, unsigned flags)
 {
    struct rbug_screen *rb_screen = rbug_screen(_screen);
    struct pipe_screen *screen = rb_screen->screen;
    struct pipe_context *result;
 
-   result = screen->context_create(screen, priv);
+   result = screen->context_create(screen, priv, flags);
    if (result)
       return rbug_context_create(_screen, result);
    return NULL;
@@ -281,7 +281,7 @@ rbug_screen_create(struct pipe_screen *screen)
 
    rb_screen->screen = screen;
 
-   rb_screen->private_context = screen->context_create(screen, NULL);
+   rb_screen->private_context = screen->context_create(screen, NULL, 0);
    if (!rb_screen->private_context)
       goto err_free;
 
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 34d2b80..d2a3220 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -186,8 +186,8 @@ softpipe_render_condition( struct pipe_context *pipe,
 
 
 struct pipe_context *
-softpipe_create_context( struct pipe_screen *screen,
-			 void *priv )
+softpipe_create_context(struct pipe_screen *screen,
+			void *priv, unsigned flags)
 {
    struct softpipe_screen *sp_screen = softpipe_screen(screen);
    struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index 577df81..073b71a 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -211,7 +211,7 @@ softpipe_context( struct pipe_context *pipe )
 
 
 struct pipe_context *
-softpipe_create_context( struct pipe_screen *, void *priv );
+softpipe_create_context(struct pipe_screen *, void *priv, unsigned flags);
 
 struct pipe_resource *
 softpipe_user_buffer_create(struct pipe_screen *screen,
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
index 0ffff9c..673d17a 100644
--- a/src/gallium/drivers/svga/svga_context.c
+++ b/src/gallium/drivers/svga/svga_context.c
@@ -81,8 +81,8 @@ static void svga_destroy( struct pipe_context *pipe )
 
 
 
-struct pipe_context *svga_context_create( struct pipe_screen *screen,
-					  void *priv )
+struct pipe_context *svga_context_create(struct pipe_screen *screen,
+					 void *priv, unsigned flags)
 {
    struct svga_screen *svgascreen = svga_screen(screen);
    struct svga_context *svga = NULL;
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index 71f038d..2726346 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -478,7 +478,7 @@ void svga_surfaces_flush(struct svga_context *svga);
 
 struct pipe_context *
 svga_context_create(struct pipe_screen *screen,
-		    void *priv);
+		    void *priv, unsigned flags);
 
 
 /***********************************************************************
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 1d86a37..8b02680 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -204,7 +204,8 @@ trace_screen_is_format_supported(struct pipe_screen *_screen,
 
 
 static struct pipe_context *
-trace_screen_context_create(struct pipe_screen *_screen, void *priv)
+trace_screen_context_create(struct pipe_screen *_screen, void *priv,
+                            unsigned flags)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
    struct pipe_screen *screen = tr_scr->screen;
@@ -213,8 +214,10 @@ trace_screen_context_create(struct pipe_screen *_screen, void *priv)
    trace_dump_call_begin("pipe_screen", "context_create");
 
    trace_dump_arg(ptr, screen);
+   trace_dump_arg(ptr, priv);
+   trace_dump_arg(uint, flags);
 
-   result = screen->context_create(screen, priv);
+   result = screen->context_create(screen, priv, flags);
 
    trace_dump_ret(ptr, result);
 
diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c
index fff6315..87d781d 100644
--- a/src/gallium/drivers/vc4/vc4_context.c
+++ b/src/gallium/drivers/vc4/vc4_context.c
@@ -194,7 +194,7 @@ vc4_context_destroy(struct pipe_context *pctx)
 }
 
 struct pipe_context *
-vc4_context_create(struct pipe_screen *pscreen, void *priv)
+vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 {
         struct vc4_screen *screen = vc4_screen(pscreen);
         struct vc4_context *vc4;
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h
index 3a63af8..33b6ec2 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -365,7 +365,7 @@ vc4_sampler_state(struct pipe_sampler_state *psampler)
 }
 
 struct pipe_context *vc4_context_create(struct pipe_screen *pscreen,
-                                        void *priv);
+                                        void *priv, unsigned flags);
 void vc4_draw_init(struct pipe_context *pctx);
 void vc4_state_init(struct pipe_context *pctx);
 void vc4_program_init(struct pipe_context *pctx);
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 4f2aa14..88e37e9 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -334,6 +334,21 @@ enum pipe_flush_flags
 #define PIPE_DEBUG_DEVICE_IS_HUNG      (1 << 0)
 
 /**
+ * Create a compute-only context. Use in pipe_screen::context_create.
+ * This disables draw, blit, and clear*, render_condition, and other graphics
+ * functions. Interop with other graphics contexts is still allowed.
+ * This allows scheduling jobs on a compute-only hardware command queue that
+ * can run in parallel with graphics without stalling it.
+ */
+#define PIPE_CONTEXT_COMPUTE_ONLY      (1 << 0)
+
+/**
+ * Gather debug information and expect that pipe_context::dump_debug_state
+ * will be called. Use in pipe_screen::context_create.
+ */
+#define PIPE_CONTEXT_DEBUG             (1 << 1)
+
+/**
  * Flags for pipe_context::memory_barrier.
  */
 #define PIPE_BARRIER_MAPPED_BUFFER     (1 << 0)
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index 0d26583..a7b7b72 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -125,8 +125,15 @@ struct pipe_screen {
     */
    uint64_t (*get_timestamp)(struct pipe_screen *);
 
-   struct pipe_context * (*context_create)( struct pipe_screen *,
-					    void *priv );
+   /**
+    * Create a context.
+    *
+    * \param screen      pipe screen
+    * \param priv        a pointer to set in pipe_context::priv
+    * \param flags       a mask of PIPE_CONTEXT_* flags
+    */
+   struct pipe_context * (*context_create)(struct pipe_screen *screen,
+					   void *priv, unsigned flags);
 
    /**
     * Check if the given pipe_format is supported as a texture or
diff --git a/src/gallium/state_trackers/clover/core/queue.cpp b/src/gallium/state_trackers/clover/core/queue.cpp
index 87f9dcc..4aaf67d 100644
--- a/src/gallium/state_trackers/clover/core/queue.cpp
+++ b/src/gallium/state_trackers/clover/core/queue.cpp
@@ -30,7 +30,7 @@ using namespace clover;
 command_queue::command_queue(clover::context &ctx, clover::device &dev,
                              cl_command_queue_properties props) :
    context(ctx), device(dev), props(props) {
-   pipe = dev.pipe->context_create(dev.pipe, NULL);
+   pipe = dev.pipe->context_create(dev.pipe, NULL, PIPE_CONTEXT_COMPUTE_ONLY);
    if (!pipe)
       throw error(CL_INVALID_DEVICE);
 }
diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c
index 9d0f2d2..f598430 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -398,7 +398,7 @@ xmesa_get_context(struct st_framebuffer_iface *stfbi)
 
    pipe = xstfb->display->pipe;
    if (!pipe) {
-      pipe = xstfb->screen->context_create(xstfb->screen, NULL);
+      pipe = xstfb->screen->context_create(xstfb->screen, NULL, 0);
       if (!pipe)
          return NULL;
       xstfb->display->pipe = pipe;
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 99197a4..f14ffea 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -163,7 +163,7 @@ NineDevice9_ctor( struct NineDevice9 *This,
     if (This->params.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING)
         DBG("Application asked mixed Software Vertex Processing. Ignoring.\n");
 
-    This->pipe = This->screen->context_create(This->screen, NULL);
+    This->pipe = This->screen->context_create(This->screen, NULL, 0);
     if (!This->pipe) { return E_OUTOFMEMORY; } /* guess */
 
     This->cso = cso_create_context(This->pipe);
diff --git a/src/gallium/state_trackers/omx/vid_dec.c b/src/gallium/state_trackers/omx/vid_dec.c
index 9e7e7ba..5584348 100644
--- a/src/gallium/state_trackers/omx/vid_dec.c
+++ b/src/gallium/state_trackers/omx/vid_dec.c
@@ -162,7 +162,7 @@ static OMX_ERRORTYPE vid_dec_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam
       return OMX_ErrorInsufficientResources;
 
    screen = priv->screen->pscreen;
-   priv->pipe = screen->context_create(screen, priv->screen);
+   priv->pipe = screen->context_create(screen, priv->screen, 0);
    if (!priv->pipe)
       return OMX_ErrorInsufficientResources;
 
diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c
index 2bd0194..aa45089 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -185,7 +185,7 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam
                                 PIPE_VIDEO_ENTRYPOINT_ENCODE,
                                 PIPE_VIDEO_CAP_STACKED_FRAMES);
 
-   priv->s_pipe = screen->context_create(screen, priv->screen);
+   priv->s_pipe = screen->context_create(screen, priv->screen, 0);
    if (!priv->s_pipe)
       return OMX_ErrorInsufficientResources;
 
@@ -202,7 +202,7 @@ static OMX_ERRORTYPE vid_enc_Constructor(OMX_COMPONENTTYPE *comp, OMX_STRING nam
       return OMX_ErrorInsufficientResources;
    }
 
-   priv->t_pipe = screen->context_create(screen, priv->screen);
+   priv->t_pipe = screen->context_create(screen, priv->screen, 0);
    if (!priv->t_pipe)
       return OMX_ErrorInsufficientResources;
 
diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c
index 0a733b3..8b003ae 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -100,7 +100,8 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
    if (!drv->vscreen)
       goto error_screen;
 
-   drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen, drv->vscreen);
+   drv->pipe = drv->vscreen->pscreen->context_create(drv->vscreen->pscreen,
+                                                     drv->vscreen, 0);
    if (!drv->pipe)
       goto error_pipe;
 
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index ba36afc..31c9505 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -70,7 +70,7 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
    }
 
    pscreen = dev->vscreen->pscreen;
-   dev->context = pscreen->context_create(pscreen, dev->vscreen);
+   dev->context = pscreen->context_create(pscreen, dev->vscreen, 0);
    if (!dev->context) {
       ret = VDP_STATUS_RESOURCES;
       goto no_context;
diff --git a/src/gallium/state_trackers/xa/xa_context.c b/src/gallium/state_trackers/xa/xa_context.c
index ebfb290..5553beb 100644
--- a/src/gallium/state_trackers/xa/xa_context.c
+++ b/src/gallium/state_trackers/xa/xa_context.c
@@ -56,7 +56,7 @@ xa_context_create(struct xa_tracker *xa)
     struct xa_context *ctx = calloc(1, sizeof(*ctx));
 
     ctx->xa = xa;
-    ctx->pipe = xa->screen->context_create(xa->screen, NULL);
+    ctx->pipe = xa->screen->context_create(xa->screen, NULL, 0);
     ctx->cso = cso_create_context(ctx->pipe);
     ctx->shaders = xa_shaders_create(ctx);
     renderer_init_state(ctx);
diff --git a/src/gallium/state_trackers/xvmc/context.c b/src/gallium/state_trackers/xvmc/context.c
index 9ded2e5..4702b44 100644
--- a/src/gallium/state_trackers/xvmc/context.c
+++ b/src/gallium/state_trackers/xvmc/context.c
@@ -237,7 +237,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
       return BadAlloc;
    }
 
-   pipe = vscreen->pscreen->context_create(vscreen->pscreen, vscreen);
+   pipe = vscreen->pscreen->context_create(vscreen->pscreen, vscreen, 0);
    if (!pipe) {
       XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n");
       vl_screen_destroy(vscreen);
diff --git a/src/gallium/tests/graw/clear.c b/src/gallium/tests/graw/clear.c
index f38da47..533ce9f 100644
--- a/src/gallium/tests/graw/clear.c
+++ b/src/gallium/tests/graw/clear.c
@@ -61,7 +61,7 @@ static void init( void )
       exit(1);
    }
    
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c
index fc5803f..bd5259a 100644
--- a/src/gallium/tests/graw/fs-test.c
+++ b/src/gallium/tests/graw/fs-test.c
@@ -398,7 +398,7 @@ static void init( void )
       exit(1);
    }
 
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/graw/graw_util.h b/src/gallium/tests/graw/graw_util.h
index e7cd0aa..f09c1ea 100644
--- a/src/gallium/tests/graw/graw_util.h
+++ b/src/gallium/tests/graw/graw_util.h
@@ -60,7 +60,7 @@ graw_util_create_window(struct graw_info *info,
       return FALSE;
    }
    
-   info->ctx = info->screen->context_create(info->screen, NULL);
+   info->ctx = info->screen->context_create(info->screen, NULL, 0);
    if (info->ctx == NULL) {
       debug_printf("graw: Failed to create context\n");
       return FALSE;
diff --git a/src/gallium/tests/graw/gs-test.c b/src/gallium/tests/graw/gs-test.c
index b685323..c680b62 100644
--- a/src/gallium/tests/graw/gs-test.c
+++ b/src/gallium/tests/graw/gs-test.c
@@ -505,7 +505,7 @@ static void init( void )
       exit(1);
    }
 
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/graw/quad-sample.c b/src/gallium/tests/graw/quad-sample.c
index 2953fe1..97f241f 100644
--- a/src/gallium/tests/graw/quad-sample.c
+++ b/src/gallium/tests/graw/quad-sample.c
@@ -313,7 +313,7 @@ static void init( void )
       exit(1);
    }
 
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/graw/shader-leak.c b/src/gallium/tests/graw/shader-leak.c
index 3c585c0..a4502af 100644
--- a/src/gallium/tests/graw/shader-leak.c
+++ b/src/gallium/tests/graw/shader-leak.c
@@ -188,7 +188,7 @@ static void init( void )
       exit(1);
    }
 
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/graw/tri-gs.c b/src/gallium/tests/graw/tri-gs.c
index 5c6f426..6aad51c 100644
--- a/src/gallium/tests/graw/tri-gs.c
+++ b/src/gallium/tests/graw/tri-gs.c
@@ -195,7 +195,7 @@ static void init( void )
       exit(1);
    }
    
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/graw/tri-instanced.c b/src/gallium/tests/graw/tri-instanced.c
index a71bf71..2065c11 100644
--- a/src/gallium/tests/graw/tri-instanced.c
+++ b/src/gallium/tests/graw/tri-instanced.c
@@ -246,7 +246,7 @@ static void init( void )
       exit(1);
    }
    
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/graw/vs-test.c b/src/gallium/tests/graw/vs-test.c
index 5189d81..5c7843e 100644
--- a/src/gallium/tests/graw/vs-test.c
+++ b/src/gallium/tests/graw/vs-test.c
@@ -392,7 +392,7 @@ static void init( void )
       exit(1);
    }
    
-   ctx = screen->context_create(screen, NULL);
+   ctx = screen->context_create(screen, NULL, 0);
    if (ctx == NULL)
       exit(3);
 
diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c
index 4edb857..b344f78 100644
--- a/src/gallium/tests/trivial/compute.c
+++ b/src/gallium/tests/trivial/compute.c
@@ -77,7 +77,7 @@ static void init_ctx(struct context *ctx)
         ctx->screen = pipe_loader_create_screen(ctx->dev, PIPE_SEARCH_DIR);
         assert(ctx->screen);
 
-        ctx->pipe = ctx->screen->context_create(ctx->screen, NULL);
+        ctx->pipe = ctx->screen->context_create(ctx->screen, NULL, 0);
         assert(ctx->pipe);
 
         DUMP_COMPUTE_PARAM(p, PIPE_COMPUTE_CAP_GRID_DIMENSION);
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index c019c7bb..f66f630 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -100,7 +100,7 @@ static void init_prog(struct program *p)
 	assert(p->screen);
 
 	/* create the pipe driver context and cso context */
-	p->pipe = p->screen->context_create(p->screen, NULL);
+	p->pipe = p->screen->context_create(p->screen, NULL, 0);
 	p->cso = cso_create_context(p->pipe);
 
 	/* set clear color */
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index 078beb8..a555200 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -95,7 +95,7 @@ static void init_prog(struct program *p)
 	assert(p->screen);
 
 	/* create the pipe driver context and cso context */
-	p->pipe = p->screen->context_create(p->screen, NULL);
+	p->pipe = p->screen->context_create(p->screen, NULL, 0);
 	p->cso = cso_create_context(p->pipe);
 
 	/* set clear color */
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index 9b90eaa0..5c17993 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -299,7 +299,7 @@ wrapper_sw_winsys_wrap_pipe_screen(struct pipe_screen *screen)
    wsw->base.destroy = wsw_destroy;
 
    wsw->screen = screen;
-   wsw->pipe = screen->context_create(screen, NULL);
+   wsw->pipe = screen->context_create(screen, NULL, 0);
    if (!wsw->pipe)
       goto err_free;
 
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 2e2c8ff..7abd128 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -657,7 +657,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
       break;
    }
 
-   pipe = smapi->screen->context_create(smapi->screen, NULL);
+   pipe = smapi->screen->context_create(smapi->screen, NULL, 0);
    if (!pipe) {
       *error = ST_CONTEXT_ERROR_NO_MEMORY;
       return NULL;
-- 
2.1.4



More information about the mesa-dev mailing list