static void nvc0_set_constant_buffer(struct pipe_context *pipe, enum pipe_shader_type shader, uint index, const struct pipe_constant_buffer *cb) { struct nvc0_context *nvc0 = nvc0_context(pipe); struct pipe_resource *res = cb ? cb->buffer : NULL; const unsigned s = nvc0_shader_stage(shader); const unsigned i = index; if (unlikely(shader == PIPE_SHADER_COMPUTE)) { if (nvc0->constbuf[s][i].user) nvc0->constbuf[s][i].u.buf = NULL; else if (nvc0->constbuf[s][i].u.buf) nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_CB(i)); nvc0->dirty_cp |= NVC0_NEW_CP_CONSTBUF; } else { if (nvc0->constbuf[s][i].user) nvc0->constbuf[s][i].u.buf = NULL; else if (nvc0->constbuf[s][i].u.buf) nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_CB(s, i)); nvc0->dirty_3d |= NVC0_NEW_3D_CONSTBUF; } nvc0->constbuf_dirty[s] |= 1 << i; if (nvc0->constbuf[s][i].u.buf) nv04_resource(nvc0->constbuf[s][i].u.buf)->cb_bindings[s] &= ~(1 << i); pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, res); nvc0->constbuf[s][i].user = (cb && cb->user_buffer) ? true : false; if (nvc0->constbuf[s][i].user) { nvc0->constbuf[s][i].u.data = cb->user_buffer; nvc0->constbuf[s][i].size = MIN2(cb->buffer_size, 0x10000); nvc0->constbuf_valid[s] |= 1 << i; nvc0->constbuf_coherent[s] &= ~(1 << i); } else if (cb) { nvc0->constbuf[s][i].offset = cb->buffer_offset; nvc0->constbuf[s][i].size = MIN2(align(cb->buffer_size, 0x100), 0x10000); nvc0->constbuf_valid[s] |= 1 << i; if (res && res->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) nvc0->constbuf_coherent[s] |= 1 << i; else nvc0->constbuf_coherent[s] &= ~(1 << i); } else { nvc0->constbuf_valid[s] &= ~(1 << i); nvc0->constbuf_coherent[s] &= ~(1 << i); } }
static void nvc0_set_shader_images(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned nr, struct pipe_image_view *images) { const unsigned s = nvc0_shader_stage(shader); if (!nvc0_bind_images_range(nvc0_context(pipe), s, start, nr, images)) return; if (s == 5) nvc0_context(pipe)->dirty_cp |= NVC0_NEW_CP_SURFACES; else nvc0_context(pipe)->dirty_3d |= NVC0_NEW_3D_SURFACES; }
static void nvc0_set_shader_buffers(struct pipe_context *pipe, unsigned shader, unsigned start, unsigned nr, struct pipe_shader_buffer *buffers) { const unsigned s = nvc0_shader_stage(shader); if (!nvc0_bind_buffers_range(nvc0_context(pipe), s, start, nr, buffers)) return; if (s == 5) nvc0_context(pipe)->dirty_cp |= NVC0_NEW_CP_BUFFERS; else nvc0_context(pipe)->dirty_3d |= NVC0_NEW_3D_BUFFERS; }
static void nvc0_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader, unsigned start, unsigned nr, struct pipe_sampler_view **views) { const unsigned s = nvc0_shader_stage(shader); assert(start == 0); nvc0_stage_set_sampler_views(nvc0_context(pipe), s, nr, views); if (s == 5) nvc0_context(pipe)->dirty_cp |= NVC0_NEW_CP_TEXTURES; else nvc0_context(pipe)->dirty_3d |= NVC0_NEW_3D_TEXTURES; }
static void nvc0_bind_sampler_states(struct pipe_context *pipe, enum pipe_shader_type shader, unsigned start, unsigned nr, void **samplers) { const unsigned s = nvc0_shader_stage(shader); assert(start == 0); nvc0_stage_sampler_states_bind(nvc0_context(pipe), s, nr, samplers); if (s == 5) nvc0_context(pipe)->dirty_cp |= NVC0_NEW_CP_SAMPLERS; else nvc0_context(pipe)->dirty_3d |= NVC0_NEW_3D_SAMPLERS; }
static void nvc0_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, struct pipe_constant_buffer *cb) { struct nvc0_context *nvc0 = nvc0_context(pipe); struct pipe_resource *res = cb ? cb->buffer : NULL; const unsigned s = nvc0_shader_stage(shader); const unsigned i = index; if (unlikely(shader == PIPE_SHADER_COMPUTE)) { assert(!cb || !cb->user_buffer); if (nvc0->constbuf[s][i].u.buf) nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_CB(i)); nvc0->dirty_cp |= NVC0_NEW_CP_CONSTBUF; } else { if (nvc0->constbuf[s][i].user) nvc0->constbuf[s][i].u.buf = NULL; else if (nvc0->constbuf[s][i].u.buf) nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_CB(s, i)); nvc0->dirty |= NVC0_NEW_CONSTBUF; } nvc0->constbuf_dirty[s] |= 1 << i; pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, res); nvc0->constbuf[s][i].user = (cb && cb->user_buffer) ? true : false; if (nvc0->constbuf[s][i].user) { nvc0->constbuf[s][i].u.data = cb->user_buffer; nvc0->constbuf[s][i].size = MIN2(cb->buffer_size, 0x10000); nvc0->constbuf_valid[s] |= 1 << i; } else if (cb) { nvc0->constbuf[s][i].offset = cb->buffer_offset; nvc0->constbuf[s][i].size = MIN2(align(cb->buffer_size, 0x100), 0x10000); nvc0->constbuf_valid[s] |= 1 << i; } else { nvc0->constbuf_valid[s] &= ~(1 << i); } }