gallium: add take_ownership param into set_constant_buffer to eliminate atomics
We often do this: pipe->set_constant_buffer(pipe, shader, slot, &cb); pipe_resource_reference(&cb->buffer, NULL); That results in atomic increment in set_constant_buffer followed by atomic decrement after set_constant_buffer. This new interface eliminates those atomics. For the case above, this should be used instead: pipe->set_constant_buffer(pipe, shader, slot, true, &cb); cb->buffer = NULL; // if cb is not a local variable, else do nothing AMD Zen benefits from this. The perf improvement is ~3% for Viewperf13/Catia. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
This commit is contained in:
parent
0aa63c31ca
commit
a51d4b10f1
|
@ -48,6 +48,8 @@ buffers, surfaces) are bound to the driver.
|
|||
type. index is used to indicate which buffer to set (some APIs may allow
|
||||
multiple ones to be set, and binding a specific one later, though drivers
|
||||
are mostly restricted to the first one right now).
|
||||
If take_ownership is true, the buffer reference is passed to the driver, so
|
||||
that the driver doesn't have to increment the reference count.
|
||||
|
||||
* ``set_inlinable_constants`` sets inlinable constants for constant buffer 0.
|
||||
|
||||
|
|
|
@ -346,16 +346,16 @@ void cso_destroy_context( struct cso_context *ctx )
|
|||
ctx->pipe->set_shader_images(ctx->pipe, sh, 0, maximg, NULL);
|
||||
}
|
||||
for (int i = 0; i < maxcb; i++) {
|
||||
ctx->pipe->set_constant_buffer(ctx->pipe, sh, i, NULL);
|
||||
ctx->pipe->set_constant_buffer(ctx->pipe, sh, i, false, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL );
|
||||
ctx->pipe->bind_fs_state( ctx->pipe, NULL );
|
||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, NULL);
|
||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
|
||||
ctx->pipe->bind_vs_state( ctx->pipe, NULL );
|
||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, NULL);
|
||||
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
|
||||
if (ctx->has_geometry_shader) {
|
||||
ctx->pipe->bind_gs_state(ctx->pipe, NULL);
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@ DD_IMM_STATE(polygon_stipple, const struct pipe_poly_stipple, *state, state)
|
|||
static void
|
||||
dd_context_set_constant_buffer(struct pipe_context *_pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *constant_buffer)
|
||||
{
|
||||
struct dd_context *dctx = dd_context(_pipe);
|
||||
|
@ -367,7 +368,7 @@ dd_context_set_constant_buffer(struct pipe_context *_pipe,
|
|||
|
||||
safe_memcpy(&dctx->draw_state.constant_buffers[shader][index],
|
||||
constant_buffer, sizeof(*constant_buffer));
|
||||
pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
|
||||
pipe->set_constant_buffer(pipe, shader, index, take_ownership, constant_buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -165,6 +165,7 @@ static void noop_set_framebuffer_state(struct pipe_context *ctx,
|
|||
|
||||
static void noop_set_constant_buffer(struct pipe_context *ctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -632,7 +632,7 @@ rbug_set_clip_state(struct pipe_context *_pipe,
|
|||
static void
|
||||
rbug_set_constant_buffer(struct pipe_context *_pipe,
|
||||
enum pipe_shader_type shader,
|
||||
uint index,
|
||||
uint index, bool take_ownership,
|
||||
const struct pipe_constant_buffer *_cb)
|
||||
{
|
||||
struct rbug_context *rb_pipe = rbug_context(_pipe);
|
||||
|
@ -648,7 +648,7 @@ rbug_set_constant_buffer(struct pipe_context *_pipe,
|
|||
mtx_lock(&rb_pipe->call_mutex);
|
||||
pipe->set_constant_buffer(pipe,
|
||||
shader,
|
||||
index,
|
||||
index, take_ownership,
|
||||
_cb ? &cb : NULL);
|
||||
mtx_unlock(&rb_pipe->call_mutex);
|
||||
}
|
||||
|
|
|
@ -749,6 +749,7 @@ trace_context_set_sample_mask(struct pipe_context *_pipe,
|
|||
static void
|
||||
trace_context_set_constant_buffer(struct pipe_context *_pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *constant_buffer)
|
||||
{
|
||||
struct trace_context *tr_ctx = trace_context(_pipe);
|
||||
|
@ -759,9 +760,10 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
|
|||
trace_dump_arg(ptr, pipe);
|
||||
trace_dump_arg(uint, shader);
|
||||
trace_dump_arg(uint, index);
|
||||
trace_dump_arg(bool, take_ownership);
|
||||
trace_dump_arg(constant_buffer, constant_buffer);
|
||||
|
||||
pipe->set_constant_buffer(pipe, shader, index, constant_buffer);
|
||||
pipe->set_constant_buffer(pipe, shader, index, take_ownership, constant_buffer);
|
||||
|
||||
trace_dump_call_end();
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
|
|||
hud->constants.translate[1] = (float) (yoffset * hud_scale);
|
||||
hud->constants.scale[0] = hud_scale;
|
||||
hud->constants.scale[1] = yscale * hud_scale;
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
|
||||
u_upload_data(hud->pipe->stream_uploader, 0,
|
||||
num_vertices * 2 * sizeof(float), 16, buffer,
|
||||
|
@ -540,7 +540,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
|
|||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1,
|
||||
&hud->font_sampler_view);
|
||||
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, 1, sampler_states);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
|
||||
/* draw accumulated vertices for background quads */
|
||||
cso_set_blend(cso, &hud->alpha_blend);
|
||||
|
@ -556,7 +556,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
|
|||
hud->constants.scale[0] = hud_scale;
|
||||
hud->constants.scale[1] = hud_scale;
|
||||
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
|
||||
cso_set_vertex_buffers(cso, 0, 1, &hud->bg.vbuf);
|
||||
cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->bg.num_vertices);
|
||||
|
@ -585,7 +585,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
|
|||
hud->constants.translate[1] = 0;
|
||||
hud->constants.scale[0] = hud_scale;
|
||||
hud->constants.scale[1] = hud_scale;
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
|
||||
if (hud->whitelines.num_vertices) {
|
||||
cso_set_vertex_buffers(cso, 0, 1, &hud->whitelines.vbuf);
|
||||
|
@ -606,7 +606,7 @@ done:
|
|||
cso_restore_state(cso);
|
||||
|
||||
/* Unbind resources that we have bound. */
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, NULL);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
|
||||
pipe->set_vertex_buffers(pipe, 0, 1, NULL);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, NULL);
|
||||
|
||||
|
|
|
@ -104,8 +104,8 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
|||
cb.user_buffer = constants;
|
||||
|
||||
struct pipe_context *pipe = ppq->p->pipe;
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &cb);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &cb);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &cb);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, false, &cb);
|
||||
|
||||
mstencil.stencil[0].enabled = 1;
|
||||
mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
|
||||
|
|
|
@ -188,8 +188,8 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
|||
|
||||
/* Unbind resources that we have bound. */
|
||||
struct pipe_context *pipe = ppq->p->pipe;
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, NULL);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, NULL);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
|
||||
pipe->set_vertex_buffers(pipe, 0, 1, NULL);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, NULL);
|
||||
|
||||
|
|
|
@ -798,8 +798,8 @@ void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter)
|
|||
struct pipe_context *pipe = blitter->pipe;
|
||||
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, blitter->cb_slot,
|
||||
&blitter->saved_fs_constant_buffer);
|
||||
pipe_resource_reference(&blitter->saved_fs_constant_buffer.buffer, NULL);
|
||||
true, &blitter->saved_fs_constant_buffer);
|
||||
blitter->saved_fs_constant_buffer.buffer = NULL;
|
||||
}
|
||||
|
||||
static void blitter_set_rectangle(struct blitter_context_priv *ctx,
|
||||
|
@ -2908,7 +2908,7 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
|
|||
.buffer_size = sizeof(mask),
|
||||
};
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, blitter->cb_slot,
|
||||
&cb);
|
||||
false, &cb);
|
||||
|
||||
pipe->bind_depth_stencil_alpha_state(pipe,
|
||||
get_stencil_blit_fallback_dsa(ctx, i));
|
||||
|
|
|
@ -108,7 +108,7 @@ void util_compute_blit(struct pipe_context *ctx, struct pipe_blit_info *blit_inf
|
|||
struct pipe_constant_buffer cb = {0};
|
||||
cb.buffer_size = sizeof(data);
|
||||
cb.user_buffer = data;
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, &cb);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, false, &cb);
|
||||
|
||||
struct pipe_image_view image = {0};
|
||||
image.resource = dst;
|
||||
|
@ -158,7 +158,7 @@ void util_compute_blit(struct pipe_context *ctx, struct pipe_blit_info *blit_inf
|
|||
ctx->memory_barrier(ctx, PIPE_BARRIER_ALL);
|
||||
|
||||
ctx->set_shader_images(ctx, PIPE_SHADER_COMPUTE, 0, 1, NULL);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, NULL);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, false, NULL);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 1, NULL);
|
||||
pipe_sampler_view_reference(&src_view, NULL);
|
||||
ctx->delete_sampler_state(ctx, sampler_state_p);
|
||||
|
|
|
@ -549,9 +549,9 @@ pipe_set_constant_buffer(struct pipe_context *pipe,
|
|||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = buf->width0;
|
||||
cb.user_buffer = NULL;
|
||||
pipe->set_constant_buffer(pipe, shader, index, &cb);
|
||||
pipe->set_constant_buffer(pipe, shader, index, false, &cb);
|
||||
} else {
|
||||
pipe->set_constant_buffer(pipe, shader, index, NULL);
|
||||
pipe->set_constant_buffer(pipe, shader, index, false, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -667,10 +667,16 @@ util_pipe_tex_to_tgsi_tex(enum pipe_texture_target pipe_tex_target,
|
|||
|
||||
static inline void
|
||||
util_copy_constant_buffer(struct pipe_constant_buffer *dst,
|
||||
const struct pipe_constant_buffer *src)
|
||||
const struct pipe_constant_buffer *src,
|
||||
bool take_ownership)
|
||||
{
|
||||
if (src) {
|
||||
pipe_resource_reference(&dst->buffer, src->buffer);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&dst->buffer, NULL);
|
||||
dst->buffer = src->buffer;
|
||||
} else {
|
||||
pipe_resource_reference(&dst->buffer, src->buffer);
|
||||
}
|
||||
dst->buffer_offset = src->buffer_offset;
|
||||
dst->buffer_size = src->buffer_size;
|
||||
dst->user_buffer = src->user_buffer;
|
||||
|
|
|
@ -774,16 +774,13 @@ tc_call_set_constant_buffer(struct pipe_context *pipe, union tc_payload *payload
|
|||
{
|
||||
struct tc_constant_buffer *p = (struct tc_constant_buffer *)payload;
|
||||
|
||||
pipe->set_constant_buffer(pipe,
|
||||
p->shader,
|
||||
p->index,
|
||||
&p->cb);
|
||||
pipe_resource_reference(&p->cb.buffer, NULL);
|
||||
pipe->set_constant_buffer(pipe, p->shader, p->index, true, &p->cb);
|
||||
}
|
||||
|
||||
static void
|
||||
tc_set_constant_buffer(struct pipe_context *_pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct threaded_context *tc = threaded_context(_pipe);
|
||||
|
@ -819,7 +816,11 @@ tc_set_constant_buffer(struct pipe_context *_pipe,
|
|||
p->index = index;
|
||||
|
||||
if (cb) {
|
||||
tc_set_resource_reference(&p->cb.buffer, cb->buffer);
|
||||
if (take_ownership)
|
||||
p->cb.buffer = cb->buffer;
|
||||
else
|
||||
tc_set_resource_reference(&p->cb.buffer, cb->buffer);
|
||||
|
||||
p->cb.user_buffer = NULL;
|
||||
p->cb.buffer_offset = cb->buffer_offset;
|
||||
p->cb.buffer_size = cb->buffer_size;
|
||||
|
|
|
@ -446,7 +446,7 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter,
|
|||
filter->pipe->clear_render_target(filter->pipe, dst, &clear_color,
|
||||
0, 0, dst->width, dst->height, false);
|
||||
filter->pipe->set_constant_buffer(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, &cb);
|
||||
0, false, &cb);
|
||||
filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state);
|
||||
filter->pipe->bind_blend_state(filter->pipe, filter->blend);
|
||||
filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
|
|
|
@ -733,7 +733,7 @@ draw_layers(struct vl_compositor *c,
|
|||
|
||||
/* Unbind. */
|
||||
c->pipe->set_shader_images(c->pipe, PIPE_SHADER_COMPUTE, 0, 1, NULL);
|
||||
c->pipe->set_constant_buffer(c->pipe, PIPE_SHADER_COMPUTE, 0, NULL);
|
||||
c->pipe->set_constant_buffer(c->pipe, PIPE_SHADER_COMPUTE, 0, false, NULL);
|
||||
c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
num_sampler_views, NULL);
|
||||
c->pipe->bind_compute_state(c->pipe, NULL);
|
||||
|
|
|
@ -1195,6 +1195,7 @@ d3d12_set_scissor_states(struct pipe_context *pctx,
|
|||
static void
|
||||
d3d12_set_constant_buffer(struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *buf)
|
||||
{
|
||||
struct d3d12_context *ctx = d3d12_context(pctx);
|
||||
|
@ -1207,8 +1208,14 @@ d3d12_set_constant_buffer(struct pipe_context *pctx,
|
|||
D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT,
|
||||
buf->user_buffer, &offset, &ctx->cbufs[shader][index].buffer);
|
||||
|
||||
} else
|
||||
pipe_resource_reference(&ctx->cbufs[shader][index].buffer, buffer);
|
||||
} else {
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&ctx->cbufs[shader][index].buffer, NULL);
|
||||
ctx->cbufs[shader][index].buffer = buffer;
|
||||
} else {
|
||||
pipe_resource_reference(&ctx->cbufs[shader][index].buffer, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ctx->cbufs[shader][index].buffer_offset = offset;
|
||||
|
|
|
@ -81,7 +81,7 @@ etna_set_sample_mask(struct pipe_context *pctx, unsigned sample_mask)
|
|||
|
||||
static void
|
||||
etna_set_constant_buffer(struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
enum pipe_shader_type shader, uint index, bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct etna_context *ctx = etna_context(pctx);
|
||||
|
@ -89,7 +89,7 @@ etna_set_constant_buffer(struct pipe_context *pctx,
|
|||
|
||||
assert(index < ETNA_MAX_CONST_BUF);
|
||||
|
||||
util_copy_constant_buffer(&so->cb[index], cb);
|
||||
util_copy_constant_buffer(&so->cb[index], cb, take_ownership);
|
||||
|
||||
/* Note that the gallium frontends can unbind constant buffers by
|
||||
* passing NULL here. */
|
||||
|
|
|
@ -195,7 +195,7 @@ fd_blitter_clear(struct pipe_context *pctx, unsigned buffers,
|
|||
.buffer_size = 16,
|
||||
.user_buffer = &color->ui,
|
||||
};
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 0, &cb);
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 0, false, &cb);
|
||||
|
||||
unsigned rs_idx = pfb->samples > 1 ? 1 : 0;
|
||||
if (!ctx->clear_rs_state[rs_idx]) {
|
||||
|
|
|
@ -97,12 +97,13 @@ fd_set_min_samples(struct pipe_context *pctx, unsigned min_samples)
|
|||
static void
|
||||
fd_set_constant_buffer(struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
struct fd_constbuf_stateobj *so = &ctx->constbuf[shader];
|
||||
|
||||
util_copy_constant_buffer(&so->cb[index], cb);
|
||||
util_copy_constant_buffer(&so->cb[index], cb, take_ownership);
|
||||
|
||||
/* Note that gallium frontends can unbind constant buffers by
|
||||
* passing NULL here.
|
||||
|
|
|
@ -676,6 +676,7 @@ static void i915_delete_vs_state(struct pipe_context *pipe, void *shader)
|
|||
|
||||
static void i915_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct i915_context *i915 = i915_context(pipe);
|
||||
|
@ -718,7 +719,12 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
|
|||
diff = i915->current.num_user_constants[shader] != 0;
|
||||
}
|
||||
|
||||
pipe_resource_reference(&i915->constants[shader], buf);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&i915->constants[shader], NULL);
|
||||
i915->constants[shader] = buf;
|
||||
} else {
|
||||
pipe_resource_reference(&i915->constants[shader], buf);
|
||||
}
|
||||
i915->current.num_user_constants[shader] = new_num;
|
||||
|
||||
if (diff)
|
||||
|
|
|
@ -3206,6 +3206,7 @@ iris_set_framebuffer_state(struct pipe_context *ctx,
|
|||
static void
|
||||
iris_set_constant_buffer(struct pipe_context *ctx,
|
||||
enum pipe_shader_type p_stage, unsigned index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *input)
|
||||
{
|
||||
struct iris_context *ice = (struct iris_context *) ctx;
|
||||
|
@ -3227,14 +3228,19 @@ iris_set_constant_buffer(struct pipe_context *ctx,
|
|||
|
||||
if (!cbuf->buffer) {
|
||||
/* Allocation was unsuccessful - just unbind */
|
||||
iris_set_constant_buffer(ctx, p_stage, index, NULL);
|
||||
iris_set_constant_buffer(ctx, p_stage, index, false, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(map);
|
||||
memcpy(map, input->user_buffer, input->buffer_size);
|
||||
} else if (input->buffer) {
|
||||
pipe_resource_reference(&cbuf->buffer, input->buffer);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&cbuf->buffer, NULL);
|
||||
cbuf->buffer = input->buffer;
|
||||
} else {
|
||||
pipe_resource_reference(&cbuf->buffer, input->buffer);
|
||||
}
|
||||
|
||||
cbuf->buffer_offset = input->buffer_offset;
|
||||
}
|
||||
|
|
|
@ -267,6 +267,7 @@ lima_set_clip_state(struct pipe_context *pctx,
|
|||
static void
|
||||
lima_set_constant_buffer(struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool pass_reference,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct lima_context *ctx = lima_context(pctx);
|
||||
|
|
|
@ -642,10 +642,10 @@ lp_setup_set_fs_constants(struct lp_setup_context *setup,
|
|||
assert(num <= ARRAY_SIZE(setup->constants));
|
||||
|
||||
for (i = 0; i < num; ++i) {
|
||||
util_copy_constant_buffer(&setup->constants[i].current, &buffers[i]);
|
||||
util_copy_constant_buffer(&setup->constants[i].current, &buffers[i], false);
|
||||
}
|
||||
for (; i < ARRAY_SIZE(setup->constants); i++) {
|
||||
util_copy_constant_buffer(&setup->constants[i].current, NULL);
|
||||
util_copy_constant_buffer(&setup->constants[i].current, NULL, false);
|
||||
}
|
||||
setup->dirty |= LP_SETUP_NEW_CONSTANTS;
|
||||
}
|
||||
|
|
|
@ -1057,10 +1057,10 @@ lp_csctx_set_cs_constants(struct lp_cs_context *csctx,
|
|||
assert(num <= ARRAY_SIZE(csctx->constants));
|
||||
|
||||
for (i = 0; i < num; ++i) {
|
||||
util_copy_constant_buffer(&csctx->constants[i].current, &buffers[i]);
|
||||
util_copy_constant_buffer(&csctx->constants[i].current, &buffers[i], false);
|
||||
}
|
||||
for (; i < ARRAY_SIZE(csctx->constants); i++) {
|
||||
util_copy_constant_buffer(&csctx->constants[i].current, NULL);
|
||||
util_copy_constant_buffer(&csctx->constants[i].current, NULL, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3786,6 +3786,7 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
|
|||
static void
|
||||
llvmpipe_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
|
@ -3795,7 +3796,8 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
|
|||
assert(index < ARRAY_SIZE(llvmpipe->constants[shader]));
|
||||
|
||||
/* note: reference counting */
|
||||
util_copy_constant_buffer(&llvmpipe->constants[shader][index], cb);
|
||||
util_copy_constant_buffer(&llvmpipe->constants[shader][index], cb,
|
||||
take_ownership);
|
||||
|
||||
if (constants) {
|
||||
if (!(constants->bind & PIPE_BIND_CONSTANT_BUFFER)) {
|
||||
|
|
|
@ -328,6 +328,7 @@ nv30_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask)
|
|||
static void
|
||||
nv30_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool pass_reference,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct nv30_context *nv30 = nv30_context(pipe);
|
||||
|
@ -345,12 +346,22 @@ nv30_set_constant_buffer(struct pipe_context *pipe,
|
|||
size = buf->width0 / (4 * sizeof(float));
|
||||
|
||||
if (shader == PIPE_SHADER_VERTEX) {
|
||||
pipe_resource_reference(&nv30->vertprog.constbuf, buf);
|
||||
if (pass_reference) {
|
||||
pipe_resource_reference(&nv30->vertprog.constbuf, NULL);
|
||||
nv30->vertprog.constbuf = buf;
|
||||
} else {
|
||||
pipe_resource_reference(&nv30->vertprog.constbuf, buf);
|
||||
}
|
||||
nv30->vertprog.constbuf_nr = size;
|
||||
nv30->dirty |= NV30_NEW_VERTCONST;
|
||||
} else
|
||||
if (shader == PIPE_SHADER_FRAGMENT) {
|
||||
pipe_resource_reference(&nv30->fragprog.constbuf, buf);
|
||||
if (pass_reference) {
|
||||
pipe_resource_reference(&nv30->fragprog.constbuf, NULL);
|
||||
nv30->fragprog.constbuf = buf;
|
||||
} else {
|
||||
pipe_resource_reference(&nv30->fragprog.constbuf, buf);
|
||||
}
|
||||
nv30->fragprog.constbuf_nr = size;
|
||||
nv30->dirty |= NV30_NEW_FRAGCONST;
|
||||
}
|
||||
|
|
|
@ -890,6 +890,7 @@ nv50_cp_state_bind(struct pipe_context *pipe, void *hwcso)
|
|||
static void
|
||||
nv50_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct nv50_context *nv50 = nv50_context(pipe);
|
||||
|
@ -908,7 +909,13 @@ nv50_set_constant_buffer(struct pipe_context *pipe,
|
|||
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);
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&nv50->constbuf[s][i].u.buf, NULL);
|
||||
nv50->constbuf[s][i].u.buf = res;
|
||||
} else {
|
||||
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) {
|
||||
|
|
|
@ -774,6 +774,7 @@ nvc0_cp_state_bind(struct pipe_context *pipe, void *hwcso)
|
|||
static void
|
||||
nvc0_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct nvc0_context *nvc0 = nvc0_context(pipe);
|
||||
|
@ -802,7 +803,13 @@ nvc0_set_constant_buffer(struct pipe_context *pipe,
|
|||
|
||||
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);
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&nvc0->constbuf[s][i].u.buf, NULL);
|
||||
nvc0->constbuf[s][i].u.buf = res;
|
||||
} else {
|
||||
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) {
|
||||
|
|
|
@ -128,7 +128,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
|
|||
};
|
||||
|
||||
if (info->input)
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, &ubuf);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, false, &ubuf);
|
||||
|
||||
/* Invoke according to the grid info */
|
||||
|
||||
|
|
|
@ -1018,13 +1018,13 @@ panfrost_set_vertex_buffers(
|
|||
static void
|
||||
panfrost_set_constant_buffer(
|
||||
struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
enum pipe_shader_type shader, uint index, bool take_ownership,
|
||||
const struct pipe_constant_buffer *buf)
|
||||
{
|
||||
struct panfrost_context *ctx = pan_context(pctx);
|
||||
struct panfrost_constant_buffer *pbuf = &ctx->constant_buffer[shader];
|
||||
|
||||
util_copy_constant_buffer(&pbuf->cb[index], buf);
|
||||
util_copy_constant_buffer(&pbuf->cb[index], buf, take_ownership);
|
||||
|
||||
unsigned mask = (1 << index);
|
||||
|
||||
|
|
|
@ -1966,6 +1966,7 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
|
|||
|
||||
static void r300_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct r300_context* r300 = r300_context(pipe);
|
||||
|
|
|
@ -193,7 +193,7 @@ static void evergreen_cs_set_constant_buffer(struct r600_context *rctx,
|
|||
cb.buffer = buffer;
|
||||
cb.user_buffer = NULL;
|
||||
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_COMPUTE, cb_index, &cb);
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_COMPUTE, cb_index, false, &cb);
|
||||
}
|
||||
|
||||
/* We need to define these R600 registers here, because we can't include
|
||||
|
|
|
@ -4525,11 +4525,11 @@ void evergreen_setup_tess_constants(struct r600_context *rctx, const struct pipe
|
|||
if (!rctx->tes_shader) {
|
||||
rctx->lds_alloc = 0;
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_VERTEX,
|
||||
R600_LDS_INFO_CONST_BUFFER, NULL);
|
||||
R600_LDS_INFO_CONST_BUFFER, false, NULL);
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_TESS_CTRL,
|
||||
R600_LDS_INFO_CONST_BUFFER, NULL);
|
||||
R600_LDS_INFO_CONST_BUFFER, false, NULL);
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_TESS_EVAL,
|
||||
R600_LDS_INFO_CONST_BUFFER, NULL);
|
||||
R600_LDS_INFO_CONST_BUFFER, false, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4589,12 +4589,11 @@ void evergreen_setup_tess_constants(struct r600_context *rctx, const struct pipe
|
|||
constbuf.buffer_size = 8 * 4;
|
||||
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_VERTEX,
|
||||
R600_LDS_INFO_CONST_BUFFER, &constbuf);
|
||||
R600_LDS_INFO_CONST_BUFFER, false, &constbuf);
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_TESS_CTRL,
|
||||
R600_LDS_INFO_CONST_BUFFER, &constbuf);
|
||||
R600_LDS_INFO_CONST_BUFFER, false, &constbuf);
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, PIPE_SHADER_TESS_EVAL,
|
||||
R600_LDS_INFO_CONST_BUFFER, &constbuf);
|
||||
pipe_resource_reference(&constbuf.buffer, NULL);
|
||||
R600_LDS_INFO_CONST_BUFFER, true, &constbuf);
|
||||
}
|
||||
|
||||
uint32_t evergreen_get_ls_hs_config(struct r600_context *rctx,
|
||||
|
|
|
@ -81,7 +81,7 @@ static void r600_destroy_context(struct pipe_context *context)
|
|||
if (rctx->append_fence)
|
||||
pipe_resource_reference((struct pipe_resource**)&rctx->append_fence, NULL);
|
||||
for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, sh, R600_BUFFER_INFO_CONST_BUFFER, NULL);
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, sh, R600_BUFFER_INFO_CONST_BUFFER, false, NULL);
|
||||
free(rctx->driver_consts[sh].constants);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ static void r600_destroy_context(struct pipe_context *context)
|
|||
|
||||
for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh)
|
||||
for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; ++i)
|
||||
rctx->b.b.set_constant_buffer(context, sh, i, NULL);
|
||||
rctx->b.b.set_constant_buffer(context, sh, i, false, NULL);
|
||||
|
||||
if (rctx->blitter) {
|
||||
util_blitter_destroy(rctx->blitter);
|
||||
|
|
|
@ -1591,10 +1591,7 @@ static void r600_restore_qbo_state(struct r600_common_context *rctx,
|
|||
struct r600_qbo_state *st)
|
||||
{
|
||||
rctx->b.bind_compute_state(&rctx->b, st->saved_compute);
|
||||
|
||||
rctx->b.set_constant_buffer(&rctx->b, PIPE_SHADER_COMPUTE, 0, &st->saved_const0);
|
||||
pipe_resource_reference(&st->saved_const0.buffer, NULL);
|
||||
|
||||
rctx->b.set_constant_buffer(&rctx->b, PIPE_SHADER_COMPUTE, 0, true, &st->saved_const0);
|
||||
rctx->b.set_shader_buffers(&rctx->b, PIPE_SHADER_COMPUTE, 0, 3, st->saved_ssbo, ~0);
|
||||
for (unsigned i = 0; i < 3; ++i)
|
||||
pipe_resource_reference(&st->saved_ssbo[i].buffer, NULL);
|
||||
|
@ -1727,7 +1724,7 @@ static void r600_query_hw_get_result_resource(struct r600_common_context *rctx,
|
|||
} else
|
||||
consts.buffer_offset = 0;
|
||||
|
||||
rctx->b.set_constant_buffer(&rctx->b, PIPE_SHADER_COMPUTE, 0, &constant_buffer);
|
||||
rctx->b.set_constant_buffer(&rctx->b, PIPE_SHADER_COMPUTE, 0, false, &constant_buffer);
|
||||
|
||||
rctx->b.set_shader_buffers(&rctx->b, PIPE_SHADER_COMPUTE, 0, 3, ssbo, ~0);
|
||||
|
||||
|
|
|
@ -1186,6 +1186,7 @@ void r600_constant_buffers_dirty(struct r600_context *rctx, struct r600_constbuf
|
|||
|
||||
static void r600_set_constant_buffer(struct pipe_context *ctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *input)
|
||||
{
|
||||
struct r600_context *rctx = (struct r600_context *)ctx;
|
||||
|
@ -1236,7 +1237,12 @@ static void r600_set_constant_buffer(struct pipe_context *ctx,
|
|||
} else {
|
||||
/* Setup the hw buffer. */
|
||||
cb->buffer_offset = input->buffer_offset;
|
||||
pipe_resource_reference(&cb->buffer, input->buffer);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&cb->buffer, NULL);
|
||||
cb->buffer = input->buffer;
|
||||
} else {
|
||||
pipe_resource_reference(&cb->buffer, input->buffer);
|
||||
}
|
||||
r600_context_add_resource_size(ctx, input->buffer);
|
||||
}
|
||||
|
||||
|
@ -1342,7 +1348,7 @@ void r600_update_driver_const_buffers(struct r600_context *rctx, bool compute_on
|
|||
cb.user_buffer = ptr;
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = size;
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, sh, R600_BUFFER_INFO_CONST_BUFFER, &cb);
|
||||
rctx->b.b.set_constant_buffer(&rctx->b.b, sh, R600_BUFFER_INFO_CONST_BUFFER, false, &cb);
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -1531,21 +1537,21 @@ static void update_gs_block_state(struct r600_context *rctx, unsigned enable)
|
|||
|
||||
if (enable) {
|
||||
r600_set_constant_buffer(&rctx->b.b, PIPE_SHADER_GEOMETRY,
|
||||
R600_GS_RING_CONST_BUFFER, &rctx->gs_rings.esgs_ring);
|
||||
R600_GS_RING_CONST_BUFFER, false, &rctx->gs_rings.esgs_ring);
|
||||
if (rctx->tes_shader) {
|
||||
r600_set_constant_buffer(&rctx->b.b, PIPE_SHADER_TESS_EVAL,
|
||||
R600_GS_RING_CONST_BUFFER, &rctx->gs_rings.gsvs_ring);
|
||||
R600_GS_RING_CONST_BUFFER, false, &rctx->gs_rings.gsvs_ring);
|
||||
} else {
|
||||
r600_set_constant_buffer(&rctx->b.b, PIPE_SHADER_VERTEX,
|
||||
R600_GS_RING_CONST_BUFFER, &rctx->gs_rings.gsvs_ring);
|
||||
R600_GS_RING_CONST_BUFFER, false, &rctx->gs_rings.gsvs_ring);
|
||||
}
|
||||
} else {
|
||||
r600_set_constant_buffer(&rctx->b.b, PIPE_SHADER_GEOMETRY,
|
||||
R600_GS_RING_CONST_BUFFER, NULL);
|
||||
R600_GS_RING_CONST_BUFFER, false, NULL);
|
||||
r600_set_constant_buffer(&rctx->b.b, PIPE_SHADER_VERTEX,
|
||||
R600_GS_RING_CONST_BUFFER, NULL);
|
||||
R600_GS_RING_CONST_BUFFER, false, NULL);
|
||||
r600_set_constant_buffer(&rctx->b.b, PIPE_SHADER_TESS_EVAL,
|
||||
R600_GS_RING_CONST_BUFFER, NULL);
|
||||
R600_GS_RING_CONST_BUFFER, false, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -388,7 +388,7 @@ static void gfx10_sh_query_get_result_resource(struct si_context *sctx, struct s
|
|||
ssbo[2].buffer_size = 8;
|
||||
}
|
||||
|
||||
sctx->b.set_constant_buffer(&sctx->b, PIPE_SHADER_COMPUTE, 0, &constant_buffer);
|
||||
sctx->b.set_constant_buffer(&sctx->b, PIPE_SHADER_COMPUTE, 0, false, &constant_buffer);
|
||||
sctx->b.set_shader_buffers(&sctx->b, PIPE_SHADER_COMPUTE, 0, 3, ssbo, 0x6);
|
||||
|
||||
if (wait) {
|
||||
|
|
|
@ -141,7 +141,7 @@ static void si_compute_clear_12bytes_buffer(struct si_context *sctx, struct pipe
|
|||
struct pipe_constant_buffer cb = {};
|
||||
cb.buffer_size = sizeof(data);
|
||||
cb.user_buffer = data;
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, &cb);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, false, &cb);
|
||||
|
||||
struct pipe_shader_buffer sb = {0};
|
||||
sb.buffer = dst;
|
||||
|
@ -166,10 +166,9 @@ static void si_compute_clear_12bytes_buffer(struct si_context *sctx, struct pipe
|
|||
si_launch_grid_internal(sctx, &info, saved_cs, SI_CS_WAIT_FOR_IDLE);
|
||||
|
||||
ctx->set_shader_buffers(ctx, PIPE_SHADER_COMPUTE, 0, 1, &saved_sb, saved_writable_mask);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, &saved_cb);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, true, &saved_cb);
|
||||
|
||||
pipe_resource_reference(&saved_sb.buffer, NULL);
|
||||
pipe_resource_reference(&saved_cb.buffer, NULL);
|
||||
}
|
||||
|
||||
static void si_compute_do_clear_or_copy(struct si_context *sctx, struct pipe_resource *dst,
|
||||
|
@ -506,7 +505,7 @@ void si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, u
|
|||
struct pipe_constant_buffer cb = {};
|
||||
cb.buffer_size = sizeof(data);
|
||||
cb.user_buffer = data;
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, &cb);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, false, &cb);
|
||||
}
|
||||
|
||||
struct pipe_image_view image[2] = {0};
|
||||
|
@ -608,8 +607,7 @@ void si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, u
|
|||
for (int i = 0; i < 2; i++)
|
||||
pipe_resource_reference(&saved_image[i].resource, NULL);
|
||||
if (!is_dcc_decompress) {
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, &saved_cb);
|
||||
pipe_resource_reference(&saved_cb.buffer, NULL);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, true, &saved_cb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -811,7 +809,7 @@ void si_compute_clear_render_target(struct pipe_context *ctx, struct pipe_surfac
|
|||
struct pipe_constant_buffer cb = {};
|
||||
cb.buffer_size = sizeof(data);
|
||||
cb.user_buffer = data;
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, &cb);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, false, &cb);
|
||||
|
||||
struct pipe_image_view image = {0};
|
||||
image.resource = dstsurf->texture;
|
||||
|
@ -855,7 +853,6 @@ void si_compute_clear_render_target(struct pipe_context *ctx, struct pipe_surfac
|
|||
(render_condition_enabled ? SI_CS_RENDER_COND_ENABLE : 0));
|
||||
|
||||
ctx->set_shader_images(ctx, PIPE_SHADER_COMPUTE, 0, 1, &saved_image);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, &saved_cb);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, true, &saved_cb);
|
||||
pipe_resource_reference(&saved_image.resource, NULL);
|
||||
pipe_resource_reference(&saved_cb.buffer, NULL);
|
||||
}
|
||||
|
|
|
@ -1093,7 +1093,7 @@ static void si_upload_const_buffer(struct si_context *sctx, struct si_resource *
|
|||
}
|
||||
|
||||
static void si_set_constant_buffer(struct si_context *sctx, struct si_buffer_resources *buffers,
|
||||
unsigned descriptors_idx, uint slot,
|
||||
unsigned descriptors_idx, uint slot, bool take_ownership,
|
||||
const struct pipe_constant_buffer *input)
|
||||
{
|
||||
struct si_descriptors *descs = &sctx->descriptors[descriptors_idx];
|
||||
|
@ -1116,11 +1116,16 @@ static void si_set_constant_buffer(struct si_context *sctx, struct si_buffer_res
|
|||
input->buffer_size, &buffer_offset);
|
||||
if (!buffer) {
|
||||
/* Just unbind on failure. */
|
||||
si_set_constant_buffer(sctx, buffers, descriptors_idx, slot, NULL);
|
||||
si_set_constant_buffer(sctx, buffers, descriptors_idx, slot, false, NULL);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
pipe_resource_reference(&buffer, input->buffer);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&buffer, NULL);
|
||||
buffer = input->buffer;
|
||||
} else {
|
||||
pipe_resource_reference(&buffer, input->buffer);
|
||||
}
|
||||
buffer_offset = input->buffer_offset;
|
||||
}
|
||||
|
||||
|
@ -1157,7 +1162,8 @@ static void si_set_constant_buffer(struct si_context *sctx, struct si_buffer_res
|
|||
}
|
||||
|
||||
static void si_pipe_set_constant_buffer(struct pipe_context *ctx, enum pipe_shader_type shader,
|
||||
uint slot, const struct pipe_constant_buffer *input)
|
||||
uint slot, bool take_ownership,
|
||||
const struct pipe_constant_buffer *input)
|
||||
{
|
||||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
|
||||
|
@ -1182,7 +1188,8 @@ static void si_pipe_set_constant_buffer(struct pipe_context *ctx, enum pipe_shad
|
|||
|
||||
slot = si_get_constbuf_slot(slot);
|
||||
si_set_constant_buffer(sctx, &sctx->const_and_shader_buffers[shader],
|
||||
si_const_and_shader_buffer_descriptors_idx(shader), slot, input);
|
||||
si_const_and_shader_buffer_descriptors_idx(shader), slot,
|
||||
take_ownership, input);
|
||||
}
|
||||
|
||||
static void si_set_inlinable_constants(struct pipe_context *ctx,
|
||||
|
@ -1303,7 +1310,7 @@ void si_get_shader_buffers(struct si_context *sctx, enum pipe_shader_type shader
|
|||
void si_set_internal_const_buffer(struct si_context *sctx, uint slot,
|
||||
const struct pipe_constant_buffer *input)
|
||||
{
|
||||
si_set_constant_buffer(sctx, &sctx->internal_bindings, SI_DESCS_INTERNAL, slot, input);
|
||||
si_set_constant_buffer(sctx, &sctx->internal_bindings, SI_DESCS_INTERNAL, slot, false, input);
|
||||
}
|
||||
|
||||
void si_set_internal_shader_buffer(struct si_context *sctx, uint slot,
|
||||
|
|
|
@ -652,7 +652,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
|
|||
unsigned start_shader = sctx->has_graphics ? 0 : PIPE_SHADER_COMPUTE;
|
||||
for (shader = start_shader; shader < SI_NUM_SHADERS; shader++) {
|
||||
for (i = 0; i < SI_NUM_CONST_BUFFERS; i++) {
|
||||
sctx->b.set_constant_buffer(&sctx->b, shader, i, &sctx->null_const_buf);
|
||||
sctx->b.set_constant_buffer(&sctx->b, shader, i, false, &sctx->null_const_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1544,7 +1544,7 @@ static void si_query_hw_get_result_resource(struct si_context *sctx, struct si_q
|
|||
params.start_offset += qbuf->results_end - query->result_size;
|
||||
}
|
||||
|
||||
sctx->b.set_constant_buffer(&sctx->b, PIPE_SHADER_COMPUTE, 0, &constant_buffer);
|
||||
sctx->b.set_constant_buffer(&sctx->b, PIPE_SHADER_COMPUTE, 0, false, &constant_buffer);
|
||||
|
||||
ssbo[0].buffer = &qbuf->buf->b.b;
|
||||
ssbo[0].buffer_offset = params.start_offset;
|
||||
|
|
|
@ -1327,8 +1327,7 @@ void si_restore_qbo_state(struct si_context *sctx, struct si_qbo_state *st)
|
|||
{
|
||||
sctx->b.bind_compute_state(&sctx->b, st->saved_compute);
|
||||
|
||||
sctx->b.set_constant_buffer(&sctx->b, PIPE_SHADER_COMPUTE, 0, &st->saved_const0);
|
||||
pipe_resource_reference(&st->saved_const0.buffer, NULL);
|
||||
sctx->b.set_constant_buffer(&sctx->b, PIPE_SHADER_COMPUTE, 0, true, &st->saved_const0);
|
||||
|
||||
sctx->b.set_shader_buffers(&sctx->b, PIPE_SHADER_COMPUTE, 0, 3, st->saved_ssbo,
|
||||
st->saved_ssbo_writable_mask);
|
||||
|
|
|
@ -373,6 +373,7 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
|
|||
static void
|
||||
softpipe_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct softpipe_context *softpipe = softpipe_context(pipe);
|
||||
|
@ -397,7 +398,12 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
|
|||
draw_flush(softpipe->draw);
|
||||
|
||||
/* note: reference counting */
|
||||
pipe_resource_reference(&softpipe->constants[shader][index], constants);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&softpipe->constants[shader][index], NULL);
|
||||
softpipe->constants[shader][index] = constants;
|
||||
} else {
|
||||
pipe_resource_reference(&softpipe->constants[shader][index], constants);
|
||||
}
|
||||
|
||||
if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) {
|
||||
draw_set_mapped_constant_buffer(softpipe->draw, shader, index, data, size);
|
||||
|
|
|
@ -44,6 +44,7 @@ struct svga_constbuf
|
|||
static void
|
||||
svga_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct svga_screen *svgascreen = svga_screen(pipe->screen);
|
||||
|
@ -66,7 +67,12 @@ svga_set_constant_buffer(struct pipe_context *pipe,
|
|||
assert(index < svgascreen->max_const_buffers);
|
||||
(void) svgascreen;
|
||||
|
||||
pipe_resource_reference(&svga->curr.constbufs[shader][index].buffer, buf);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&svga->curr.constbufs[shader][index].buffer, NULL);
|
||||
svga->curr.constbufs[shader][index].buffer = buf;
|
||||
} else {
|
||||
pipe_resource_reference(&svga->curr.constbufs[shader][index].buffer, buf);
|
||||
}
|
||||
|
||||
/* Make sure the constant buffer size to be updated is within the
|
||||
* limit supported by the device.
|
||||
|
|
|
@ -320,7 +320,7 @@ get_passthrough_tcs(struct svga_context *svga)
|
|||
cb.user_buffer = (void *) svga->curr.default_tesslevels;
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = 2 * 4 * sizeof(float);
|
||||
svga->pipe.set_constant_buffer(&svga->pipe, PIPE_SHADER_TESS_CTRL, 0, &cb);
|
||||
svga->pipe.set_constant_buffer(&svga->pipe, PIPE_SHADER_TESS_CTRL, 0, false, &cb);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ swr_delete_tes_state(struct pipe_context *pipe, void *tes)
|
|||
static void
|
||||
swr_set_constant_buffer(struct pipe_context *pipe,
|
||||
enum pipe_shader_type shader,
|
||||
uint index,
|
||||
uint index, bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct swr_context *ctx = swr_context(pipe);
|
||||
|
@ -556,7 +556,7 @@ swr_set_constant_buffer(struct pipe_context *pipe,
|
|||
assert(index < ARRAY_SIZE(ctx->constants[shader]));
|
||||
|
||||
/* note: reference counting */
|
||||
util_copy_constant_buffer(&ctx->constants[shader][index], cb);
|
||||
util_copy_constant_buffer(&ctx->constants[shader][index], cb, take_ownership);
|
||||
|
||||
if (shader == PIPE_SHADER_VERTEX) {
|
||||
ctx->dirty |= SWR_NEW_VSCONSTANTS;
|
||||
|
|
|
@ -479,7 +479,7 @@ tegra_set_clip_state(struct pipe_context *pcontext,
|
|||
|
||||
static void
|
||||
tegra_set_constant_buffer(struct pipe_context *pcontext, unsigned int shader,
|
||||
unsigned int index,
|
||||
unsigned int index, bool take_ownership,
|
||||
const struct pipe_constant_buffer *buf)
|
||||
{
|
||||
struct tegra_context *context = to_tegra_context(pcontext);
|
||||
|
@ -491,7 +491,7 @@ tegra_set_constant_buffer(struct pipe_context *pcontext, unsigned int shader,
|
|||
buf = &buffer;
|
||||
}
|
||||
|
||||
context->gpu->set_constant_buffer(context->gpu, shader, index, buf);
|
||||
context->gpu->set_constant_buffer(context->gpu, shader, index, take_ownership, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -446,12 +446,13 @@ v3d_vertex_state_bind(struct pipe_context *pctx, void *hwcso)
|
|||
|
||||
static void
|
||||
v3d_set_constant_buffer(struct pipe_context *pctx, uint shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct v3d_context *v3d = v3d_context(pctx);
|
||||
struct v3d_constbuf_stateobj *so = &v3d->constbuf[shader];
|
||||
|
||||
util_copy_constant_buffer(&so->cb[index], cb);
|
||||
util_copy_constant_buffer(&so->cb[index], cb, take_ownership);
|
||||
|
||||
/* Note that the gallium frontend can unbind constant buffers by
|
||||
* passing NULL here.
|
||||
|
|
|
@ -369,14 +369,14 @@ vc4_yuv_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
|
|||
.user_buffer = &stride,
|
||||
.buffer_size = sizeof(stride),
|
||||
};
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 0, &cb_uniforms);
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 0, false, &cb_uniforms);
|
||||
struct pipe_constant_buffer cb_src = {
|
||||
.buffer = info->src.resource,
|
||||
.buffer_offset = src->slices[info->src.level].offset,
|
||||
.buffer_size = (src->bo->size -
|
||||
src->slices[info->src.level].offset),
|
||||
};
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 1, &cb_src);
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 1, false, &cb_src);
|
||||
|
||||
/* Unbind the textures, to make sure we don't try to recurse into the
|
||||
* shadow blit.
|
||||
|
@ -392,7 +392,7 @@ vc4_yuv_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
|
|||
util_blitter_restore_constant_buffer_state(vc4->blitter);
|
||||
/* Restore cb1 (util_blitter doesn't handle this one). */
|
||||
struct pipe_constant_buffer cb_disabled = { 0 };
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 1, &cb_disabled);
|
||||
pctx->set_constant_buffer(pctx, PIPE_SHADER_FRAGMENT, 1, false, &cb_disabled);
|
||||
|
||||
pipe_surface_reference(&dst_surf, NULL);
|
||||
|
||||
|
|
|
@ -382,6 +382,7 @@ vc4_vertex_state_bind(struct pipe_context *pctx, void *hwcso)
|
|||
static void
|
||||
vc4_set_constant_buffer(struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct vc4_context *vc4 = vc4_context(pctx);
|
||||
|
@ -399,10 +400,7 @@ vc4_set_constant_buffer(struct pipe_context *pctx,
|
|||
if (index == 1 && so->cb[index].buffer_size != cb->buffer_size)
|
||||
vc4->dirty |= VC4_DIRTY_UBO_1_SIZE;
|
||||
|
||||
pipe_resource_reference(&so->cb[index].buffer, cb->buffer);
|
||||
so->cb[index].buffer_offset = cb->buffer_offset;
|
||||
so->cb[index].buffer_size = cb->buffer_size;
|
||||
so->cb[index].user_buffer = cb->user_buffer;
|
||||
util_copy_constant_buffer(&so->cb[index], cb, take_ownership);
|
||||
|
||||
so->enabled_mask |= 1 << index;
|
||||
so->dirty_mask |= 1 << index;
|
||||
|
|
|
@ -632,6 +632,7 @@ static void virgl_hw_set_index_buffer(struct virgl_context *vctx,
|
|||
|
||||
static void virgl_set_constant_buffer(struct pipe_context *ctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *buf)
|
||||
{
|
||||
struct virgl_context *vctx = virgl_context(ctx);
|
||||
|
@ -646,7 +647,12 @@ static void virgl_set_constant_buffer(struct pipe_context *ctx,
|
|||
buf->buffer_offset,
|
||||
buf->buffer_size, res);
|
||||
|
||||
pipe_resource_reference(&binding->ubos[index].buffer, buf->buffer);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&binding->ubos[index].buffer, NULL);
|
||||
binding->ubos[index].buffer = buf->buffer;
|
||||
} else {
|
||||
pipe_resource_reference(&binding->ubos[index].buffer, buf->buffer);
|
||||
}
|
||||
binding->ubos[index] = *buf;
|
||||
binding->ubo_enabled_mask |= 1 << index;
|
||||
} else {
|
||||
|
|
|
@ -552,6 +552,7 @@ zink_set_scissor_states(struct pipe_context *pctx,
|
|||
static void
|
||||
zink_set_constant_buffer(struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct zink_context *ctx = zink_context(pctx);
|
||||
|
@ -566,7 +567,12 @@ zink_set_constant_buffer(struct pipe_context *pctx,
|
|||
cb->user_buffer, &offset, &buffer);
|
||||
}
|
||||
|
||||
pipe_resource_reference(&ctx->ubos[shader][index].buffer, buffer);
|
||||
if (take_ownership) {
|
||||
pipe_resource_reference(&ctx->ubos[shader][index].buffer, NULL);
|
||||
ctx->ubos[shader][index].buffer = buffer;
|
||||
} else {
|
||||
pipe_resource_reference(&ctx->ubos[shader][index].buffer, buffer);
|
||||
}
|
||||
ctx->ubos[shader][index].buffer_offset = offset;
|
||||
ctx->ubos[shader][index].buffer_size = cb->buffer_size;
|
||||
ctx->ubos[shader][index].user_buffer = NULL;
|
||||
|
|
|
@ -142,14 +142,14 @@ static void emit_compute_state(struct rendering_state *state)
|
|||
|
||||
if (state->pcbuf_dirty[PIPE_SHADER_COMPUTE]) {
|
||||
state->pctx->set_constant_buffer(state->pctx, PIPE_SHADER_COMPUTE,
|
||||
0, &state->pc_buffer[PIPE_SHADER_COMPUTE]);
|
||||
0, false, &state->pc_buffer[PIPE_SHADER_COMPUTE]);
|
||||
state->pcbuf_dirty[PIPE_SHADER_COMPUTE] = false;
|
||||
}
|
||||
|
||||
if (state->constbuf_dirty[PIPE_SHADER_COMPUTE]) {
|
||||
for (unsigned i = 0; i < state->num_const_bufs[PIPE_SHADER_COMPUTE]; i++)
|
||||
state->pctx->set_constant_buffer(state->pctx, PIPE_SHADER_COMPUTE,
|
||||
i + 1, &state->const_buffer[PIPE_SHADER_COMPUTE][i]);
|
||||
i + 1, false, &state->const_buffer[PIPE_SHADER_COMPUTE][i]);
|
||||
state->constbuf_dirty[PIPE_SHADER_COMPUTE] = false;
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ static void emit_state(struct rendering_state *state)
|
|||
if (state->constbuf_dirty[sh]) {
|
||||
for (unsigned idx = 0; idx < state->num_const_bufs[sh]; idx++)
|
||||
state->pctx->set_constant_buffer(state->pctx, sh,
|
||||
idx + 1, &state->const_buffer[sh][idx]);
|
||||
idx + 1, false, &state->const_buffer[sh][idx]);
|
||||
}
|
||||
state->constbuf_dirty[sh] = false;
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ static void emit_state(struct rendering_state *state)
|
|||
for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
|
||||
if (state->pcbuf_dirty[sh]) {
|
||||
state->pctx->set_constant_buffer(state->pctx, sh,
|
||||
0, &state->pc_buffer[sh]);
|
||||
0, false, &state->pc_buffer[sh]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1109,15 +1109,15 @@ commit_vs_constants(struct NineDevice9 *device)
|
|||
struct pipe_context *pipe = context->pipe;
|
||||
|
||||
if (unlikely(!context->programmable_vs))
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb_vs_ff);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &context->pipe_data.cb_vs_ff);
|
||||
else {
|
||||
if (context->swvp) {
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb0_swvp);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 1, &context->pipe_data.cb1_swvp);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 2, &context->pipe_data.cb2_swvp);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 3, &context->pipe_data.cb3_swvp);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &context->pipe_data.cb0_swvp);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 1, false, &context->pipe_data.cb1_swvp);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 2, false, &context->pipe_data.cb2_swvp);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 3, false, &context->pipe_data.cb3_swvp);
|
||||
} else {
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb_vs);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &context->pipe_data.cb_vs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1129,9 +1129,9 @@ commit_ps_constants(struct NineDevice9 *device)
|
|||
struct pipe_context *pipe = context->pipe;
|
||||
|
||||
if (unlikely(!context->ps))
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &context->pipe_data.cb_ps_ff);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, false, &context->pipe_data.cb_ps_ff);
|
||||
else
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &context->pipe_data.cb_ps);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, false, &context->pipe_data.cb_ps);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -3145,13 +3145,13 @@ update_vs_constants_sw(struct NineDevice9 *device)
|
|||
|
||||
buf = cb.user_buffer;
|
||||
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 0, &cb);
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 0, false, &cb);
|
||||
if (cb.buffer)
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
|
||||
cb.user_buffer = (char *)buf + 4096 * sizeof(float[4]);
|
||||
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 1, &cb);
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 1, false, &cb);
|
||||
if (cb.buffer)
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
|
@ -3164,7 +3164,7 @@ update_vs_constants_sw(struct NineDevice9 *device)
|
|||
cb.buffer_size = 2048 * sizeof(float[4]);
|
||||
cb.user_buffer = state->vs_const_i;
|
||||
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 2, &cb);
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 2, false, &cb);
|
||||
if (cb.buffer)
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
|
@ -3177,7 +3177,7 @@ update_vs_constants_sw(struct NineDevice9 *device)
|
|||
cb.buffer_size = 512 * sizeof(float[4]);
|
||||
cb.user_buffer = state->vs_const_b;
|
||||
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 3, &cb);
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 3, false, &cb);
|
||||
if (cb.buffer)
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
|
@ -3208,7 +3208,7 @@ update_vs_constants_sw(struct NineDevice9 *device)
|
|||
cb.user_buffer = NULL;
|
||||
}
|
||||
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 4, &cb);
|
||||
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 4, false, &cb);
|
||||
if (cb.buffer)
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEF
|
|||
|
||||
cb.buffer_size = sizeof(constants);
|
||||
cb.user_buffer = constants;
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, &cb);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, false, &cb);
|
||||
|
||||
/* Use the optimal block size for the linear image layout. */
|
||||
struct pipe_grid_info info = {};
|
||||
|
@ -497,7 +497,7 @@ OMX_ERRORTYPE enc_LoadImage_common(vid_enc_PrivateType * priv, OMX_VIDEO_PORTDEF
|
|||
|
||||
/* Unbind. */
|
||||
pipe->set_shader_images(pipe, PIPE_SHADER_COMPUTE, 0, 3, NULL);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, NULL);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_COMPUTE, 0, false, NULL);
|
||||
pipe->bind_compute_state(pipe, NULL);
|
||||
} else {
|
||||
/* Graphics path */
|
||||
|
|
|
@ -358,8 +358,18 @@ struct pipe_context {
|
|||
void (*set_clip_state)( struct pipe_context *,
|
||||
const struct pipe_clip_state * );
|
||||
|
||||
/**
|
||||
* Set constant buffer
|
||||
*
|
||||
* \param shader Shader stage
|
||||
* \param index Buffer binding slot index within a shader stage
|
||||
* \param take_ownership The callee takes ownership of the buffer reference.
|
||||
* (the callee shouldn't increment the ref count)
|
||||
* \param buf Constant buffer parameters
|
||||
*/
|
||||
void (*set_constant_buffer)( struct pipe_context *,
|
||||
enum pipe_shader_type shader, uint index,
|
||||
bool take_ownership,
|
||||
const struct pipe_constant_buffer *buf );
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,7 +117,7 @@ static void init_fs_constbuf( void )
|
|||
cb1.user_buffer = constants1;
|
||||
|
||||
ctx->set_constant_buffer(ctx,
|
||||
PIPE_SHADER_FRAGMENT, 0,
|
||||
PIPE_SHADER_FRAGMENT, 0, false,
|
||||
&cb1);
|
||||
|
||||
memset(&cb2, 0, sizeof cb2);
|
||||
|
@ -125,7 +125,7 @@ static void init_fs_constbuf( void )
|
|||
cb2.user_buffer = constants2;
|
||||
|
||||
ctx->set_constant_buffer(ctx,
|
||||
PIPE_SHADER_FRAGMENT, 1,
|
||||
PIPE_SHADER_FRAGMENT, 1, false,
|
||||
&cb2);
|
||||
}
|
||||
|
||||
|
|
|
@ -122,8 +122,7 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
_mesa_upload_state_parameters(st->ctx, params, ptr);
|
||||
|
||||
u_upload_unmap(pipe->const_uploader);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, &cb);
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, true, &cb);
|
||||
|
||||
/* Set inlinable constants. This is more involved because state
|
||||
* parameters are uploaded directly above instead of being loaded
|
||||
|
@ -162,7 +161,7 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
if (params->StateFlags)
|
||||
_mesa_load_state_parameters(st->ctx, params);
|
||||
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, &cb);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, false, &cb);
|
||||
|
||||
/* Set inlinable constants. */
|
||||
unsigned num_inlinable_uniforms = prog->info.num_inlinable_uniforms;
|
||||
|
@ -184,7 +183,7 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
/* Unbind. */
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, NULL);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, false, NULL);
|
||||
st->state.constbuf0_enabled_shader_mask &= ~(1 << shader_type);
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +289,7 @@ st_bind_ubos(struct st_context *st, struct gl_program *prog,
|
|||
cb.buffer_size = 0;
|
||||
}
|
||||
|
||||
pipe->set_constant_buffer(pipe, shader_type, 1 + i, &cb);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 1 + i, false, &cb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
|
|||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = sizeof(addr->constants);
|
||||
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &cb);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, false, &cb);
|
||||
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue