nir: change nir_frag_coord_form options to a bitmask

this makes it easier to add more options

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41461>
This commit is contained in:
Marek Olšák 2026-05-01 03:40:38 -04:00 committed by Marge Bot
parent 7f5a307c12
commit 2d8d200c70
2 changed files with 9 additions and 9 deletions

View file

@ -809,7 +809,7 @@ nir_build_frag_coord(nir_builder *b, unsigned num_components)
assert(b->shader->info.stage == MESA_SHADER_FRAGMENT);
assert(num_components && num_components <= 4);
if (b->shader->options->frag_coord_form >= nir_frag_coord_xy_z_w_separate) {
if (b->shader->options->frag_coord_form & nir_frag_coord_xy_z_w_separate) {
nir_def *xy = nir_load_frag_coord_xy(b);
if (num_components <= 2)
@ -822,8 +822,7 @@ nir_build_frag_coord(nir_builder *b, unsigned num_components)
nir_def *w;
if (b->shader->options->frag_coord_form ==
nir_frag_coord_xy_z_w_rcp_separate)
if (b->shader->options->frag_coord_form & nir_frag_coord_use_w_rcp)
w = nir_frcp(b, nir_load_frag_coord_w_rcp(b));
else
w = nir_load_frag_coord_w(b);

View file

@ -244,12 +244,13 @@ typedef enum {
} nir_lower_packing_op;
typedef enum {
/* Build: frag_coord */
nir_frag_coord_regular,
/* Build: frag_coord_xy, frag_coord_z, frag_coord_w */
nir_frag_coord_xy_z_w_separate,
/* Build: frag_coord_xy, frag_coord_z, frcp(frag_coord_w_rcp) */
nir_frag_coord_xy_z_w_rcp_separate,
/* When set: use frag_coord_xy, frag_coord_z, frag_coord_w
* When unset: use frag_coord
*/
nir_frag_coord_xy_z_w_separate = BITFIELD_BIT(0),
/* Use frag_coord_w_rcp instead of frag_coord_w. */
nir_frag_coord_use_w_rcp = BITFIELD_BIT(1),
} nir_frag_coord_form;
typedef struct nir_shader_compiler_options {