mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 20:20:18 +01:00
gallium: eliminate frontend refcounting from samplerviews
A significant CPU performance bottleneck in mesa GL is refcounting atomics: even with the current pinning attempts, eliminating them can yield huge performance gains (easily verified by running drawoverhead with return false at the top of pipe_reference_described()). This is a proof of concept for removing refcounts from gallium objects, namely sampler views and resources. Sampler views were smaller in scope, so I started there. This MR alone is not expected to noticeably affect performance, though if applied to all drivers/frontends, it would enable a bunch of code deletion for crazy samplerview refcounting hacks currently used to try circumventing the existing overhead. Co-authored-by: Karol Herbst <kherbst@redhat.com Co-authored-by: David Rosca <david.rosca@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33813>
This commit is contained in:
parent
f47da0caef
commit
73da0dcddc
103 changed files with 425 additions and 541 deletions
|
|
@ -402,7 +402,7 @@ cso_unbind_context(struct cso_context *cso)
|
|||
ctx->base.pipe->bind_sampler_states(ctx->base.pipe, sh, 0, maxsam, zeros);
|
||||
}
|
||||
if (maxview > 0) {
|
||||
ctx->base.pipe->set_sampler_views(ctx->base.pipe, sh, 0, maxview, 0, false, views);
|
||||
ctx->base.pipe->set_sampler_views(ctx->base.pipe, sh, 0, maxview, 0, views);
|
||||
}
|
||||
if (maxssbo > 0) {
|
||||
ctx->base.pipe->set_shader_buffers(ctx->base.pipe, sh, 0, maxssbo, ssbos, 0);
|
||||
|
|
@ -1727,10 +1727,10 @@ cso_restore_state(struct cso_context *ctx, unsigned unbind)
|
|||
cso_restore_vertex_shader(cso);
|
||||
if (unbind & CSO_UNBIND_FS_SAMPLERVIEWS)
|
||||
cso->base.pipe->set_sampler_views(cso->base.pipe, PIPE_SHADER_FRAGMENT, 0, 0,
|
||||
cso->max_fs_samplerviews, false, NULL);
|
||||
cso->max_fs_samplerviews, NULL);
|
||||
if (unbind & CSO_UNBIND_FS_SAMPLERVIEW0)
|
||||
cso->base.pipe->set_sampler_views(cso->base.pipe, PIPE_SHADER_FRAGMENT, 0, 0,
|
||||
1, false, NULL);
|
||||
1, NULL);
|
||||
if (state_mask & CSO_BIT_FRAGMENT_SAMPLERS)
|
||||
cso_restore_fragment_samplers(cso);
|
||||
if (unbind & CSO_UNBIND_FS_IMAGE0)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ struct pstip_stage
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **);
|
||||
|
||||
void (*driver_set_polygon_stipple)(struct pipe_context *,
|
||||
|
|
@ -215,8 +214,7 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
|
|||
|
||||
/* plug in our sampler, texture */
|
||||
pstip->state.samplers[pstip->fs->sampler_unit] = pstip->sampler_cso;
|
||||
pipe_sampler_view_reference(&pstip->state.sampler_views[pstip->fs->sampler_unit],
|
||||
pstip->sampler_view);
|
||||
pstip->state.sampler_views[pstip->fs->sampler_unit] = pstip->sampler_view;
|
||||
|
||||
assert(num_samplers <= PIPE_MAX_SAMPLERS);
|
||||
|
||||
|
|
@ -226,7 +224,7 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
|
|||
num_samplers, pstip->state.samplers);
|
||||
|
||||
pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
num_sampler_views, 0, false,
|
||||
num_sampler_views, 0,
|
||||
pstip->state.sampler_views);
|
||||
|
||||
draw->suspend_flushing = false;
|
||||
|
|
@ -256,7 +254,7 @@ pstip_flush(struct draw_stage *stage, unsigned flags)
|
|||
pstip->state.samplers);
|
||||
|
||||
pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
pstip->num_sampler_views, 0, false,
|
||||
pstip->num_sampler_views, 0,
|
||||
pstip->state.sampler_views);
|
||||
|
||||
draw->suspend_flushing = false;
|
||||
|
|
@ -283,9 +281,7 @@ pstip_destroy(struct draw_stage *stage)
|
|||
|
||||
pipe_resource_reference(&pstip->texture, NULL);
|
||||
|
||||
if (pstip->sampler_view) {
|
||||
pipe_sampler_view_reference(&pstip->sampler_view, NULL);
|
||||
}
|
||||
pipe_sampler_view_release_ptr(&pstip->sampler_view);
|
||||
|
||||
draw_free_temp_verts(stage);
|
||||
FREE(stage);
|
||||
|
|
@ -419,7 +415,6 @@ pstip_set_sampler_views(struct pipe_context *pipe,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned num,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
|
||||
|
|
@ -428,19 +423,17 @@ pstip_set_sampler_views(struct pipe_context *pipe,
|
|||
/* save current */
|
||||
unsigned i;
|
||||
for (i = 0; i < num; i++) {
|
||||
pipe_sampler_view_reference(&pstip->state.sampler_views[start + i],
|
||||
views[i]);
|
||||
pstip->state.sampler_views[start + i] = views[i];
|
||||
}
|
||||
for (; i < num + unbind_num_trailing_slots; i++) {
|
||||
pipe_sampler_view_reference(&pstip->state.sampler_views[start + i],
|
||||
NULL);
|
||||
pstip->state.sampler_views[start + i] = NULL;
|
||||
}
|
||||
pstip->num_sampler_views = num;
|
||||
}
|
||||
|
||||
/* pass-through */
|
||||
pstip->driver_set_sampler_views(pstip->pipe, shader, start, num,
|
||||
unbind_num_trailing_slots, take_ownership, views);
|
||||
unbind_num_trailing_slots, views);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -484,6 +484,15 @@ dd_context_sampler_view_destroy(struct pipe_context *_pipe,
|
|||
pipe->sampler_view_destroy(pipe, view);
|
||||
}
|
||||
|
||||
static void
|
||||
dd_context_sampler_view_release(struct pipe_context *_pipe,
|
||||
struct pipe_sampler_view *view)
|
||||
{
|
||||
struct pipe_context *pipe = dd_context(_pipe)->pipe;
|
||||
|
||||
pipe->sampler_view_release(pipe, view);
|
||||
}
|
||||
|
||||
static struct pipe_stream_output_target *
|
||||
dd_context_create_stream_output_target(struct pipe_context *_pipe,
|
||||
struct pipe_resource *res,
|
||||
|
|
@ -520,7 +529,6 @@ dd_context_set_sampler_views(struct pipe_context *_pipe,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned num,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct dd_context *dctx = dd_context(_pipe);
|
||||
|
|
@ -530,7 +538,7 @@ dd_context_set_sampler_views(struct pipe_context *_pipe,
|
|||
sizeof(views[0]) * num);
|
||||
safe_memcpy(&dctx->draw_state.sampler_views[shader][start + num], NULL,
|
||||
sizeof(views[0]) * unbind_num_trailing_slots);
|
||||
pipe->set_sampler_views(pipe, shader, start, num, take_ownership,
|
||||
pipe->set_sampler_views(pipe, shader, start, num,
|
||||
unbind_num_trailing_slots, views);
|
||||
}
|
||||
|
||||
|
|
@ -935,6 +943,7 @@ dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
|
|||
CTX_INIT(fence_server_sync);
|
||||
CTX_INIT(create_sampler_view);
|
||||
CTX_INIT(sampler_view_destroy);
|
||||
CTX_INIT(sampler_view_release);
|
||||
CTX_INIT(create_surface);
|
||||
CTX_INIT(surface_destroy);
|
||||
CTX_INIT(texture_barrier);
|
||||
|
|
|
|||
|
|
@ -125,15 +125,8 @@ static void noop_set_sampler_views(struct pipe_context *ctx,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
if (take_ownership && views) {
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
struct pipe_sampler_view *view = views[i];
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void noop_bind_sampler_states(struct pipe_context *ctx,
|
||||
|
|
@ -207,6 +200,13 @@ static void noop_sampler_view_destroy(struct pipe_context *ctx,
|
|||
}
|
||||
|
||||
|
||||
static void noop_sampler_view_release(struct pipe_context *ctx,
|
||||
struct pipe_sampler_view *state)
|
||||
{
|
||||
noop_sampler_view_destroy(ctx, state);
|
||||
}
|
||||
|
||||
|
||||
static void noop_surface_destroy(struct pipe_context *ctx,
|
||||
struct pipe_surface *surface)
|
||||
{
|
||||
|
|
@ -481,6 +481,7 @@ void noop_init_state_functions(struct pipe_context *ctx)
|
|||
ctx->set_viewport_states = noop_set_viewport_states;
|
||||
ctx->set_window_rectangles = noop_set_window_rectangles;
|
||||
ctx->sampler_view_destroy = noop_sampler_view_destroy;
|
||||
ctx->sampler_view_release = noop_sampler_view_release;
|
||||
ctx->surface_destroy = noop_surface_destroy;
|
||||
ctx->draw_vbo = noop_draw_vbo;
|
||||
ctx->draw_vertex_state = noop_draw_vertex_state;
|
||||
|
|
|
|||
|
|
@ -1135,20 +1135,27 @@ trace_context_create_sampler_view(struct pipe_context *_pipe,
|
|||
static void
|
||||
trace_context_sampler_view_destroy(struct pipe_context *_pipe,
|
||||
struct pipe_sampler_view *_view)
|
||||
{
|
||||
unreachable("Trace should never hit this!");
|
||||
}
|
||||
|
||||
static void
|
||||
trace_context_sampler_view_release(struct pipe_context *_pipe,
|
||||
struct pipe_sampler_view *_view)
|
||||
{
|
||||
struct trace_context *tr_ctx = trace_context(_pipe);
|
||||
struct trace_sampler_view *tr_view = trace_sampler_view(_view);
|
||||
struct pipe_context *pipe = tr_ctx->pipe;
|
||||
struct pipe_sampler_view *view = tr_view->sampler_view;
|
||||
|
||||
trace_dump_call_begin("pipe_context", "sampler_view_destroy");
|
||||
trace_dump_call_begin("pipe_context", "sampler_view_release");
|
||||
|
||||
trace_dump_arg(ptr, pipe);
|
||||
trace_dump_arg(ptr, view);
|
||||
|
||||
trace_sampler_view_destroy(tr_view);
|
||||
|
||||
trace_dump_call_end();
|
||||
|
||||
trace_sampler_view_destroy(tr_view);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
|
@ -1213,7 +1220,6 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
|
|||
unsigned start,
|
||||
unsigned num,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct trace_context *tr_ctx = trace_context(_pipe);
|
||||
|
|
@ -1234,7 +1240,7 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
|
|||
}
|
||||
views = unwrapped_views;
|
||||
pipe->set_sampler_views(pipe, shader, start, num,
|
||||
unbind_num_trailing_slots, take_ownership, views);
|
||||
unbind_num_trailing_slots, views);
|
||||
|
||||
trace_dump_call_begin("pipe_context", "set_sampler_views");
|
||||
|
||||
|
|
@ -1244,7 +1250,6 @@ trace_context_set_sampler_views(struct pipe_context *_pipe,
|
|||
start = 0;
|
||||
trace_dump_arg(uint, start);
|
||||
trace_dump_arg(uint, unbind_num_trailing_slots);
|
||||
trace_dump_arg(bool, take_ownership);
|
||||
if (found)
|
||||
trace_dump_arg_array(ptr, views, num);
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -116,10 +116,6 @@ trace_transfer_destroy(struct trace_context *tr_context,
|
|||
FREE(tr_trans);
|
||||
}
|
||||
|
||||
/* Arbitrarily large refcount to "avoid having the driver bypass the samplerview wrapper and destroying
|
||||
the samplerview prematurely" see 7f5a3530125 ("aux/trace: use private refcounts for samplerviews") */
|
||||
#define SAMPLER_VIEW_PRIVATE_REFCOUNT 100000000
|
||||
|
||||
struct pipe_sampler_view *
|
||||
trace_sampler_view_create(struct trace_context *tr_ctx,
|
||||
struct pipe_resource *tr_res,
|
||||
|
|
@ -133,16 +129,12 @@ trace_sampler_view_create(struct trace_context *tr_ctx,
|
|||
pipe_resource_reference(&tr_view->base.texture, tr_res);
|
||||
tr_view->base.context = &tr_ctx->base;
|
||||
tr_view->sampler_view = view;
|
||||
view->reference.count += SAMPLER_VIEW_PRIVATE_REFCOUNT;
|
||||
tr_view->refcount = SAMPLER_VIEW_PRIVATE_REFCOUNT;
|
||||
return &tr_view->base;
|
||||
}
|
||||
|
||||
void
|
||||
trace_sampler_view_destroy(struct trace_sampler_view *tr_view)
|
||||
{
|
||||
p_atomic_add(&tr_view->sampler_view->reference.count, -tr_view->refcount);
|
||||
pipe_sampler_view_reference(&tr_view->sampler_view, NULL);
|
||||
pipe_resource_reference(&tr_view->base.texture, NULL);
|
||||
FREE(tr_view);
|
||||
}
|
||||
|
|
@ -152,11 +144,6 @@ trace_sampler_view_unwrap(struct trace_sampler_view *tr_view)
|
|||
{
|
||||
if (!tr_view)
|
||||
return NULL;
|
||||
tr_view->refcount--;
|
||||
if (!tr_view->refcount) {
|
||||
tr_view->refcount = SAMPLER_VIEW_PRIVATE_REFCOUNT;
|
||||
p_atomic_add(&tr_view->sampler_view->reference.count, tr_view->refcount);
|
||||
}
|
||||
return tr_view->sampler_view;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
|
|||
cso_set_vertex_shader_handle(cso, hud->vs_color);
|
||||
cso_set_vertex_elements(cso, &hud->velems);
|
||||
cso_set_render_condition(cso, NULL, false, 0);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false,
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0,
|
||||
&hud->font_sampler_view);
|
||||
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, 1, sampler_states);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
|
|
@ -1698,7 +1698,7 @@ hud_unset_draw_context(struct hud_context *hud)
|
|||
if (!pipe)
|
||||
return;
|
||||
|
||||
pipe_sampler_view_reference(&hud->font_sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, hud->font_sampler_view);
|
||||
|
||||
if (hud->fs_color) {
|
||||
pipe->delete_fs_state(pipe, hud->fs_color);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ pp_nocolor(struct pp_queue_t *ppq, struct pipe_resource *in,
|
|||
pp_filter_misc_state(p);
|
||||
|
||||
cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &p->view);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &p->view);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]);
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][1]);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
|||
const struct pipe_sampler_state *samplers[] = {&p->sampler_point};
|
||||
cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers);
|
||||
}
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &p->view);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &p->view);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][2]);
|
||||
|
|
@ -166,14 +166,13 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
|||
}
|
||||
|
||||
arr[0] = p->view;
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, 0, false, arr);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, 0, arr);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]); /* passvs */
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][3]);
|
||||
|
||||
pp_filter_draw(p);
|
||||
pp_filter_end_pass(p);
|
||||
pipe_sampler_view_reference(&arr[1], NULL);
|
||||
|
||||
|
||||
/* Third pass: smoothed edges */
|
||||
|
|
@ -198,7 +197,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
|||
}
|
||||
|
||||
arr[1] = p->view;
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0, false, arr);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0, arr);
|
||||
|
||||
cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */
|
||||
cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][4]);
|
||||
|
|
@ -208,7 +207,8 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
|||
|
||||
pp_filter_draw(p);
|
||||
pp_filter_end_pass(p);
|
||||
pipe_sampler_view_reference(&arr[0], NULL);
|
||||
pipe->sampler_view_release(pipe, arr[0]);
|
||||
pipe->sampler_view_release(pipe, arr[1]);
|
||||
|
||||
p->blend.rt[0].blend_enable = 0;
|
||||
p->framebuffer.zsbuf = NULL;
|
||||
|
|
@ -338,4 +338,3 @@ pp_jimenezmlaa_free(struct pp_queue_t *ppq, unsigned int n)
|
|||
{
|
||||
pipe_resource_reference(&ppq->areamaptex, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -788,16 +788,16 @@ static void util_blitter_restore_textures_internal(struct blitter_context *blitt
|
|||
/* Fragment sampler views. */
|
||||
if (ctx->base.saved_num_sampler_views)
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
ctx->base.saved_num_sampler_views, 0, true,
|
||||
ctx->base.saved_num_sampler_views, 0,
|
||||
ctx->base.saved_sampler_views);
|
||||
else if (count)
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
0, count, true,
|
||||
0, count,
|
||||
NULL);
|
||||
|
||||
/* Just clear them to NULL because set_sampler_views(take_ownership = true). */
|
||||
/* expect that driver will always refcount */
|
||||
for (i = 0; i < ctx->base.saved_num_sampler_views; i++)
|
||||
ctx->base.saved_sampler_views[i] = NULL;
|
||||
pipe_sampler_view_reference(&ctx->base.saved_sampler_views[i], NULL);
|
||||
|
||||
ctx->base.saved_num_sampler_views = ~0;
|
||||
}
|
||||
|
|
@ -2150,7 +2150,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter,
|
|||
views[1] = pipe->create_sampler_view(pipe, src->texture, &templ);
|
||||
|
||||
count = 2;
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0, false, views);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0, views);
|
||||
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 2, samplers);
|
||||
|
||||
pipe_sampler_view_reference(&views[1], NULL);
|
||||
|
|
@ -2166,14 +2166,14 @@ void util_blitter_blit_generic(struct blitter_context *blitter,
|
|||
view = pipe->create_sampler_view(pipe, src->texture, &templ);
|
||||
|
||||
count = 1;
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &view);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &view);
|
||||
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, &sampler_state);
|
||||
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
} else {
|
||||
count = 1;
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &src);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src);
|
||||
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, &sampler_state);
|
||||
}
|
||||
|
|
@ -2330,7 +2330,7 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
|
|||
src_templ.format = format;
|
||||
src_view = pipe->create_sampler_view(pipe, tex, &src_templ);
|
||||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &src_view);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
|
||||
|
||||
do_blits(ctx, dst_view, &dstbox, src_view, tex->width0, tex->height0,
|
||||
&srcbox, is_depth, false, false, 0);
|
||||
|
|
@ -2908,7 +2908,7 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
|
|||
pipe->set_scissor_states(pipe, 0, 1, scissor);
|
||||
}
|
||||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &src_view);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
|
||||
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &ctx->sampler_state);
|
||||
|
||||
unsigned stencil_bits =
|
||||
|
|
|
|||
|
|
@ -218,6 +218,38 @@ pipe_sampler_view_reference(struct pipe_sampler_view **dst,
|
|||
*dst = src;
|
||||
}
|
||||
|
||||
static inline void
|
||||
pipe_sampler_view_release(struct pipe_sampler_view *view)
|
||||
{
|
||||
if (view)
|
||||
view->context->sampler_view_release(view->context, view);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pipe_sampler_view_release_ptr(struct pipe_sampler_view **view_ptr)
|
||||
{
|
||||
struct pipe_sampler_view *view = *view_ptr;
|
||||
*view_ptr = NULL;
|
||||
if (view)
|
||||
view->context->sampler_view_release(view->context, view);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pipe_sampler_view_set_release(struct pipe_sampler_view **dst,
|
||||
struct pipe_sampler_view *src)
|
||||
{
|
||||
struct pipe_sampler_view *old_dst = *dst;
|
||||
*dst = src;
|
||||
if (old_dst)
|
||||
old_dst->context->sampler_view_release(old_dst->context, old_dst);
|
||||
}
|
||||
|
||||
static inline void
|
||||
u_default_sampler_view_release(struct pipe_context *pctx, struct pipe_sampler_view *view)
|
||||
{
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
}
|
||||
|
||||
static inline void
|
||||
pipe_so_target_reference(struct pipe_stream_output_target **dst,
|
||||
struct pipe_stream_output_target *src)
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ null_sampler_view(struct pipe_context *ctx, unsigned tgsi_tex_target)
|
|||
PIPE_FORMAT_R8G8B8A8_UNORM, 0);
|
||||
util_set_common_states_and_clear(cso, ctx, cb);
|
||||
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 0, 1, false, NULL);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 0, 1, NULL);
|
||||
|
||||
/* Fragment shader. */
|
||||
fs = util_make_fragment_tex_shader(ctx, tgsi_tex_target,
|
||||
|
|
@ -708,7 +708,7 @@ test_texture_barrier(struct pipe_context *ctx, bool use_fbfetch,
|
|||
templ.swizzle_b = PIPE_SWIZZLE_Z;
|
||||
templ.swizzle_a = PIPE_SWIZZLE_W;
|
||||
view = ctx->create_sampler_view(ctx, cb, &templ);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &view);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &view);
|
||||
|
||||
/* Fragment shader. */
|
||||
if (num_samples > 1) {
|
||||
|
|
|
|||
|
|
@ -1793,7 +1793,7 @@ tc_call_set_sampler_views(struct pipe_context *pipe, void *call)
|
|||
struct tc_sampler_views *p = (struct tc_sampler_views *)call;
|
||||
|
||||
pipe->set_sampler_views(pipe, p->shader, p->start, p->count,
|
||||
p->unbind_num_trailing_slots, true, p->slot);
|
||||
p->unbind_num_trailing_slots, p->slot);
|
||||
return p->base.num_slots;
|
||||
}
|
||||
|
||||
|
|
@ -1801,7 +1801,7 @@ static void
|
|||
tc_set_sampler_views(struct pipe_context *_pipe,
|
||||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots, bool take_ownership,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
if (!count && !unbind_num_trailing_slots)
|
||||
|
|
@ -1821,7 +1821,6 @@ tc_set_sampler_views(struct pipe_context *_pipe,
|
|||
p->count = count;
|
||||
p->unbind_num_trailing_slots = unbind_num_trailing_slots;
|
||||
|
||||
if (take_ownership) {
|
||||
memcpy(p->slot, views, sizeof(*views) * count);
|
||||
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
|
|
@ -1835,22 +1834,6 @@ tc_set_sampler_views(struct pipe_context *_pipe,
|
|||
tc_unbind_buffer(&tc->sampler_buffers[shader][start + i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
p->slot[i] = NULL;
|
||||
pipe_sampler_view_reference(&p->slot[i], views[i]);
|
||||
|
||||
if (views[i]) {
|
||||
if (views[i]->target == PIPE_BUFFER)
|
||||
tc_bind_buffer(&tc->sampler_buffers[shader][start + i], next,
|
||||
views[i]->texture);
|
||||
else
|
||||
tc_set_resource_batch_usage(tc, views[i]->texture);
|
||||
} else {
|
||||
tc_unbind_buffer(&tc->sampler_buffers[shader][start + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tc_unbind_buffers(&tc->sampler_buffers[shader][start + count],
|
||||
unbind_num_trailing_slots);
|
||||
|
|
@ -1864,6 +1847,33 @@ tc_set_sampler_views(struct pipe_context *_pipe,
|
|||
}
|
||||
}
|
||||
|
||||
struct tc_sampler_view_release {
|
||||
struct tc_call_base base;
|
||||
struct pipe_sampler_view *view;
|
||||
};
|
||||
|
||||
static uint16_t ALWAYS_INLINE
|
||||
tc_call_sampler_view_release(struct pipe_context *pipe, void *call)
|
||||
{
|
||||
struct tc_sampler_view_release *p = (struct tc_sampler_view_release *)call;
|
||||
|
||||
pipe->sampler_view_release(pipe, p->view);
|
||||
return call_size(tc_sampler_view_release);
|
||||
}
|
||||
|
||||
static void
|
||||
tc_sampler_view_release(struct pipe_context *_pipe, struct pipe_sampler_view *view)
|
||||
{
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
struct threaded_context *tc = threaded_context(_pipe);
|
||||
struct tc_sampler_view_release *p =
|
||||
tc_add_call(tc, TC_CALL_sampler_view_release, tc_sampler_view_release);
|
||||
|
||||
p->view = view;
|
||||
}
|
||||
|
||||
struct tc_shader_images {
|
||||
struct tc_call_base base;
|
||||
uint8_t shader, start, count;
|
||||
|
|
@ -5458,6 +5468,7 @@ threaded_context_create(struct pipe_context *pipe,
|
|||
CTX_INIT(set_stream_output_targets);
|
||||
CTX_INIT(create_sampler_view);
|
||||
CTX_INIT(sampler_view_destroy);
|
||||
CTX_INIT(sampler_view_release);
|
||||
CTX_INIT(create_surface);
|
||||
CTX_INIT(surface_destroy);
|
||||
CTX_INIT(buffer_map);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ CALL(bind_vs_state)
|
|||
CALL(bind_fs_state)
|
||||
CALL(bind_depth_stencil_alpha_state)
|
||||
CALL(set_sampler_views)
|
||||
CALL(sampler_view_release)
|
||||
CALL(set_viewport_states)
|
||||
CALL(flush)
|
||||
CALL(flush_resource)
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ vl_bicubic_filter_render(struct vl_bicubic_filter *filter,
|
|||
filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, &filter->sampler);
|
||||
filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, 0, false, &src);
|
||||
0, 1, 0, &src);
|
||||
filter->pipe->bind_vs_state(filter->pipe, filter->vs);
|
||||
filter->pipe->bind_fs_state(filter->pipe, filter->fs);
|
||||
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ set_yuv_layer(struct vl_compositor_state *s, struct vl_compositor *c,
|
|||
sampler_views = buffer->get_sampler_view_components(buffer);
|
||||
for (i = 0; i < 3; ++i) {
|
||||
s->layers[layer].samplers[i] = c->sampler_linear;
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[i], sampler_views[i]);
|
||||
s->layers[layer].sampler_views[i] = sampler_views[i];
|
||||
}
|
||||
|
||||
calc_src_and_dst(&s->layers[layer], buffer->width, buffer->height,
|
||||
|
|
@ -433,9 +433,9 @@ set_rgb_to_yuv_layer(struct vl_compositor_state *s, struct vl_compositor *c,
|
|||
s->layers[layer].samplers[1] = NULL;
|
||||
s->layers[layer].samplers[2] = NULL;
|
||||
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[0], v);
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[1], NULL);
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[2], NULL);
|
||||
s->layers[layer].sampler_views[0] = v;
|
||||
s->layers[layer].sampler_views[1] = NULL;
|
||||
s->layers[layer].sampler_views[2] = NULL;
|
||||
|
||||
calc_src_and_dst(&s->layers[layer], v->texture->width0, v->texture->height0,
|
||||
src_rect ? *src_rect : default_rect(&s->layers[layer]),
|
||||
|
|
@ -492,7 +492,7 @@ vl_compositor_clear_layers(struct vl_compositor_state *s)
|
|||
s->layers[i].mirror = VL_COMPOSITOR_MIRROR_NONE;
|
||||
|
||||
for ( j = 0; j < 3; j++)
|
||||
pipe_sampler_view_reference(&s->layers[i].sampler_views[j], NULL);
|
||||
s->layers[i].sampler_views[j] = NULL;
|
||||
for ( j = 0; j < 4; ++j)
|
||||
s->layers[i].colors[j] = v_one;
|
||||
}
|
||||
|
|
@ -589,7 +589,7 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
|
|||
sampler_views = buffer->get_sampler_view_components(buffer);
|
||||
for (i = 0; i < 3; ++i) {
|
||||
s->layers[layer].samplers[i] = c->sampler_linear;
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[i], sampler_views[i]);
|
||||
s->layers[layer].sampler_views[i] = sampler_views[i];
|
||||
}
|
||||
|
||||
calc_src_and_dst(&s->layers[layer], buffer->width, buffer->height,
|
||||
|
|
@ -662,9 +662,9 @@ vl_compositor_set_palette_layer(struct vl_compositor_state *s,
|
|||
s->layers[layer].samplers[0] = c->sampler_linear;
|
||||
s->layers[layer].samplers[1] = c->sampler_nearest;
|
||||
s->layers[layer].samplers[2] = NULL;
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[0], indexes);
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[1], palette);
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[2], NULL);
|
||||
s->layers[layer].sampler_views[0] = indexes;
|
||||
s->layers[layer].sampler_views[1] = palette;
|
||||
s->layers[layer].sampler_views[2] = NULL;
|
||||
calc_src_and_dst(&s->layers[layer], indexes->texture->width0, indexes->texture->height0,
|
||||
src_rect ? *src_rect : default_rect(&s->layers[layer]),
|
||||
dst_rect ? *dst_rect : default_rect(&s->layers[layer]));
|
||||
|
|
@ -696,9 +696,9 @@ vl_compositor_set_rgba_layer(struct vl_compositor_state *s,
|
|||
s->layers[layer].samplers[0] = c->sampler_linear;
|
||||
s->layers[layer].samplers[1] = NULL;
|
||||
s->layers[layer].samplers[2] = NULL;
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[0], rgba);
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[1], NULL);
|
||||
pipe_sampler_view_reference(&s->layers[layer].sampler_views[2], NULL);
|
||||
s->layers[layer].sampler_views[0] = rgba;
|
||||
s->layers[layer].sampler_views[1] = NULL;
|
||||
s->layers[layer].sampler_views[2] = NULL;
|
||||
calc_src_and_dst(&s->layers[layer], rgba->texture->width0, rgba->texture->height0,
|
||||
src_rect ? *src_rect : default_rect(&s->layers[layer]),
|
||||
dst_rect ? *dst_rect : default_rect(&s->layers[layer]));
|
||||
|
|
@ -818,7 +818,7 @@ vl_compositor_convert_rgb_to_yuv(struct vl_compositor_state *s,
|
|||
}
|
||||
}
|
||||
|
||||
pipe_sampler_view_reference(&sv, NULL);
|
||||
s->pipe->sampler_view_release(s->pipe, sv);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -861,7 +861,7 @@ draw_layers(struct vl_compositor *c,
|
|||
c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
num_sampler_views, layer->samplers);
|
||||
c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
num_sampler_views, 0, false, samplers);
|
||||
num_sampler_views, 0, samplers);
|
||||
|
||||
cs_launch(c, layer->cs, &(drawn.area));
|
||||
|
||||
|
|
@ -869,7 +869,7 @@ draw_layers(struct vl_compositor *c,
|
|||
c->pipe->set_shader_images(c->pipe, PIPE_SHADER_COMPUTE, 0, 0, 1, NULL);
|
||||
c->pipe->set_constant_buffer(c->pipe, PIPE_SHADER_COMPUTE, 0, false, NULL);
|
||||
c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_COMPUTE, 0, 0,
|
||||
num_sampler_views, false, NULL);
|
||||
num_sampler_views, NULL);
|
||||
c->pipe->bind_compute_state(c->pipe, NULL);
|
||||
c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
num_sampler_views, NULL);
|
||||
|
|
|
|||
|
|
@ -686,7 +686,7 @@ draw_layers(struct vl_compositor *c, struct vl_compositor_state *s, struct u_rec
|
|||
c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
num_sampler_views, layer->samplers);
|
||||
c->pipe->set_sampler_views(c->pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
num_sampler_views, 0, false, samplers);
|
||||
num_sampler_views, 0, samplers);
|
||||
|
||||
util_draw_arrays(c->pipe, MESA_PRIM_QUADS, vb_index * 4, 4);
|
||||
vb_index++;
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ vl_deint_filter_render(struct vl_deint_filter *filter,
|
|||
sampler_views[2] = cur_sv[k];
|
||||
sampler_views[3] = next_sv[k];
|
||||
filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 4, 0, false, sampler_views);
|
||||
0, 4, 0, sampler_views);
|
||||
|
||||
/* blit current field */
|
||||
fb_state.cbufs[0] = blit_surf;
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ vl_deint_filter_cs_render(struct vl_deint_filter *filter,
|
|||
sampler_views[2] = cur_sv[i];
|
||||
sampler_views[3] = next_sv[i];
|
||||
filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_COMPUTE,
|
||||
0, 4, 0, false, sampler_views);
|
||||
0, 4, 0, sampler_views);
|
||||
|
||||
/* Bind the image */
|
||||
struct pipe_image_view image = {
|
||||
|
|
|
|||
|
|
@ -835,7 +835,7 @@ vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_
|
|||
0, 2, idct->samplers);
|
||||
|
||||
idct->pipe->set_sampler_views(idct->pipe, PIPE_SHADER_FRAGMENT, 0, 2, 0,
|
||||
false, buffer->sampler_views.stage[0]);
|
||||
buffer->sampler_views.stage[0]);
|
||||
|
||||
/* mismatch control */
|
||||
idct->pipe->set_framebuffer_state(idct->pipe, &buffer->fb_state_mismatch);
|
||||
|
|
@ -862,6 +862,5 @@ vl_idct_prepare_stage2(struct vl_idct *idct, struct vl_idct_buffer *buffer)
|
|||
idct->pipe->bind_sampler_states(idct->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 2, idct->samplers);
|
||||
idct->pipe->set_sampler_views(idct->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 2, 0, false, buffer->sampler_views.stage[1]);
|
||||
0, 2, 0, buffer->sampler_views.stage[1]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ vl_matrix_filter_render(struct vl_matrix_filter *filter,
|
|||
filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, &filter->sampler);
|
||||
filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, 0, false, &src);
|
||||
0, 1, 0, &src);
|
||||
filter->pipe->bind_vs_state(filter->pipe, filter->vs);
|
||||
filter->pipe->bind_fs_state(filter->pipe, filter->fs);
|
||||
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ vl_mc_render_ref(struct vl_mc *renderer, struct vl_mc_buffer *buffer, struct pip
|
|||
renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs_ref);
|
||||
|
||||
renderer->pipe->set_sampler_views(renderer->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, 0, false, &ref);
|
||||
0, 1, 0, &ref);
|
||||
renderer->pipe->bind_sampler_states(renderer->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, &renderer->sampler_ref);
|
||||
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ vl_median_filter_render(struct vl_median_filter *filter,
|
|||
filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, &filter->sampler);
|
||||
filter->pipe->set_sampler_views(filter->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 1, 0, false, &src);
|
||||
0, 1, 0, &src);
|
||||
filter->pipe->bind_vs_state(filter->pipe, filter->vs);
|
||||
filter->pipe->bind_fs_state(filter->pipe, filter->fs);
|
||||
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
|
||||
|
|
|
|||
|
|
@ -831,7 +831,7 @@ vl_mpeg12_end_frame(struct pipe_video_codec *decoder,
|
|||
vl_idct_prepare_stage2(i ? &dec->idct_c : &dec->idct_y, &buf->idct[plane]);
|
||||
else {
|
||||
dec->context->set_sampler_views(dec->context,
|
||||
PIPE_SHADER_FRAGMENT, 0, 1, 0, false,
|
||||
PIPE_SHADER_FRAGMENT, 0, 1, 0,
|
||||
&mc_source_sv[plane]);
|
||||
dec->context->bind_sampler_states(dec->context,
|
||||
PIPE_SHADER_FRAGMENT,
|
||||
|
|
|
|||
|
|
@ -221,8 +221,9 @@ vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
|
|||
assert(buf);
|
||||
|
||||
for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
|
||||
pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);
|
||||
pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
|
||||
buf->base.context->sampler_view_release(buf->base.context, buf->sampler_view_planes[i]);
|
||||
if (i < buf->num_sampler_view_components)
|
||||
buf->base.context->sampler_view_release(buf->base.context, buf->sampler_view_components[i]);
|
||||
pipe_resource_reference(&buf->resources[i], NULL);
|
||||
}
|
||||
|
||||
|
|
@ -279,8 +280,8 @@ vl_video_buffer_sampler_view_planes(struct pipe_video_buffer *buffer)
|
|||
return buf->sampler_view_planes;
|
||||
|
||||
error:
|
||||
for (i = 0; i < num_planes; ++i )
|
||||
pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);
|
||||
for (i = 0; i < num_planes; ++i)
|
||||
pipe->sampler_view_release(pipe, buf->sampler_view_planes[i]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -333,13 +334,15 @@ vl_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)
|
|||
assert(component != 0);
|
||||
|
||||
for (i = component; i < VL_NUM_COMPONENTS; ++i)
|
||||
pipe_sampler_view_reference(&buf->sampler_view_components[i], buf->sampler_view_components[component - 1]);
|
||||
buf->sampler_view_components[i] = buf->sampler_view_components[component - 1];
|
||||
|
||||
buf->num_sampler_view_components = component;
|
||||
|
||||
return buf->sampler_view_components;
|
||||
|
||||
error:
|
||||
for (i = 0; i < VL_NUM_COMPONENTS; ++i )
|
||||
pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);
|
||||
for (i = 0; i < buf->num_sampler_view_components; ++i)
|
||||
pipe->sampler_view_release(pipe, buf->sampler_view_components[i]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ struct vl_video_buffer
|
|||
struct pipe_resource *resources[VL_NUM_COMPONENTS];
|
||||
struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];
|
||||
struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];
|
||||
unsigned num_sampler_view_components;
|
||||
struct pipe_surface *surfaces[VL_MAX_SURFACES];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -536,7 +536,7 @@ vl_zscan_render(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, unsigned
|
|||
zscan->pipe->set_framebuffer_state(zscan->pipe, &buffer->fb_state);
|
||||
zscan->pipe->set_viewport_states(zscan->pipe, 0, 1, &buffer->viewport);
|
||||
zscan->pipe->set_sampler_views(zscan->pipe, PIPE_SHADER_FRAGMENT,
|
||||
0, 3, 0, false, &buffer->src);
|
||||
0, 3, 0, &buffer->src);
|
||||
zscan->pipe->bind_vs_state(zscan->pipe, zscan->vs);
|
||||
zscan->pipe->bind_fs_state(zscan->pipe, zscan->fs);
|
||||
util_draw_arrays_instanced(zscan->pipe, MESA_PRIM_QUADS, 0, 4, 0, num_instances);
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ asahi_compute_restore(struct agx_context *ctx)
|
|||
blitter->saved_cb.buffer = NULL;
|
||||
|
||||
if (blitter->saved_sampler_view) {
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_COMPUTE, 0, 1, 0, true,
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_COMPUTE, 0, 1, 0,
|
||||
&blitter->saved_sampler_view);
|
||||
|
||||
blitter->saved_sampler_view = NULL;
|
||||
|
|
@ -422,7 +422,8 @@ asahi_compute_blit(struct pipe_context *ctx, const struct pipe_blit_info *info,
|
|||
src_templ.u.tex.first_level = info->src.level;
|
||||
src_templ.u.tex.last_level = info->src.level;
|
||||
src_view = ctx->create_sampler_view(ctx, src, &src_templ);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 1, 0, true, &src_view);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 1, 0, &src_view);
|
||||
ctx->sampler_view_release(ctx, src_view);
|
||||
|
||||
struct asahi_blit_key key = {
|
||||
.src_format = info->src.format,
|
||||
|
|
@ -458,7 +459,7 @@ asahi_compute_blit(struct pipe_context *ctx, const struct pipe_blit_info *info,
|
|||
ctx->launch_grid(ctx, &grid_info);
|
||||
ctx->set_shader_images(ctx, PIPE_SHADER_COMPUTE, 0, 0, 1, NULL);
|
||||
ctx->set_constant_buffer(ctx, PIPE_SHADER_COMPUTE, 0, false, NULL);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 0, 1, false, NULL);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 0, 1, NULL);
|
||||
|
||||
asahi_compute_restore(agx_context(ctx));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -814,7 +814,7 @@ agx_create_sampler_view(struct pipe_context *pctx,
|
|||
static void
|
||||
agx_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots, bool take_ownership,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct agx_context *ctx = agx_context(pctx);
|
||||
|
|
@ -827,16 +827,10 @@ agx_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
|||
count = 0;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(
|
||||
(struct pipe_sampler_view **)&ctx->stage[shader].textures[i], NULL);
|
||||
ctx->stage[shader].textures[i] = (struct agx_sampler_view *)views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(
|
||||
(struct pipe_sampler_view **)&ctx->stage[shader].textures[i],
|
||||
views[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < count + unbind_num_trailing_slots; i++) {
|
||||
pipe_sampler_view_reference(
|
||||
|
|
@ -5551,6 +5545,7 @@ agx_init_state_functions(struct pipe_context *ctx)
|
|||
ctx->set_vertex_buffers = agx_set_vertex_buffers;
|
||||
ctx->set_viewport_states = agx_set_viewport_states;
|
||||
ctx->sampler_view_destroy = agx_sampler_view_destroy;
|
||||
ctx->sampler_view_release = u_default_sampler_view_release;
|
||||
ctx->surface_destroy = agx_surface_destroy;
|
||||
ctx->draw_vbo = agx_draw_vbo;
|
||||
ctx->launch_grid = agx_launch_grid;
|
||||
|
|
|
|||
|
|
@ -3139,7 +3139,6 @@ crocus_set_sampler_views(struct pipe_context *ctx,
|
|||
enum pipe_shader_type p_stage,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct crocus_context *ice = (struct crocus_context *) ctx;
|
||||
|
|
@ -3151,14 +3150,8 @@ crocus_set_sampler_views(struct pipe_context *ctx,
|
|||
for (unsigned i = 0; i < count; i++) {
|
||||
struct pipe_sampler_view *pview = views ? views[i] : NULL;
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference((struct pipe_sampler_view **)
|
||||
&shs->textures[start + i], NULL);
|
||||
shs->textures[start + i] = (struct crocus_sampler_view *)pview;
|
||||
} else {
|
||||
pipe_sampler_view_reference((struct pipe_sampler_view **)
|
||||
&shs->textures[start + i], pview);
|
||||
}
|
||||
|
||||
struct crocus_sampler_view *view = (void *) pview;
|
||||
if (view) {
|
||||
|
|
@ -9273,6 +9266,7 @@ genX(crocus_init_state)(struct crocus_context *ice)
|
|||
ctx->set_vertex_buffers = crocus_set_vertex_buffers;
|
||||
ctx->set_viewport_states = crocus_set_viewport_states;
|
||||
ctx->sampler_view_destroy = crocus_sampler_view_destroy;
|
||||
ctx->sampler_view_release = u_default_sampler_view_release;
|
||||
ctx->surface_destroy = crocus_surface_destroy;
|
||||
ctx->draw_vbo = crocus_draw_vbo;
|
||||
ctx->launch_grid = crocus_launch_grid;
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ resolve_stencil_to_temp(struct d3d12_context *ctx,
|
|||
void *sampler_state = get_sampler_state(ctx);
|
||||
|
||||
util_blit_save_state(ctx);
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &src_view);
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
|
||||
pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_state);
|
||||
util_blitter_custom_shader(ctx->blitter, dst_surf,
|
||||
get_stencil_resolve_vs(ctx),
|
||||
|
|
|
|||
|
|
@ -977,7 +977,6 @@ d3d12_set_sampler_views(struct pipe_context *pctx,
|
|||
unsigned start_slot,
|
||||
unsigned num_views,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct d3d12_context *ctx = d3d12_context(pctx);
|
||||
|
|
@ -993,12 +992,7 @@ d3d12_set_sampler_views(struct pipe_context *pctx,
|
|||
if (new_view)
|
||||
d3d12_increment_sampler_view_bind_count(pctx, shader_type, new_view);
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&old_view, NULL);
|
||||
old_view = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&old_view, views[i]);
|
||||
}
|
||||
|
||||
if (views[i]) {
|
||||
dxil_wrap_sampler_state &wss = ctx->tex_wrap_states[shader_type][start_slot + i];
|
||||
|
|
@ -2239,6 +2233,7 @@ d3d12_init_graphics_context_functions(struct d3d12_context *ctx)
|
|||
|
||||
ctx->base.create_sampler_view = d3d12_create_sampler_view;
|
||||
ctx->base.sampler_view_destroy = d3d12_destroy_sampler_view;
|
||||
ctx->base.sampler_view_release = u_default_sampler_view_release;
|
||||
|
||||
ctx->base.create_vertex_elements_state = d3d12_create_vertex_elements_state;
|
||||
ctx->base.bind_vertex_elements_state = d3d12_bind_vertex_elements_state;
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ etna_texture_handle_incompatible(struct pipe_context *pctx, struct pipe_resource
|
|||
|
||||
static void
|
||||
set_sampler_views(struct etna_context *ctx, unsigned start, unsigned end,
|
||||
unsigned nr, bool take_ownership, struct pipe_sampler_view **views)
|
||||
unsigned nr, struct pipe_sampler_view **views)
|
||||
{
|
||||
unsigned i, j;
|
||||
uint32_t mask = 1 << start;
|
||||
|
|
@ -267,12 +267,7 @@ set_sampler_views(struct etna_context *ctx, unsigned start, unsigned end,
|
|||
for (i = start, j = 0; j < nr; i++, j++, mask <<= 1) {
|
||||
struct pipe_sampler_view *view = views ? views[j] : NULL;
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&ctx->sampler_view[i], NULL);
|
||||
ctx->sampler_view[i] = view;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&ctx->sampler_view[i], view);
|
||||
}
|
||||
if (view) {
|
||||
ctx->active_sampler_views |= mask;
|
||||
ctx->dirty_sampler_views |= mask;
|
||||
|
|
@ -291,35 +286,32 @@ set_sampler_views(struct etna_context *ctx, unsigned start, unsigned end,
|
|||
|
||||
static inline void
|
||||
etna_fragtex_set_sampler_views(struct etna_context *ctx, unsigned nr,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct etna_screen *screen = ctx->screen;
|
||||
unsigned start = 0;
|
||||
unsigned end = start + screen->specs.fragment_sampler_count;
|
||||
|
||||
set_sampler_views(ctx, start, end, nr, take_ownership, views);
|
||||
set_sampler_views(ctx, start, end, nr, views);
|
||||
ctx->num_fragment_sampler_views = nr;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
etna_vertex_set_sampler_views(struct etna_context *ctx, unsigned nr,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct etna_screen *screen = ctx->screen;
|
||||
unsigned start = screen->specs.vertex_sampler_offset;
|
||||
unsigned end = start + screen->specs.vertex_sampler_count;
|
||||
|
||||
set_sampler_views(ctx, start, end, nr, take_ownership, views);
|
||||
set_sampler_views(ctx, start, end, nr, views);
|
||||
}
|
||||
|
||||
static void
|
||||
etna_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
||||
unsigned start_slot, unsigned num_views,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct etna_context *ctx = etna_context(pctx);
|
||||
|
|
@ -329,10 +321,10 @@ etna_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
|||
|
||||
switch (shader) {
|
||||
case PIPE_SHADER_FRAGMENT:
|
||||
etna_fragtex_set_sampler_views(ctx, num_views, take_ownership, views);
|
||||
etna_fragtex_set_sampler_views(ctx, num_views, views);
|
||||
break;
|
||||
case PIPE_SHADER_VERTEX:
|
||||
etna_vertex_set_sampler_views(ctx, num_views, take_ownership, views);
|
||||
etna_vertex_set_sampler_views(ctx, num_views, views);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ etna_texture_desc_init(struct pipe_context *pctx)
|
|||
ctx->base.delete_sampler_state = etna_delete_sampler_state_desc;
|
||||
ctx->base.create_sampler_view = etna_create_sampler_view_desc;
|
||||
ctx->base.sampler_view_destroy = etna_sampler_view_desc_destroy;
|
||||
ctx->base.sampler_view_release = u_default_sampler_view_release;
|
||||
ctx->emit_texture_state = etna_emit_texture_desc;
|
||||
ctx->ts_for_sampler_view = etna_ts_for_sampler_view_state;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -616,6 +616,7 @@ etna_texture_state_init(struct pipe_context *pctx)
|
|||
ctx->base.delete_sampler_state = etna_delete_sampler_state_state;
|
||||
ctx->base.create_sampler_view = etna_create_sampler_view_state;
|
||||
ctx->base.sampler_view_destroy = etna_sampler_view_state_destroy;
|
||||
ctx->base.sampler_view_release = u_default_sampler_view_release;
|
||||
ctx->ts_for_sampler_view = etna_ts_for_sampler_view_state;
|
||||
|
||||
STATIC_ASSERT(VIVS_TE_SAMPLER_LOD_ADDR__LEN == VIVS_NTE_SAMPLER_ADDR_LOD__LEN);
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ static void
|
|||
fd2_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views) in_dt
|
||||
{
|
||||
if (shader == PIPE_SHADER_FRAGMENT) {
|
||||
|
|
@ -201,7 +200,7 @@ fd2_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
|||
}
|
||||
|
||||
fd_set_sampler_views(pctx, shader, start, nr, unbind_num_trailing_slots,
|
||||
take_ownership, views);
|
||||
views);
|
||||
}
|
||||
|
||||
/* map gallium sampler-id to hw const-idx.. adreno uses a flat address
|
||||
|
|
|
|||
|
|
@ -216,7 +216,6 @@ static void
|
|||
fd4_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
|
|
@ -268,7 +267,7 @@ fd4_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
|||
}
|
||||
|
||||
fd_set_sampler_views(pctx, shader, start, nr, unbind_num_trailing_slots,
|
||||
take_ownership, views);
|
||||
views);
|
||||
|
||||
for (i = 0; i < unbind_num_trailing_slots; i++) {
|
||||
astc_srgb &= ~(1 << (start + nr + i));
|
||||
|
|
|
|||
|
|
@ -478,14 +478,13 @@ static void
|
|||
fd6_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
in_dt
|
||||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
|
||||
fd_set_sampler_views(pctx, shader, start, nr, unbind_num_trailing_slots,
|
||||
take_ownership, views);
|
||||
views);
|
||||
|
||||
if (!views)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ void
|
|||
fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views) in_dt
|
||||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
|
|
@ -66,12 +65,7 @@ fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
|
|||
struct pipe_sampler_view *view = views ? views[i] : NULL;
|
||||
unsigned p = i + start;
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&tex->textures[p], NULL);
|
||||
tex->textures[p] = view;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&tex->textures[p], view);
|
||||
}
|
||||
|
||||
if (tex->textures[p]) {
|
||||
fd_resource_set_usage(tex->textures[p]->texture, FD_DIRTY_TEX);
|
||||
|
|
@ -100,6 +94,7 @@ fd_texture_init(struct pipe_context *pctx)
|
|||
pctx->delete_sampler_state = fd_sampler_state_delete;
|
||||
if (!pctx->sampler_view_destroy)
|
||||
pctx->sampler_view_destroy = fd_sampler_view_destroy;
|
||||
pctx->sampler_view_release = u_default_sampler_view_release;
|
||||
}
|
||||
|
||||
/* helper for setting up border-color buffer for a3xx/a4xx: */
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ void fd_sampler_states_bind(struct pipe_context *pctx,
|
|||
void fd_set_sampler_views(struct pipe_context *pctx,
|
||||
enum pipe_shader_type shader, unsigned start,
|
||||
unsigned nr, unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views);
|
||||
|
||||
void fd_texture_init(struct pipe_context *pctx);
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ i915_set_constant_buffer(struct pipe_context *pipe,
|
|||
static void
|
||||
i915_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned num,
|
||||
unsigned unbind_num_trailing_slots, bool take_ownership,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
if (shader != PIPE_SHADER_FRAGMENT) {
|
||||
|
|
@ -787,24 +787,13 @@ i915_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
|
|||
if (views && num == i915->num_fragment_sampler_views &&
|
||||
!memcmp(i915->fragment_sampler_views, views,
|
||||
num * sizeof(struct pipe_sampler_view *))) {
|
||||
if (take_ownership) {
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
struct pipe_sampler_view *view = views[i];
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&i915->fragment_sampler_views[i], NULL);
|
||||
i915->fragment_sampler_views[i] = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&i915->fragment_sampler_views[i],
|
||||
views[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = num; i < i915->num_fragment_sampler_views; i++)
|
||||
pipe_sampler_view_reference(&i915->fragment_sampler_views[i], NULL);
|
||||
|
|
@ -1105,6 +1094,7 @@ i915_init_state_functions(struct i915_context *i915)
|
|||
i915->base.set_sampler_views = i915_set_sampler_views;
|
||||
i915->base.create_sampler_view = i915_create_sampler_view;
|
||||
i915->base.sampler_view_destroy = i915_sampler_view_destroy;
|
||||
i915->base.sampler_view_release = u_default_sampler_view_release;
|
||||
i915->base.set_viewport_states = i915_set_viewport_states;
|
||||
i915->base.set_vertex_buffers = i915_set_vertex_buffers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3501,7 +3501,6 @@ iris_set_sampler_views(struct pipe_context *ctx,
|
|||
enum pipe_shader_type p_stage,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct iris_context *ice = (struct iris_context *) ctx;
|
||||
|
|
@ -3529,14 +3528,8 @@ iris_set_sampler_views(struct pipe_context *ctx,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference((struct pipe_sampler_view **)
|
||||
&shs->textures[start + i], NULL);
|
||||
shs->textures[start + i] = (struct iris_sampler_view *)pview;
|
||||
} else {
|
||||
pipe_sampler_view_reference((struct pipe_sampler_view **)
|
||||
&shs->textures[start + i], pview);
|
||||
}
|
||||
if (view) {
|
||||
view->res->bind_history |= PIPE_BIND_SAMPLER_VIEW;
|
||||
view->res->bind_stages |= 1 << stage;
|
||||
|
|
@ -10550,6 +10543,7 @@ genX(init_state)(struct iris_context *ice)
|
|||
ctx->set_vertex_buffers = iris_set_vertex_buffers;
|
||||
ctx->set_viewport_states = iris_set_viewport_states;
|
||||
ctx->sampler_view_destroy = iris_sampler_view_destroy;
|
||||
ctx->sampler_view_release = u_default_sampler_view_release;
|
||||
ctx->surface_destroy = iris_surface_destroy;
|
||||
ctx->draw_vbo = iris_draw_vbo;
|
||||
ctx->launch_grid = iris_launch_grid;
|
||||
|
|
|
|||
|
|
@ -382,7 +382,6 @@ lima_set_sampler_views(struct pipe_context *pctx,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct lima_context *ctx = lima_context(pctx);
|
||||
|
|
@ -396,13 +395,8 @@ lima_set_sampler_views(struct pipe_context *pctx,
|
|||
if (views[i])
|
||||
new_nr = i + 1;
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&lima_tex->textures[i], NULL);
|
||||
lima_tex->textures[i] = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&lima_tex->textures[i], views[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < lima_tex->num_textures; i++) {
|
||||
pipe_sampler_view_reference(&lima_tex->textures[i], NULL);
|
||||
|
|
@ -457,6 +451,7 @@ lima_state_init(struct lima_context *ctx)
|
|||
|
||||
ctx->base.create_sampler_view = lima_create_sampler_view;
|
||||
ctx->base.sampler_view_destroy = lima_sampler_view_destroy;
|
||||
ctx->base.sampler_view_release = u_default_sampler_view_release;
|
||||
ctx->base.set_sampler_views = lima_set_sampler_views;
|
||||
|
||||
ctx->base.set_sample_mask = lima_set_sample_mask;
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe,
|
|||
unsigned start,
|
||||
unsigned num,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
|
|
@ -164,14 +163,7 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe,
|
|||
if (view)
|
||||
llvmpipe_flush_resource(pipe, view->texture, 0, true, false, false, "sampler_view");
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i],
|
||||
NULL);
|
||||
llvmpipe->sampler_views[shader][start + i] = view;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i],
|
||||
view);
|
||||
}
|
||||
pipe_sampler_view_reference(&llvmpipe->sampler_views[shader][start + i], view);
|
||||
}
|
||||
|
||||
for (; i < num + unbind_num_trailing_slots; i++) {
|
||||
|
|
@ -629,5 +621,6 @@ llvmpipe_init_sampler_funcs(struct llvmpipe_context *llvmpipe)
|
|||
llvmpipe->pipe.create_sampler_view = llvmpipe_create_sampler_view;
|
||||
llvmpipe->pipe.set_sampler_views = llvmpipe_set_sampler_views;
|
||||
llvmpipe->pipe.sampler_view_destroy = llvmpipe_sampler_view_destroy;
|
||||
llvmpipe->pipe.sampler_view_release = u_default_sampler_view_release;
|
||||
llvmpipe->pipe.delete_sampler_state = llvmpipe_delete_sampler_state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,12 +188,11 @@ nv40_verttex_sampler_states_bind(struct pipe_context *pipe,
|
|||
|
||||
void
|
||||
nv40_verttex_set_sampler_views(struct pipe_context *pipe, unsigned nr,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views);
|
||||
|
||||
void
|
||||
nv30_fragtex_set_sampler_views(struct pipe_context *pipe,
|
||||
unsigned nr, bool take_ownership,
|
||||
unsigned nr,
|
||||
struct pipe_sampler_view **views);
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -174,7 +174,6 @@ nv30_fragtex_sampler_states_bind(struct pipe_context *pipe,
|
|||
|
||||
void
|
||||
nv30_fragtex_set_sampler_views(struct pipe_context *pipe, unsigned nr,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct nv30_context *nv30 = nv30_context(pipe);
|
||||
|
|
@ -182,12 +181,7 @@ nv30_fragtex_set_sampler_views(struct pipe_context *pipe, unsigned nr,
|
|||
|
||||
for (i = 0; i < nr; i++) {
|
||||
nouveau_bufctx_reset(nv30->bufctx, BUFCTX_FRAGTEX(i));
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&nv30->fragprog.textures[i], NULL);
|
||||
nv30->fragprog.textures[i] = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&nv30->fragprog.textures[i], views[i]);
|
||||
}
|
||||
nv30->fragprog.dirty_samplers |= (1 << i);
|
||||
}
|
||||
|
||||
|
|
@ -206,16 +200,15 @@ static void
|
|||
nv30_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
assert(start == 0);
|
||||
switch (shader) {
|
||||
case PIPE_SHADER_FRAGMENT:
|
||||
nv30_fragtex_set_sampler_views(pipe, nr, take_ownership, views);
|
||||
nv30_fragtex_set_sampler_views(pipe, nr, views);
|
||||
break;
|
||||
case PIPE_SHADER_VERTEX:
|
||||
nv40_verttex_set_sampler_views(pipe, nr, take_ownership, views);
|
||||
nv40_verttex_set_sampler_views(pipe, nr, views);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
|
|
|
|||
|
|
@ -324,4 +324,5 @@ nv30_texture_init(struct pipe_context *pipe)
|
|||
|
||||
pipe->create_sampler_view = nv30_sampler_view_create;
|
||||
pipe->sampler_view_destroy = nv30_sampler_view_destroy;
|
||||
pipe->sampler_view_release = u_default_sampler_view_release;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ nv40_verttex_sampler_states_bind(struct pipe_context *pipe,
|
|||
|
||||
void
|
||||
nv40_verttex_set_sampler_views(struct pipe_context *pipe, unsigned nr,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct nv30_context *nv30 = nv30_context(pipe);
|
||||
|
|
@ -81,12 +80,7 @@ nv40_verttex_set_sampler_views(struct pipe_context *pipe, unsigned nr,
|
|||
|
||||
for (i = 0; i < nr; i++) {
|
||||
nouveau_bufctx_reset(nv30->bufctx, BUFCTX_VERTTEX(i));
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&nv30->vertprog.textures[i], NULL);
|
||||
nv30->vertprog.textures[i] = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&nv30->vertprog.textures[i], views[i]);
|
||||
}
|
||||
nv30->vertprog.dirty_samplers |= (1 << i);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ nv50_sampler_view_destroy(struct pipe_context *pipe,
|
|||
|
||||
static inline void
|
||||
nv50_stage_set_sampler_views(struct nv50_context *nv50, int s,
|
||||
unsigned nr, bool take_ownership,
|
||||
unsigned nr,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
unsigned i;
|
||||
|
|
@ -684,13 +684,8 @@ nv50_stage_set_sampler_views(struct nv50_context *nv50, int s,
|
|||
nv50->textures_coherent[s] &= ~(1 << i);
|
||||
}
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&nv50->textures[s][i], NULL);
|
||||
nv50->textures[s][i] = view;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&nv50->textures[s][i], view);
|
||||
}
|
||||
}
|
||||
|
||||
assert(nv50->num_textures[s] <= PIPE_MAX_SAMPLERS);
|
||||
for (i = nr; i < nv50->num_textures[s]; ++i) {
|
||||
|
|
@ -709,14 +704,13 @@ static void
|
|||
nv50_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct nv50_context *nv50 = nv50_context(pipe);
|
||||
unsigned s = nv50_context_shader_stage(shader);
|
||||
|
||||
assert(start == 0);
|
||||
nv50_stage_set_sampler_views(nv50, s, nr, take_ownership, views);
|
||||
nv50_stage_set_sampler_views(nv50, s, nr, views);
|
||||
|
||||
if (unlikely(s == NV50_SHADER_STAGE_COMPUTE)) {
|
||||
nouveau_bufctx_reset(nv50->bufctx_cp, NV50_BIND_CP_TEXTURES);
|
||||
|
|
@ -1488,6 +1482,7 @@ nv50_init_state_functions(struct nv50_context *nv50)
|
|||
|
||||
pipe->create_sampler_view = nv50_create_sampler_view;
|
||||
pipe->sampler_view_destroy = nv50_sampler_view_destroy;
|
||||
pipe->sampler_view_release = u_default_sampler_view_release;
|
||||
pipe->set_sampler_views = nv50_set_sampler_views;
|
||||
|
||||
pipe->create_vs_state = nv50_vp_state_create;
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ nvc0_sampler_view_destroy(struct pipe_context *pipe,
|
|||
|
||||
static inline void
|
||||
nvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s,
|
||||
unsigned nr, bool take_ownership,
|
||||
unsigned nr,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
unsigned i;
|
||||
|
|
@ -526,8 +526,6 @@ nvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s,
|
|||
struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]);
|
||||
|
||||
if (view == nvc0->textures[s][i]) {
|
||||
if (take_ownership)
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
continue;
|
||||
}
|
||||
nvc0->textures_dirty[s] |= 1 << i;
|
||||
|
|
@ -551,13 +549,8 @@ nvc0_stage_set_sampler_views(struct nvc0_context *nvc0, int s,
|
|||
nvc0_screen_tic_unlock(nvc0->screen, old);
|
||||
}
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&nvc0->textures[s][i], NULL);
|
||||
nvc0->textures[s][i] = view;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&nvc0->textures[s][i], view);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = nr; i < nvc0->num_textures[s]; ++i) {
|
||||
struct nv50_tic_entry *old = nv50_tic_entry(nvc0->textures[s][i]);
|
||||
|
|
@ -578,13 +571,12 @@ static void
|
|||
nvc0_set_sampler_views(struct pipe_context *pipe, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
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, take_ownership, views);
|
||||
nvc0_stage_set_sampler_views(nvc0_context(pipe), s, nr, views);
|
||||
|
||||
if (s == 5)
|
||||
nvc0_context(pipe)->dirty_cp |= NVC0_NEW_CP_TEXTURES;
|
||||
|
|
@ -1482,6 +1474,7 @@ nvc0_init_state_functions(struct nvc0_context *nvc0)
|
|||
|
||||
pipe->create_sampler_view = nvc0_create_sampler_view;
|
||||
pipe->sampler_view_destroy = nvc0_sampler_view_destroy;
|
||||
pipe->sampler_view_release = u_default_sampler_view_release;
|
||||
pipe->set_sampler_views = nvc0_set_sampler_views;
|
||||
|
||||
pipe->create_vs_state = nvc0_vp_state_create;
|
||||
|
|
|
|||
|
|
@ -4079,6 +4079,7 @@ context_populate_vtbl(struct pipe_context *pipe)
|
|||
pipe->create_depth_stencil_alpha_state = panfrost_create_depth_stencil_state;
|
||||
pipe->create_sampler_view = panfrost_create_sampler_view;
|
||||
pipe->sampler_view_destroy = panfrost_sampler_view_destroy;
|
||||
pipe->sampler_view_release = u_default_sampler_view_release;
|
||||
pipe->create_sampler_state = panfrost_create_sampler_state;
|
||||
pipe->create_blend_state = panfrost_create_blend_state;
|
||||
|
||||
|
|
|
|||
|
|
@ -391,7 +391,6 @@ panfrost_set_sampler_views(struct pipe_context *pctx,
|
|||
enum pipe_shader_type shader, unsigned start_slot,
|
||||
unsigned num_views,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct panfrost_context *ctx = pan_context(pctx);
|
||||
|
|
@ -407,15 +406,9 @@ panfrost_set_sampler_views(struct pipe_context *pctx,
|
|||
if (view)
|
||||
new_nr = p + 1;
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(
|
||||
(struct pipe_sampler_view **)&ctx->sampler_views[shader][p], NULL);
|
||||
ctx->sampler_views[shader][i] = (struct panfrost_sampler_view *)view;
|
||||
} else {
|
||||
pipe_sampler_view_reference(
|
||||
(struct pipe_sampler_view **)&ctx->sampler_views[shader][p], view);
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < num_views + unbind_num_trailing_slots; i++) {
|
||||
unsigned p = i + start_slot;
|
||||
|
|
|
|||
|
|
@ -1571,7 +1571,6 @@ static void r300_set_sampler_views(struct pipe_context* pipe,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view** views)
|
||||
{
|
||||
struct r300_context* r300 = r300_context(pipe);
|
||||
|
|
@ -1585,12 +1584,6 @@ static void r300_set_sampler_views(struct pipe_context* pipe,
|
|||
assert(start == 0); /* non-zero not handled yet */
|
||||
|
||||
if (shader != PIPE_SHADER_FRAGMENT || count > tex_units) {
|
||||
if (take_ownership) {
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
struct pipe_sampler_view *view = views[i];
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1601,15 +1594,9 @@ static void r300_set_sampler_views(struct pipe_context* pipe,
|
|||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(
|
||||
(struct pipe_sampler_view**)&state->sampler_views[i], NULL);
|
||||
state->sampler_views[i] = (struct r300_sampler_view*)views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(
|
||||
(struct pipe_sampler_view**)&state->sampler_views[i],
|
||||
views[i]);
|
||||
}
|
||||
|
||||
if (!views[i]) {
|
||||
continue;
|
||||
|
|
@ -2183,6 +2170,7 @@ void r300_init_state_functions(struct r300_context* r300)
|
|||
r300->context.set_sampler_views = r300_set_sampler_views;
|
||||
r300->context.create_sampler_view = r300_create_sampler_view;
|
||||
r300->context.sampler_view_destroy = r300_sampler_view_destroy;
|
||||
r300->context.sampler_view_release = u_default_sampler_view_release;
|
||||
|
||||
r300->context.set_scissor_states = r300_set_scissor_states;
|
||||
|
||||
|
|
|
|||
|
|
@ -620,7 +620,6 @@ static void r600_set_sampler_views(struct pipe_context *pipe,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct r600_context *rctx = (struct r600_context *) pipe;
|
||||
|
|
@ -654,10 +653,6 @@ static void r600_set_sampler_views(struct pipe_context *pipe,
|
|||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (rviews[i] == dst->views.views[i]) {
|
||||
if (take_ownership) {
|
||||
struct pipe_sampler_view *view = views[i];
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -688,12 +683,7 @@ static void r600_set_sampler_views(struct pipe_context *pipe,
|
|||
dirty_sampler_states_mask |= 1 << i;
|
||||
}
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views.views[i], NULL);
|
||||
dst->views.views[i] = (struct r600_pipe_sampler_view*)views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views.views[i], views[i]);
|
||||
}
|
||||
new_mask |= 1 << i;
|
||||
r600_context_add_resource_size(pipe, views[i]->texture);
|
||||
} else {
|
||||
|
|
@ -3462,6 +3452,7 @@ void r600_init_common_state_functions(struct r600_context *rctx)
|
|||
rctx->b.b.set_vertex_buffers = r600_set_vertex_buffers;
|
||||
rctx->b.b.set_sampler_views = r600_set_sampler_views;
|
||||
rctx->b.b.sampler_view_destroy = r600_sampler_view_destroy;
|
||||
rctx->b.b.sampler_view_release = u_default_sampler_view_release;
|
||||
rctx->b.b.memory_barrier = r600_memory_barrier;
|
||||
rctx->b.b.texture_barrier = r600_texture_barrier;
|
||||
rctx->b.b.set_stream_output_targets = r600_set_streamout_targets;
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ static void si_reset_sampler_view_slot(struct si_samplers *samplers, unsigned sl
|
|||
static void si_set_sampler_views(struct si_context *sctx, unsigned shader,
|
||||
unsigned start_slot, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership, struct pipe_sampler_view **views,
|
||||
struct pipe_sampler_view **views,
|
||||
bool disallow_early_out)
|
||||
{
|
||||
struct si_samplers *samplers = &sctx->samplers[shader];
|
||||
|
|
@ -452,10 +452,6 @@ static void si_set_sampler_views(struct si_context *sctx, unsigned shader,
|
|||
uint32_t *restrict desc = descs->list + desc_slot * 16;
|
||||
|
||||
if (samplers->views[slot] == &sview->base && !disallow_early_out) {
|
||||
if (take_ownership) {
|
||||
struct pipe_sampler_view *view = views[i];
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -501,12 +497,7 @@ static void si_set_sampler_views(struct si_context *sctx, unsigned shader,
|
|||
}
|
||||
}
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&samplers->views[slot], NULL);
|
||||
samplers->views[slot] = &sview->base;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&samplers->views[slot], &sview->base);
|
||||
}
|
||||
samplers->enabled_mask |= 1u << slot;
|
||||
|
||||
/* Since this can flush, it must be done after enabled_mask is
|
||||
|
|
@ -566,7 +557,7 @@ static void si_update_shader_needs_decompress_mask(struct si_context *sctx, unsi
|
|||
static void si_pipe_set_sampler_views(struct pipe_context *ctx, enum pipe_shader_type shader,
|
||||
unsigned start, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership, struct pipe_sampler_view **views)
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
|
||||
|
|
@ -574,7 +565,7 @@ static void si_pipe_set_sampler_views(struct pipe_context *ctx, enum pipe_shader
|
|||
return;
|
||||
|
||||
si_set_sampler_views(sctx, shader, start, count, unbind_num_trailing_slots,
|
||||
take_ownership, views, false);
|
||||
views, false);
|
||||
si_update_shader_needs_decompress_mask(sctx, shader);
|
||||
}
|
||||
|
||||
|
|
@ -2015,7 +2006,7 @@ void si_update_all_texture_descriptors(struct si_context *sctx)
|
|||
if (!view || !view->texture || view->texture->target == PIPE_BUFFER)
|
||||
continue;
|
||||
|
||||
si_set_sampler_views(sctx, shader, i, 1, 0, false, &samplers->views[i], true);
|
||||
si_set_sampler_views(sctx, shader, i, 1, 0, &samplers->views[i], true);
|
||||
}
|
||||
|
||||
si_update_shader_needs_decompress_mask(sctx, shader);
|
||||
|
|
|
|||
|
|
@ -4855,6 +4855,7 @@ void si_init_state_compute_functions(struct si_context *sctx)
|
|||
sctx->b.delete_sampler_state = si_delete_sampler_state;
|
||||
sctx->b.create_sampler_view = si_create_sampler_view;
|
||||
sctx->b.sampler_view_destroy = si_sampler_view_destroy;
|
||||
sctx->b.sampler_view_release = u_default_sampler_view_release;
|
||||
}
|
||||
|
||||
void si_init_state_functions(struct si_context *sctx)
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
|
|||
unsigned start,
|
||||
unsigned num,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
|
|||
unsigned start,
|
||||
unsigned num,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct softpipe_context *softpipe = softpipe_context(pipe);
|
||||
|
|
@ -119,12 +118,7 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
|
|||
&softpipe->tgsi.sampler[shader]->sp_sview[start + i];
|
||||
struct pipe_sampler_view **pview = &softpipe->sampler_views[shader][start + i];
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(pview, NULL);
|
||||
*pview = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(pview, views[i]);
|
||||
}
|
||||
sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i],
|
||||
views[i]);
|
||||
/*
|
||||
|
|
@ -355,5 +349,5 @@ softpipe_init_sampler_funcs(struct pipe_context *pipe)
|
|||
pipe->create_sampler_view = softpipe_create_sampler_view;
|
||||
pipe->set_sampler_views = softpipe_set_sampler_views;
|
||||
pipe->sampler_view_destroy = softpipe_sampler_view_destroy;
|
||||
pipe->sampler_view_release = u_default_sampler_view_release;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,6 @@ svga_set_sampler_views(struct pipe_context *pipe,
|
|||
unsigned start,
|
||||
unsigned num,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct svga_context *svga = svga_context(pipe);
|
||||
|
|
@ -437,11 +436,7 @@ svga_set_sampler_views(struct pipe_context *pipe,
|
|||
|
||||
any_change |= svga->curr.sampler_views[shader][start + i] != views[i];
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&svga->curr.sampler_views[shader][start + i],
|
||||
NULL);
|
||||
svga->curr.sampler_views[shader][start + i] = views[i];
|
||||
} else if (svga->curr.sampler_views[shader][start + i] != views[i]) {
|
||||
if (svga->curr.sampler_views[shader][start + i] != views[i]) {
|
||||
pipe_sampler_view_reference(&svga->curr.sampler_views[shader][start + i],
|
||||
views[i]);
|
||||
}
|
||||
|
|
@ -548,4 +543,5 @@ svga_init_sampler_functions( struct svga_context *svga )
|
|||
svga->pipe.set_sampler_views = svga_set_sampler_views;
|
||||
svga->pipe.create_sampler_view = svga_create_sampler_view;
|
||||
svga->pipe.sampler_view_destroy = svga_sampler_view_destroy;
|
||||
svga->pipe.sampler_view_release = u_default_sampler_view_release;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -562,7 +562,6 @@ static void
|
|||
tegra_set_sampler_views(struct pipe_context *pcontext, enum pipe_shader_type shader,
|
||||
unsigned start_slot, unsigned num_views,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **pviews)
|
||||
{
|
||||
struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
|
|
@ -586,7 +585,7 @@ tegra_set_sampler_views(struct pipe_context *pcontext, enum pipe_shader_type sha
|
|||
|
||||
context->gpu->set_sampler_views(context->gpu, shader, start_slot,
|
||||
num_views, unbind_num_trailing_slots,
|
||||
take_ownership, views);
|
||||
views);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1381,6 +1380,7 @@ tegra_screen_context_create(struct pipe_screen *pscreen, void *priv,
|
|||
|
||||
context->base.create_sampler_view = tegra_create_sampler_view;
|
||||
context->base.sampler_view_destroy = tegra_sampler_view_destroy;
|
||||
context->base.sampler_view_release = u_default_sampler_view_release;
|
||||
|
||||
context->base.create_surface = tegra_create_surface;
|
||||
context->base.surface_destroy = tegra_surface_destroy;
|
||||
|
|
|
|||
|
|
@ -846,7 +846,7 @@ v3d_sand8_blit(struct pipe_context *pctx, struct pipe_blit_info *info)
|
|||
/* Unbind the textures, to make sure we don't try to recurse into the
|
||||
* shadow blit.
|
||||
*/
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, false, NULL);
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, NULL);
|
||||
pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL);
|
||||
|
||||
util_blitter_custom_shader(v3d->blitter, dst_surf,
|
||||
|
|
@ -1166,7 +1166,7 @@ v3d_sand30_blit(struct pipe_context *pctx, struct pipe_blit_info *info)
|
|||
/* Unbind the textures, to make sure we don't try to recurse into the
|
||||
* shadow blit.
|
||||
*/
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, false,
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0,
|
||||
NULL);
|
||||
pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1168,7 +1168,6 @@ v3d_set_sampler_views(struct pipe_context *pctx,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct v3d_context *v3d = v3d_context(pctx);
|
||||
|
|
@ -1181,12 +1180,7 @@ v3d_set_sampler_views(struct pipe_context *pctx,
|
|||
for (i = 0; i < nr; i++) {
|
||||
if (views[i])
|
||||
new_nr = i + 1;
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&stage_tex->textures[i], NULL);
|
||||
stage_tex->textures[i] = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&stage_tex->textures[i], views[i]);
|
||||
}
|
||||
/* If our sampler serial doesn't match our texture serial it
|
||||
* means the texture has been updated with a new BO, in which
|
||||
* case we need to update the sampler state to point to the
|
||||
|
|
@ -1459,6 +1453,7 @@ v3dX(state_init)(struct pipe_context *pctx)
|
|||
|
||||
pctx->create_sampler_view = v3d_create_sampler_view;
|
||||
pctx->sampler_view_destroy = v3d_sampler_view_destroy;
|
||||
pctx->sampler_view_release = u_default_sampler_view_release;
|
||||
pctx->set_sampler_views = v3d_set_sampler_views;
|
||||
|
||||
pctx->set_shader_buffers = v3d_set_shader_buffers;
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ vc4_yuv_blit(struct pipe_context *pctx, struct pipe_blit_info *info)
|
|||
/* Unbind the textures, to make sure we don't try to recurse into the
|
||||
* shadow blit.
|
||||
*/
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, false, NULL);
|
||||
pctx->set_sampler_views(pctx, PIPE_SHADER_FRAGMENT, 0, 0, 0, NULL);
|
||||
pctx->bind_sampler_states(pctx, PIPE_SHADER_FRAGMENT, 0, 0, NULL);
|
||||
|
||||
util_blitter_custom_shader(vc4->blitter, dst_surf,
|
||||
|
|
|
|||
|
|
@ -648,7 +648,6 @@ vc4_set_sampler_views(struct pipe_context *pctx,
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start, unsigned nr,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct vc4_context *vc4 = vc4_context(pctx);
|
||||
|
|
@ -661,13 +660,8 @@ vc4_set_sampler_views(struct pipe_context *pctx,
|
|||
for (i = 0; i < nr; i++) {
|
||||
if (views[i])
|
||||
new_nr = i + 1;
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&stage_tex->textures[i], NULL);
|
||||
stage_tex->textures[i] = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&stage_tex->textures[i], views[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < stage_tex->num_textures; i++) {
|
||||
pipe_sampler_view_reference(&stage_tex->textures[i], NULL);
|
||||
|
|
@ -713,5 +707,6 @@ vc4_state_init(struct pipe_context *pctx)
|
|||
|
||||
pctx->create_sampler_view = vc4_create_sampler_view;
|
||||
pctx->sampler_view_destroy = vc4_sampler_view_destroy;
|
||||
pctx->sampler_view_release = u_default_sampler_view_release;
|
||||
pctx->set_sampler_views = vc4_set_sampler_views;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1142,7 +1142,6 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
|
|||
unsigned start_slot,
|
||||
unsigned num_views,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct virgl_context *vctx = virgl_context(ctx);
|
||||
|
|
@ -1155,12 +1154,7 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
|
|||
struct virgl_resource *res = virgl_resource(views[i]->texture);
|
||||
res->bind_history |= PIPE_BIND_SAMPLER_VIEW;
|
||||
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&binding->views[idx], NULL);
|
||||
binding->views[idx] = views[i];
|
||||
} else {
|
||||
pipe_sampler_view_reference(&binding->views[idx], views[i]);
|
||||
}
|
||||
} else {
|
||||
pipe_sampler_view_reference(&binding->views[idx], NULL);
|
||||
}
|
||||
|
|
@ -1172,7 +1166,7 @@ static void virgl_set_sampler_views(struct pipe_context *ctx,
|
|||
|
||||
if (unbind_num_trailing_slots) {
|
||||
virgl_set_sampler_views(ctx, shader_type, start_slot + num_views,
|
||||
unbind_num_trailing_slots, 0, false, NULL);
|
||||
unbind_num_trailing_slots, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1756,6 +1750,7 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
|
|||
vctx->base.screen = pscreen;
|
||||
vctx->base.create_sampler_view = virgl_create_sampler_view;
|
||||
vctx->base.sampler_view_destroy = virgl_destroy_sampler_view;
|
||||
vctx->base.sampler_view_release = u_default_sampler_view_release;
|
||||
vctx->base.set_sampler_views = virgl_set_sampler_views;
|
||||
vctx->base.texture_barrier = virgl_texture_barrier;
|
||||
|
||||
|
|
|
|||
|
|
@ -2247,11 +2247,9 @@ zink_set_sampler_views(struct pipe_context *pctx,
|
|||
unsigned start_slot,
|
||||
unsigned num_views,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views)
|
||||
{
|
||||
struct zink_context *ctx = zink_context(pctx);
|
||||
|
||||
const uint32_t mask = BITFIELD_RANGE(start_slot, num_views);
|
||||
uint32_t shadow_mask = ctx->di.zs_swizzle[shader_type].mask;
|
||||
ctx->di.cubes[shader_type] &= ~mask;
|
||||
|
|
@ -2265,10 +2263,6 @@ zink_set_sampler_views(struct pipe_context *pctx,
|
|||
struct zink_sampler_view *b = zink_sampler_view(pview);
|
||||
|
||||
if (a == b) {
|
||||
if (take_ownership) {
|
||||
struct pipe_sampler_view *view = views[i];
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -2353,12 +2347,7 @@ zink_set_sampler_views(struct pipe_context *pctx,
|
|||
unbind_samplerview(ctx, shader_type, start_slot + i);
|
||||
update = true;
|
||||
}
|
||||
if (take_ownership) {
|
||||
pipe_sampler_view_reference(&ctx->sampler_views[shader_type][start_slot + i], NULL);
|
||||
ctx->sampler_views[shader_type][start_slot + i] = pview;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&ctx->sampler_views[shader_type][start_slot + i], pview);
|
||||
}
|
||||
update_descriptor_state_sampler(ctx, shader_type, start_slot + i, res);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2369,9 +2358,7 @@ zink_set_sampler_views(struct pipe_context *pctx,
|
|||
unsigned slot = start_slot + num_views + i;
|
||||
update |= !!ctx->sampler_views[shader_type][slot];
|
||||
unbind_samplerview(ctx, shader_type, slot);
|
||||
pipe_sampler_view_reference(
|
||||
&ctx->sampler_views[shader_type][slot],
|
||||
NULL);
|
||||
pipe_sampler_view_reference(&ctx->sampler_views[shader_type][slot], NULL);
|
||||
update_descriptor_state_sampler(ctx, shader_type, slot, NULL);
|
||||
}
|
||||
ctx->di.num_sampler_views[shader_type] = start_slot + num_views;
|
||||
|
|
@ -5449,6 +5436,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||
ctx->base.create_sampler_view = zink_create_sampler_view;
|
||||
ctx->base.set_sampler_views = zink_set_sampler_views;
|
||||
ctx->base.sampler_view_destroy = zink_sampler_view_destroy;
|
||||
ctx->base.sampler_view_release = u_default_sampler_view_release;
|
||||
ctx->base.get_sample_position = zink_get_sample_position;
|
||||
ctx->base.set_sample_locations = zink_set_sample_locations;
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ kernel::launch(command_queue &q,
|
|||
exec.samplers.data());
|
||||
|
||||
q.pipe->set_sampler_views(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
exec.sviews.size(), 0, false, exec.sviews.data());
|
||||
exec.sviews.size(), 0, exec.sviews.data());
|
||||
q.pipe->set_shader_images(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
exec.iviews.size(), 0, exec.iviews.data());
|
||||
q.pipe->set_compute_resources(q.pipe, 0, exec.resources.size(),
|
||||
|
|
@ -109,7 +109,7 @@ kernel::launch(command_queue &q,
|
|||
q.pipe->set_shader_images(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
0, exec.iviews.size(), NULL);
|
||||
q.pipe->set_sampler_views(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
0, exec.sviews.size(), false, NULL);
|
||||
0, exec.sviews.size(), NULL);
|
||||
q.pipe->bind_sampler_states(q.pipe, PIPE_SHADER_COMPUTE, 0,
|
||||
exec.samplers.size(), NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ resource::bind_sampler_view(command_queue &q) {
|
|||
void
|
||||
resource::unbind_sampler_view(command_queue &q,
|
||||
pipe_sampler_view *st) {
|
||||
q.pipe->sampler_view_destroy(q.pipe, st);
|
||||
q.pipe->sampler_view_release(q.pipe, st);
|
||||
}
|
||||
|
||||
pipe_image_view
|
||||
|
|
|
|||
|
|
@ -356,11 +356,11 @@ DestroyDevice(D3D10DDI_HDEVICE hDevice) // IN
|
|||
static struct pipe_sampler_view * sampler_views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||
memset(sampler_views, 0, sizeof sampler_views);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, false, sampler_views);
|
||||
PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, sampler_views);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0,
|
||||
PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, false, sampler_views);
|
||||
PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, sampler_views);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_GEOMETRY, 0,
|
||||
PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, false, sampler_views);
|
||||
PIPE_MAX_SHADER_SAMPLER_VIEWS, 0, sampler_views);
|
||||
|
||||
pipe->destroy(pipe);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ SetShaderResources(enum pipe_shader_type shader_type, // IN
|
|||
* probably think about not updating all always... It should just work.
|
||||
*/
|
||||
pipe->set_sampler_views(pipe, shader_type, 0, PIPE_MAX_SHADER_SAMPLER_VIEWS,
|
||||
0, false, sampler_views);
|
||||
0, sampler_views);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1358,7 +1358,11 @@ DestroyShaderResourceView(D3D10DDI_HDEVICE hDevice, //
|
|||
|
||||
ShaderResourceView *pSRView = CastShaderResourceView(hShaderResourceView);
|
||||
|
||||
pipe_sampler_view_reference(&pSRView->handle, NULL);
|
||||
Device *pDevice = CastDevice(hDevice);
|
||||
struct pipe_context *pipe = pDevice->pipe;
|
||||
|
||||
pipe->sampler_view_release(pipe, pSRView->handle);
|
||||
pSRView->handle = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,10 @@ NineBaseTexture9_dtor( struct NineBaseTexture9 *This )
|
|||
{
|
||||
DBG("This=%p\n", This);
|
||||
|
||||
pipe_sampler_view_reference(&This->view[0], NULL);
|
||||
pipe_sampler_view_reference(&This->view[1], NULL);
|
||||
nine_context_get_pipe_acquire(This->base.base.device);
|
||||
pipe_sampler_view_release_ptr(&This->view[0]);
|
||||
pipe_sampler_view_release_ptr(&This->view[1]);
|
||||
nine_context_get_pipe_release(This->base.base.device);
|
||||
|
||||
if (list_is_linked(&This->list))
|
||||
list_del(&This->list);
|
||||
|
|
@ -177,8 +179,10 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This )
|
|||
|
||||
DBG("updating LOD from %u to %u ...\n", This->managed.lod_resident, This->managed.lod);
|
||||
|
||||
pipe_sampler_view_reference(&This->view[0], NULL);
|
||||
pipe_sampler_view_reference(&This->view[1], NULL);
|
||||
nine_context_get_pipe_acquire(This->base.base.device);
|
||||
pipe_sampler_view_release_ptr(&This->view[0]);
|
||||
pipe_sampler_view_release_ptr(&This->view[1]);
|
||||
nine_context_get_pipe_release(This->base.base.device);
|
||||
|
||||
/* Allocate a new resource */
|
||||
hr = NineBaseTexture9_CreatePipeResource(This, This->managed.lod_resident != -1);
|
||||
|
|
@ -487,7 +491,10 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
|
|||
}
|
||||
assert(resource);
|
||||
|
||||
pipe_sampler_view_reference(&This->view[sRGB], NULL);
|
||||
pipe = nine_context_get_pipe_acquire(This->base.base.device);
|
||||
pipe->sampler_view_release(pipe, This->view[sRGB]);
|
||||
This->view[sRGB] = NULL;
|
||||
nine_context_get_pipe_release(This->base.base.device);
|
||||
|
||||
swizzle[0] = PIPE_SWIZZLE_X;
|
||||
swizzle[1] = PIPE_SWIZZLE_Y;
|
||||
|
|
|
|||
|
|
@ -636,7 +636,7 @@ NineDevice9_dtor( struct NineDevice9 *This )
|
|||
|
||||
nine_bind(&This->record, NULL);
|
||||
|
||||
pipe_sampler_view_reference(&This->dummy_sampler_view, NULL);
|
||||
This->context.pipe->sampler_view_release(This->context.pipe, This->dummy_sampler_view);
|
||||
pipe_resource_reference(&This->dummy_texture, NULL);
|
||||
pipe_resource_reference(&This->dummy_vbo, NULL);
|
||||
if (This->screen != This->screen_sw)
|
||||
|
|
|
|||
|
|
@ -418,11 +418,10 @@ name##_priv( struct NineDevice9 *device ARGS_FOR_DECLARATION( __VA_ARGS__ ) )
|
|||
x * _##y ,\
|
||||
args->_##y = NULL; \
|
||||
if (y) \
|
||||
pipe_sampler_view_reference(&args->_##y, y); ,\
|
||||
args->_##y = y;,\
|
||||
x *y ,\
|
||||
args->_##y ,\
|
||||
if (args->_##y) \
|
||||
pipe_sampler_view_reference(&args->_##y, NULL); ,\
|
||||
args->_##y = NULL;,\
|
||||
,\
|
||||
y
|
||||
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
|
|||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_textures,
|
||||
num_textures < context->enabled_sampler_count_ps ? context->enabled_sampler_count_ps - num_textures : 0,
|
||||
false, view);
|
||||
view);
|
||||
context->enabled_sampler_count_ps = num_textures;
|
||||
|
||||
if (commit_samplers)
|
||||
|
|
@ -1105,7 +1105,7 @@ update_textures_and_samplers(struct NineDevice9 *device)
|
|||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, num_textures,
|
||||
num_textures < context->enabled_sampler_count_vs ? context->enabled_sampler_count_vs - num_textures : 0,
|
||||
false, view);
|
||||
view);
|
||||
context->enabled_sampler_count_vs = num_textures;
|
||||
|
||||
if (commit_samplers)
|
||||
|
|
@ -1526,8 +1526,8 @@ CSMT_ITEM_NO_WAIT(nine_context_set_texture_apply,
|
|||
context->texture[stage].type = type;
|
||||
context->texture[stage].pstype = pstype;
|
||||
pipe_resource_reference(&context->texture[stage].resource, res);
|
||||
pipe_sampler_view_reference(&context->texture[stage].view[0], view0);
|
||||
pipe_sampler_view_reference(&context->texture[stage].view[1], view1);
|
||||
context->texture[stage].view[0] = view0;
|
||||
context->texture[stage].view[1] = view1;
|
||||
|
||||
context->changed.group |= NINE_STATE_TEXTURE;
|
||||
}
|
||||
|
|
@ -3051,9 +3051,9 @@ nine_context_clear(struct NineDevice9 *device)
|
|||
context->enabled_sampler_count_ps = 0;
|
||||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, 0,
|
||||
NINE_MAX_SAMPLERS_VS, false, NULL);
|
||||
NINE_MAX_SAMPLERS_VS, NULL);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0,
|
||||
NINE_MAX_SAMPLERS_PS, false, NULL);
|
||||
NINE_MAX_SAMPLERS_PS, NULL);
|
||||
|
||||
pipe->set_vertex_buffers(pipe, 0, NULL);
|
||||
|
||||
|
|
@ -3073,10 +3073,8 @@ nine_context_clear(struct NineDevice9 *device)
|
|||
context->texture[i].enabled = false;
|
||||
pipe_resource_reference(&context->texture[i].resource,
|
||||
NULL);
|
||||
pipe_sampler_view_reference(&context->texture[i].view[0],
|
||||
NULL);
|
||||
pipe_sampler_view_reference(&context->texture[i].view[1],
|
||||
NULL);
|
||||
context->texture[i].view[0] = NULL;
|
||||
context->texture[i].view[1] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use mesa_rust_gen::pipe_fd_type::*;
|
|||
use mesa_rust_gen::*;
|
||||
use mesa_rust_util::has_required_feature;
|
||||
|
||||
use std::mem;
|
||||
use std::mem::size_of;
|
||||
use std::os::raw::*;
|
||||
use std::ptr;
|
||||
|
|
@ -500,14 +499,9 @@ impl PipeContext {
|
|||
0,
|
||||
views.len() as u32,
|
||||
0,
|
||||
true,
|
||||
PipeSamplerView::as_pipe(views.as_mut_slice()),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// the take_ownership parameter of set_sampler_views is set to true, so we need to forget
|
||||
// about them on our side as ownership has been transferred to the driver.
|
||||
views.into_iter().for_each(mem::forget);
|
||||
}
|
||||
|
||||
pub fn clear_sampler_views(&self, count: u32) {
|
||||
|
|
@ -519,7 +513,6 @@ impl PipeContext {
|
|||
0,
|
||||
count,
|
||||
0,
|
||||
true,
|
||||
samplers.as_mut_ptr(),
|
||||
)
|
||||
}
|
||||
|
|
@ -674,6 +667,7 @@ fn has_required_cbs(context: &pipe_context) -> bool {
|
|||
& has_required_feature!(context, set_constant_buffer)
|
||||
& has_required_feature!(context, set_global_binding)
|
||||
& has_required_feature!(context, set_sampler_views)
|
||||
& has_required_feature!(context, sampler_view_release)
|
||||
& has_required_feature!(context, set_shader_images)
|
||||
& has_required_feature!(context, texture_map)
|
||||
& has_required_feature!(context, texture_subdata)
|
||||
|
|
|
|||
|
|
@ -324,7 +324,8 @@ impl<'c, 'r> PipeSamplerView<'c, 'r> {
|
|||
impl Drop for PipeSamplerView<'_, '_> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
pipe_sampler_view_reference(&mut ptr::null_mut(), self.view.as_ptr());
|
||||
let ctx = self.view.as_ref().context;
|
||||
(*ctx).sampler_view_release.unwrap()(ctx, self.view.as_ptr())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,7 +287,8 @@ vlVaDeassociateSubpicture(VADriverContextP ctx, VASubpictureID subpicture,
|
|||
while (surf->subpics.size && util_dynarray_top(&surf->subpics, vlVaSubpicture *) == NULL)
|
||||
(void)util_dynarray_pop(&surf->subpics, vlVaSubpicture *);
|
||||
}
|
||||
pipe_sampler_view_reference(&sub->sampler,NULL);
|
||||
sub->sampler->context->sampler_view_release(sub->sampler->context, sub->sampler);
|
||||
sub->sampler = NULL;
|
||||
mtx_unlock(&drv->mutex);
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ vlVdpBitmapSurfaceCreate(VdpDevice device,
|
|||
return VDP_STATUS_OK;
|
||||
|
||||
err_sampler:
|
||||
pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
||||
err_unlock:
|
||||
mtx_unlock(&dev->mutex);
|
||||
DeviceReference(&vlsurface->device, NULL);
|
||||
|
|
@ -134,8 +134,9 @@ vlVdpBitmapSurfaceDestroy(VdpBitmapSurface surface)
|
|||
if (!vlsurface)
|
||||
return VDP_STATUS_INVALID_HANDLE;
|
||||
|
||||
struct pipe_context *pipe = vlsurface->sampler_view->context;
|
||||
mtx_lock(&vlsurface->device->mutex);
|
||||
pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
||||
mtx_unlock(&vlsurface->device->mutex);
|
||||
|
||||
vlRemoveDataHTAB(surface);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
|
|||
no_compositor:
|
||||
vlRemoveDataHTAB(*device);
|
||||
no_handle:
|
||||
pipe_sampler_view_reference(&dev->dummy_sv, NULL);
|
||||
dev->context->sampler_view_release(dev->context, dev->dummy_sv);
|
||||
no_resource:
|
||||
dev->context->destroy(dev->context);
|
||||
no_context:
|
||||
|
|
@ -243,7 +243,7 @@ vlVdpDeviceFree(vlVdpDevice *dev)
|
|||
{
|
||||
mtx_destroy(&dev->mutex);
|
||||
vl_compositor_cleanup(&dev->compositor);
|
||||
pipe_sampler_view_reference(&dev->dummy_sv, NULL);
|
||||
dev->context->sampler_view_release(dev->context, dev->dummy_sv);
|
||||
dev->context->destroy(dev->context);
|
||||
dev->vscreen->destroy(dev->vscreen);
|
||||
FREE(dev);
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
|
|||
vl_median_filter_render(vmixer->noise_reduction.filter,
|
||||
sampler_view, surface_temp);
|
||||
|
||||
pipe_sampler_view_reference(&sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, sampler_view);
|
||||
pipe_surface_reference(&surface, NULL);
|
||||
|
||||
sampler_view = sampler_view_temp;
|
||||
|
|
@ -437,7 +437,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
|
|||
vl_matrix_filter_render(vmixer->sharpness.filter,
|
||||
sampler_view, surface_temp);
|
||||
|
||||
pipe_sampler_view_reference(&sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, sampler_view);
|
||||
pipe_surface_reference(&surface, NULL);
|
||||
|
||||
sampler_view = sampler_view_temp;
|
||||
|
|
@ -452,7 +452,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
|
|||
RectToPipe(destination_rect, &clip));
|
||||
|
||||
if(surface != dst->surface) {
|
||||
pipe_sampler_view_reference(&sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, sampler_view);
|
||||
pipe_surface_reference(&surface, NULL);
|
||||
}
|
||||
mtx_unlock(&vmixer->device->mutex);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
|
|||
return VDP_STATUS_OK;
|
||||
|
||||
err_resource:
|
||||
pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
||||
pipe_surface_reference(&vlsurface->surface, NULL);
|
||||
pipe_resource_reference(&res, NULL);
|
||||
err_unlock:
|
||||
|
|
@ -156,7 +156,7 @@ vlVdpOutputSurfaceDestroy(VdpOutputSurface surface)
|
|||
mtx_lock(&vlsurface->device->mutex);
|
||||
|
||||
pipe_surface_reference(&vlsurface->surface, NULL);
|
||||
pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
|
||||
pipe->sampler_view_release(pipe, vlsurface->sampler_view);
|
||||
pipe->screen->fence_reference(pipe->screen, &vlsurface->fence, NULL);
|
||||
vl_compositor_cleanup_state(&vlsurface->cstate);
|
||||
mtx_unlock(&vlsurface->device->mutex);
|
||||
|
|
@ -412,15 +412,15 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
|
|||
vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
|
||||
vl_compositor_render(cstate, compositor, vlsurface->surface, &vlsurface->dirty_area, false);
|
||||
|
||||
pipe_sampler_view_reference(&sv_idx, NULL);
|
||||
pipe_sampler_view_reference(&sv_tbl, NULL);
|
||||
context->sampler_view_release(context, sv_idx);
|
||||
context->sampler_view_release(context, sv_tbl);
|
||||
mtx_unlock(&vlsurface->device->mutex);
|
||||
|
||||
return VDP_STATUS_OK;
|
||||
|
||||
error_resource:
|
||||
pipe_sampler_view_reference(&sv_idx, NULL);
|
||||
pipe_sampler_view_reference(&sv_tbl, NULL);
|
||||
context->sampler_view_release(context, sv_idx);
|
||||
context->sampler_view_release(context, sv_tbl);
|
||||
mtx_unlock(&vlsurface->device->mutex);
|
||||
return VDP_STATUS_RESOURCES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ bind_samplers(struct xa_context *ctx,
|
|||
cso_set_samplers(ctx->cso, PIPE_SHADER_FRAGMENT, num_samplers,
|
||||
(const struct pipe_sampler_state **)samplers);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_samplers, 0,
|
||||
false, ctx->bound_sampler_views);
|
||||
ctx->bound_sampler_views);
|
||||
ctx->num_bound_samplers = num_samplers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst,
|
|||
bind_solid_blend_state(ctx);
|
||||
cso_set_samplers(ctx->cso, PIPE_SHADER_FRAGMENT, 0, NULL);
|
||||
ctx->pipe->set_sampler_views(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, 0,
|
||||
XA_MAX_SAMPLERS, false, NULL);
|
||||
XA_MAX_SAMPLERS, NULL);
|
||||
|
||||
shader = xa_shaders_get(ctx->shaders, vs_traits, fs_traits);
|
||||
cso_set_vertex_shader_handle(ctx->cso, shader.vs);
|
||||
|
|
@ -415,6 +415,7 @@ xa_ctx_sampler_views_destroy(struct xa_context *ctx)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < ctx->num_bound_samplers; ++i)
|
||||
pipe_sampler_view_reference(&ctx->bound_sampler_views[i], NULL);
|
||||
ctx->pipe->sampler_view_release(ctx->pipe, ctx->bound_sampler_views[i]);
|
||||
memset(ctx->bound_sampler_views, 0, sizeof(ctx->bound_sampler_views));
|
||||
ctx->num_bound_samplers = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -447,8 +447,8 @@ renderer_copy_prepare(struct xa_context *r,
|
|||
u_sampler_view_default_template(&templ,
|
||||
src_texture, src_texture->format);
|
||||
src_view = pipe->create_sampler_view(pipe, src_texture, &templ);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &src_view);
|
||||
pipe_sampler_view_reference(&src_view, NULL);
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &src_view);
|
||||
pipe->sampler_view_release(pipe, src_view);
|
||||
}
|
||||
|
||||
/* shaders */
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ xa_yuv_bind_samplers(struct xa_context *r, struct xa_surface *yuv[])
|
|||
}
|
||||
r->num_bound_samplers = 3;
|
||||
cso_set_samplers(r->cso, PIPE_SHADER_FRAGMENT, 3, (const struct pipe_sampler_state **)samplers);
|
||||
r->pipe->set_sampler_views(r->pipe, PIPE_SHADER_FRAGMENT, 0, 3, 0, false, r->bound_sampler_views);
|
||||
r->pipe->set_sampler_views(r->pipe, PIPE_SHADER_FRAGMENT, 0, 3, 0, r->bound_sampler_views);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -538,7 +538,6 @@ struct pipe_context {
|
|||
enum pipe_shader_type shader,
|
||||
unsigned start_slot, unsigned num_views,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
struct pipe_sampler_view **views);
|
||||
|
||||
void (*set_tess_state)(struct pipe_context *,
|
||||
|
|
@ -840,6 +839,19 @@ struct pipe_context {
|
|||
void (*sampler_view_destroy)(struct pipe_context *ctx,
|
||||
struct pipe_sampler_view *view);
|
||||
|
||||
/**
|
||||
* Signal the driver that the frontend has released a view on a texture.
|
||||
*
|
||||
* \param ctx the current context
|
||||
* \param view the view to be released
|
||||
*
|
||||
* \note The current context may not be the context in which the view was
|
||||
* created (view->context). Following this call, the driver has full
|
||||
* ownership of the view.
|
||||
*/
|
||||
void (*sampler_view_release)(struct pipe_context *ctx,
|
||||
struct pipe_sampler_view *view);
|
||||
|
||||
|
||||
/**
|
||||
* Get a surface which is a "view" into a resource, used by
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ static void draw(struct program *p)
|
|||
cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers);
|
||||
|
||||
/* texture sampler view */
|
||||
p->pipe->set_sampler_views(p->pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, false, &p->view);
|
||||
p->pipe->set_sampler_views(p->pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &p->view);
|
||||
|
||||
/* shaders */
|
||||
cso_set_fragment_shader_handle(p->cso, p->fs);
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ class Context(Dispatcher):
|
|||
def sampler_view_destroy(self, view):
|
||||
pass
|
||||
|
||||
def set_sampler_views(self, shader, start, num, unbind_num_trailing_slots, take_ownership, views):
|
||||
def set_sampler_views(self, shader, start, num, unbind_num_trailing_slots, views):
|
||||
# FIXME: Handle non-zero start
|
||||
assert start == 0
|
||||
self._get_stage_state(shader).sampler_views = views
|
||||
|
|
|
|||
|
|
@ -237,9 +237,9 @@ new_texture_handle(struct gl_context *ctx, struct gl_texture_object *texObj,
|
|||
|
||||
/* TODO: Clarify the interaction of ARB_bindless_texture and EXT_texture_sRGB_decode */
|
||||
view = st_get_texture_sampler_view_from_stobj(st, texObj, sampObj, 0,
|
||||
true, false);
|
||||
false);
|
||||
} else {
|
||||
view = st_get_buffer_sampler_view_from_stobj(st, texObj, false);
|
||||
view = st_get_buffer_sampler_view_from_stobj(st, texObj);
|
||||
sampler.unnormalized_coords = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
struct pipe_sampler_view *
|
||||
st_update_single_texture(struct st_context *st,
|
||||
GLuint texUnit, bool glsl130_or_later,
|
||||
bool ignore_srgb_decode, bool get_reference)
|
||||
bool ignore_srgb_decode)
|
||||
{
|
||||
struct gl_context *ctx = st->ctx;
|
||||
struct gl_texture_object *texObj;
|
||||
|
|
@ -69,7 +69,7 @@ st_update_single_texture(struct st_context *st,
|
|||
GLenum target = texObj->Target;
|
||||
|
||||
if (unlikely(target == GL_TEXTURE_BUFFER))
|
||||
return st_get_buffer_sampler_view_from_stobj(st, texObj, get_reference);
|
||||
return st_get_buffer_sampler_view_from_stobj(st, texObj);
|
||||
|
||||
if (!st_finalize_texture(ctx, st->pipe, texObj, 0) || !texObj->pt)
|
||||
return NULL; /* out of mem */
|
||||
|
|
@ -81,7 +81,7 @@ st_update_single_texture(struct st_context *st,
|
|||
return st_get_texture_sampler_view_from_stobj(st, texObj,
|
||||
_mesa_get_samplerobj(ctx, texUnit),
|
||||
glsl130_or_later,
|
||||
ignore_srgb_decode, get_reference);
|
||||
ignore_srgb_decode);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -90,7 +90,8 @@ unsigned
|
|||
st_get_sampler_views(struct st_context *st,
|
||||
enum pipe_shader_type shader_stage,
|
||||
const struct gl_program *prog,
|
||||
struct pipe_sampler_view **sampler_views)
|
||||
struct pipe_sampler_view **sampler_views,
|
||||
unsigned *num_owned_views)
|
||||
{
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
const GLuint old_max = st->state.num_sampler_views[shader_stage];
|
||||
|
|
@ -99,6 +100,7 @@ st_get_sampler_views(struct st_context *st,
|
|||
GLbitfield free_slots = ~prog->SamplersUsed;
|
||||
GLbitfield external_samplers_used = prog->ExternalSamplersUsed;
|
||||
GLuint unit;
|
||||
*num_owned_views = 0;
|
||||
|
||||
if (samplers_used == 0x0 && old_max == 0)
|
||||
return 0;
|
||||
|
|
@ -145,7 +147,7 @@ st_get_sampler_views(struct st_context *st,
|
|||
*/
|
||||
sampler_views[unit] =
|
||||
st_update_single_texture(st, prog->SamplerUnits[unit], glsl130,
|
||||
texel_fetch_samplers & bit, true);
|
||||
texel_fetch_samplers & bit);
|
||||
}
|
||||
|
||||
/* For any external samplers with multiplaner YUV, stuff the additional
|
||||
|
|
@ -281,6 +283,9 @@ st_get_sampler_views(struct st_context *st,
|
|||
break;
|
||||
}
|
||||
|
||||
if (extra)
|
||||
(*num_owned_views) = extra;
|
||||
|
||||
num_textures = MAX2(num_textures, extra + 1);
|
||||
}
|
||||
|
||||
|
|
@ -294,16 +299,24 @@ update_textures(struct st_context *st,
|
|||
{
|
||||
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
unsigned num_owned_views = 0;
|
||||
unsigned num_textures =
|
||||
st_get_sampler_views(st, shader_stage, prog, sampler_views);
|
||||
st_get_sampler_views(st, shader_stage, prog, sampler_views, &num_owned_views);
|
||||
|
||||
unsigned old_num_textures = st->state.num_sampler_views[shader_stage];
|
||||
unsigned num_unbind = old_num_textures > num_textures ?
|
||||
old_num_textures - num_textures : 0;
|
||||
|
||||
pipe->set_sampler_views(pipe, shader_stage, 0, num_textures, num_unbind,
|
||||
true, sampler_views);
|
||||
sampler_views);
|
||||
st->state.num_sampler_views[shader_stage] = num_textures;
|
||||
|
||||
/* release YUV views back to driver */
|
||||
if (pipe->sampler_view_release) {
|
||||
unsigned base_idx = num_textures - num_owned_views;
|
||||
for (unsigned i = 0; i < num_owned_views; i++)
|
||||
pipe->sampler_view_release(pipe, sampler_views[base_idx + i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -243,15 +243,19 @@ setup_render_state(struct gl_context *ctx,
|
|||
|
||||
/* user textures, plus the bitmap texture */
|
||||
{
|
||||
unsigned num_owned_views = 0;
|
||||
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
|
||||
unsigned num_views =
|
||||
st_get_sampler_views(st, PIPE_SHADER_FRAGMENT, fp, sampler_views);
|
||||
st_get_sampler_views(st, PIPE_SHADER_FRAGMENT, fp, sampler_views, &num_owned_views);
|
||||
|
||||
num_views = MAX2(fpv->bitmap_sampler + 1, num_views);
|
||||
sampler_views[fpv->bitmap_sampler] = sv;
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_views, 0,
|
||||
true, sampler_views);
|
||||
sampler_views);
|
||||
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = num_views;
|
||||
|
||||
for (unsigned i = 0; i < num_views; i++)
|
||||
pipe->sampler_view_release(pipe, sampler_views[i]);
|
||||
}
|
||||
|
||||
/* viewport state: viewport matching window dims */
|
||||
|
|
|
|||
|
|
@ -846,11 +846,12 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
|
|||
|
||||
/* user textures, plus the drawpix textures */
|
||||
if (fpv) {
|
||||
/* drawing a color image */
|
||||
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
|
||||
unsigned num_owned_views = 0;
|
||||
/* drawing a color image */
|
||||
unsigned num_views =
|
||||
st_get_sampler_views(st, PIPE_SHADER_FRAGMENT,
|
||||
ctx->FragmentProgram._Current, sampler_views);
|
||||
ctx->FragmentProgram._Current, sampler_views, &num_owned_views);
|
||||
|
||||
num_views = MAX3(fpv->drawpix_sampler + 1, fpv->pixelmap_sampler + 1,
|
||||
num_views);
|
||||
|
|
@ -859,12 +860,17 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
|
|||
if (sv[1])
|
||||
sampler_views[fpv->pixelmap_sampler] = sv[1];
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_views, 0,
|
||||
true, sampler_views);
|
||||
sampler_views);
|
||||
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = num_views;
|
||||
|
||||
/* release YUV views back to driver */
|
||||
unsigned base_idx = num_views - num_owned_views;
|
||||
for (unsigned i = 0; i < num_owned_views; i++)
|
||||
pipe->sampler_view_release(pipe, sampler_views[base_idx + i]);
|
||||
} else {
|
||||
/* drawing a depth/stencil image */
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_view,
|
||||
0, false, sv);
|
||||
0, sv);
|
||||
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
|
||||
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num_sampler_view);
|
||||
}
|
||||
|
|
@ -1319,8 +1325,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
driver_fp = fpv->base.driver_shader;
|
||||
|
||||
if (ctx->Pixel.MapColorFlag && format != GL_COLOR_INDEX) {
|
||||
pipe_sampler_view_reference(&sv[1],
|
||||
st->pixel_xfer.pixelmap_sampler_view);
|
||||
sv[1] = st->pixel_xfer.pixelmap_sampler_view;
|
||||
num_sampler_view++;
|
||||
}
|
||||
|
||||
|
|
@ -1359,7 +1364,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
if (!sv[1]) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
|
||||
pipe_resource_reference(&pt, NULL);
|
||||
pipe_sampler_view_reference(&sv[0], NULL);
|
||||
st->pipe->sampler_view_release(st->pipe, sv[0]);
|
||||
return;
|
||||
}
|
||||
num_sampler_view++;
|
||||
|
|
@ -1377,7 +1382,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
|
||||
|
||||
for (unsigned i = 0; i < num_sampler_view; i++)
|
||||
pipe_sampler_view_reference(&sv[i], NULL);
|
||||
st->pipe->sampler_view_release(st->pipe, sv[i]);
|
||||
|
||||
/* free the texture (but may persist in the cache) */
|
||||
pipe_resource_reference(&pt, NULL);
|
||||
|
|
@ -1662,6 +1667,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
|
||||
GLboolean write_stencil = GL_FALSE;
|
||||
GLboolean write_depth = GL_FALSE;
|
||||
bool frontend_owns_sv1 = false;
|
||||
|
||||
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
|
||||
|
||||
|
|
@ -1708,8 +1714,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
driver_fp = fpv->base.driver_shader;
|
||||
|
||||
if (ctx->Pixel.MapColorFlag) {
|
||||
pipe_sampler_view_reference(&sv[1],
|
||||
st->pixel_xfer.pixelmap_sampler_view);
|
||||
sv[1] = st->pixel_xfer.pixelmap_sampler_view;
|
||||
num_sampler_view++;
|
||||
}
|
||||
|
||||
|
|
@ -1853,10 +1858,11 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
if (!sv[1]) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
|
||||
pipe_resource_reference(&pt, NULL);
|
||||
pipe_sampler_view_reference(&sv[0], NULL);
|
||||
st->pipe->sampler_view_release(st->pipe, sv[0]);
|
||||
return;
|
||||
}
|
||||
num_sampler_view++;
|
||||
frontend_owns_sv1 = true;
|
||||
}
|
||||
/* Copy the src region to the temporary texture. */
|
||||
{
|
||||
|
|
@ -1905,8 +1911,9 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
ctx->Current.Attrib[VERT_ATTRIB_COLOR0],
|
||||
invertTex, write_depth, write_stencil);
|
||||
|
||||
for (unsigned i = 0; i < num_sampler_view; i++)
|
||||
pipe_sampler_view_reference(&sv[i], NULL);
|
||||
st->pipe->sampler_view_release(st->pipe, sv[0]);
|
||||
if (frontend_owns_sv1)
|
||||
st->pipe->sampler_view_release(st->pipe, sv[1]);
|
||||
|
||||
pipe_resource_reference(&pt, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,11 +189,11 @@ try_pbo_readpixels(struct st_context *st, struct gl_renderbuffer *rb,
|
|||
goto fail;
|
||||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0,
|
||||
false, &sampler_view);
|
||||
&sampler_view);
|
||||
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
|
||||
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], 1);
|
||||
|
||||
pipe_sampler_view_reference(&sampler_view, NULL);
|
||||
pipe_sampler_view_release(sampler_view);
|
||||
|
||||
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, 1, samplers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1770,11 +1770,11 @@ try_pbo_upload_common(struct gl_context *ctx,
|
|||
goto fail;
|
||||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0,
|
||||
false, &sampler_view);
|
||||
&sampler_view);
|
||||
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
|
||||
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], 1);
|
||||
|
||||
pipe_sampler_view_reference(&sampler_view, NULL);
|
||||
pipe_sampler_view_release(sampler_view);
|
||||
}
|
||||
|
||||
/* Framebuffer_state */
|
||||
|
|
@ -2039,8 +2039,8 @@ try_pbo_download(struct st_context *st,
|
|||
if (sampler_view == NULL)
|
||||
goto fail;
|
||||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, true, &sampler_view);
|
||||
sampler_view = NULL;
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &sampler_view);
|
||||
pipe->sampler_view_release(pipe, sampler_view);
|
||||
|
||||
cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, 1, samplers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ free_zombie_sampler_views(struct st_context *st)
|
|||
list_del(&entry->node); // remove this entry from the list
|
||||
|
||||
assert(entry->view->context == st->pipe);
|
||||
pipe_sampler_view_reference(&entry->view, NULL);
|
||||
st->pipe->sampler_view_release(st->pipe, entry->view);
|
||||
|
||||
free(entry);
|
||||
}
|
||||
|
|
@ -952,7 +952,7 @@ st_destroy_context(struct st_context *st)
|
|||
|
||||
_mesa_HashWalk(&ctx->Shared->FrameBuffers, destroy_framebuffer_attachment_sampler_cb, st);
|
||||
|
||||
pipe_sampler_view_reference(&st->pixel_xfer.pixelmap_sampler_view, NULL);
|
||||
st->pipe->sampler_view_release(st->pipe, st->pixel_xfer.pixelmap_sampler_view);
|
||||
pipe_resource_reference(&st->pixel_xfer.pixelmap_texture, NULL);
|
||||
|
||||
_vbo_DestroyContext(ctx);
|
||||
|
|
|
|||
|
|
@ -259,8 +259,9 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
|||
|
||||
/* sampler views */
|
||||
struct pipe_sampler_view *views[PIPE_MAX_SAMPLERS];
|
||||
unsigned num_owned_views = 0;
|
||||
unsigned num_views =
|
||||
st_get_sampler_views(st, PIPE_SHADER_VERTEX, prog, views);
|
||||
st_get_sampler_views(st, PIPE_SHADER_VERTEX, prog, views, &num_owned_views);
|
||||
|
||||
draw_set_sampler_views(draw, PIPE_SHADER_VERTEX, views, num_views);
|
||||
|
||||
|
|
@ -415,14 +416,17 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
|||
} else {
|
||||
pipe_buffer_unmap(pipe, sv_transfer[i][0]);
|
||||
}
|
||||
|
||||
pipe_sampler_view_reference(&views[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
draw_set_samplers(draw, PIPE_SHADER_VERTEX, NULL, 0);
|
||||
draw_set_sampler_views(draw, PIPE_SHADER_VERTEX, NULL, 0);
|
||||
|
||||
/* release YUV views back to driver */
|
||||
unsigned base_idx = num_views - num_owned_views;
|
||||
for (unsigned i = 0; i < num_owned_views; i++)
|
||||
pipe->sampler_view_release(pipe, views[base_idx + i]);
|
||||
|
||||
for (unsigned i = 0; i < prog->info.num_ssbos; i++) {
|
||||
if (ssbo_transfer[i]) {
|
||||
draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 1 + i,
|
||||
|
|
|
|||
|
|
@ -1009,9 +1009,9 @@ download_texture_compute(struct st_context *st,
|
|||
cso_set_compute_shader_handle(cso, cs);
|
||||
|
||||
/* Set up the sampler_view */
|
||||
struct pipe_sampler_view *sampler_view = NULL;
|
||||
{
|
||||
struct pipe_sampler_view templ;
|
||||
struct pipe_sampler_view *sampler_view;
|
||||
struct pipe_sampler_state sampler = {0};
|
||||
const struct pipe_sampler_state *samplers[1] = {&sampler};
|
||||
const struct util_format_description *desc = util_format_description(dst_format);
|
||||
|
|
@ -1111,13 +1111,11 @@ download_texture_compute(struct st_context *st,
|
|||
if (sampler_view == NULL)
|
||||
goto fail;
|
||||
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_COMPUTE, 0, 1, 0, false,
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_COMPUTE, 0, 1, 0,
|
||||
&sampler_view);
|
||||
st->state.num_sampler_views[PIPE_SHADER_COMPUTE] =
|
||||
MAX2(st->state.num_sampler_views[PIPE_SHADER_COMPUTE], 1);
|
||||
|
||||
pipe_sampler_view_reference(&sampler_view, NULL);
|
||||
|
||||
cso_set_samplers(cso, PIPE_SHADER_COMPUTE, 1, samplers);
|
||||
}
|
||||
|
||||
|
|
@ -1159,6 +1157,7 @@ download_texture_compute(struct st_context *st,
|
|||
|
||||
pipe->launch_grid(pipe, &info);
|
||||
|
||||
st->pipe->sampler_view_release(st->pipe, sampler_view);
|
||||
fail:
|
||||
cso_restore_compute_state(cso);
|
||||
|
||||
|
|
@ -1167,7 +1166,7 @@ fail:
|
|||
*/
|
||||
pipe->set_sampler_views(pipe, PIPE_SHADER_COMPUTE, 0, 0,
|
||||
st->state.num_sampler_views[PIPE_SHADER_COMPUTE],
|
||||
false, NULL);
|
||||
NULL);
|
||||
st->state.num_sampler_views[PIPE_SHADER_COMPUTE] = 0;
|
||||
pipe->set_shader_buffers(pipe, PIPE_SHADER_COMPUTE, 0, 1, NULL, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,37 +40,6 @@
|
|||
#include "st_format.h"
|
||||
#include "st_cb_texture.h"
|
||||
|
||||
/* Subtract remaining private references. Typically used before
|
||||
* destruction. See the header file for explanation.
|
||||
*/
|
||||
static void
|
||||
st_remove_private_references(struct st_sampler_view *sv)
|
||||
{
|
||||
if (sv->private_refcount) {
|
||||
assert(sv->private_refcount > 0);
|
||||
p_atomic_add(&sv->view->reference.count, -sv->private_refcount);
|
||||
sv->private_refcount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a sampler view while incrementing the refcount by 1. */
|
||||
static struct pipe_sampler_view *
|
||||
get_sampler_view_reference(struct st_sampler_view *sv,
|
||||
struct pipe_sampler_view *view)
|
||||
{
|
||||
if (unlikely(sv->private_refcount <= 0)) {
|
||||
assert(sv->private_refcount == 0);
|
||||
|
||||
/* This is the number of atomic increments we will skip. */
|
||||
sv->private_refcount = 100000000;
|
||||
p_atomic_add(&view->reference.count, sv->private_refcount);
|
||||
}
|
||||
|
||||
/* Return a reference while decrementing the private refcount. */
|
||||
sv->private_refcount--;
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given view as the current context's view for the texture.
|
||||
*
|
||||
|
|
@ -87,7 +56,7 @@ st_texture_set_sampler_view(struct st_context *st,
|
|||
struct gl_texture_object *stObj,
|
||||
struct pipe_sampler_view *view,
|
||||
bool glsl130_or_later, bool srgb_skip_decode,
|
||||
bool get_reference, bool locked)
|
||||
bool locked)
|
||||
{
|
||||
struct st_sampler_views *views;
|
||||
struct st_sampler_view *free = NULL;
|
||||
|
|
@ -105,8 +74,8 @@ st_texture_set_sampler_view(struct st_context *st,
|
|||
if (sv->view) {
|
||||
/* check if the context matches */
|
||||
if (sv->view->context == st->pipe) {
|
||||
st_remove_private_references(sv);
|
||||
pipe_sampler_view_reference(&sv->view, NULL);
|
||||
st->pipe->sampler_view_release(st->pipe, sv->view);
|
||||
sv->view = NULL;
|
||||
goto found;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -126,13 +95,13 @@ st_texture_set_sampler_view(struct st_context *st,
|
|||
|
||||
if (new_max < views->max ||
|
||||
new_max > (UINT_MAX - sizeof(*views)) / sizeof(views->views[0])) {
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
pipe_sampler_view_release_ptr(&view);
|
||||
goto out;
|
||||
}
|
||||
|
||||
struct st_sampler_views *new_views = malloc(new_size);
|
||||
if (!new_views) {
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
pipe_sampler_view_release_ptr(&view);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -184,9 +153,6 @@ found:
|
|||
sv->view = view;
|
||||
sv->st = st;
|
||||
|
||||
if (get_reference)
|
||||
view = get_sampler_view_reference(sv, view);
|
||||
|
||||
out:
|
||||
if (!locked)
|
||||
simple_mtx_unlock(&stObj->validate_mutex);
|
||||
|
|
@ -233,8 +199,7 @@ st_texture_release_context_sampler_view(struct st_context *st,
|
|||
struct st_sampler_view *sv = &views->views[i];
|
||||
|
||||
if (sv->view && sv->view->context == st->pipe) {
|
||||
st_remove_private_references(sv);
|
||||
pipe_sampler_view_reference(&sv->view, NULL);
|
||||
pipe_sampler_view_release_ptr(&sv->view);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -263,8 +228,6 @@ st_texture_release_all_sampler_views(struct st_context *st,
|
|||
for (unsigned i = 0; i < views->count; ++i) {
|
||||
struct st_sampler_view *stsv = &views->views[i];
|
||||
if (stsv->view) {
|
||||
st_remove_private_references(stsv);
|
||||
|
||||
if (stsv->st && stsv->st != st) {
|
||||
/* Transfer this reference to the zombie list. It will
|
||||
* likely be freed when the zombie list is freed.
|
||||
|
|
@ -272,7 +235,7 @@ st_texture_release_all_sampler_views(struct st_context *st,
|
|||
st_save_zombie_sampler_view(stsv->st, stsv->view);
|
||||
stsv->view = NULL;
|
||||
} else {
|
||||
pipe_sampler_view_reference(&stsv->view, NULL);
|
||||
pipe_sampler_view_release_ptr(&stsv->view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -530,8 +493,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
struct gl_texture_object *texObj,
|
||||
const struct gl_sampler_object *samp,
|
||||
bool glsl130_or_later,
|
||||
bool ignore_srgb_decode,
|
||||
bool get_reference)
|
||||
bool ignore_srgb_decode)
|
||||
{
|
||||
struct st_sampler_view *sv;
|
||||
bool srgb_skip_decode = false;
|
||||
|
|
@ -563,8 +525,6 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
assert(texObj->layer_override < 0 ||
|
||||
(texObj->layer_override == view->u.tex.first_layer &&
|
||||
texObj->layer_override == view->u.tex.last_layer));
|
||||
if (get_reference)
|
||||
view = get_sampler_view_reference(sv, view);
|
||||
simple_mtx_unlock(&texObj->validate_mutex);
|
||||
return view;
|
||||
}
|
||||
|
|
@ -578,7 +538,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
|
||||
view = st_texture_set_sampler_view(st, texObj, view,
|
||||
glsl130_or_later, srgb_skip_decode,
|
||||
get_reference, true);
|
||||
true);
|
||||
simple_mtx_unlock(&texObj->validate_mutex);
|
||||
|
||||
return view;
|
||||
|
|
@ -587,8 +547,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
|
||||
struct pipe_sampler_view *
|
||||
st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
||||
struct gl_texture_object *texObj,
|
||||
bool get_reference)
|
||||
struct gl_texture_object *texObj)
|
||||
{
|
||||
struct st_sampler_view *sv;
|
||||
struct gl_buffer_object *stBuf =
|
||||
|
|
@ -617,8 +576,6 @@ st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
|||
(unsigned) texObj->BufferSize);
|
||||
assert(view->u.buf.offset == base);
|
||||
assert(view->u.buf.size == size);
|
||||
if (get_reference)
|
||||
view = get_sampler_view_reference(sv, view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
|
@ -653,7 +610,7 @@ st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
|||
st->pipe->create_sampler_view(st->pipe, buf, &templ);
|
||||
|
||||
view = st_texture_set_sampler_view(st, texObj, view, false, false,
|
||||
get_reference, false);
|
||||
false);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,13 +75,11 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
struct gl_texture_object *stObj,
|
||||
const struct gl_sampler_object *samp,
|
||||
bool glsl130_or_later,
|
||||
bool ignore_srgb_decode,
|
||||
bool get_reference);
|
||||
bool ignore_srgb_decode);
|
||||
|
||||
struct pipe_sampler_view *
|
||||
st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
||||
struct gl_texture_object *stObj,
|
||||
bool get_reference);
|
||||
struct gl_texture_object *stObj);
|
||||
|
||||
enum pipe_format
|
||||
st_get_sampler_view_format(const struct st_context *st,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue