Mesa (staging/21.0): compiler: Use util/bitset.h for system_values_read
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 18:46:54 UTC 2021
Module: Mesa
Branch: staging/21.0
Commit: 343f1aba2026c97a258214a65575f6c673356752
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=343f1aba2026c97a258214a65575f6c673356752
Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date: Tue Jan 19 17:14:28 2021 -0800
compiler: Use util/bitset.h for system_values_read
It is currently a bitset on top of a uint64_t but there are already
more than 64 values. Change to use BITSET to cover all the
SYSTEM_VALUE_MAX bits.
Cc: mesa-stable
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Karol Herbst <kherbst at redhat.com>
Acked-by: Jesse Natalie <jenatali at microsoft.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Acked-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8585>
(cherry picked from commit 9f3d5e99ea601ae4bc492ff47738290eed520651)
---
.pick_status.json | 2 +-
src/broadcom/compiler/nir_to_vir.c | 40 ++++++-----
src/broadcom/compiler/vir.c | 22 +++---
src/compiler/glsl/ir_set_program_inouts.cpp | 4 +-
src/compiler/nir/nir_gather_info.c | 34 +++++-----
src/compiler/shader_enums.h | 9 ---
src/compiler/shader_info.h | 3 +-
src/gallium/auxiliary/nir/nir_to_tgsi.c | 2 +-
src/gallium/auxiliary/nir/tgsi_to_nir.c | 4 +-
src/gallium/drivers/d3d12/d3d12_compiler.cpp | 2 +-
src/gallium/drivers/iris/iris_draw.c | 2 +-
src/gallium/drivers/iris/iris_program.c | 2 +-
.../drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 20 +++---
src/gallium/drivers/panfrost/pan_assemble.c | 8 +--
src/gallium/drivers/radeonsi/si_shader_nir.c | 55 ++++++++-------
src/gallium/frontends/lavapipe/lvp_pipeline.c | 4 +-
src/intel/compiler/brw_fs.cpp | 12 ++--
src/intel/compiler/brw_nir.c | 9 ++-
src/intel/compiler/brw_vec4.cpp | 32 ++++-----
src/intel/compiler/brw_vec4_gs_visitor.cpp | 2 +-
src/intel/compiler/brw_vec4_tcs.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_curbe.c | 2 +-
src/mesa/main/state.c | 16 ++---
src/mesa/program/prog_to_nir.c | 6 +-
src/mesa/program/program.c | 4 +-
src/mesa/program/programopt.c | 2 +-
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 78 ++++++++++------------
src/microsoft/compiler/nir_to_dxil.c | 2 +-
28 files changed, 178 insertions(+), 202 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 8e1ef0ab613..b506d865fba 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -409,7 +409,7 @@
"description": "compiler: Use util/bitset.h for system_values_read",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 4e924350a1d..5d78d99d8d3 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1620,14 +1620,16 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
unsigned num_components = 0;
uint32_t vpm_components_queued = 0;
- bool uses_iid = c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_INSTANCE_ID |
- 1ull << SYSTEM_VALUE_INSTANCE_INDEX);
- bool uses_biid = c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_BASE_INSTANCE);
- bool uses_vid = c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_VERTEX_ID |
- 1ull << SYSTEM_VALUE_VERTEX_ID_ZERO_BASE);
+ bool uses_iid = BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_INSTANCE_ID) ||
+ BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_INSTANCE_INDEX);
+ bool uses_biid = BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_BASE_INSTANCE);
+ bool uses_vid = BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_VERTEX_ID) ||
+ BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_VERTEX_ID_ZERO_BASE);
num_components += uses_iid;
num_components += uses_biid;
@@ -2079,16 +2081,16 @@ ntq_emit_load_input(struct v3d_compile *c, nir_intrinsic_instr *instr)
* be slower if the VPM unit is busy with another QPU.
*/
int index = 0;
- if (c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_INSTANCE_ID)) {
+ if (BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_INSTANCE_ID)) {
index++;
}
- if (c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_BASE_INSTANCE)) {
+ if (BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_BASE_INSTANCE)) {
index++;
}
- if (c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_VERTEX_ID)) {
+ if (BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_VERTEX_ID)) {
index++;
}
for (int i = 0; i < offset; i++)
@@ -3130,16 +3132,18 @@ nir_to_vir(struct v3d_compile *c)
c->uses_implicit_point_line_varyings = true;
} else if (c->fs_key->is_lines &&
(c->devinfo->ver < 40 ||
- (c->s->info.system_values_read &
- BITFIELD64_BIT(SYSTEM_VALUE_LINE_COORD)))) {
+ BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_LINE_COORD))) {
c->line_x = emit_fragment_varying(c, NULL, -1, 0, 0);
c->uses_implicit_point_line_varyings = true;
}
c->force_per_sample_msaa =
c->s->info.fs.uses_sample_qualifier ||
- (c->s->info.system_values_read & (SYSTEM_BIT_SAMPLE_ID |
- SYSTEM_BIT_SAMPLE_POS));
+ BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_SAMPLE_ID) ||
+ BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_SAMPLE_POS);
break;
case MESA_SHADER_COMPUTE:
/* Set up the TSO for barriers, assuming we do some. */
diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 42ce76fb28b..583b5215350 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -640,16 +640,18 @@ v3d_vs_set_prog_data(struct v3d_compile *c,
prog_data->vpm_input_size += c->vattr_sizes[i];
}
- prog_data->uses_vid = (c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_VERTEX_ID |
- 1ull << SYSTEM_VALUE_VERTEX_ID_ZERO_BASE));
+ prog_data->uses_vid = BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_VERTEX_ID) ||
+ BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_VERTEX_ID_ZERO_BASE);
- prog_data->uses_biid = (c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_BASE_INSTANCE));
+ prog_data->uses_biid = BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_BASE_INSTANCE);
- prog_data->uses_iid = (c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_INSTANCE_ID |
- 1ull << SYSTEM_VALUE_INSTANCE_INDEX));
+ prog_data->uses_iid = BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_INSTANCE_ID) ||
+ BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_INSTANCE_INDEX);
if (prog_data->uses_vid)
prog_data->vpm_input_size++;
@@ -703,8 +705,8 @@ v3d_gs_set_prog_data(struct v3d_compile *c,
* it after reading it if necessary, so it doesn't add to the VPM
* size requirements.
*/
- prog_data->uses_pid = (c->s->info.system_values_read &
- (1ull << SYSTEM_VALUE_PRIMITIVE_ID));
+ prog_data->uses_pid = BITSET_TEST(c->s->info.system_values_read,
+ SYSTEM_VALUE_PRIMITIVE_ID);
/* Output segment size is in sectors (8 rows of 32 bits per channel) */
prog_data->vpm_output_size = align(c->vpm_output_size, 8) / 8;
diff --git a/src/compiler/glsl/ir_set_program_inouts.cpp b/src/compiler/glsl/ir_set_program_inouts.cpp
index a3cb19479b8..9657703ead8 100644
--- a/src/compiler/glsl/ir_set_program_inouts.cpp
+++ b/src/compiler/glsl/ir_set_program_inouts.cpp
@@ -124,7 +124,7 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
prog->info.fs.uses_sample_qualifier |= var->data.sample;
}
} else if (var->data.mode == ir_var_system_value) {
- prog->info.system_values_read |= bitfield;
+ BITSET_SET(prog->info.system_values_read, idx);
} else {
assert(var->data.mode == ir_var_shader_out);
if (is_patch_generic) {
@@ -432,7 +432,7 @@ do_set_program_inouts(exec_list *instructions, struct gl_program *prog,
prog->info.outputs_read = 0;
prog->info.patch_inputs_read = 0;
prog->info.patch_outputs_written = 0;
- prog->info.system_values_read = 0;
+ BITSET_ZERO(prog->info.system_values_read);
if (shader_stage == MESA_SHADER_FRAGMENT) {
prog->info.fs.uses_sample_qualifier = false;
prog->info.fs.uses_discard = false;
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index b9fd6b6b13b..f8edfbd5a1e 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -495,40 +495,40 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
case nir_intrinsic_load_barycentric_model:
case nir_intrinsic_load_gs_header_ir3:
case nir_intrinsic_load_tcs_header_ir3:
- shader->info.system_values_read |=
- (1ull << nir_system_value_from_intrinsic(instr->intrinsic));
+ BITSET_SET(shader->info.system_values_read,
+ nir_system_value_from_intrinsic(instr->intrinsic));
break;
case nir_intrinsic_load_barycentric_pixel:
if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_SMOOTH ||
nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE) {
- shader->info.system_values_read |=
- BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL);
+ BITSET_SET(shader->info.system_values_read,
+ SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL);
} else if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_NOPERSPECTIVE) {
- shader->info.system_values_read |=
- BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL);
+ BITSET_SET(shader->info.system_values_read,
+ SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL);
}
break;
case nir_intrinsic_load_barycentric_centroid:
if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_SMOOTH ||
nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE) {
- shader->info.system_values_read |=
- BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID);
+ BITSET_SET(shader->info.system_values_read,
+ SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID);
} else if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_NOPERSPECTIVE) {
- shader->info.system_values_read |=
- BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID);
+ BITSET_SET(shader->info.system_values_read,
+ SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID);
}
break;
case nir_intrinsic_load_barycentric_sample:
if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_SMOOTH ||
nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE) {
- shader->info.system_values_read |=
- BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE);
+ BITSET_SET(shader->info.system_values_read,
+ SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE);
} else if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_NOPERSPECTIVE) {
- shader->info.system_values_read |=
- BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE);
+ BITSET_SET(shader->info.system_values_read,
+ SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE);
}
if (shader->info.stage == MESA_SHADER_FRAGMENT)
shader->info.fs.uses_sample_qualifier = true;
@@ -831,7 +831,7 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
shader->info.patch_outputs_read = 0;
shader->info.patch_inputs_read = 0;
shader->info.patch_outputs_written = 0;
- shader->info.system_values_read = 0;
+ BITSET_ZERO(shader->info.system_values_read);
shader->info.inputs_read_indirectly = 0;
shader->info.outputs_accessed_indirectly = 0;
shader->info.patch_inputs_read_indirectly = 0;
@@ -864,8 +864,8 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
if (shader->info.stage == MESA_SHADER_FRAGMENT &&
(shader->info.fs.uses_sample_qualifier ||
- (shader->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_ID)) ||
- shader->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_POS))) {
+ (BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID) ||
+ BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS)))) {
/* This shouldn't be cleared because if optimizations remove all
* sample-qualified inputs and that pass is run again, the sample
* shading must stay enabled.
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 0759fdf1618..f76d863839a 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -382,15 +382,6 @@ const char *gl_varying_slot_name_for_stage(gl_varying_slot slot,
#define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
/*@}*/
-/**
- * Bitflags for system values.
- */
-#define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID)
-#define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS)
-#define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN)
-#define SYSTEM_BIT_LOCAL_INVOCATION_ID ((uint64_t)1 << SYSTEM_VALUE_LOCAL_INVOCATION_ID)
-#define SYSTEM_BIT_FRONT_FACE ((uint64_t)1 << SYSTEM_VALUE_FRONT_FACE)
-
/**
* If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be
* one of these values. If a NIR variable's mode is nir_var_system_value, it
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index f890b6c028f..097284e9d26 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -25,6 +25,7 @@
#ifndef SHADER_INFO_H
#define SHADER_INFO_H
+#include "util/bitset.h"
#include "shader_enums.h"
#include <stdint.h>
@@ -144,7 +145,7 @@ typedef struct shader_info {
/* Which outputs are actually read */
uint64_t outputs_read;
/* Which system values are actually read */
- uint64_t system_values_read;
+ BITSET_DECLARE(system_values_read, SYSTEM_VALUE_MAX);
/* Which patch inputs are actually read */
uint32_t patch_inputs_read;
diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c
index 9384406d7ca..8b52d646e79 100644
--- a/src/gallium/auxiliary/nir/nir_to_tgsi.c
+++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c
@@ -2668,7 +2668,7 @@ nir_to_tgsi(struct nir_shader *s,
* gl-2.1-polygon-stipple-fs on softpipe.
*/
if ((s->info.inputs_read & VARYING_BIT_POS) ||
- (s->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD))) {
+ BITSET_TEST(s->info.system_values_read, SYSTEM_VALUE_FRAG_COORD)) {
ureg_property(c->ureg, TGSI_PROPERTY_FS_COORD_ORIGIN,
s->info.fs.origin_upper_left ?
TGSI_FS_COORD_ORIGIN_UPPER_LEFT :
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 4eac81856f9..b58690bb1c3 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -653,8 +653,8 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
load = nir_swizzle(b, load, SWIZ(X, Y, Z, Z), 4);
src = nir_src_for_ssa(load);
- b->shader->info.system_values_read |=
- (1ull << nir_system_value_from_intrinsic(op));
+ BITSET_SET(b->shader->info.system_values_read,
+ nir_system_value_from_intrinsic(op));
break;
}
diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
index 268e23d2201..aa73f8269c9 100644
--- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
@@ -521,7 +521,7 @@ validate_geometry_shader_variant(struct d3d12_selection_context *sel_ctx)
if (sel_ctx->fill_mode_lowered != PIPE_POLYGON_MODE_FILL) {
key.fill_mode = sel_ctx->fill_mode_lowered;
key.cull_mode = sel_ctx->cull_mode_lowered;
- key.has_front_face = (fs->initial->info.system_values_read & SYSTEM_BIT_FRONT_FACE) ? 1 : 0;
+ key.has_front_face = BITSET_TEST(fs->initial->info.system_values_read, SYSTEM_VALUE_FRONT_FACE);
if (key.cull_mode != PIPE_FACE_NONE || key.has_front_face)
key.front_ccw = ctx->gfx_pipeline_state.rast->base.front_ccw ^ (ctx->flip_y < 0);
key.edge_flag_fix = needs_edge_flag_fix(ctx->initial_api_prim);
diff --git a/src/gallium/drivers/iris/iris_draw.c b/src/gallium/drivers/iris/iris_draw.c
index f64517089c3..8c05c1e22de 100644
--- a/src/gallium/drivers/iris/iris_draw.c
+++ b/src/gallium/drivers/iris/iris_draw.c
@@ -92,7 +92,7 @@ iris_update_draw_info(struct iris_context *ice,
const struct shader_info *tcs_info =
iris_get_shader_info(ice, MESA_SHADER_TESS_CTRL);
if (tcs_info &&
- tcs_info->system_values_read & (1ull << SYSTEM_VALUE_VERTICES_IN)) {
+ BITSET_TEST(tcs_info->system_values_read, SYSTEM_VALUE_VERTICES_IN)) {
ice->state.stage_dirty |= IRIS_STAGE_DIRTY_CONSTANTS_TCS;
ice->state.shaders[MESA_SHADER_TESS_CTRL].sysvals_need_upload = true;
}
diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c
index 20bef98d44b..a3b6089ab02 100644
--- a/src/gallium/drivers/iris/iris_program.c
+++ b/src/gallium/drivers/iris/iris_program.c
@@ -1537,7 +1537,7 @@ iris_update_compiled_tes(struct iris_context *ice)
/* TODO: Could compare and avoid flagging this. */
const struct shader_info *tes_info = &ish->nir->info;
- if (tes_info->system_values_read & (1ull << SYSTEM_VALUE_VERTICES_IN)) {
+ if (BITSET_TEST(tes_info->system_values_read, SYSTEM_VALUE_VERTICES_IN)) {
ice->state.stage_dirty |= IRIS_STAGE_DIRTY_CONSTANTS_TES;
ice->state.shaders[MESA_SHADER_TESS_EVAL].sysvals_need_upload = true;
}
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
index b857d3cd6a9..b52d6fd1d61 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp
@@ -983,10 +983,8 @@ bool Converter::assignSlots() {
info_out->numOutputs = 0;
info_out->numSysVals = 0;
- for (uint8_t i = 0; i < SYSTEM_VALUE_MAX; ++i) {
- if (!(nir->info.system_values_read & 1ull << i))
- continue;
-
+ uint8_t i;
+ BITSET_FOREACH_SET(i, nir->info.system_values_read, SYSTEM_VALUE_MAX) {
info_out->sv[info_out->numSysVals].sn = tgsi_get_sysval_semantic(i);
info_out->sv[info_out->numSysVals].si = 0;
info_out->sv[info_out->numSysVals].input = 0; // TODO inferSysValDirection(sn);
@@ -1299,14 +1297,14 @@ Converter::parseNIR()
case Program::TYPE_FRAGMENT:
info_out->prop.fp.earlyFragTests = nir->info.fs.early_fragment_tests;
prog->persampleInvocation =
- (nir->info.system_values_read & SYSTEM_BIT_SAMPLE_ID) ||
- (nir->info.system_values_read & SYSTEM_BIT_SAMPLE_POS);
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS);
info_out->prop.fp.postDepthCoverage = nir->info.fs.post_depth_coverage;
info_out->prop.fp.readsSampleLocations =
- (nir->info.system_values_read & SYSTEM_BIT_SAMPLE_POS);
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS);
info_out->prop.fp.usesDiscard = nir->info.fs.uses_discard || nir->info.fs.uses_demote;
info_out->prop.fp.usesSampleMaskIn =
- !!(nir->info.system_values_read & SYSTEM_BIT_SAMPLE_MASK_IN);
+ !BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_MASK_IN);
break;
case Program::TYPE_GEOMETRY:
info_out->prop.gp.instanceCount = nir->info.gs.invocations;
@@ -1327,9 +1325,9 @@ Converter::parseNIR()
break;
case Program::TYPE_VERTEX:
info_out->prop.vp.usesDrawParameters =
- (nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BASE_VERTEX)) ||
- (nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE)) ||
- (nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_DRAW_ID));
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_INSTANCE) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_DRAW_ID);
break;
default:
break;
diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c
index 8e45025f1ca..e3556b9afb8 100644
--- a/src/gallium/drivers/panfrost/pan_assemble.c
+++ b/src/gallium/drivers/panfrost/pan_assemble.c
@@ -284,8 +284,8 @@ panfrost_shader_compile(struct panfrost_context *ctx,
state->sysval_count = program->sysval_count;
memcpy(state->sysval, program->sysvals, sizeof(state->sysval[0]) * state->sysval_count);
- bool vertex_id = s->info.system_values_read & (1 << SYSTEM_VALUE_VERTEX_ID);
- bool instance_id = s->info.system_values_read & (1 << SYSTEM_VALUE_INSTANCE_ID);
+ bool vertex_id = BITSET_TEST(s->info.system_values_read, SYSTEM_VALUE_VERTEX_ID);
+ bool instance_id = BITSET_TEST(s->info.system_values_read, SYSTEM_VALUE_INSTANCE_ID);
state->writes_global = s->info.writes_memory;
@@ -343,10 +343,10 @@ panfrost_shader_compile(struct panfrost_context *ctx,
state->stack_size = program->tls_size;
state->reads_frag_coord = (s->info.inputs_read & (1 << VARYING_SLOT_POS)) ||
- (s->info.system_values_read & (1 << SYSTEM_VALUE_FRAG_COORD));
+ BITSET_TEST(s->info.system_values_read, SYSTEM_VALUE_FRAG_COORD);
state->reads_point_coord = s->info.inputs_read & (1 << VARYING_SLOT_PNTC);
state->reads_face = (s->info.inputs_read & (1 << VARYING_SLOT_FACE)) ||
- (s->info.system_values_read & (1 << SYSTEM_VALUE_FRONT_FACE));
+ BITSET_TEST(s->info.system_values_read, SYSTEM_VALUE_FRONT_FACE);
state->writes_point_size = s->info.outputs_written & (1 << VARYING_SLOT_PSIZ);
if (outputs_written)
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 366063ae118..6f2d5348262 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -374,28 +374,28 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
info->tessfactors_are_def_in_all_invocs = ac_are_tessfactors_def_in_all_invocs(nir);
}
- info->uses_frontface = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_FRONT_FACE);
- info->uses_instanceid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID);
- info->uses_base_vertex = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BASE_VERTEX);
- info->uses_base_instance = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE);
- info->uses_invocationid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_INVOCATION_ID);
- info->uses_grid_size = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_NUM_WORK_GROUPS);
- info->uses_subgroup_info = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_LOCAL_INVOCATION_INDEX) ||
- nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SUBGROUP_ID) ||
- nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_NUM_SUBGROUPS);
- info->uses_variable_block_size = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_LOCAL_GROUP_SIZE);
- info->uses_drawid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_DRAW_ID);
- info->uses_primid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_PRIMITIVE_ID) ||
+ info->uses_frontface = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_FRONT_FACE);
+ info->uses_instanceid = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_INSTANCE_ID);
+ info->uses_base_vertex = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX);
+ info->uses_base_instance = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_INSTANCE);
+ info->uses_invocationid = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_INVOCATION_ID);
+ info->uses_grid_size = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_NUM_WORK_GROUPS);
+ info->uses_subgroup_info = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_LOCAL_INVOCATION_INDEX) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SUBGROUP_ID) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_NUM_SUBGROUPS);
+ info->uses_variable_block_size = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_LOCAL_GROUP_SIZE);
+ info->uses_drawid = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_DRAW_ID);
+ info->uses_primid = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) ||
nir->info.inputs_read & VARYING_BIT_PRIMITIVE_ID;
- info->reads_samplemask = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_MASK_IN);
- info->reads_tess_factors = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_TESS_LEVEL_INNER) ||
- nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_TESS_LEVEL_OUTER);
- info->uses_linear_sample = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE);
- info->uses_linear_centroid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID);
- info->uses_linear_center = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL);
- info->uses_persp_sample = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE);
- info->uses_persp_centroid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID);
- info->uses_persp_center = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL);
+ info->reads_samplemask = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_MASK_IN);
+ info->reads_tess_factors = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_TESS_LEVEL_INNER) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_TESS_LEVEL_OUTER);
+ info->uses_linear_sample = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE);
+ info->uses_linear_centroid = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID);
+ info->uses_linear_center = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL);
+ info->uses_persp_sample = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE);
+ info->uses_persp_centroid = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID);
+ info->uses_persp_center = BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL);
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
info->writes_z = nir->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH);
@@ -434,13 +434,12 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
info->uses_interp_at_sample || nir->info.writes_memory ||
nir->info.fs.uses_fbfetch_output ||
nir->info.fs.needs_quad_helper_invocations ||
- (nir->info.system_values_read &
- (BITFIELD64_BIT(SYSTEM_VALUE_FRAG_COORD) |
- BITFIELD64_BIT(SYSTEM_VALUE_POINT_COORD) |
- BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_ID) |
- BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_POS) |
- BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_MASK_IN) |
- BITFIELD64_BIT(SYSTEM_VALUE_HELPER_INVOCATION))));
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_FRAG_COORD) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_POINT_COORD) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_MASK_IN) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_HELPER_INVOCATION));
}
/* Add color inputs to the list of inputs. */
diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c
index 28aa1ddbe57..f97153463ab 100644
--- a/src/gallium/frontends/lavapipe/lvp_pipeline.c
+++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c
@@ -792,8 +792,8 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
if (pipeline->pipeline_nir[MESA_SHADER_FRAGMENT]) {
if (pipeline->pipeline_nir[MESA_SHADER_FRAGMENT]->info.fs.uses_sample_qualifier ||
- pipeline->pipeline_nir[MESA_SHADER_FRAGMENT]->info.system_values_read & (SYSTEM_BIT_SAMPLE_ID |
- SYSTEM_BIT_SAMPLE_POS))
+ BITSET_TEST(pipeline->pipeline_nir[MESA_SHADER_FRAGMENT]->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID) ||
+ BITSET_TEST(pipeline->pipeline_nir[MESA_SHADER_FRAGMENT]->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS))
pipeline->force_min_sample = true;
}
if (pipeline->pipeline_nir[MESA_SHADER_TESS_CTRL]) {
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index 3420028cb60..a2e0e40ff48 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -8505,7 +8505,7 @@ fs_visitor::run_fs(bool allow_spilling, bool do_rep_send)
emit_shader_time_begin();
if (nir->info.inputs_read > 0 ||
- (nir->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD)) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_FRAG_COORD) ||
(nir->info.outputs_read > 0 && !wm_key->coherent_fb_fetch)) {
if (devinfo->gen < 6)
emit_interpolation_setup_gen4();
@@ -8886,7 +8886,7 @@ brw_nir_populate_wm_prog_data(const nir_shader *shader,
struct brw_wm_prog_data *prog_data)
{
prog_data->uses_src_depth = prog_data->uses_src_w =
- shader->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_FRAG_COORD);
+ BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_FRAG_COORD);
/* key->alpha_test_func means simulating alpha testing via discards,
* so the shader definitely kills pixels.
@@ -8902,14 +8902,14 @@ brw_nir_populate_wm_prog_data(const nir_shader *shader,
prog_data->persample_dispatch =
key->multisample_fbo &&
(key->persample_interp ||
- (shader->info.system_values_read & (SYSTEM_BIT_SAMPLE_ID |
- SYSTEM_BIT_SAMPLE_POS)) ||
+ BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID) ||
+ BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS) ||
shader->info.fs.uses_sample_qualifier ||
shader->info.outputs_read);
if (devinfo->gen >= 6) {
prog_data->uses_sample_mask =
- shader->info.system_values_read & SYSTEM_BIT_SAMPLE_MASK_IN;
+ BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_MASK_IN);
/* From the Ivy Bridge PRM documentation for 3DSTATE_PS:
*
@@ -8921,7 +8921,7 @@ brw_nir_populate_wm_prog_data(const nir_shader *shader,
* persample dispatch, we hard-code it to 0.5.
*/
prog_data->uses_pos_offset = prog_data->persample_dispatch &&
- (shader->info.system_values_read & SYSTEM_BIT_SAMPLE_POS);
+ BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS);
}
prog_data->has_render_target_reads = shader->info.outputs_read != 0ull;
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index 16ae9ccc04f..af322f5cff4 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -186,11 +186,10 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
* included here as it lives in its own vec4.
*/
const bool has_sgvs =
- nir->info.system_values_read &
- (BITFIELD64_BIT(SYSTEM_VALUE_FIRST_VERTEX) |
- BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE) |
- BITFIELD64_BIT(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) |
- BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID));
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_FIRST_VERTEX) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_INSTANCE) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_INSTANCE_ID);
const unsigned num_inputs = util_bitcount64(nir->info.inputs_read);
diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp
index d21c6750edf..b00c31c6b39 100644
--- a/src/intel/compiler/brw_vec4.cpp
+++ b/src/intel/compiler/brw_vec4.cpp
@@ -2876,43 +2876,35 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
/* gl_VertexID and gl_InstanceID are system values, but arrive via an
* incoming vertex attribute. So, add an extra slot.
*/
- if (nir->info.system_values_read &
- (BITFIELD64_BIT(SYSTEM_VALUE_FIRST_VERTEX) |
- BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE) |
- BITFIELD64_BIT(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) |
- BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID))) {
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_FIRST_VERTEX) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_INSTANCE) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_INSTANCE_ID)) {
nr_attribute_slots++;
}
/* gl_DrawID and IsIndexedDraw share its very own vec4 */
- if (nir->info.system_values_read &
- (BITFIELD64_BIT(SYSTEM_VALUE_DRAW_ID) |
- BITFIELD64_BIT(SYSTEM_VALUE_IS_INDEXED_DRAW))) {
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_DRAW_ID) ||
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_IS_INDEXED_DRAW)) {
nr_attribute_slots++;
}
- if (nir->info.system_values_read &
- BITFIELD64_BIT(SYSTEM_VALUE_IS_INDEXED_DRAW))
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_IS_INDEXED_DRAW))
prog_data->uses_is_indexed_draw = true;
- if (nir->info.system_values_read &
- BITFIELD64_BIT(SYSTEM_VALUE_FIRST_VERTEX))
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_FIRST_VERTEX))
prog_data->uses_firstvertex = true;
- if (nir->info.system_values_read &
- BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE))
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_BASE_INSTANCE))
prog_data->uses_baseinstance = true;
- if (nir->info.system_values_read &
- BITFIELD64_BIT(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE))
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE))
prog_data->uses_vertexid = true;
- if (nir->info.system_values_read &
- BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID))
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_INSTANCE_ID))
prog_data->uses_instanceid = true;
- if (nir->info.system_values_read &
- BITFIELD64_BIT(SYSTEM_VALUE_DRAW_ID))
+ if (BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_DRAW_ID))
prog_data->uses_drawid = true;
/* The 3DSTATE_VS documentation lists the lower bound on "Vertex URB Entry
diff --git a/src/intel/compiler/brw_vec4_gs_visitor.cpp b/src/intel/compiler/brw_vec4_gs_visitor.cpp
index 2a1841c7875..3c8ab531215 100644
--- a/src/intel/compiler/brw_vec4_gs_visitor.cpp
+++ b/src/intel/compiler/brw_vec4_gs_visitor.cpp
@@ -625,7 +625,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
nir->info.clip_distance_array_size;
prog_data->include_primitive_id =
- (nir->info.system_values_read & (1 << SYSTEM_VALUE_PRIMITIVE_ID)) != 0;
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID);
prog_data->invocations = nir->info.gs.invocations;
diff --git a/src/intel/compiler/brw_vec4_tcs.cpp b/src/intel/compiler/brw_vec4_tcs.cpp
index 5268e8b6cf6..a358b21daf1 100644
--- a/src/intel/compiler/brw_vec4_tcs.cpp
+++ b/src/intel/compiler/brw_vec4_tcs.cpp
@@ -392,7 +392,7 @@ brw_compile_tcs(const struct brw_compiler *compiler,
brw_postprocess_nir(nir, compiler, is_scalar);
bool has_primitive_id =
- nir->info.system_values_read & (1 << SYSTEM_VALUE_PRIMITIVE_ID);
+ BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID);
prog_data->patch_count_threshold = brw::get_patch_count_threshold(key->input_vertices);
diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
index abe8d099a19..58b098a997c 100644
--- a/src/mesa/drivers/dri/i965/brw_curbe.c
+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
@@ -332,7 +332,7 @@ emit:
* BRW_NEW_FRAGMENT_PROGRAM
*/
if (devinfo->gen == 4 && !devinfo->is_g4x &&
- (fp->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD))) {
+ BITSET_TEST(fp->info.system_values_read, SYSTEM_VALUE_FRAG_COORD)) {
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP << 16 | (2 - 2));
OUT_BATCH(0);
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 6b1c5cf1fa9..1083ded50d3 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -174,14 +174,14 @@ _mesa_update_primitive_id_is_unused(struct gl_context *ctx)
* then the restriction on fragment shaders reading gl_PrimitiveID can be lifted.
*/
ctx->_PrimitiveIDIsUnused = !(
- (tcs && (tcs->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_PRIMITIVE_ID) ||
- tcs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) ||
- (tes && (tes->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_PRIMITIVE_ID) ||
- tes->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) ||
- (gs && (gs->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_PRIMITIVE_ID) ||
- gs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) ||
- (fs && (fs->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_PRIMITIVE_ID) ||
- fs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)));
+ (tcs && (BITSET_TEST(tcs->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) ||
+ tcs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) ||
+ (tes && (BITSET_TEST(tes->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) ||
+ tes->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) ||
+ (gs && (BITSET_TEST(gs->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) ||
+ gs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)) ||
+ (fs && (BITSET_TEST(fs->info.system_values_read, SYSTEM_VALUE_PRIMITIVE_ID) ||
+ fs->info.inputs_read & VARYING_BIT_PRIMITIVE_ID)));
}
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index d8465b3bbfe..bb569e4284d 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -904,10 +904,8 @@ setup_registers_and_variables(struct ptn_compile *c)
}
/* Create system value variables */
- uint64_t system_values_read = c->prog->info.system_values_read;
- while (system_values_read) {
- const int i = u_bit_scan64(&system_values_read);
-
+ int i;
+ BITSET_FOREACH_SET(i, c->prog->info.system_values_read, SYSTEM_VALUE_MAX) {
nir_variable *var =
nir_variable_create(shader, nir_var_system_value, glsl_vec4_type(),
ralloc_asprintf(shader, "sv_%d", i));
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index 2bdfdb591fa..d23cbafd230 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -524,8 +524,8 @@ _mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
* forces per-sample shading"
*/
if (prog->info.fs.uses_sample_qualifier ||
- (prog->info.system_values_read & (SYSTEM_BIT_SAMPLE_ID |
- SYSTEM_BIT_SAMPLE_POS)))
+ BITSET_TEST(prog->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID) ||
+ BITSET_TEST(prog->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS))
return MAX2(_mesa_geometric_samples(ctx->DrawBuffer), 1);
else if (ctx->Multisample.SampleShading)
return MAX2(ceilf(ctx->Multisample.MinSampleShadingValue *
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
index 71d53eea65f..ddbfbb45eff 100644
--- a/src/mesa/program/programopt.c
+++ b/src/mesa/program/programopt.c
@@ -597,7 +597,7 @@ _mesa_program_fragment_position_to_sysval(struct gl_program *prog)
return;
prog->info.inputs_read &= ~BITFIELD64_BIT(VARYING_SLOT_POS);
- prog->info.system_values_read |= 1 << SYSTEM_VALUE_FRAG_COORD;
+ BITSET_SET(prog->info.system_values_read, SYSTEM_VALUE_FRAG_COORD);
for (i = 0; i < prog->arb.NumInstructions; i++) {
struct prog_instruction *inst = prog->arb.Instructions + i;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 9e9289b41cb..e7aa568fcf5 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6886,49 +6886,41 @@ st_translate_program(
/* Declare misc input registers
*/
- {
- GLbitfield64 sysInputs = proginfo->info.system_values_read;
-
- for (i = 0; sysInputs; i++) {
- if (sysInputs & (1ull << i)) {
- enum tgsi_semantic semName = tgsi_get_sysval_semantic(i);
-
- t->systemValues[i] = ureg_DECL_system_value(ureg, semName, 0);
-
- if (semName == TGSI_SEMANTIC_INSTANCEID ||
- semName == TGSI_SEMANTIC_VERTEXID) {
- /* From Gallium perspective, these system values are always
- * integer, and require native integer support. However, if
- * native integer is supported on the vertex stage but not the
- * pixel stage (e.g, i915g + draw), Mesa will generate IR that
- * assumes these system values are floats. To resolve the
- * inconsistency, we insert a U2F.
- */
- struct st_context *st = st_context(ctx);
- struct pipe_screen *pscreen = st->screen;
- assert(procType == PIPE_SHADER_VERTEX);
- assert(pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS));
- (void) pscreen;
- if (!ctx->Const.NativeIntegers) {
- struct ureg_dst temp = ureg_DECL_local_temporary(t->ureg);
- ureg_U2F(t->ureg, ureg_writemask(temp, TGSI_WRITEMASK_X),
- t->systemValues[i]);
- t->systemValues[i] = ureg_scalar(ureg_src(temp), 0);
- }
- }
-
- if (procType == PIPE_SHADER_FRAGMENT &&
- semName == TGSI_SEMANTIC_POSITION)
- emit_wpos(st_context(ctx), t, proginfo, ureg,
- program->wpos_transform_const);
-
- if (procType == PIPE_SHADER_FRAGMENT &&
- semName == TGSI_SEMANTIC_SAMPLEPOS)
- emit_samplepos_adjustment(t, program->wpos_transform_const);
-
- sysInputs &= ~(1ull << i);
+ BITSET_FOREACH_SET(i, proginfo->info.system_values_read, SYSTEM_VALUE_MAX) {
+ enum tgsi_semantic semName = tgsi_get_sysval_semantic(i);
+
+ t->systemValues[i] = ureg_DECL_system_value(ureg, semName, 0);
+
+ if (semName == TGSI_SEMANTIC_INSTANCEID ||
+ semName == TGSI_SEMANTIC_VERTEXID) {
+ /* From Gallium perspective, these system values are always
+ * integer, and require native integer support. However, if
+ * native integer is supported on the vertex stage but not the
+ * pixel stage (e.g, i915g + draw), Mesa will generate IR that
+ * assumes these system values are floats. To resolve the
+ * inconsistency, we insert a U2F.
+ */
+ struct st_context *st = st_context(ctx);
+ struct pipe_screen *pscreen = st->screen;
+ assert(procType == PIPE_SHADER_VERTEX);
+ assert(pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS));
+ (void) pscreen;
+ if (!ctx->Const.NativeIntegers) {
+ struct ureg_dst temp = ureg_DECL_local_temporary(t->ureg);
+ ureg_U2F(t->ureg, ureg_writemask(temp, TGSI_WRITEMASK_X),
+ t->systemValues[i]);
+ t->systemValues[i] = ureg_scalar(ureg_src(temp), 0);
}
}
+
+ if (procType == PIPE_SHADER_FRAGMENT &&
+ semName == TGSI_SEMANTIC_POSITION)
+ emit_wpos(st_context(ctx), t, proginfo, ureg,
+ program->wpos_transform_const);
+
+ if (procType == PIPE_SHADER_FRAGMENT &&
+ semName == TGSI_SEMANTIC_SAMPLEPOS)
+ emit_samplepos_adjustment(t, program->wpos_transform_const);
}
t->array_sizes = program->array_sizes;
@@ -7231,8 +7223,8 @@ get_mesa_program_tgsi(struct gl_context *ctx,
/* This must be done before the uniform storage is associated. */
if (shader->Stage == MESA_SHADER_FRAGMENT &&
(prog->info.inputs_read & VARYING_BIT_POS ||
- prog->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD) ||
- prog->info.system_values_read & (1ull << SYSTEM_VALUE_SAMPLE_POS))) {
+ BITSET_TEST(prog->info.system_values_read, SYSTEM_VALUE_FRAG_COORD) ||
+ BITSET_TEST(prog->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS))) {
static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
};
diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c
index 6156848c161..597dd4d59ff 100644
--- a/src/microsoft/compiler/nir_to_dxil.c
+++ b/src/microsoft/compiler/nir_to_dxil.c
@@ -4214,7 +4214,7 @@ allocate_sysvalues(struct ntd_context *ctx, nir_shader *s)
for (unsigned i = 0; i < ARRAY_SIZE(possible_sysvalues); ++i) {
struct sysvalue_name *info = &possible_sysvalues[i];
- if ((1 << info->value) & s->info.system_values_read) {
+ if (BITSET_TEST(s->info.system_values_read, info->value)) {
if (!append_input_or_sysvalue(ctx, s, info->slot,
info->value, info->name,
driver_location++))
More information about the mesa-commit
mailing list