From 98e8dc1db8fcf3b31dd3d1ab20b616e17565a986 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 20 Dec 2020 02:49:07 -0500 Subject: [PATCH] gallium/pp: don't use cso_context to restore VBs, constbuf 0 and sampler views MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit These cso_context capabilities will be removed. Reviewed-by: Eric Anholt Reviewed-by: Zoltán Böszörményi Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/auxiliary/postprocess/postprocess.h | 4 +++- src/gallium/auxiliary/postprocess/pp_colors.c | 3 ++- src/gallium/auxiliary/postprocess/pp_init.c | 4 ++-- src/gallium/auxiliary/postprocess/pp_mlaa.c | 19 +++++++++++------- src/gallium/auxiliary/postprocess/pp_private.h | 3 ++- src/gallium/auxiliary/postprocess/pp_program.c | 3 ++- src/gallium/auxiliary/postprocess/pp_run.c | 23 ++++++++++++++++------ src/gallium/frontends/dri/dri_context.c | 3 ++- src/gallium/frontends/osmesa/osmesa.c | 3 ++- .../targets/haiku-softpipe/GalliumContext.cpp | 2 +- 10 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/gallium/auxiliary/postprocess/postprocess.h b/src/gallium/auxiliary/postprocess/postprocess.h index 9b9f981..293bd5a 100644 --- a/src/gallium/auxiliary/postprocess/postprocess.h +++ b/src/gallium/auxiliary/postprocess/postprocess.h @@ -35,6 +35,7 @@ extern "C" { #endif struct cso_context; +struct st_context_iface; struct pp_queue_t; /* Forward definition */ struct pp_program; @@ -52,7 +53,8 @@ typedef void (*pp_func) (struct pp_queue_t *, struct pipe_resource *, */ struct pp_queue_t *pp_init(struct pipe_context *pipe, const unsigned int *enabled, - struct cso_context *); + struct cso_context *, + struct st_context_iface *st); void pp_run(struct pp_queue_t *, struct pipe_resource *, struct pipe_resource *, struct pipe_resource *); diff --git a/src/gallium/auxiliary/postprocess/pp_colors.c b/src/gallium/auxiliary/postprocess/pp_colors.c index e6ea010..4240364 100644 --- a/src/gallium/auxiliary/postprocess/pp_colors.c +++ b/src/gallium/auxiliary/postprocess/pp_colors.c @@ -37,6 +37,7 @@ pp_nocolor(struct pp_queue_t *ppq, struct pipe_resource *in, { struct pp_program *p = ppq->p; + struct pipe_context *pipe = p->pipe; const struct pipe_sampler_state *samplers[] = {&p->sampler_point}; pp_filter_setup_in(p, in); @@ -46,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); - cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 1, &p->view); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &p->view); cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]); cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][1]); diff --git a/src/gallium/auxiliary/postprocess/pp_init.c b/src/gallium/auxiliary/postprocess/pp_init.c index 2c830e8..97660ee 100644 --- a/src/gallium/auxiliary/postprocess/pp_init.c +++ b/src/gallium/auxiliary/postprocess/pp_init.c @@ -40,7 +40,7 @@ /** Initialize the post-processing queue. */ struct pp_queue_t * pp_init(struct pipe_context *pipe, const unsigned int *enabled, - struct cso_context *cso) + struct cso_context *cso, struct st_context_iface *st) { unsigned int num_filters = 0; unsigned int curpos = 0, i, tmp_req = 0; @@ -78,7 +78,7 @@ pp_init(struct pipe_context *pipe, const unsigned int *enabled, goto error; } - ppq->p = pp_init_prog(ppq, pipe, cso); + ppq->p = pp_init_prog(ppq, pipe, cso, st); if (ppq->p == NULL) { pp_debug("pp_init_prog returned NULL.\n"); goto error; diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c index 537fd24..6ec4269 100644 --- a/src/gallium/auxiliary/postprocess/pp_mlaa.c +++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c @@ -97,10 +97,15 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, dimensions[1] = p->framebuffer.height; } - cso_set_constant_user_buffer(p->cso, PIPE_SHADER_VERTEX, - 0, constants, sizeof(constants)); - cso_set_constant_user_buffer(p->cso, PIPE_SHADER_FRAGMENT, - 0, constants, sizeof(constants)); + struct pipe_constant_buffer cb; + cb.buffer = NULL; + cb.buffer_offset = 0; + cb.buffer_size = sizeof(constants); + cb.user_buffer = constants; + + struct pipe_context *pipe = ppq->p->pipe; + pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &cb); + pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &cb); mstencil.stencil[0].enabled = 1; mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0; @@ -129,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); } - cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 1, &p->view); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &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]); @@ -161,7 +166,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, } arr[0] = p->view; - cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 3, arr); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, arr); cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][0]); /* passvs */ cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][3]); @@ -193,7 +198,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in, } arr[1] = p->view; - cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 2, arr); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 2, arr); cso_set_vertex_shader_handle(p->cso, ppq->shaders[n][1]); /* offsetvs */ cso_set_fragment_shader_handle(p->cso, ppq->shaders[n][4]); diff --git a/src/gallium/auxiliary/postprocess/pp_private.h b/src/gallium/auxiliary/postprocess/pp_private.h index 7e63b5b..922b93c 100644 --- a/src/gallium/auxiliary/postprocess/pp_private.h +++ b/src/gallium/auxiliary/postprocess/pp_private.h @@ -41,6 +41,7 @@ struct pp_program struct pipe_screen *screen; struct pipe_context *pipe; struct cso_context *cso; + struct st_context_iface *st; struct pipe_blend_state blend; struct pipe_depth_stencil_alpha_state depthstencil; @@ -94,7 +95,7 @@ void pp_free_fbos(struct pp_queue_t *); void pp_debug(const char *, ...); struct pp_program *pp_init_prog(struct pp_queue_t *, struct pipe_context *pipe, - struct cso_context *); + struct cso_context *, struct st_context_iface *st); void pp_blit(struct pipe_context *pipe, struct pipe_resource *src_tex, diff --git a/src/gallium/auxiliary/postprocess/pp_program.c b/src/gallium/auxiliary/postprocess/pp_program.c index 65d7f95..258133b 100644 --- a/src/gallium/auxiliary/postprocess/pp_program.c +++ b/src/gallium/auxiliary/postprocess/pp_program.c @@ -41,7 +41,7 @@ /** Initialize the internal details */ struct pp_program * pp_init_prog(struct pp_queue_t *ppq, struct pipe_context *pipe, - struct cso_context *cso) + struct cso_context *cso, struct st_context_iface *st) { struct pp_program *p; @@ -56,6 +56,7 @@ pp_init_prog(struct pp_queue_t *ppq, struct pipe_context *pipe, p->screen = pipe->screen; p->pipe = pipe; p->cso = cso; + p->st = st; { static const float verts[4][2][4] = { diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c index c6987153..dd931b9 100644 --- a/src/gallium/auxiliary/postprocess/pp_run.c +++ b/src/gallium/auxiliary/postprocess/pp_run.c @@ -29,6 +29,7 @@ #include "postprocess/pp_filters.h" #include "postprocess/pp_private.h" +#include "frontend/api.h" #include "util/u_inlines.h" #include "util/u_sampler.h" @@ -126,17 +127,13 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in, CSO_BIT_SAMPLE_MASK | CSO_BIT_MIN_SAMPLES | CSO_BIT_FRAGMENT_SAMPLERS | - CSO_BIT_FRAGMENT_SAMPLER_VIEWS | CSO_BIT_STENCIL_REF | CSO_BIT_STREAM_OUTPUTS | CSO_BIT_VERTEX_ELEMENTS | CSO_BIT_VERTEX_SHADER | CSO_BIT_VIEWPORT | - CSO_BIT_AUX_VERTEX_BUFFER_SLOT | CSO_BIT_PAUSE_QUERIES | CSO_BIT_RENDER_CONDITION)); - cso_save_constant_buffer_slot0(cso, PIPE_SHADER_VERTEX); - cso_save_constant_buffer_slot0(cso, PIPE_SHADER_FRAGMENT); /* set default state */ cso_set_sample_mask(cso, ~0); @@ -188,8 +185,22 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in, /* restore state we changed */ cso_restore_state(cso); - cso_restore_constant_buffer_slot0(cso, PIPE_SHADER_VERTEX); - cso_restore_constant_buffer_slot0(cso, PIPE_SHADER_FRAGMENT); + + /* Unbind resources that we have bound. */ + struct pipe_context *pipe = ppq->p->pipe; + pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, NULL); + pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, NULL); + pipe->set_vertex_buffers(pipe, 0, 1, NULL); + pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 3, NULL); + + /* restore states not restored by cso */ + if (ppq->p->st) { + ppq->p->st->invalidate_state(ppq->p->st, + ST_INVALIDATE_FS_SAMPLER_VIEWS | + ST_INVALIDATE_FS_CONSTBUF0 | + ST_INVALIDATE_VS_CONSTBUF0 | + ST_INVALIDATE_VERTEX_BUFFERS); + } pipe_resource_reference(&ppq->depth, NULL); pipe_resource_reference(&refin, NULL); diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c index a40efa8..39eae5f 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -192,7 +192,8 @@ dri_create_context(gl_api api, const struct gl_config * visual, ctx->stapi = stapi; if (ctx->st->cso_context) { - ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context); + ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context, + ctx->st); ctx->hud = hud_create(ctx->st->cso_context, ctx->st, share_ctx ? share_ctx->hud : NULL); } diff --git a/src/gallium/frontends/osmesa/osmesa.c b/src/gallium/frontends/osmesa/osmesa.c index 7d06c8d..38ac4b7 100644 --- a/src/gallium/frontends/osmesa/osmesa.c +++ b/src/gallium/frontends/osmesa/osmesa.c @@ -820,7 +820,8 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type, if (any_pp_enabled) { osmesa->pp = pp_init(osmesa->stctx->pipe, osmesa->pp_enabled, - osmesa->stctx->cso_context); + osmesa->stctx->cso_context, + osmesa->stctx); pp_init_fbos(osmesa->pp, width, height); } diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp index 15eea94..760381a 100644 --- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp +++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp @@ -222,7 +222,7 @@ GalliumContext::CreateContext(HGLWinsysContext *wsContext) // Init Gallium3D Post Processing // TODO: no pp filters are enabled yet through postProcessEnable context->postProcess = pp_init(stContext->pipe, context->postProcessEnable, - stContext->cso_context); + stContext->cso_context, &stContext->iface); context_id contextNext = -1; Lock(); -- 2.7.4