diff options
Diffstat (limited to 'src/gallium/drivers/nvc0/nvc0_shader_state.c')
-rw-r--r-- | src/gallium/drivers/nvc0/nvc0_shader_state.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/gallium/drivers/nvc0/nvc0_shader_state.c b/src/gallium/drivers/nvc0/nvc0_shader_state.c index 287160e0b2a..0a5581241d7 100644 --- a/src/gallium/drivers/nvc0/nvc0_shader_state.c +++ b/src/gallium/drivers/nvc0/nvc0_shader_state.c @@ -31,18 +31,37 @@ static INLINE void nvc0_program_update_context_state(struct nvc0_context *nvc0, struct nvc0_program *prog, int stage) { + struct nouveau_channel *chan = nvc0->screen->base.channel; + if (prog->hdr[1]) nvc0->state.tls_required |= 1 << stage; else nvc0->state.tls_required &= ~(1 << stage); + + if (prog->immd_size) { + const unsigned rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD; + + BEGIN_RING(chan, RING_3D(CB_SIZE), 3); + /* NOTE: may overlap code of a different shader */ + OUT_RING (chan, align(prog->immd_size, 0x100)); + OUT_RELOCh(chan, nvc0->screen->text, prog->immd_base, rl); + OUT_RELOCl(chan, nvc0->screen->text, prog->immd_base, rl); + BEGIN_RING(chan, RING_3D(CB_BIND(stage)), 1); + OUT_RING (chan, (14 << 4) | 1); + + nvc0->state.c14_bound |= 1 << stage; + } else + if (nvc0->state.c14_bound & (1 << stage)) { + BEGIN_RING(chan, RING_3D(CB_BIND(stage)), 1); + OUT_RING (chan, (14 << 4) | 0); + + nvc0->state.c14_bound &= ~(1 << stage); + } } -static boolean +static INLINE boolean nvc0_program_validate(struct nvc0_context *nvc0, struct nvc0_program *prog) { - int ret; - unsigned size; - if (prog->translated) return TRUE; @@ -50,25 +69,7 @@ nvc0_program_validate(struct nvc0_context *nvc0, struct nvc0_program *prog) if (!prog->translated) return FALSE; - size = align(prog->code_size + NVC0_SHADER_HEADER_SIZE, 0x100); - - ret = nouveau_resource_alloc(nvc0->screen->text_heap, size, prog, - &prog->res); - if (ret) - return FALSE; - - prog->code_base = prog->res->start; - - nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->text, prog->code_base, - NOUVEAU_BO_VRAM, NVC0_SHADER_HEADER_SIZE, prog->hdr); - nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->text, - prog->code_base + NVC0_SHADER_HEADER_SIZE, - NOUVEAU_BO_VRAM, prog->code_size, prog->code); - - BEGIN_RING(nvc0->screen->base.channel, RING_3D(MEM_BARRIER), 1); - OUT_RING (nvc0->screen->base.channel, 0x1111); - - return TRUE; + return nvc0_program_upload_code(nvc0, prog); } void |