gallium: pass pipe_stencil_ref by value (it has only 2 bytes)

This changes pipe_context::set_stencil_ref to pass the parameter by value.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7940>
This commit is contained in:
Marek Olšák 2020-12-03 11:36:53 -05:00 committed by Marge Bot
parent 2d87e52b37
commit b7f12a0452
37 changed files with 77 additions and 80 deletions

View File

@ -849,10 +849,10 @@ cso_restore_min_samples(struct cso_context *ctx)
}
void cso_set_stencil_ref(struct cso_context *ctx,
const struct pipe_stencil_ref *sr)
const struct pipe_stencil_ref sr)
{
if (memcmp(&ctx->stencil_ref, sr, sizeof(ctx->stencil_ref))) {
ctx->stencil_ref = *sr;
if (memcmp(&ctx->stencil_ref, &sr, sizeof(ctx->stencil_ref))) {
ctx->stencil_ref = sr;
ctx->pipe->set_stencil_ref(ctx->pipe, sr);
}
}
@ -870,7 +870,7 @@ cso_restore_stencil_ref(struct cso_context *ctx)
if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved,
sizeof(ctx->stencil_ref))) {
ctx->stencil_ref = ctx->stencil_ref_saved;
ctx->pipe->set_stencil_ref(ctx->pipe, &ctx->stencil_ref);
ctx->pipe->set_stencil_ref(ctx->pipe, ctx->stencil_ref);
}
}

View File

@ -129,7 +129,7 @@ void cso_set_sample_mask(struct cso_context *cso, unsigned stencil_mask);
void cso_set_min_samples(struct cso_context *cso, unsigned min_samples);
void cso_set_stencil_ref(struct cso_context *cso,
const struct pipe_stencil_ref *sr);
const struct pipe_stencil_ref sr);
void cso_set_render_condition(struct cso_context *cso,
struct pipe_query *query,

View File

@ -350,7 +350,7 @@ DD_SHADER_NOCREATE(COMPUTE, compute)
}
DD_IMM_STATE(blend_color, const struct pipe_blend_color, *state, state)
DD_IMM_STATE(stencil_ref, const struct pipe_stencil_ref, *state, state)
DD_IMM_STATE(stencil_ref, const struct pipe_stencil_ref, state, state)
DD_IMM_STATE(clip_state, const struct pipe_clip_state, *state, state)
DD_IMM_STATE(sample_mask, unsigned, sample_mask, sample_mask)
DD_IMM_STATE(min_samples, unsigned, min_samples, min_samples)

View File

@ -147,7 +147,7 @@ static void noop_set_scissor_states(struct pipe_context *ctx,
}
static void noop_set_stencil_ref(struct pipe_context *ctx,
const struct pipe_stencil_ref *state)
const struct pipe_stencil_ref state)
{
}

View File

@ -605,7 +605,7 @@ rbug_set_blend_color(struct pipe_context *_pipe,
static void
rbug_set_stencil_ref(struct pipe_context *_pipe,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct rbug_context *rb_pipe = rbug_context(_pipe);
struct pipe_context *pipe = rb_pipe->pipe;

View File

@ -696,7 +696,7 @@ trace_context_set_blend_color(struct pipe_context *_pipe,
static void
trace_context_set_stencil_ref(struct pipe_context *_pipe,
const struct pipe_stencil_ref *state)
const struct pipe_stencil_ref state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
@ -704,7 +704,7 @@ trace_context_set_stencil_ref(struct pipe_context *_pipe,
trace_dump_call_begin("pipe_context", "set_stencil_ref");
trace_dump_arg(ptr, pipe);
trace_dump_arg(stencil_ref, state);
trace_dump_arg(stencil_ref, &state);
pipe->set_stencil_ref(pipe, state);

View File

@ -85,7 +85,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
memset(&mstencil, 0, sizeof(mstencil));
cso_set_stencil_ref(p->cso, &ref);
cso_set_stencil_ref(p->cso, ref);
/* Init the pixel size constant */
if (dimensions[0] != p->framebuffer.width ||

View File

@ -714,7 +714,7 @@ void util_blitter_restore_fragment_states(struct blitter_context *blitter)
/* Miscellaneous states. */
/* XXX check whether these are saved and whether they need to be restored
* (depending on the operation) */
pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
pipe->set_stencil_ref(pipe, ctx->base.saved_stencil_ref);
if (!blitter->skip_viewport_restore)
pipe->set_viewport_states(pipe, 0, 1, &ctx->base.saved_viewport);
@ -1496,7 +1496,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
custom_blend, custom_dsa);
sr.ref_value[0] = stencil & 0xff;
pipe->set_stencil_ref(pipe, &sr);
pipe->set_stencil_ref(pipe, sr);
bind_fs_write_all_cbufs(ctx);
@ -2363,7 +2363,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) == PIPE_CLEAR_DEPTHSTENCIL) {
sr.ref_value[0] = stencil & 0xff;
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil);
pipe->set_stencil_ref(pipe, &sr);
pipe->set_stencil_ref(pipe, sr);
}
else if (clear_flags & PIPE_CLEAR_DEPTH) {
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_keep_stencil);
@ -2371,7 +2371,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
else if (clear_flags & PIPE_CLEAR_STENCIL) {
sr.ref_value[0] = stencil & 0xff;
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_write_stencil);
pipe->set_stencil_ref(pipe, &sr);
pipe->set_stencil_ref(pipe, sr);
}
else
/* hmm that should be illegal probably, or make it a no-op somewhere */
@ -2892,7 +2892,7 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
UTIL_FORMAT_COLORSPACE_ZS, 1);
struct pipe_stencil_ref sr = { { (1u << stencil_bits) - 1 } };
pipe->set_stencil_ref(pipe, &sr);
pipe->set_stencil_ref(pipe, sr);
union blitter_attrib coord;
get_texcoords(src_view, src->width0, src->height0,

View File

@ -430,7 +430,7 @@ threaded_context_unwrap_sync(struct pipe_context *pipe)
TC_FUNC1(set_active_query_state, flags, , bool, , *)
TC_FUNC1(set_blend_color, blend_color, const, struct pipe_blend_color, *, )
TC_FUNC1(set_stencil_ref, stencil_ref, const, struct pipe_stencil_ref, *, )
TC_FUNC1(set_stencil_ref, stencil_ref, const, struct pipe_stencil_ref, , *)
TC_FUNC1(set_clip_state, clip_state, const, struct pipe_clip_state, *, )
TC_FUNC1(set_sample_mask, sample_mask, , unsigned, , *)
TC_FUNC1(set_min_samples, min_samples, , unsigned, , *)

View File

@ -1278,13 +1278,13 @@ d3d12_set_sample_mask(struct pipe_context *pctx, unsigned sample_mask)
static void
d3d12_set_stencil_ref(struct pipe_context *pctx,
const struct pipe_stencil_ref *ref)
const struct pipe_stencil_ref ref)
{
struct d3d12_context *ctx = d3d12_context(pctx);
if ((ref->ref_value[0] != ref->ref_value[1]) &&
if ((ref.ref_value[0] != ref.ref_value[1]) &&
(d3d12_debug & D3D12_DEBUG_VERBOSE))
debug_printf("D3D12: Different values for front and back stencil reference are not supported\n");
ctx->stencil_ref = *ref;
ctx->stencil_ref = ref;
ctx->state_dirty |= D3D12_DIRTY_STENCIL_REF;
}

View File

@ -48,18 +48,18 @@
#include "util/u_upload_mgr.h"
static void
etna_set_stencil_ref(struct pipe_context *pctx, const struct pipe_stencil_ref *sr)
etna_set_stencil_ref(struct pipe_context *pctx, const struct pipe_stencil_ref sr)
{
struct etna_context *ctx = etna_context(pctx);
struct compiled_stencil_ref *cs = &ctx->stencil_ref;
ctx->stencil_ref_s = *sr;
ctx->stencil_ref_s = sr;
for (unsigned i = 0; i < 2; i++) {
cs->PE_STENCIL_CONFIG[i] =
VIVS_PE_STENCIL_CONFIG_REF_FRONT(sr->ref_value[i]);
VIVS_PE_STENCIL_CONFIG_REF_FRONT(sr.ref_value[i]);
cs->PE_STENCIL_CONFIG_EXT[i] =
VIVS_PE_STENCIL_CONFIG_EXT_REF_BACK(sr->ref_value[!i]);
VIVS_PE_STENCIL_CONFIG_EXT_REF_BACK(sr.ref_value[!i]);
}
ctx->dirty |= ETNA_DIRTY_STENCIL_REF;
}

View File

@ -189,7 +189,7 @@ fd_blitter_clear(struct pipe_context *pctx, unsigned buffers,
struct pipe_stencil_ref sr = {
.ref_value = { stencil & 0xff }
};
pctx->set_stencil_ref(pctx, &sr);
pctx->set_stencil_ref(pctx, sr);
struct pipe_constant_buffer cb = {
.buffer_size = 16,

View File

@ -54,10 +54,10 @@ fd_set_blend_color(struct pipe_context *pctx,
static void
fd_set_stencil_ref(struct pipe_context *pctx,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct fd_context *ctx = fd_context(pctx);
ctx->stencil_ref =* stencil_ref;
ctx->stencil_ref = stencil_ref;
ctx->dirty |= FD_DIRTY_STENCIL_REF;
}

View File

@ -207,11 +207,11 @@ static void i915_set_blend_color( struct pipe_context *pipe,
}
static void i915_set_stencil_ref( struct pipe_context *pipe,
const struct pipe_stencil_ref *stencil_ref )
const struct pipe_stencil_ref stencil_ref )
{
struct i915_context *i915 = i915_context(pipe);
i915->stencil_ref = *stencil_ref;
i915->stencil_ref = stencil_ref;
i915->dirty |= I915_NEW_DEPTH_STENCIL;
}

View File

@ -3021,10 +3021,10 @@ iris_set_scissor_states(struct pipe_context *ctx,
*/
static void
iris_set_stencil_ref(struct pipe_context *ctx,
const struct pipe_stencil_ref *state)
const struct pipe_stencil_ref state)
{
struct iris_context *ice = (struct iris_context *) ctx;
memcpy(&ice->state.stencil_ref, state, sizeof(*state));
memcpy(&ice->state.stencil_ref, &state, sizeof(state));
if (GEN_GEN >= 12)
ice->state.dirty |= IRIS_DIRTY_STENCIL_REF;
else if (GEN_GEN >= 9)

View File

@ -246,11 +246,11 @@ lima_set_blend_color(struct pipe_context *pctx,
static void
lima_set_stencil_ref(struct pipe_context *pctx,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct lima_context *ctx = lima_context(pctx);
ctx->stencil_ref = *stencil_ref;
ctx->stencil_ref = stencil_ref;
ctx->dirty |= LIMA_CONTEXT_DIRTY_STENCIL_REF;
}

View File

@ -155,19 +155,16 @@ llvmpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
static void
llvmpipe_set_stencil_ref(struct pipe_context *pipe,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
if (!stencil_ref)
return;
if(memcmp(&llvmpipe->stencil_ref, stencil_ref, sizeof *stencil_ref) == 0)
if(memcmp(&llvmpipe->stencil_ref, &stencil_ref, sizeof stencil_ref) == 0)
return;
draw_flush(llvmpipe->draw);
memcpy(&llvmpipe->stencil_ref, stencil_ref, sizeof *stencil_ref);
memcpy(&llvmpipe->stencil_ref, &stencil_ref, sizeof stencil_ref);
/* not sure. want new flag? */
llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA;

View File

@ -297,11 +297,11 @@ nv30_set_blend_color(struct pipe_context *pipe,
static void
nv30_set_stencil_ref(struct pipe_context *pipe,
const struct pipe_stencil_ref *sr)
const struct pipe_stencil_ref sr)
{
struct nv30_context *nv30 = nv30_context(pipe);
nv30->stencil_ref = *sr;
nv30->stencil_ref = sr;
nv30->dirty |= NV30_NEW_STENCIL_REF;
}

View File

@ -949,11 +949,11 @@ nv50_set_blend_color(struct pipe_context *pipe,
static void
nv50_set_stencil_ref(struct pipe_context *pipe,
const struct pipe_stencil_ref *sr)
const struct pipe_stencil_ref sr)
{
struct nv50_context *nv50 = nv50_context(pipe);
nv50->stencil_ref = *sr;
nv50->stencil_ref = sr;
nv50->dirty_3d |= NV50_NEW_3D_STENCIL_REF;
}

View File

@ -841,11 +841,11 @@ nvc0_set_blend_color(struct pipe_context *pipe,
static void
nvc0_set_stencil_ref(struct pipe_context *pipe,
const struct pipe_stencil_ref *sr)
const struct pipe_stencil_ref sr)
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
nvc0->stencil_ref = *sr;
nvc0->stencil_ref = sr;
nvc0->dirty_3d |= NVC0_NEW_3D_STENCIL_REF;
}

View File

@ -964,10 +964,10 @@ panfrost_set_constant_buffer(
static void
panfrost_set_stencil_ref(
struct pipe_context *pctx,
const struct pipe_stencil_ref *ref)
const struct pipe_stencil_ref ref)
{
struct panfrost_context *ctx = pan_context(pctx);
ctx->stencil_ref = *ref;
ctx->stencil_ref = ref;
}
void

View File

@ -817,11 +817,11 @@ static void r300_delete_dsa_state(struct pipe_context* pipe,
}
static void r300_set_stencil_ref(struct pipe_context* pipe,
const struct pipe_stencil_ref* sr)
const struct pipe_stencil_ref sr)
{
struct r300_context* r300 = r300_context(pipe);
r300->stencil_ref = *sr;
r300->stencil_ref = sr;
r300_dsa_inject_stencilref(r300);
r300_mark_atom_dirty(r300, &r300->dsa_state);

View File

@ -285,11 +285,11 @@ static void r600_set_clip_state(struct pipe_context *ctx,
}
static void r600_set_stencil_ref(struct pipe_context *ctx,
const struct r600_stencil_ref *state)
const struct r600_stencil_ref state)
{
struct r600_context *rctx = (struct r600_context *)ctx;
rctx->stencil_ref.state = *state;
rctx->stencil_ref.state = state;
r600_mark_atom_dirty(rctx, &rctx->stencil_ref.atom);
}
@ -310,25 +310,25 @@ void r600_emit_stencil_ref(struct r600_context *rctx, struct r600_atom *atom)
}
static void r600_set_pipe_stencil_ref(struct pipe_context *ctx,
const struct pipe_stencil_ref *state)
const struct pipe_stencil_ref state)
{
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_dsa_state *dsa = (struct r600_dsa_state*)rctx->dsa_state.cso;
struct r600_stencil_ref ref;
rctx->stencil_ref.pipe_state = *state;
rctx->stencil_ref.pipe_state = state;
if (!dsa)
return;
ref.ref_value[0] = state->ref_value[0];
ref.ref_value[1] = state->ref_value[1];
ref.ref_value[0] = state.ref_value[0];
ref.ref_value[1] = state.ref_value[1];
ref.valuemask[0] = dsa->valuemask[0];
ref.valuemask[1] = dsa->valuemask[1];
ref.writemask[0] = dsa->writemask[0];
ref.writemask[1] = dsa->writemask[1];
r600_set_stencil_ref(ctx, &ref);
r600_set_stencil_ref(ctx, ref);
}
static void r600_bind_dsa_state(struct pipe_context *ctx, void *state)
@ -361,7 +361,7 @@ static void r600_bind_dsa_state(struct pipe_context *ctx, void *state)
}
}
r600_set_stencil_ref(ctx, &ref);
r600_set_stencil_ref(ctx, ref);
/* Update alphatest state. */
if (rctx->alphatest_state.sx_alpha_test_control != dsa->sx_alpha_test_control ||

View File

@ -1059,14 +1059,14 @@ static void si_emit_stencil_ref(struct si_context *sctx)
S_028434_STENCILOPVAL_BF(1));
}
static void si_set_stencil_ref(struct pipe_context *ctx, const struct pipe_stencil_ref *state)
static void si_set_stencil_ref(struct pipe_context *ctx, const struct pipe_stencil_ref state)
{
struct si_context *sctx = (struct si_context *)ctx;
if (memcmp(&sctx->stencil_ref.state, state, sizeof(*state)) == 0)
if (memcmp(&sctx->stencil_ref.state, &state, sizeof(state)) == 0)
return;
sctx->stencil_ref.state = *state;
sctx->stencil_ref.state = state;
si_mark_atom_dirty(sctx, &sctx->atoms.s.stencil_ref);
}

View File

@ -114,11 +114,11 @@ softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
static void
softpipe_set_stencil_ref(struct pipe_context *pipe,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
softpipe->stencil_ref = *stencil_ref;
softpipe->stencil_ref = stencil_ref;
softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA;
}

View File

@ -263,7 +263,7 @@ svga_delete_depth_stencil_state(struct pipe_context *pipe, void *depth_stencil)
static void
svga_set_stencil_ref(struct pipe_context *pipe,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct svga_context *svga = svga_context(pipe);
@ -272,7 +272,7 @@ svga_set_stencil_ref(struct pipe_context *pipe,
svga_hwtnl_flush_retry(svga);
}
svga->curr.stencil_ref = *stencil_ref;
svga->curr.stencil_ref = stencil_ref;
svga->dirty |= SVGA_NEW_STENCIL_REF;
}

View File

@ -164,11 +164,11 @@ swr_set_blend_color(struct pipe_context *pipe,
static void
swr_set_stencil_ref(struct pipe_context *pipe,
const struct pipe_stencil_ref *ref)
const struct pipe_stencil_ref ref)
{
struct swr_context *ctx = swr_context(pipe);
ctx->stencil_ref = *ref;
ctx->stencil_ref = ref;
ctx->dirty |= SWR_NEW_DEPTH_STENCIL_ALPHA;
}

View File

@ -431,7 +431,7 @@ tegra_set_blend_color(struct pipe_context *pcontext,
static void
tegra_set_stencil_ref(struct pipe_context *pcontext,
const struct pipe_stencil_ref *ref)
const struct pipe_stencil_ref ref)
{
struct tegra_context *context = to_tegra_context(pcontext);

View File

@ -59,10 +59,10 @@ v3d_set_blend_color(struct pipe_context *pctx,
static void
v3d_set_stencil_ref(struct pipe_context *pctx,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct v3d_context *v3d = v3d_context(pctx);
v3d->stencil_ref = *stencil_ref;
v3d->stencil_ref = stencil_ref;
v3d->dirty |= VC5_DIRTY_STENCIL_REF;
}

View File

@ -60,10 +60,10 @@ vc4_set_blend_color(struct pipe_context *pctx,
static void
vc4_set_stencil_ref(struct pipe_context *pctx,
const struct pipe_stencil_ref *stencil_ref)
const struct pipe_stencil_ref stencil_ref)
{
struct vc4_context *vc4 = vc4_context(pctx);
vc4->stencil_ref =* stencil_ref;
vc4->stencil_ref = stencil_ref;
vc4->dirty |= VC4_DIRTY_STENCIL_REF;
}

View File

@ -610,10 +610,10 @@ static void virgl_hw_set_vertex_buffers(struct virgl_context *vctx)
}
static void virgl_set_stencil_ref(struct pipe_context *ctx,
const struct pipe_stencil_ref *ref)
const struct pipe_stencil_ref ref)
{
struct virgl_context *vctx = virgl_context(ctx);
virgl_encoder_set_stencil_ref(vctx, ref);
virgl_encoder_set_stencil_ref(vctx, &ref);
}
static void virgl_set_blend_color(struct pipe_context *ctx,

View File

@ -583,10 +583,10 @@ zink_set_sampler_views(struct pipe_context *pctx,
static void
zink_set_stencil_ref(struct pipe_context *pctx,
const struct pipe_stencil_ref *ref)
const struct pipe_stencil_ref ref)
{
struct zink_context *ctx = zink_context(pctx);
ctx->stencil_ref = *ref;
ctx->stencil_ref = ref;
}
static void

View File

@ -231,7 +231,7 @@ static void emit_state(struct rendering_state *state)
}
if (state->stencil_ref_dirty) {
state->pctx->set_stencil_ref(state->pctx, &state->stencil_ref);
state->pctx->set_stencil_ref(state->pctx, state->stencil_ref);
state->stencil_ref_dirty = false;
}

