From a9b70a86db9fe948ca7ce40aad4831408b1377ef Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 11 Jan 2016 22:11:19 +0100 Subject: [PATCH] nvc0: bind driver constbuf for compute on Fermi Changes from v3: - add new validation state for COMPUTE driver constbuf Changes from v2: - always bind the driver consts even if user params come in via clover Signed-off-by: Samuel Pitoiset Reviewed-by: Ilia Mirkin --- .../drivers/nouveau/nvc0/nvc0_compute.c | 18 ++++++++++++++++++ .../drivers/nouveau/nvc0/nvc0_context.c | 6 ++++++ .../drivers/nouveau/nvc0/nvc0_context.h | 1 + .../drivers/nouveau/nvc0/nvc0_program.c | 2 ++ .../drivers/nouveau/nvc0/nvc0_state_validate.c | 2 ++ 5 files changed, 29 insertions(+) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c index 0fe6353b2ab..2314c5386ca 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c @@ -196,6 +196,22 @@ nvc0_compute_validate_constbufs(struct nvc0_context *nvc0) PUSH_DATA (push, NVC0_COMPUTE_FLUSH_CB); } +static void +nvc0_compute_validate_driverconst(struct nvc0_context *nvc0) +{ + struct nouveau_pushbuf *push = nvc0->base.pushbuf; + struct nvc0_screen *screen = nvc0->screen; + + BEGIN_NVC0(push, NVC0_COMPUTE(CB_SIZE), 3); + PUSH_DATA (push, 1024); + PUSH_DATAh(push, screen->uniform_bo->offset + (6 << 16) + (5 << 10)); + PUSH_DATA (push, screen->uniform_bo->offset + (6 << 16) + (5 << 10)); + BEGIN_NVC0(push, NVC0_COMPUTE(CB_BIND), 1); + PUSH_DATA (push, (15 << 8) | 1); + + nvc0->dirty |= NVC0_NEW_DRIVERCONST; +} + static bool nvc0_compute_state_validate(struct nvc0_context *nvc0) { @@ -203,6 +219,8 @@ nvc0_compute_state_validate(struct nvc0_context *nvc0) return false; if (nvc0->dirty_cp & NVC0_NEW_CP_CONSTBUF) nvc0_compute_validate_constbufs(nvc0); + if (nvc0->dirty_cp & NVC0_NEW_CP_DRIVERCONST) + nvc0_compute_validate_driverconst(nvc0); /* TODO: textures, samplers, surfaces, global memory buffers */ diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c index 4fed7b24a76..3d2ed75e03a 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c @@ -349,6 +349,11 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) /* set the empty tctl prog on next draw in case one is never set */ nvc0->dirty |= NVC0_NEW_TCTLPROG; + /* Do not bind the COMPUTE driver constbuf at screen initialization because + * CBs are aliased between 3D and COMPUTE, but make sure it will be bound if + * a grid is launched later. */ + nvc0->dirty_cp |= NVC0_NEW_CP_DRIVERCONST; + /* now that there are no more opportunities for errors, set the current * context if there isn't already one. */ @@ -368,6 +373,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags) BCTX_REFN_bo(nvc0->bufctx_3d, SCREEN, flags, screen->txc); if (screen->compute) { BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->text); + BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->uniform_bo); BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->txc); BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->parm); } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h index d8dc48b1f0d..86116a07f85 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.h @@ -65,6 +65,7 @@ #define NVC0_NEW_CP_SAMPLERS (1 << 3) #define NVC0_NEW_CP_CONSTBUF (1 << 4) #define NVC0_NEW_CP_GLOBALS (1 << 5) +#define NVC0_NEW_CP_DRIVERCONST (1 << 6) /* 3d bufctx (during draw_vbo, blit_3d) */ #define NVC0_BIND_FB 0 diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c index 93f211bd5fc..afcff537147 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c @@ -544,6 +544,8 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t chipset, info->io.texBindBase = NVE4_CP_INPUT_TEX(0); info->io.suInfoBase = NVE4_CP_INPUT_SUF(0); info->prop.cp.gridInfoBase = NVE4_CP_INPUT_GRID_INFO(0); + } else { + info->io.resInfoCBSlot = 15; } info->io.msInfoCBSlot = 0; info->io.msInfoBase = NVE4_CP_INPUT_MS_OFFSETS; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c index 86557d73cb2..e2a4e4220d1 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c @@ -555,6 +555,8 @@ nvc0_validate_driverconst(struct nvc0_context *nvc0) BEGIN_NVC0(push, NVC0_3D(CB_BIND(i)), 1); PUSH_DATA (push, (15 << 4) | 1); } + + nvc0->dirty_cp |= NVC0_NEW_CP_DRIVERCONST; } void -- 2.30.2