gallium/pp: don't use cso_context to restore VBs, constbuf 0 and sampler views
These cso_context capabilities will be removed. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8180>
This commit is contained in:
@@ -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 *);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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] = {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user