panfrost: switch to u_tristate

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32224>
This commit is contained in:
Alyssa Rosenzweig
2024-11-19 12:25:35 -04:00
committed by Marge Bot
parent 847e0e78f8
commit 358f40ea90
5 changed files with 13 additions and 57 deletions
+3 -3
View File
@@ -3024,7 +3024,7 @@ panfrost_compatible_batch_state(struct panfrost_batch *batch,
struct pipe_rasterizer_state *rast = &ctx->rasterizer->base;
if (reduced_prim == MESA_PRIM_LINES &&
!pan_tristate_set(&batch->line_smoothing, rast->line_smooth))
!u_tristate_set(&batch->line_smoothing, rast->line_smooth))
return false;
/* Only applies on Valhall */
@@ -3038,9 +3038,9 @@ panfrost_compatible_batch_state(struct panfrost_batch *batch,
* provoking vertex doesn't matter for points.
*/
if (reduced_prim == MESA_PRIM_POINTS)
return pan_tristate_set(&batch->sprite_coord_origin, coord);
return u_tristate_set(&batch->sprite_coord_origin, coord);
else
return pan_tristate_set(&batch->first_provoking_vertex, first);
return u_tristate_set(&batch->first_provoking_vertex, first);
}
static struct panfrost_batch *
+1 -1
View File
@@ -961,7 +961,7 @@ csf_get_tiler_desc(struct panfrost_batch *batch)
tiler.sample_pattern =
pan_sample_pattern(util_framebuffer_get_num_samples(&batch->key));
tiler.first_provoking_vertex =
pan_tristate_get(batch->first_provoking_vertex);
batch->first_provoking_vertex == U_TRISTATE_YES;
tiler.geometry_buffer = ctx->csf.tmp_geom_bo->ptr.gpu;
tiler.geometry_buffer_size = ctx->csf.tmp_geom_bo->kmod_bo->size;
}
+1 -1
View File
@@ -435,7 +435,7 @@ jm_emit_tiler_desc(struct panfrost_batch *batch)
pan_sample_pattern(util_framebuffer_get_num_samples(&batch->key));
#if PAN_ARCH >= 9
tiler.first_provoking_vertex =
pan_tristate_get(batch->first_provoking_vertex);
batch->first_provoking_vertex == U_TRISTATE_YES;
#endif
}
+4 -3
View File
@@ -468,10 +468,11 @@ panfrost_batch_to_fb_info(const struct panfrost_batch *batch,
fb->extent.maxx = batch->maxx - 1;
fb->extent.maxy = batch->maxy - 1;
fb->nr_samples = util_framebuffer_get_num_samples(&batch->key);
fb->force_samples = pan_tristate_get(batch->line_smoothing) ? 16 : 0;
fb->force_samples = (batch->line_smoothing == U_TRISTATE_YES) ? 16 : 0;
fb->rt_count = batch->key.nr_cbufs;
fb->sprite_coord_origin = pan_tristate_get(batch->sprite_coord_origin);
fb->first_provoking_vertex = pan_tristate_get(batch->first_provoking_vertex);
fb->sprite_coord_origin = (batch->sprite_coord_origin == U_TRISTATE_YES);
fb->first_provoking_vertex =
(batch->first_provoking_vertex == U_TRISTATE_YES);
static const unsigned char id_swz[] = {
PIPE_SWIZZLE_X,
+4 -49
View File
@@ -28,58 +28,13 @@
#include "pipe/p_state.h"
#include "util/u_dynarray.h"
#include "util/u_tristate.h"
#include "pan_csf.h"
#include "pan_desc.h"
#include "pan_jm.h"
#include "pan_mempool.h"
#include "pan_resource.h"
/* Simple tri-state data structure. In the default "don't care" state, the value
* may be set to true or false. However, once the value is set, it must not be
* changed. Declared inside of a struct to prevent casting to bool, which is an
* error. The getter needs to be used instead.
*/
struct pan_tristate {
enum {
PAN_TRISTATE_DONTCARE,
PAN_TRISTATE_FALSE,
PAN_TRISTATE_TRUE,
} v;
};
/*
* Try to set a tristate value to a desired boolean value. Returns whether the
* operation is successful.
*/
static inline bool
pan_tristate_set(struct pan_tristate *state, bool value)
{
switch (state->v) {
case PAN_TRISTATE_DONTCARE:
state->v = value ? PAN_TRISTATE_TRUE : PAN_TRISTATE_FALSE;
return true;
case PAN_TRISTATE_FALSE:
return (value == false);
case PAN_TRISTATE_TRUE:
return (value == true);
default:
unreachable("Invalid tristate value");
}
}
/*
* Read the boolean value of a tristate. Return value undefined in the don't
* care state.
*/
static inline bool
pan_tristate_get(struct pan_tristate state)
{
return (state.v == PAN_TRISTATE_TRUE);
}
/* A panfrost_batch corresponds to a bound FBO we're rendering to,
* collecting over multiple draws. */
@@ -207,11 +162,11 @@ struct panfrost_batch {
/* On Valhall, these are properties of the batch. On Bifrost, they are
* per draw.
*/
struct pan_tristate sprite_coord_origin;
struct pan_tristate first_provoking_vertex;
enum u_tristate sprite_coord_origin;
enum u_tristate first_provoking_vertex;
/** This one is always on the batch */
struct pan_tristate line_smoothing;
enum u_tristate line_smoothing;
/* Number of effective draws in the batch. Draws with rasterization disabled
* don't count as effective draws. It's basically the number of IDVS or