diff options
author | Christoph Bumiller <[email protected]> | 2012-05-16 20:52:41 +0200 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2012-05-17 15:24:58 +0200 |
commit | fcb28682101dfa127486373411043d5d97a0ff8f (patch) | |
tree | 178155b68e55c7d7278c70cff3569c985677d428 /src/gallium/drivers/nv50/nv50_state.c | |
parent | 07323a80a258372875e61f73a4f745374bea6bda (diff) |
nv50,nvc0: handle user constbufs without wrapping them in a resource
Diffstat (limited to 'src/gallium/drivers/nv50/nv50_state.c')
-rw-r--r-- | src/gallium/drivers/nv50/nv50_state.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 7f840e2b42e..eea3ffd5270 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -751,28 +751,36 @@ nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, { struct nv50_context *nv50 = nv50_context(pipe); struct pipe_resource *res = cb ? cb->buffer : NULL; + const unsigned s = nv50_context_shader_stage(shader); + const unsigned i = index; - if (cb && cb->user_buffer) { - res = nouveau_user_buffer_create(pipe->screen, cb->user_buffer, - cb->buffer_size, - PIPE_BIND_CONSTANT_BUFFER); - } - - pipe_resource_reference(&nv50->constbuf[shader][index], res); + if (shader == PIPE_SHADER_COMPUTE) + return; - nv50->constbuf_dirty[shader] |= 1 << index; - if (res) - nv50->constbuf_valid[shader] |= 1 << index; + if (nv50->constbuf[s][i].user) + nv50->constbuf[s][i].u.buf = NULL; else - nv50->constbuf_valid[shader] &= ~(1 << index); - - nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_CB(shader, index)); + if (nv50->constbuf[s][i].u.buf) + nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_CB(s, i)); + + pipe_resource_reference(&nv50->constbuf[s][i].u.buf, res); + + nv50->constbuf[s][i].user = (cb && cb->user_buffer) ? TRUE : FALSE; + if (nv50->constbuf[s][i].user) { + nv50->constbuf[s][i].u.data = cb->user_buffer; + nv50->constbuf[s][i].size = cb->buffer_size; + nv50->constbuf_valid[s] |= 1 << i; + } else + if (res) { + nv50->constbuf[s][i].offset = cb->buffer_offset; + nv50->constbuf[s][i].size = align(cb->buffer_size, 0x100); + nv50->constbuf_valid[s] |= 1 << i; + } else { + nv50->constbuf_valid[s] &= ~(1 << i); + } + nv50->constbuf_dirty[s] |= 1 << i; nv50->dirty |= NV50_NEW_CONSTBUF; - - if (cb && cb->user_buffer) { - pipe_resource_reference(&res, NULL); - } } /* ============================================================================= |