This allows creating compute-only and debug contexts.
Reviewed-by: Brian Paul <brianp@vmware.com>
Acked-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
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);
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;
};
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);
}
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_ */
};
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);
}
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_ */
};
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);
}
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_ */
}
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;
* i915_context.c
*/
struct pipe_context *i915_create_context(struct pipe_screen *screen,
- void *priv);
+ void *priv, unsigned flags);
/***********************************************************************
}
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;
}
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;
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,
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);
} 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);
}
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);
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;
}
/* 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);
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;
/* 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 *);
}
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);
}
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);
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;
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 = {};
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;
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;
}
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;
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;
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);
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,
-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;
struct pipe_context *
svga_context_create(struct pipe_screen *screen,
- void *priv);
+ void *priv, unsigned flags);
/***********************************************************************
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;
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);
}
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;
}
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);
*/
#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.
*/
*/
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
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);
}
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;
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);
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;
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;
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;
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;
}
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;
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);
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);
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
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;
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
exit(1);
}
- ctx = screen->context_create(screen, NULL);
+ ctx = screen->context_create(screen, NULL, 0);
if (ctx == NULL)
exit(3);
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);
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 */
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 */
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;
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;