summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorDylan Baker <[email protected]>2018-08-21 09:46:46 -0700
committerDylan Baker <[email protected]>2018-09-07 10:21:26 -0700
commit8396043f304bb2a752130230055605c5c966e89f (patch)
treeee2e8a5494b88bff3b5e67ece8ffdba70d12c087 /src/compiler
parent80825abb5d1a7491035880253ffd531c55acae6b (diff)
Replace uses of _mesa_bitcount with util_bitcount
and _mesa_bitcount_64 with util_bitcount_64. This fixes a build problem in nir for platforms that don't have popcount or popcountll, such as 32bit msvc. v2: - Fix additional uses of _mesa_bitcount added after this was originally written Acked-by: Eric Engestrom <[email protected]> (v1) Acked-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/ir_constant_expression.cpp2
-rw-r--r--src/compiler/glsl/ir_expression_operation.py2
-rw-r--r--src/compiler/glsl/link_varyings.cpp5
-rw-r--r--src/compiler/glsl/linker.cpp9
-rw-r--r--src/compiler/nir/nir.c6
-rw-r--r--src/compiler/nir/nir_split_vars.c6
6 files changed, 16 insertions, 14 deletions
diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp
index c9788c70535..bfc22c0011a 100644
--- a/src/compiler/glsl/ir_constant_expression.cpp
+++ b/src/compiler/glsl/ir_constant_expression.cpp
@@ -39,7 +39,7 @@
#include "ir.h"
#include "compiler/glsl_types.h"
#include "util/hash_table.h"
-#include "main/imports.h"
+#include "util/u_math.h"
static float
dot_f(ir_constant *op0, ir_constant *op1)
diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py
index 16b98690a6d..306fc35f605 100644
--- a/src/compiler/glsl/ir_expression_operation.py
+++ b/src/compiler/glsl/ir_expression_operation.py
@@ -535,7 +535,7 @@ ir_expression_operation = [
# Bit operations, part of ARB_gpu_shader5.
operation("bitfield_reverse", 1, source_types=(uint_type, int_type), c_expression="bitfield_reverse({src0})"),
- operation("bit_count", 1, source_types=(uint_type, int_type), dest_type=int_type, c_expression="_mesa_bitcount({src0})"),
+ operation("bit_count", 1, source_types=(uint_type, int_type), dest_type=int_type, c_expression="util_bitcount({src0})"),
operation("find_msb", 1, source_types=(uint_type, int_type), dest_type=int_type, c_expression={'u': "find_msb_uint({src0})", 'i': "find_msb_int({src0})"}),
operation("find_lsb", 1, source_types=(uint_type, int_type), dest_type=int_type, c_expression="find_msb_uint({src0} & -{src0})"),
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 211633d9ee3..52e493cb599 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -38,6 +38,7 @@
#include "link_varyings.h"
#include "main/macros.h"
#include "util/hash_table.h"
+#include "util/u_math.h"
#include "program.h"
@@ -2879,13 +2880,13 @@ link_varyings(struct gl_shader_program *prog, unsigned first, unsigned last,
/* This must be done after all dead varyings are eliminated. */
if (sh_i != NULL) {
- unsigned slots_used = _mesa_bitcount_64(reserved_out_slots);
+ unsigned slots_used = util_bitcount64(reserved_out_slots);
if (!check_against_output_limit(ctx, prog, sh_i, slots_used)) {
return false;
}
}
- unsigned slots_used = _mesa_bitcount_64(reserved_in_slots);
+ unsigned slots_used = util_bitcount64(reserved_in_slots);
if (!check_against_input_limit(ctx, prog, sh_next, slots_used))
return false;
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index f08971d7803..57cf7eb2a8c 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -84,6 +84,7 @@
#include "builtin_functions.h"
#include "shader_cache.h"
#include "util/u_string.h"
+#include "util/u_math.h"
#include "main/imports.h"
#include "main/shaderobj.h"
@@ -3013,8 +3014,8 @@ assign_attribute_or_color_locations(void *mem_ctx,
if (target_index == MESA_SHADER_VERTEX) {
unsigned total_attribs_size =
- _mesa_bitcount(used_locations & SAFE_MASK_FROM_INDEX(max_index)) +
- _mesa_bitcount(double_storage_locations);
+ util_bitcount(used_locations & SAFE_MASK_FROM_INDEX(max_index)) +
+ util_bitcount(double_storage_locations);
if (total_attribs_size > max_index) {
linker_error(prog,
"attempt to use %d vertex attribute slots only %d available ",
@@ -3077,8 +3078,8 @@ assign_attribute_or_color_locations(void *mem_ctx,
*/
if (target_index == MESA_SHADER_VERTEX) {
unsigned total_attribs_size =
- _mesa_bitcount(used_locations & SAFE_MASK_FROM_INDEX(max_index)) +
- _mesa_bitcount(double_storage_locations);
+ util_bitcount(used_locations & SAFE_MASK_FROM_INDEX(max_index)) +
+ util_bitcount(double_storage_locations);
if (total_attribs_size > max_index) {
linker_error(prog,
"attempt to use %d vertex attribute slots only %d available ",
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index a6240c11f2d..402fd2c7725 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -31,8 +31,8 @@
#include <limits.h>
#include <assert.h>
#include <math.h>
+#include "util/u_math.h"
-#include "main/imports.h" /* _mesa_bitcount_64 */
#include "main/menums.h" /* BITFIELD64_MASK */
nir_shader *
@@ -1862,7 +1862,7 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
* the original OpenGL single-slot input numbering. The mapping from old
* locations to new locations is as follows:
*
- * new_loc = loc + _mesa_bitcount(dual_slot & BITFIELD64_MASK(loc))
+ * new_loc = loc + util_bitcount(dual_slot & BITFIELD64_MASK(loc))
*/
void
nir_remap_dual_slot_attributes(nir_shader *shader, uint64_t *dual_slot)
@@ -1879,7 +1879,7 @@ nir_remap_dual_slot_attributes(nir_shader *shader, uint64_t *dual_slot)
nir_foreach_variable(var, &shader->inputs) {
var->data.location +=
- _mesa_bitcount_64(*dual_slot & BITFIELD64_MASK(var->data.location));
+ util_bitcount64(*dual_slot & BITFIELD64_MASK(var->data.location));
}
}
diff --git a/src/compiler/nir/nir_split_vars.c b/src/compiler/nir/nir_split_vars.c
index 6cd835cb013..02aef2a9b47 100644
--- a/src/compiler/nir/nir_split_vars.c
+++ b/src/compiler/nir/nir_split_vars.c
@@ -26,8 +26,8 @@
#include "nir_deref.h"
#include "nir_vla.h"
-/* Needed for _mesa_bitcount() */
-#include "main/macros.h"
+#include "util/u_math.h"
+
struct split_var_state {
void *mem_ctx;
@@ -1277,7 +1277,7 @@ shrink_vec_var_list(struct exec_list *vars,
}
/* Build the new var type */
- unsigned new_num_comps = _mesa_bitcount(usage->comps_kept);
+ unsigned new_num_comps = util_bitcount(usage->comps_kept);
const struct glsl_type *new_type =
glsl_vector_type(glsl_get_base_type(vec_type), new_num_comps);
for (int i = usage->num_levels - 1; i >= 0; i--) {