static void nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *cb) { 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 (shader == PIPE_SHADER_COMPUTE) return; assert(i < NV50_MAX_PIPE_CONSTBUFS); if (nv50->constbuf[s][i].user) nv50->constbuf[s][i].u.buf = NULL; else if (nv50->constbuf[s][i].u.buf) { nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_3D_CB(s, i)); nv04_resource(nv50->constbuf[s][i].u.buf)->cb_bindings[s] &= ~(1 << 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 = MIN2(cb->buffer_size, 0x10000); nv50->constbuf_valid[s] |= 1 << i; nv50->constbuf_coherent[s] &= ~(1 << i); } else if (res) { nv50->constbuf[s][i].offset = cb->buffer_offset; nv50->constbuf[s][i].size = MIN2(align(cb->buffer_size, 0x100), 0x10000); nv50->constbuf_valid[s] |= 1 << i; if (res->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) nv50->constbuf_coherent[s] |= 1 << i; else nv50->constbuf_coherent[s] &= ~(1 << i); } else { nv50->constbuf_valid[s] &= ~(1 << i); nv50->constbuf_coherent[s] &= ~(1 << i); } nv50->constbuf_dirty[s] |= 1 << i; nv50->dirty_3d |= NV50_NEW_3D_CONSTBUF; }
static void nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, struct pipe_constant_buffer *cb) { 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 (shader == PIPE_SHADER_COMPUTE) return; assert(i < NV50_MAX_PIPE_CONSTBUFS); if (nv50->constbuf[s][i].user) nv50->constbuf[s][i].u.buf = NULL; else if (nv50->constbuf[s][i].u.buf) { nv04_resource(nv50->constbuf[s][i].u.buf)->cb_slot = -1; 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; }