From 2d8d200c7076b2717b84621590139c5c64b72e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 May 2026 03:40:38 -0400 Subject: [PATCH] nir: change nir_frag_coord_form options to a bitmask this makes it easier to add more options Reviewed-by: Samuel Pitoiset Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/compiler/nir/nir_builder.c | 5 ++--- src/compiler/nir/nir_shader_compiler_options.h | 13 +++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/nir/nir_builder.c b/src/compiler/nir/nir_builder.c index 7b921b1af32..4dd43dd364d 100644 --- a/src/compiler/nir/nir_builder.c +++ b/src/compiler/nir/nir_builder.c @@ -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); diff --git a/src/compiler/nir/nir_shader_compiler_options.h b/src/compiler/nir/nir_shader_compiler_options.h index fab88a77224..d61e39394fc 100644 --- a/src/compiler/nir/nir_shader_compiler_options.h +++ b/src/compiler/nir/nir_shader_compiler_options.h @@ -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 {