#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)
# 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})"),
#include "link_varyings.h"
#include "main/macros.h"
#include "util/hash_table.h"
+#include "util/u_math.h"
#include "program.h"
/* 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;
#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"
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 ",
*/
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 ",
#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 *
* 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)
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));
}
}
#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;
}
/* 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--) {
#include "xm_api.h"
#include "main/imports.h"
#include "main/errors.h"
+#include "util/u_math.h"
/* An "Atrribs/Attribs" typo was fixed in glxproto.h in Nov 2014.
* This is in case we don't have the updated header.
* 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
*/
if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
- if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 &&
- _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
- _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
+ if (util_bitcount((GLuint) vis->red_mask ) <= 8 &&
+ util_bitcount((GLuint) vis->green_mask) <= 8 &&
+ util_bitcount((GLuint) vis->blue_mask ) <= 8) {
return vis;
}
else {
#include "util/u_atomic.h"
#include "util/u_inlines.h"
+#include "util/u_math.h"
#include "hud/hud_context.h"
{
const int xclass = v->visualType;
if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) {
- red_bits = _mesa_bitcount(GET_REDMASK(v));
- green_bits = _mesa_bitcount(GET_GREENMASK(v));
- blue_bits = _mesa_bitcount(GET_BLUEMASK(v));
+ red_bits = util_bitcount(GET_REDMASK(v));
+ green_bits = util_bitcount(GET_GREENMASK(v));
+ blue_bits = util_bitcount(GET_BLUEMASK(v));
}
else {
/* this is an approximation */
if (ctx->Extensions.ARB_texture_non_power_of_two) {
target = GLX_TEXTURE_2D_EXT;
}
- else if ( _mesa_bitcount(b->width) == 1
- && _mesa_bitcount(b->height) == 1) {
+ else if ( util_bitcount(b->width) == 1
+ && util_bitcount(b->height) == 1) {
/* power of two size */
if (b->height == 1) {
target = GLX_TEXTURE_1D_EXT;
$(top_builddir)/src/mapi/glapi/libglapi.la \
$(top_builddir)/src/mesa/libmesagallium.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
+ $(top_builddir)/src/util/libmesautil.la \
$(SHARED_GLAPI_LIB) \
$(GL_LIB_DEPS) \
$(CLOCK_LIB) \
#include "util/format_rgb9e5.h"
/* header-only include needed for _mesa_unorm_to_float and friends. */
#include "mesa/main/format_utils.h"
+#include "util/u_math.h"
#define FILE_DEBUG_FLAG DEBUG_BLORP
#ifdef HAVE___BUILTIN_CTZ
return __builtin_ctz(~value);
#else
- return _mesa_bitcount(value & ~(value + 1));
+ return util_bitcount(value & ~(value + 1));
#endif
}
nir_ssa_def *texture_data[5];
unsigned stack_depth = 0;
for (unsigned i = 0; i < tex_samples; ++i) {
- assert(stack_depth == _mesa_bitcount(i)); /* Loop invariant */
+ assert(stack_depth == util_bitcount(i)); /* Loop invariant */
/* Push sample i onto the stack */
assert(stack_depth < ARRAY_SIZE(texture_data));
#include "compiler/glsl_types.h"
#include "compiler/nir/nir_builder.h"
#include "program/prog_parameter.h"
+#include "util/u_math.h"
using namespace brw;
int urb_next = 0;
/* Figure out where each of the incoming setup attributes lands. */
if (devinfo->gen >= 6) {
- if (_mesa_bitcount_64(nir->info.inputs_read &
+ if (util_bitcount64(nir->info.inputs_read &
BRW_FS_VARYING_INPUT_MASK) <= 16) {
/* The SF/SBE pipeline stage can do arbitrary rearrangement of the
* first 16 varying inputs, so we can put them wherever we want.
#include "brw_fs.h"
#include "brw_fs_surface_builder.h"
#include "brw_nir.h"
+#include "util/u_math.h"
using namespace brw;
using namespace brw::surface_access;
/* Since NIR is doing the scalarizing for us, we should only ever see
* vectorized operations with a single channel.
*/
- assert(_mesa_bitcount(instr->dest.write_mask) == 1);
+ assert(util_bitcount(instr->dest.write_mask) == 1);
channel = ffs(instr->dest.write_mask) - 1;
result = offset(result, bld, channel);
#include "common/gen_debug.h"
#include "compiler/glsl_types.h"
#include "compiler/nir/nir_builder.h"
+#include "util/u_math.h"
static bool
is_input(nir_intrinsic_instr *intrin)
BITFIELD64_BIT(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) |
BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID));
- const unsigned num_inputs = _mesa_bitcount_64(nir->info.inputs_read);
+ const unsigned num_inputs = util_bitcount64(nir->info.inputs_read);
nir_foreach_function(function, nir) {
if (!function->impl)
* before it and counting the bits.
*/
int attr = nir_intrinsic_base(intrin);
- int slot = _mesa_bitcount_64(nir->info.inputs_read &
+ int slot = util_bitcount64(nir->info.inputs_read &
BITFIELD64_MASK(attr));
nir_intrinsic_set_base(intrin, slot);
break;
#include "brw_dead_control_flow.h"
#include "common/gen_debug.h"
#include "program/prog_parameter.h"
+#include "util/u_math.h"
#define MAX_INSTRUCTION (1 << 30)
((1 << shader->info.cull_distance_array_size) - 1) <<
shader->info.clip_distance_array_size;
- unsigned nr_attribute_slots = _mesa_bitcount_64(prog_data->inputs_read);
+ unsigned nr_attribute_slots = util_bitcount64(prog_data->inputs_read);
/* gl_VertexID and gl_InstanceID are system values, but arrive via an
* incoming vertex attribute. So, add an extra slot.
#include "brw_vec4.h"
#include "brw_cfg.h"
#include "brw_eu.h"
+#include "util/u_math.h"
namespace brw {
* determine which edges should be drawn as wireframe.
*/
current_annotation = "edge flag";
- int edge_attr = _mesa_bitcount_64(nir->info.inputs_read &
+ int edge_attr = util_bitcount64(nir->info.inputs_read &
BITFIELD64_MASK(VERT_ATTRIB_EDGEFLAG));
emit(MOV(reg, src_reg(dst_reg(ATTR, edge_attr,
glsl_type::float_type, WRITEMASK_XYZW))));
assert(anv_image_aspects_compatible(src_mask, dst_mask));
- if (_mesa_bitcount(src_mask) > 1) {
+ if (util_bitcount(src_mask) > 1) {
uint32_t aspect_bit;
anv_foreach_image_aspect_bit(aspect_bit, src_image, src_mask) {
struct blorp_surf src_surf, dst_surf;
#include "anv_private.h"
#include "util/debug.h"
#include "vk_util.h"
+#include "util/u_math.h"
#include "vk_format_info.h"
assert(image != NULL);
/* The aspect must be exactly one of the image aspects. */
- assert(_mesa_bitcount(aspect) == 1 && (aspect & image->aspects));
+ assert(util_bitcount(aspect) == 1 && (aspect & image->aspects));
/* Determine the optimal buffer. */
const VkImageLayout layout)
{
/* The aspect must be exactly one of the image aspects. */
- assert(_mesa_bitcount(aspect) == 1 && (aspect & image->aspects));
+ assert(util_bitcount(aspect) == 1 && (aspect & image->aspects));
uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
remap_aspect_flags(VkImageAspectFlags view_aspects)
{
if (view_aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) {
- if (_mesa_bitcount(view_aspects) == 1)
+ if (util_bitcount(view_aspects) == 1)
return VK_IMAGE_ASPECT_COLOR_BIT;
VkImageAspectFlags color_aspects = 0;
- for (uint32_t i = 0; i < _mesa_bitcount(view_aspects); i++)
+ for (uint32_t i = 0; i < util_bitcount(view_aspects); i++)
color_aspects |= VK_IMAGE_ASPECT_PLANE_0_BIT << i;
return color_aspects;
}
*/
state->instance_id =
nir_idiv(b, nir_load_instance_id(b),
- nir_imm_int(b, _mesa_bitcount(state->view_mask)));
+ nir_imm_int(b, util_bitcount(state->view_mask)));
}
return state->instance_id;
b->cursor = nir_before_block(nir_start_block(b->impl));
assert(state->view_mask != 0);
- if (_mesa_bitcount(state->view_mask) == 1) {
+ if (util_bitcount(state->view_mask) == 1) {
/* Set the view index directly. */
state->view_index = nir_imm_int(b, ffs(state->view_mask) - 1);
} else if (state->builder.shader->info.stage == MESA_SHADER_VERTEX) {
*/
nir_ssa_def *compacted =
nir_umod(b, nir_load_instance_id(b),
- nir_imm_int(b, _mesa_bitcount(state->view_mask)));
+ nir_imm_int(b, util_bitcount(state->view_mask)));
if (util_is_power_of_two_or_zero(state->view_mask + 1)) {
/* If we have a full view mask, then compacted is what we want */
/* Unless there is only one possible view index (that would be set
* directly), pass it to the next stage. */
- if (_mesa_bitcount(state.view_mask) != 1) {
+ if (util_bitcount(state.view_mask) != 1) {
nir_variable *view_index_out =
nir_variable_create(shader, nir_var_shader_out,
glsl_int_type(), "view index");
key->color_outputs_valid |= (1 << i);
}
- key->nr_color_regions = _mesa_bitcount(key->color_outputs_valid);
+ key->nr_color_regions = util_bitcount(key->color_outputs_valid);
key->replicate_alpha = key->nr_color_regions > 1 &&
ms_info && ms_info->alphaToCoverageEnable;
#include "util/set.h"
#include "util/u_atomic.h"
#include "util/u_vector.h"
+#include "util/u_math.h"
#include "util/vma.h"
#include "vk_alloc.h"
#include "vk_debug_report.h"
uint32_t plane)
{
if (image_aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) {
- if (_mesa_bitcount(image_aspects) > 1)
+ if (util_bitcount(image_aspects) > 1)
return VK_IMAGE_ASPECT_PLANE_0_BIT << plane;
return VK_IMAGE_ASPECT_COLOR_BIT;
}
/* Only 1 color aspects are compatibles. */
if ((aspects1 & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) != 0 &&
(aspects2 & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) != 0 &&
- _mesa_bitcount(aspects1) == _mesa_bitcount(aspects2))
+ util_bitcount(aspects1) == util_bitcount(aspects2))
return true;
return false;
static inline unsigned
anv_subpass_view_count(const struct anv_subpass *subpass)
{
- return MAX2(1, _mesa_bitcount(subpass->view_mask));
+ return MAX2(1, util_bitcount(subpass->view_mask));
}
struct anv_render_pass_attachment {
uint32_t layer_count)
{
/* The aspect must be exactly one of the image aspects. */
- assert(_mesa_bitcount(aspect) == 1 && (aspect & image->aspects));
+ assert(util_bitcount(aspect) == 1 && (aspect & image->aspects));
/* The only compression types with more than just fast-clears are MCS,
* CCS_E, and HiZ. With HiZ we just trust the layout and don't actually
#endif
const unsigned num_stages =
- _mesa_bitcount(stages & VK_SHADER_STAGE_ALL_GRAPHICS);
+ util_bitcount(stages & VK_SHADER_STAGE_ALL_GRAPHICS);
unsigned size_per_stage = push_constant_kb / num_stages;
/* Broadwell+ and Haswell gt3 require that the push constant sizes be in
pipeline_statistics &= ANV_PIPELINE_STATISTICS_MASK;
/* Statistics queries have a min and max for every statistic */
- uint64s_per_slot += 2 * _mesa_bitcount(pipeline_statistics);
+ uint64s_per_slot += 2 * util_bitcount(pipeline_statistics);
break;
default:
assert(!"Invalid query type");
idx++;
}
- assert(idx == _mesa_bitcount(pool->pipeline_statistics));
+ assert(idx == util_bitcount(pool->pipeline_statistics));
break;
}
if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) {
uint32_t idx = (pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS) ?
- _mesa_bitcount(pool->pipeline_statistics) : 1;
+ util_bitcount(pool->pipeline_statistics) : 1;
cpu_write_query_result(pData, flags, idx, available);
}
*/
if (cmd_buffer->state.subpass && cmd_buffer->state.subpass->view_mask) {
const uint32_t num_queries =
- _mesa_bitcount(cmd_buffer->state.subpass->view_mask);
+ util_bitcount(cmd_buffer->state.subpass->view_mask);
if (num_queries > 1)
emit_zero_queries(cmd_buffer, pool, query + 1, num_queries - 1);
}
*/
if (cmd_buffer->state.subpass && cmd_buffer->state.subpass->view_mask) {
const uint32_t num_queries =
- _mesa_bitcount(cmd_buffer->state.subpass->view_mask);
+ util_bitcount(cmd_buffer->state.subpass->view_mask);
if (num_queries > 1)
emit_zero_queries(cmd_buffer, pool, query + 1, num_queries - 1);
}
idx++;
}
- assert(idx == _mesa_bitcount(pool->pipeline_statistics));
+ assert(idx == util_bitcount(pool->pipeline_statistics));
break;
}
if (flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT) {
uint32_t idx = (pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS) ?
- _mesa_bitcount(pool->pipeline_statistics) : 1;
+ util_bitcount(pool->pipeline_statistics) : 1;
emit_load_alu_reg_u64(&cmd_buffer->batch, CS_GPR(0),
&pool->bo, slot_offset);
#include "util/bitscan.h"
#include "util/ralloc.h"
#include "compiler/nir/nir.h"
+#include "util/u_math.h"
/** Return offset in bytes of the field within a vertex struct */
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
assert((bits & ~BUFFER_BITS_COLOR) == 0);
/* Make sure we don't overflow any arrays. */
- assert(_mesa_bitcount(bits) <= MAX_DRAW_BUFFERS);
+ assert(util_bitcount(bits) <= MAX_DRAW_BUFFERS);
enums[0] = GL_NONE;
assert((mask & ~BUFFER_BITS_COLOR) == 0);
/* Make sure we don't overflow any arrays. */
- assert(_mesa_bitcount(mask) <= MAX_DRAW_BUFFERS);
+ assert(util_bitcount(mask) <= MAX_DRAW_BUFFERS);
enums[0] = GL_NONE;
#include "brw_defines.h"
#include "brw_state.h"
#include "brw_util.h"
+#include "util/u_math.h"
/**
/* _NEW_TRANSFORM */
if (ctx->Transform.ClipPlanesEnabled) {
- GLuint nr_planes = 6 + _mesa_bitcount(ctx->Transform.ClipPlanesEnabled);
+ GLuint nr_planes = 6 + util_bitcount(ctx->Transform.ClipPlanesEnabled);
nr_clip_regs = (nr_planes * 4 + 15) / 16;
}
#include "util/ralloc.h"
#include "util/hash_table.h"
#include "util/list.h"
+#include "util/u_math.h"
#include "brw_context.h"
#include "brw_defines.h"
for (int i = 0; i < sizeof(devinfo->subslice_masks[i]); i++) {
brw->perfquery.sys_vars.n_eu_sub_slices +=
- _mesa_bitcount(devinfo->subslice_masks[i]);
+ util_bitcount(devinfo->subslice_masks[i]);
}
for (int i = 0; i < sizeof(devinfo->eu_masks); i++)
- brw->perfquery.sys_vars.n_eus += _mesa_bitcount(devinfo->eu_masks[i]);
+ brw->perfquery.sys_vars.n_eus += util_bitcount(devinfo->eu_masks[i]);
brw->perfquery.sys_vars.eu_threads_count =
brw->perfquery.sys_vars.n_eus * devinfo->num_thread_per_eu;
#include "brw_program.h"
#include "util/ralloc.h"
+#include "util/u_math.h"
static void
assign_fs_binding_table_offsets(const struct gen_device_info *devinfo,
}
/* BRW_NEW_VUE_MAP_GEOM_OUT */
- if (devinfo->gen < 6 || _mesa_bitcount_64(prog->info.inputs_read &
+ if (devinfo->gen < 6 || util_bitcount64(prog->info.inputs_read &
BRW_FS_VARYING_INPUT_MASK) > 16) {
key->input_slots_valid = brw->vue_map_geom_out.slots_valid;
}
key->iz_lookup |= BRW_WM_IZ_DEPTH_WRITE_ENABLE_BIT;
}
- if (devinfo->gen < 6 || _mesa_bitcount_64(prog->info.inputs_read &
+ if (devinfo->gen < 6 || util_bitcount64(prog->info.inputs_read &
BRW_FS_VARYING_INPUT_MASK) > 16) {
key->input_slots_valid = prog->info.inputs_read | VARYING_BIT_POS;
}
brw_setup_tex_for_precompile(devinfo, &key->tex, prog);
- key->nr_color_regions = _mesa_bitcount_64(outputs_written &
+ key->nr_color_regions = util_bitcount64(outputs_written &
~(BITFIELD64_BIT(FRAG_RESULT_DEPTH) |
BITFIELD64_BIT(FRAG_RESULT_STENCIL) |
BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)));
lib@GL_LIB@_la_LIBADD = \
$(top_builddir)/src/mesa/libmesa.la \
$(top_builddir)/src/mapi/glapi/libglapi.la \
+ $(top_builddir)/src/util/libmesautil.la \
$(SHARED_GLAPI_LIB) \
$(GL_LIB_DEPS)
#include "main/version.h"
#include "xfonts.h"
#include "xmesaP.h"
+#include "util/u_math.h"
/* This indicates the client-side GLX API and GLX encoder version. */
#define CLIENT_MAJOR_VERSION 1
* 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
*/
if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
- if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 &&
- _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
- _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
+ if (util_bitcount((GLuint) vis->red_mask ) <= 8 &&
+ util_bitcount((GLuint) vis->green_mask) <= 8 &&
+ util_bitcount((GLuint) vis->blue_mask ) <= 8) {
return vis;
}
else {
include_directories : [
inc_include, inc_src, inc_mesa, inc_mapi, inc_gallium, inc_gallium_aux
],
- link_with : [libmesa_classic, libglapi_static, gl_link_with],
+ link_with : [libmesa_classic, libglapi_static, libmesa_util, gl_link_with],
dependencies : [dep_x11, dep_xext, dep_xcb, dep_thread],
version : '1.6.0',
install : true,
#include "tnl/t_pipeline.h"
#include "drivers/common/driverfuncs.h"
#include "drivers/common/meta.h"
+#include "util/u_math.h"
/**
* Global X driver lock
3*16, 11*16, 1*16, 9*16,
15*16, 7*16, 13*16, 5*16,
};
- GLint rBits = _mesa_bitcount(rmask);
- GLint gBits = _mesa_bitcount(gmask);
- GLint bBits = _mesa_bitcount(bmask);
+ GLint rBits = util_bitcount(rmask);
+ GLint gBits = util_bitcount(gmask);
+ GLint bBits = util_bitcount(bmask);
GLint maxBits;
GLuint i;
{
const int xclass = v->visualType;
if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) {
- red_bits = _mesa_bitcount(GET_REDMASK(v));
- green_bits = _mesa_bitcount(GET_GREENMASK(v));
- blue_bits = _mesa_bitcount(GET_BLUEMASK(v));
+ red_bits = util_bitcount(GET_REDMASK(v));
+ green_bits = util_bitcount(GET_GREENMASK(v));
+ blue_bits = util_bitcount(GET_BLUEMASK(v));
}
else {
/* this is an approximation */
if (ctx->Extensions.ARB_texture_non_power_of_two) {
target = GLX_TEXTURE_2D_EXT;
}
- else if ( _mesa_bitcount(width) == 1
- && _mesa_bitcount(height) == 1) {
+ else if ( util_bitcount(width) == 1
+ && util_bitcount(height) == 1) {
/* power of two size */
if (height == 1) {
target = GLX_TEXTURE_1D_EXT;
#include "varray.h"
#include "util/bitscan.h"
#include "util/u_atomic.h"
+#include "util/u_math.h"
const GLubyte
* grouping information in a seperate array beside
* gl_array_attributes/gl_vertex_buffer_binding.
*/
- assert(_mesa_bitcount(binding->_BoundArrays & vao->_Enabled) == 1
+ assert(util_bitcount(binding->_BoundArrays & vao->_Enabled) == 1
|| (vao->_Enabled & ~binding->_BoundArrays) == 0);
/* Start this current effective binding with the array */
&vao->BufferBinding[attrib2->BufferBindingIndex];
/* See the comment at the same assert above. */
- assert(_mesa_bitcount(binding2->_BoundArrays & vao->_Enabled) == 1
+ assert(util_bitcount(binding2->_BoundArrays & vao->_Enabled) == 1
|| (vao->_Enabled & ~binding->_BoundArrays) == 0);
/* Check if we have an identical binding */
#include "fbobject.h"
#include "mtypes.h"
#include "util/bitscan.h"
+#include "util/u_math.h"
#define BAD_MASK ~0u
* For OpenGL 4.x we check that behaviour. For any previous version we
* keep considering it wrong (as INVALID_ENUM).
*/
- if (_mesa_bitcount(destMask[output]) > 1) {
+ if (util_bitcount(destMask[output]) > 1) {
if (_mesa_is_winsys_fbo(fb) && ctx->Version >= 40 &&
buffers[output] == GL_BACK) {
if (n != 1) {
* (ex: glDrawBuffer(GL_FRONT_AND_BACK)).
* Otherwise, destMask[x] can only have one bit set.
*/
- if (n > 0 && _mesa_bitcount(destMask[0]) > 1) {
+ if (n > 0 && util_bitcount(destMask[0]) > 1) {
GLuint count = 0, destMask0 = destMask[0];
while (destMask0) {
const gl_buffer_index bufIndex = u_bit_scan(&destMask0);
if (destMask[buf]) {
gl_buffer_index bufIndex = ffs(destMask[buf]) - 1;
/* only one bit should be set in the destMask[buf] field */
- assert(_mesa_bitcount(destMask[buf]) == 1);
+ assert(util_bitcount(destMask[buf]) == 1);
if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = bufIndex;
/*@}*/
-/**********************************************************************/
-/** \name Math */
-/*@{*/
-
-
-#ifndef HAVE___BUILTIN_POPCOUNT
-/**
- * Return number of bits set in given GLuint.
- */
-unsigned int
-_mesa_bitcount(unsigned int n)
-{
- unsigned int bits;
- for (bits = 0; n > 0; n = n >> 1) {
- bits += (n & 1);
- }
- return bits;
-}
-#endif
-
-#ifndef HAVE___BUILTIN_POPCOUNTLL
-/**
- * Return number of bits set in given 64-bit uint.
- */
-unsigned int
-_mesa_bitcount_64(uint64_t n)
-{
- unsigned int bits;
- for (bits = 0; n > 0; n = n >> 1) {
- bits += (n & 1);
- }
- return bits;
-}
-#endif
-
-/*@}*/
-
-
/** Needed due to #ifdef's, above. */
int
_mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list args)
_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
unsigned long alignment);
-#ifdef HAVE___BUILTIN_POPCOUNT
-#define _mesa_bitcount(i) __builtin_popcount(i)
-#else
-extern unsigned int
-_mesa_bitcount(unsigned int n);
-#endif
-
-#ifdef HAVE___BUILTIN_POPCOUNTLL
-#define _mesa_bitcount_64(i) __builtin_popcountll(i)
-#else
-extern unsigned int
-_mesa_bitcount_64(uint64_t n);
-#endif
-
-
extern int
_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4);
#include "program/symbol_table.h"
#include "program/program_parser.h"
+#include "util/u_math.h"
+
extern void *yy_scan_string(char *);
extern void yy_delete_buffer(void *);
state->prog->arb.NumParameters = state->prog->Parameters->NumParameters;
state->prog->arb.NumAttributes =
- _mesa_bitcount_64(state->prog->info.inputs_read);
+ util_bitcount64(state->prog->info.inputs_read);
/*
* Initialize native counts to logical counts. The device driver may
#include "program/prog_parameter.h"
#include "program/ir_to_mesa.h"
#include "main/mtypes.h"
-#include "main/imports.h"
#include "main/errors.h"
#include "main/shaderapi.h"
#include "main/uniforms.h"
*/
if (var->data.location == VERT_ATTRIB_EDGEFLAG) {
/* bit of a hack, mirroring st_translate_vertex_program */
- var->data.driver_location = _mesa_bitcount_64(nir->info.inputs_read);
+ var->data.driver_location = util_bitcount64(nir->info.inputs_read);
} else if (nir->info.inputs_read & BITFIELD64_BIT(var->data.location)) {
var->data.driver_location =
- _mesa_bitcount_64(nir->info.inputs_read &
+ util_bitcount64(nir->info.inputs_read &
BITFIELD64_MASK(var->data.location));
nir->num_inputs++;
} else {