mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 05:50:11 +01:00
nouveau: use the contexts pushbuf and client where possible
At the moment the context uses the screens object, but in order to fix threading without having to lock too much we will have to allocate those objects per context later. Cc: mesa-stable Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10752>
This commit is contained in:
parent
5c2c8652d1
commit
607a9e1fd2
11 changed files with 38 additions and 36 deletions
|
|
@ -124,7 +124,7 @@ nv30_render_draw_elements(struct vbuf_render *render,
|
|||
{
|
||||
struct nv30_render *r = nv30_render(render);
|
||||
struct nv30_context *nv30 = r->nv30;
|
||||
struct nouveau_pushbuf *push = nv30->screen->base.pushbuf;
|
||||
struct nouveau_pushbuf *push = nv30->base.pushbuf;
|
||||
unsigned i;
|
||||
|
||||
BEGIN_NV04(push, NV30_3D(VTXBUF(0)), r->vertex_info.num_attribs);
|
||||
|
|
@ -280,7 +280,7 @@ nv30_render_validate(struct nv30_context *nv30)
|
|||
struct nv30_render *r = nv30_render(nv30->draw->render);
|
||||
struct nv30_rasterizer_stateobj *rast = nv30->rast;
|
||||
struct pipe_screen *pscreen = &nv30->screen->base.base;
|
||||
struct nouveau_pushbuf *push = nv30->screen->base.pushbuf;
|
||||
struct nouveau_pushbuf *push = nv30->base.pushbuf;
|
||||
struct nouveau_object *eng3d = nv30->screen->eng3d;
|
||||
struct nv30_vertprog *vp = nv30->vertprog.program;
|
||||
struct vertex_info *vinfo = &r->vertex_info;
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ static void
|
|||
nv50_compute_upload_input(struct nv50_context *nv50, const uint32_t *input)
|
||||
{
|
||||
struct nv50_screen *screen = nv50->screen;
|
||||
struct nouveau_pushbuf *push = screen->base.pushbuf;
|
||||
struct nouveau_pushbuf *push = nv50->base.pushbuf;
|
||||
unsigned size = align(nv50->compprog->parm_size, 0x4);
|
||||
|
||||
BEGIN_NV04(push, NV50_CP(USER_PARAM_COUNT), 1);
|
||||
|
|
@ -540,7 +540,7 @@ nv50_compute_upload_input(struct nv50_context *nv50, const uint32_t *input)
|
|||
mm = nouveau_mm_allocate(screen->base.mm_GART, size, &bo, &offset);
|
||||
assert(mm);
|
||||
|
||||
nouveau_bo_map(bo, 0, screen->base.client);
|
||||
nouveau_bo_map(bo, 0, nv50->base.client);
|
||||
memcpy(bo->map + offset, input, size);
|
||||
|
||||
nouveau_bufctx_refn(nv50->bufctx, 0, bo, NOUVEAU_BO_GART | NOUVEAU_BO_RD);
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ nv50_flush(struct pipe_context *pipe,
|
|||
struct pipe_fence_handle **fence,
|
||||
unsigned flags)
|
||||
{
|
||||
struct nouveau_screen *screen = nouveau_screen(pipe->screen);
|
||||
struct nouveau_context *context = nouveau_context(pipe);
|
||||
struct nouveau_screen *screen = context->screen;
|
||||
|
||||
if (fence)
|
||||
nouveau_fence_ref(screen->fence.current, (struct nouveau_fence **)fence);
|
||||
|
||||
PUSH_KICK(screen->pushbuf);
|
||||
PUSH_KICK(context->pushbuf);
|
||||
|
||||
nouveau_context_update_frame_stats(nouveau_context(pipe));
|
||||
}
|
||||
|
|
@ -315,12 +316,12 @@ nv50_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
|
|||
nv50->base.pushbuf = screen->base.pushbuf;
|
||||
nv50->base.client = screen->base.client;
|
||||
|
||||
ret = nouveau_bufctx_new(screen->base.client, 2, &nv50->bufctx);
|
||||
ret = nouveau_bufctx_new(nv50->base.client, 2, &nv50->bufctx);
|
||||
if (!ret)
|
||||
ret = nouveau_bufctx_new(screen->base.client, NV50_BIND_3D_COUNT,
|
||||
ret = nouveau_bufctx_new(nv50->base.client, NV50_BIND_3D_COUNT,
|
||||
&nv50->bufctx_3d);
|
||||
if (!ret)
|
||||
ret = nouveau_bufctx_new(screen->base.client, NV50_BIND_CP_COUNT,
|
||||
ret = nouveau_bufctx_new(nv50->base.client, NV50_BIND_CP_COUNT,
|
||||
&nv50->bufctx_cp);
|
||||
if (ret)
|
||||
goto out_err;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ nv50_hw_query_allocate(struct nv50_context *nv50, struct nv50_query *q,
|
|||
return false;
|
||||
hq->offset = hq->base_offset;
|
||||
|
||||
ret = nouveau_bo_map(hq->bo, 0, screen->base.client);
|
||||
ret = nouveau_bo_map(hq->bo, 0, nv50->base.client);
|
||||
if (ret) {
|
||||
nv50_hw_query_allocate(nv50, q, 0);
|
||||
return false;
|
||||
|
|
@ -294,7 +294,7 @@ nv50_hw_get_query_result(struct nv50_context *nv50, struct nv50_query *q,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->screen->base.client))
|
||||
if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->base.client))
|
||||
return false;
|
||||
}
|
||||
hq->state = NV50_HW_QUERY_STATE_READY;
|
||||
|
|
|
|||
|
|
@ -375,7 +375,6 @@ nv50_miptree_transfer_map(struct pipe_context *pctx,
|
|||
const struct pipe_box *box,
|
||||
struct pipe_transfer **ptransfer)
|
||||
{
|
||||
struct nv50_screen *screen = nv50_screen(pctx->screen);
|
||||
struct nv50_context *nv50 = nv50_context(pctx);
|
||||
struct nouveau_device *dev = nv50->screen->base.device;
|
||||
const struct nv50_miptree *mt = nv50_miptree(res);
|
||||
|
|
@ -454,7 +453,7 @@ nv50_miptree_transfer_map(struct pipe_context *pctx,
|
|||
if (usage & PIPE_MAP_WRITE)
|
||||
flags |= NOUVEAU_BO_WR;
|
||||
|
||||
ret = nouveau_bo_map(tx->rect[1].bo, flags, screen->base.client);
|
||||
ret = nouveau_bo_map(tx->rect[1].bo, flags, nv50->base.client);
|
||||
if (ret) {
|
||||
nouveau_bo_ref(NULL, &tx->rect[1].bo);
|
||||
FREE(tx);
|
||||
|
|
|
|||
|
|
@ -493,17 +493,17 @@ nv84_create_decoder(struct pipe_context *context,
|
|||
surf.offset = dec->vpring->size - 0x1000;
|
||||
context->clear_render_target(context, &surf.base, &color, 0, 0, 1024, 1, false);
|
||||
|
||||
PUSH_SPACE(screen->pushbuf, 5);
|
||||
PUSH_REFN(screen->pushbuf, dec->fence, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
|
||||
PUSH_SPACE(nv50->base.pushbuf, 5);
|
||||
PUSH_REFN(nv50->base.pushbuf, dec->fence, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
|
||||
/* The clear_render_target is done via 3D engine, so use it to write to a
|
||||
* sempahore to indicate that it's done.
|
||||
*/
|
||||
BEGIN_NV04(screen->pushbuf, NV50_3D(QUERY_ADDRESS_HIGH), 4);
|
||||
PUSH_DATAh(screen->pushbuf, dec->fence->offset);
|
||||
PUSH_DATA (screen->pushbuf, dec->fence->offset);
|
||||
PUSH_DATA (screen->pushbuf, 1);
|
||||
PUSH_DATA (screen->pushbuf, 0xf010);
|
||||
PUSH_KICK (screen->pushbuf);
|
||||
BEGIN_NV04(nv50->base.pushbuf, NV50_3D(QUERY_ADDRESS_HIGH), 4);
|
||||
PUSH_DATAh(nv50->base.pushbuf, dec->fence->offset);
|
||||
PUSH_DATA (nv50->base.pushbuf, dec->fence->offset);
|
||||
PUSH_DATA (nv50->base.pushbuf, 1);
|
||||
PUSH_DATA (nv50->base.pushbuf, 0xf010);
|
||||
PUSH_KICK (nv50->base.pushbuf);
|
||||
|
||||
PUSH_SPACE(bsp_push, 2 + 12 + 2 + 4 + 3);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ struct pipe_video_codec *
|
|||
nv98_create_decoder(struct pipe_context *context,
|
||||
const struct pipe_video_codec *templ)
|
||||
{
|
||||
struct nouveau_screen *screen = &((struct nv50_context *)context)->screen->base;
|
||||
struct nv50_context *nv50 = nv50_context(context);
|
||||
struct nouveau_screen *screen = &nv50->screen->base;
|
||||
struct nouveau_vp3_decoder *dec;
|
||||
struct nouveau_pushbuf **push;
|
||||
struct nv04_fifo nv04_data = {.vram = 0xbeef0201, .gart = 0xbeef0202};
|
||||
|
|
@ -106,7 +107,7 @@ nv98_create_decoder(struct pipe_context *context,
|
|||
dec = CALLOC_STRUCT(nouveau_vp3_decoder);
|
||||
if (!dec)
|
||||
return NULL;
|
||||
dec->client = screen->client;
|
||||
dec->client = nv50->base.client;
|
||||
dec->base = *templ;
|
||||
nouveau_vp3_decoder_init_common(&dec->base);
|
||||
|
||||
|
|
@ -119,7 +120,7 @@ nv98_create_decoder(struct pipe_context *context,
|
|||
&nv04_data, sizeof(nv04_data), &dec->channel[0]);
|
||||
|
||||
if (!ret)
|
||||
ret = nouveau_pushbuf_new(screen->client, dec->channel[0], 4,
|
||||
ret = nouveau_pushbuf_new(nv50->base.client, dec->channel[0], 4,
|
||||
32 * 1024, true, &dec->pushbuf[0]);
|
||||
|
||||
for (i = 1; i < 3; ++i) {
|
||||
|
|
|
|||
|
|
@ -428,12 +428,12 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
|
|||
nvc0->base.pushbuf = screen->base.pushbuf;
|
||||
nvc0->base.client = screen->base.client;
|
||||
|
||||
ret = nouveau_bufctx_new(screen->base.client, 2, &nvc0->bufctx);
|
||||
ret = nouveau_bufctx_new(nvc0->base.client, 2, &nvc0->bufctx);
|
||||
if (!ret)
|
||||
ret = nouveau_bufctx_new(screen->base.client, NVC0_BIND_3D_COUNT,
|
||||
ret = nouveau_bufctx_new(nvc0->base.client, NVC0_BIND_3D_COUNT,
|
||||
&nvc0->bufctx_3d);
|
||||
if (!ret)
|
||||
ret = nouveau_bufctx_new(screen->base.client, NVC0_BIND_CP_COUNT,
|
||||
ret = nouveau_bufctx_new(nvc0->base.client, NVC0_BIND_CP_COUNT,
|
||||
&nvc0->bufctx_cp);
|
||||
if (ret)
|
||||
goto out_err;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ nvc0_hw_query_allocate(struct nvc0_context *nvc0, struct nvc0_query *q,
|
|||
return false;
|
||||
hq->offset = hq->base_offset;
|
||||
|
||||
ret = nouveau_bo_map(hq->bo, 0, screen->base.client);
|
||||
ret = nouveau_bo_map(hq->bo, 0, nvc0->base.client);
|
||||
if (ret) {
|
||||
nvc0_hw_query_allocate(nvc0, q, 0);
|
||||
return false;
|
||||
|
|
@ -319,7 +319,7 @@ nvc0_hw_get_query_result(struct nvc0_context *nvc0, struct nvc0_query *q,
|
|||
return hq->funcs->get_query_result(nvc0, hq, wait, result);
|
||||
|
||||
if (hq->state != NVC0_HW_QUERY_STATE_READY)
|
||||
nvc0_hw_query_update(nvc0->screen->base.client, q);
|
||||
nvc0_hw_query_update(nvc0->base.client, q);
|
||||
|
||||
if (hq->state != NVC0_HW_QUERY_STATE_READY) {
|
||||
if (!wait) {
|
||||
|
|
@ -330,7 +330,7 @@ nvc0_hw_get_query_result(struct nvc0_context *nvc0, struct nvc0_query *q,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->screen->base.client))
|
||||
if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->base.client))
|
||||
return false;
|
||||
NOUVEAU_DRV_STAT(&nvc0->screen->base, query_sync_count, 1);
|
||||
}
|
||||
|
|
@ -403,7 +403,7 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0,
|
|||
if (index == -1) {
|
||||
/* TODO: Use a macro to write the availability of the query */
|
||||
if (hq->state != NVC0_HW_QUERY_STATE_READY)
|
||||
nvc0_hw_query_update(nvc0->screen->base.client, q);
|
||||
nvc0_hw_query_update(nvc0->base.client, q);
|
||||
uint32_t ready[2] = {hq->state == NVC0_HW_QUERY_STATE_READY};
|
||||
nvc0->base.push_cb(&nvc0->base, buf, offset,
|
||||
result_type >= PIPE_QUERY_TYPE_I64 ? 2 : 1,
|
||||
|
|
@ -430,7 +430,7 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0,
|
|||
* outputs the difference (no need to worry about 64-bit clamping).
|
||||
*/
|
||||
if (hq->state != NVC0_HW_QUERY_STATE_READY)
|
||||
nvc0_hw_query_update(nvc0->screen->base.client, q);
|
||||
nvc0_hw_query_update(nvc0->base.client, q);
|
||||
|
||||
if ((flags & PIPE_QUERY_WAIT) && hq->state != NVC0_HW_QUERY_STATE_READY)
|
||||
nvc0_hw_query_fifo_wait(nvc0, q);
|
||||
|
|
|
|||
|
|
@ -480,7 +480,7 @@ nvc0_miptree_transfer_map(struct pipe_context *pctx,
|
|||
if (usage & PIPE_MAP_WRITE)
|
||||
flags |= NOUVEAU_BO_WR;
|
||||
|
||||
ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client);
|
||||
ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->base.client);
|
||||
if (ret) {
|
||||
pipe_resource_reference(&tx->base.resource, NULL);
|
||||
nouveau_bo_ref(NULL, &tx->rect[1].bo);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ struct pipe_video_codec *
|
|||
nvc0_create_decoder(struct pipe_context *context,
|
||||
const struct pipe_video_codec *templ)
|
||||
{
|
||||
struct nouveau_screen *screen = &((struct nvc0_context *)context)->screen->base;
|
||||
struct nvc0_context *nvc0 = nvc0_context(context);
|
||||
struct nouveau_screen *screen = &nvc0->screen->base;
|
||||
struct nouveau_vp3_decoder *dec;
|
||||
struct nouveau_pushbuf **push;
|
||||
union nouveau_bo_config cfg;
|
||||
|
|
@ -116,7 +117,7 @@ nvc0_create_decoder(struct pipe_context *context,
|
|||
dec = CALLOC_STRUCT(nouveau_vp3_decoder);
|
||||
if (!dec)
|
||||
return NULL;
|
||||
dec->client = screen->client;
|
||||
dec->client = nvc0->base.client;
|
||||
dec->base = *templ;
|
||||
nouveau_vp3_decoder_init_common(&dec->base);
|
||||
|
||||
|
|
@ -160,7 +161,7 @@ nvc0_create_decoder(struct pipe_context *context,
|
|||
data, size, &dec->channel[i]);
|
||||
|
||||
if (!ret)
|
||||
ret = nouveau_pushbuf_new(screen->client, dec->channel[i], 4,
|
||||
ret = nouveau_pushbuf_new(nvc0->base.client, dec->channel[i], 4,
|
||||
32 * 1024, true, &dec->pushbuf[i]);
|
||||
if (ret)
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue