gallium: add # of MRT to blend state

To make it possible for drivers to avoid unnecessary blend state change
for unused MRTs.  Otherwise the driver would have to manage different
blend CSOs for different potential #s of render targets.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4619>
This commit is contained in:
Rob Clark
2020-04-16 10:53:03 -07:00
committed by Marge Bot
parent b88778e2de
commit 85f84ea148
8 changed files with 14 additions and 2 deletions
@@ -432,7 +432,7 @@ void trace_dump_blend_state(const struct pipe_blend_state *state)
trace_dump_member_begin("rt");
if (state->independent_blend_enable)
valid_entries = PIPE_MAX_COLOR_BUFS;
valid_entries = state->max_rt + 1;
trace_dump_struct_array(rt_blend_state, state->rt, valid_entries);
trace_dump_member_end();
+1
View File
@@ -1419,6 +1419,7 @@ static void *get_clear_blend_state(struct blitter_context_priv *ctx,
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
if (clear_buffers & (PIPE_CLEAR_COLOR0 << i)) {
blend.rt[i].colormask = PIPE_MASK_RGBA;
blend.max_rt = i;
}
}
+2 -1
View File
@@ -603,6 +603,7 @@ util_dump_blend_state(FILE *stream, const struct pipe_blend_state *state)
util_dump_member(stream, bool, state, dither);
util_dump_member(stream, bool, state, alpha_to_coverage);
util_dump_member(stream, bool, state, alpha_to_one);
util_dump_member(stream, uint, state, max_rt);
util_dump_member(stream, bool, state, logicop_enable);
if (state->logicop_enable) {
@@ -613,7 +614,7 @@ util_dump_blend_state(FILE *stream, const struct pipe_blend_state *state)
util_dump_member_begin(stream, "rt");
if (state->independent_blend_enable)
valid_entries = PIPE_MAX_COLOR_BUFS;
valid_entries = state->max_rt + 1;
util_dump_struct_array(stream, rt_blend_state, state->rt, valid_entries);
util_dump_member_end(stream);
}
+4
View File
@@ -99,6 +99,10 @@ alpha_to_one
If enabled, the fragment's alpha value will be set to one. As with
alpha_to_coverage, this step happens regardless of whether multisample
is enabled or the destination buffer is multisampled.
max_rt
The index of the max render target (irrespecitive of whether independent
blend is enabled), ie. the number of MRTs minus one. This is provided
so that the driver can avoid the overhead of programming unused MRTs.
Per-rendertarget Members
+1
View File
@@ -363,6 +363,7 @@ struct pipe_blend_state
unsigned dither:1;
unsigned alpha_to_coverage:1;
unsigned alpha_to_one:1;
unsigned max_rt:3; /* index of max rt, Ie. # of cbufs minus 1 */
struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];
};
@@ -186,6 +186,7 @@ nine_convert_blend_state(struct pipe_blend_state *blend_state, const DWORD *rs)
nine_convert_blend_state_fixup(&blend, rs); /* for BOTH[INV]SRCALPHA */
}
blend.max_rt = 0;
blend.rt[0].colormask = rs[D3DRS_COLORWRITEENABLE];
if (rs[D3DRS_COLORWRITEENABLE1] != rs[D3DRS_COLORWRITEENABLE] ||
@@ -198,6 +199,7 @@ nine_convert_blend_state(struct pipe_blend_state *blend_state, const DWORD *rs)
blend.rt[1].colormask = rs[D3DRS_COLORWRITEENABLE1];
blend.rt[2].colormask = rs[D3DRS_COLORWRITEENABLE2];
blend.rt[3].colormask = rs[D3DRS_COLORWRITEENABLE3];
blend.max_rt = 3;
}
/* blend.force_srgb = !!rs[D3DRS_SRGBWRITEENABLE]; */
+2
View File
@@ -201,6 +201,8 @@ st_update_blend( struct st_context *st )
memset(blend, 0, sizeof(*blend));
blend->max_rt = MAX2(1, num_cb) - 1;
if (num_cb > 1 &&
(blend_per_rt(st, num_cb) || colormask_per_rt(ctx, num_cb))) {
num_state = num_cb;
+1
View File
@@ -280,6 +280,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
int i;
blend.independent_blend_enable = num_buffers > 1;
blend.max_rt = num_buffers - 1;
for (i = 0; i < num_buffers; i++) {
if (!(clear_buffers & (PIPE_CLEAR_COLOR0 << i)))