View File

@ -1283,7 +1283,7 @@ nine_update_state(struct NineDevice9 *device)
struct pipe_stencil_ref ref;
ref.ref_value[0] = context->rs[D3DRS_STENCILREF];
ref.ref_value[1] = ref.ref_value[0];
pipe->set_stencil_ref(pipe, &ref);
pipe->set_stencil_ref(pipe, ref);
}
}

View File

@ -337,7 +337,7 @@ struct pipe_context {
const struct pipe_blend_color * );
void (*set_stencil_ref)( struct pipe_context *,
const struct pipe_stencil_ref * );
const struct pipe_stencil_ref ref);
void (*set_sample_mask)( struct pipe_context *,
unsigned sample_mask );

View File

@ -157,5 +157,5 @@ st_update_depth_stencil_alpha(struct st_context *st)
}
cso_set_depth_stencil_alpha(st->cso_context, dsa);
cso_set_stencil_ref(st->cso_context, &sr);
cso_set_stencil_ref(st->cso_context, sr);
}

View File

@ -316,7 +316,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
depth_stencil.stencil[0].valuemask = 0xff;
depth_stencil.stencil[0].writemask = ctx->Stencil.WriteMask[0] & 0xff;
stencil_ref.ref_value[0] = ctx->Stencil.Clear;
cso_set_stencil_ref(cso, &stencil_ref);
cso_set_stencil_ref(cso, stencil_ref);
}
cso_set_depth_stencil_alpha(cso, &depth_stencil);