const struct brw_reg *arg0,
const struct brw_reg *arg1)
{
- int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+ int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code */
const struct brw_reg *arg0,
const struct brw_reg *arg1)
{
- int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+ int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code */
const struct brw_reg *arg0,
const struct brw_reg *arg1)
{
- int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+ int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code */
const struct brw_reg *arg0,
const struct brw_reg *arg1)
{
- const int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+ const int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code */
{
struct brw_compile *p = &c->func;
struct intel_context *intel = &p->brw->intel;
- int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+ int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
GLuint saturate = ((mask & SATURATE) ?
BRW_MATH_SATURATE_SATURATE :
BRW_MATH_SATURATE_NONE);
{
struct brw_compile *p = &c->func;
struct intel_context *intel = &p->brw->intel;
- int dst_chan = _mesa_ffs(mask & WRITEMASK_XYZW) - 1;
+ int dst_chan = ffs(mask & WRITEMASK_XYZW) - 1;
if (!(mask & WRITEMASK_XYZW))
return; /* Do not emit dead code */
static struct prog_dst_register get_temp( struct brw_wm_compile *c )
{
- int bit = _mesa_ffs( ~c->fp_temp );
+ int bit = ffs( ~c->fp_temp );
if (!bit) {
printf("%s: out of temporaries\n", __FILE__);
if (inst0->DstReg.WriteMask == 0)
return NULL;
- dst_chan = _mesa_ffs(inst0->DstReg.WriteMask) - 1;
+ dst_chan = ffs(inst0->DstReg.WriteMask) - 1;
inst = get_fp_inst(c);
*inst = *inst0;
inst->DstReg.WriteMask = 1 << dst_chan;
/* Loop over all renderbuffers */
mask &= (1 << BUFFER_COUNT) - 1;
while (mask) {
- GLuint buf = _mesa_ffs(mask) - 1;
+ GLuint buf = ffs(mask) - 1;
bool is_depth_stencil = buf == BUFFER_DEPTH || buf == BUFFER_STENCIL;
struct intel_renderbuffer *irb;
int x1, y1, x2, y2;
* buffer with it.
*/
if (mask & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
- int color_bit = _mesa_ffs(mask & BUFFER_BITS_COLOR);
+ int color_bit = ffs(mask & BUFFER_BITS_COLOR);
if (color_bit != 0) {
tri_mask |= blit_mask & (1 << (color_bit - 1));
blit_mask &= ~(1 << (color_bit - 1));
GLuint min = ~0u;
while (enabled) {
- GLint attrib = _mesa_ffsll(enabled) - 1;
+ GLint attrib = ffsll(enabled) - 1;
enabled &= ~BITFIELD64_BIT(attrib);
min = update_min(min, &arrayObj->VertexAttrib[attrib]);
}
for (i = 0; i < n; i++) {
if (x[i])
- return _mesa_ffs(x[i]) + BITSET_WORDBITS * i;
+ return ffs(x[i]) + BITSET_WORDBITS * i;
}
return 0;
if (n == 1) {
GLuint count = 0, destMask0 = destMask[0];
while (destMask0) {
- GLint bufIndex = _mesa_ffs(destMask0) - 1;
+ GLint bufIndex = ffs(destMask0) - 1;
if (fb->_ColorDrawBufferIndexes[count] != bufIndex) {
updated_drawbuffers(ctx);
fb->_ColorDrawBufferIndexes[count] = bufIndex;
GLuint count = 0;
for (buf = 0; buf < n; buf++ ) {
if (destMask[buf]) {
- GLint bufIndex = _mesa_ffs(destMask[buf]) - 1;
+ GLint bufIndex = ffs(destMask[buf]) - 1;
/* only one bit should be set in the destMask[buf] field */
ASSERT(_mesa_bitcount(destMask[buf]) == 1);
if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
static GLuint translate_tex_src_bit( GLbitfield bit )
{
ASSERT(bit);
- return _mesa_ffs(bit) - 1;
+ return ffs(bit) - 1;
}
static struct ureg get_temp( struct tnl_program *p )
{
- int bit = _mesa_ffs( ~p->temp_in_use );
+ int bit = ffs( ~p->temp_in_use );
if (!bit) {
_mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
exit(1);
* Find the first bit set in a word.
*/
int
-_mesa_ffs(int32_t i)
+ffs(int i)
{
-#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__)
register int bit = 0;
if (i != 0) {
if ((i & 0xffff) == 0) {
bit++;
}
return bit;
-#else
- return ffs(i);
-#endif
}
* if no bits set.
*/
int
-_mesa_ffsll(int64_t val)
+ffsll(long long int val)
{
int bit;
assert(sizeof(val) == 8);
- bit = _mesa_ffs((int32_t)val);
+ bit = ffs((int) val);
if (bit != 0)
return bit;
- bit = _mesa_ffs((int32_t)(val >> 32));
+ bit = ffs((int) (val >> 32));
if (bit != 0)
return 32 + bit;
return 0;
}
-#endif
+#endif /* __GNUC__ */
+
#if !defined(__GNUC__) ||\
((__GNUC__ * 100 + __GNUC_MINOR__) < 304) /* Not gcc 3.4 or later */
#define ffsll __builtin_ffsll
#endif
-#define _mesa_ffs(i) ffs(i)
-#define _mesa_ffsll(i) ffsll(i)
+#else
+
+extern int ffs(int i);
+extern int ffsll(long long int i);
+
+#endif /*__ GNUC__ */
-#if ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
+
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304) /* gcc 3.4 or later */
#define _mesa_bitcount(i) __builtin_popcount(i)
#define _mesa_bitcount_64(i) __builtin_popcountll(i)
#else
_mesa_bitcount_64(uint64_t n);
#endif
-#else
-extern int
-_mesa_ffs(int32_t i);
-
-extern int
-_mesa_ffsll(int64_t i);
-
-extern unsigned int
-_mesa_bitcount(unsigned int n);
-#endif
extern GLhalfARB
_mesa_float_to_half(float f);
ctx->Driver.UseProgram(ctx, shProg);
}
+
/**
* Do validation of the given shader program.
* \param errMsg returns error message if validation fails.
{
printf("VP Inputs 0x%x: \n", inputs);
while (inputs) {
- GLint attr = _mesa_ffs(inputs) - 1;
+ GLint attr = ffs(inputs) - 1;
const char *name = arb_input_attrib_string(attr,
GL_VERTEX_PROGRAM_ARB);
printf(" %d: %s\n", attr, name);
{
printf("FP Inputs 0x%x: \n", inputs);
while (inputs) {
- GLint attr = _mesa_ffs(inputs) - 1;
+ GLint attr = ffs(inputs) - 1;
const char *name = arb_input_attrib_string(attr,
GL_FRAGMENT_PROGRAM_ARB);
printf(" %d: %s\n", attr, name);
/* loop over enabled texture units */
while (enabledUnits) {
- GLuint unit = _mesa_ffs(enabledUnits) - 1;
+ GLuint unit = ffs(enabledUnits) - 1;
struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
_swrast_map_texture(ctx, texObj);
/* loop over enabled texture units */
while (enabledUnits) {
- GLuint unit = _mesa_ffs(enabledUnits) - 1;
+ GLuint unit = ffs(enabledUnits) - 1;
struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
_swrast_unmap_texture(ctx, texObj);