aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_symbol.c12
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_linkage.c149
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_linkage.h67
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h18
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_tile.c12
5 files changed, 24 insertions, 234 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
index bba9122e7..542493252 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c
@@ -82,18 +82,10 @@ getDbgHelpProcAddress(LPCSTR lpProcName)
hModule = LoadLibraryA("mgwhelp.dll");
if (!hModule) {
_debug_printf("warning: mgwhelp.dll not found: symbol names will not be resolved\n"
- "warning: download it from http://code.google.com/p/jrfonseca/wiki/DrMingw#MgwHelp\n");
+ "warning: download it from https://github.com/jrfonseca/drmingw/#mgwhelp\n");
}
}
-
- /*
- * bfdhelp.dll was the predecessor of mgwhelp.dll. It is available from
- * http://people.freedesktop.org/~jrfonseca/bfdhelp/ for now.
- */
- if (!hModule) {
- hModule = LoadLibraryA("bfdhelp.dll");
- }
- #endif
+#endif
/*
* Fallback to the real DbgHelp.
diff --git a/mesalib/src/gallium/auxiliary/util/u_linkage.c b/mesalib/src/gallium/auxiliary/util/u_linkage.c
deleted file mode 100644
index 245d941dc..000000000
--- a/mesalib/src/gallium/auxiliary/util/u_linkage.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Luca Barbieri
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "util/u_debug.h"
-#include "pipe/p_shader_tokens.h"
-#include "tgsi/tgsi_parse.h"
-#include "tgsi/tgsi_scan.h"
-#include "util/u_linkage.h"
-
-/* we must only record the registers that are actually used, not just declared */
-static INLINE boolean
-util_semantic_set_test_and_set(struct util_semantic_set *set, unsigned value)
-{
- unsigned mask = 1 << (value % (sizeof(long) * 8));
- unsigned long *p = &set->masks[value / (sizeof(long) * 8)];
- unsigned long v = *p & mask;
- *p |= mask;
- return !!v;
-}
-
-unsigned
-util_semantic_set_from_program_file(struct util_semantic_set *set, const struct tgsi_token *tokens, enum tgsi_file_type file)
-{
- struct tgsi_shader_info info;
- struct tgsi_parse_context parse;
- unsigned count = 0;
- ubyte *semantic_name;
- ubyte *semantic_index;
-
- tgsi_scan_shader(tokens, &info);
-
- if(file == TGSI_FILE_INPUT)
- {
- semantic_name = info.input_semantic_name;
- semantic_index = info.input_semantic_index;
- }
- else if(file == TGSI_FILE_OUTPUT)
- {
- semantic_name = info.output_semantic_name;
- semantic_index = info.output_semantic_index;
- }
- else
- {
- assert(0);
- semantic_name = NULL;
- semantic_index = NULL;
- }
-
- tgsi_parse_init(&parse, tokens);
-
- memset(set->masks, 0, sizeof(set->masks));
- while(!tgsi_parse_end_of_tokens(&parse))
- {
- tgsi_parse_token(&parse);
-
- if(parse.FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION)
- {
- const struct tgsi_full_instruction *finst = &parse.FullToken.FullInstruction;
- unsigned i;
- for(i = 0; i < finst->Instruction.NumDstRegs; ++i)
- {
- if(finst->Dst[i].Register.File == file)
- {
- unsigned idx = finst->Dst[i].Register.Index;
- if(semantic_name[idx] == TGSI_SEMANTIC_GENERIC)
- {
- if(!util_semantic_set_test_and_set(set, semantic_index[idx]))
- ++count;
- }
- }
- }
-
- for(i = 0; i < finst->Instruction.NumSrcRegs; ++i)
- {
- if(finst->Src[i].Register.File == file)
- {
- unsigned idx = finst->Src[i].Register.Index;
- if(semantic_name[idx] == TGSI_SEMANTIC_GENERIC)
- {
- if(!util_semantic_set_test_and_set(set, semantic_index[idx]))
- ++count;
- }
- }
- }
- }
- }
- tgsi_parse_free(&parse);
-
- return count;
-}
-
-#define UTIL_SEMANTIC_SET_FOR_EACH(i, set) for(i = 0; i < 256; ++i) if(set->masks[i / (sizeof(long) * 8)] & (1 << (i % (sizeof(long) * 8))))
-
-void
-util_semantic_layout_from_set(unsigned char *layout, const struct util_semantic_set *set, unsigned efficient_slots, unsigned num_slots)
-{
- int first = -1;
- int last = -1;
- unsigned i;
-
- memset(layout, 0xff, num_slots);
-
- UTIL_SEMANTIC_SET_FOR_EACH(i, set)
- {
- if(first < 0)
- first = i;
- last = i;
- }
-
- if (last < (int) efficient_slots)
- {
- UTIL_SEMANTIC_SET_FOR_EACH(i, set)
- layout[i] = i;
- }
- else if ((last - first) < (int) efficient_slots)
- {
- UTIL_SEMANTIC_SET_FOR_EACH(i, set)
- layout[i - first] = i;
- }
- else
- {
- unsigned idx = 0;
- UTIL_SEMANTIC_SET_FOR_EACH(i, set)
- layout[idx++] = i;
- }
-}
diff --git a/mesalib/src/gallium/auxiliary/util/u_linkage.h b/mesalib/src/gallium/auxiliary/util/u_linkage.h
deleted file mode 100644
index 7b23123d3..000000000
--- a/mesalib/src/gallium/auxiliary/util/u_linkage.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 Luca Barbieri
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef U_LINKAGE_H_
-#define U_LINKAGE_H_
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_shader_tokens.h"
-
-struct util_semantic_set
-{
- unsigned long masks[256 / 8 / sizeof(unsigned long)];
-};
-
-static INLINE boolean
-util_semantic_set_contains(struct util_semantic_set *set, unsigned char value)
-{
- return !!(set->masks[value / (sizeof(long) * 8)] & (1 << (value / (sizeof(long) * 8))));
-}
-
-unsigned util_semantic_set_from_program_file(struct util_semantic_set *set, const struct tgsi_token *tokens, enum tgsi_file_type file);
-
-/* efficient_slots is the number of slots such that hardware performance is
- * the same for using that amount, with holes, or less slots but with less
- * holes.
- *
- * num_slots is the size of the layout array and hardware limit instead.
- *
- * efficient_slots == 0 or efficient_slots == num_slots are typical settings.
- */
-void util_semantic_layout_from_set(unsigned char *layout, const struct util_semantic_set *set, unsigned efficient_slots, unsigned num_slots);
-
-static INLINE void
-util_semantic_table_from_layout(unsigned char *table, size_t table_size, unsigned char *layout,
- unsigned char first_slot_value, unsigned char num_slots)
-{
- unsigned char i;
- memset(table, 0xff, table_size);
-
- for(i = 0; i < num_slots; ++i)
- table[layout[i]] = first_slot_value + i;
-}
-
-#endif /* U_LINKAGE_H_ */
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 8f62cac66..3d27a59e8 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -383,14 +383,28 @@ unsigned ffs( unsigned u )
return i;
}
-#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID)
+#elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID) || \
+ defined(HAVE___BUILTIN_FFS)
#define ffs __builtin_ffs
-#define ffsll __builtin_ffsll
#endif
#endif /* FFS_DEFINED */
/**
+ * Find first bit set in long long. Least significant bit is 1.
+ * Return 0 if no bits set.
+ */
+#ifndef FFSLL_DEFINED
+#define FFSLL_DEFINED 1
+
+#if defined(__MINGW32__) || defined(PIPE_OS_ANDROID) || \
+ defined(HAVE___BUILTIN_FFSLL)
+#define ffsll __builtin_ffsll
+#endif
+
+#endif /* FFSLL_DEFINED */
+
+/**
* Find last bit set in a word. The least significant bit is 1.
* Return 0 if no bits are set.
*/
diff --git a/mesalib/src/gallium/auxiliary/util/u_tile.c b/mesalib/src/gallium/auxiliary/util/u_tile.c
index 6252e5dcf..8e199200f 100644
--- a/mesalib/src/gallium/auxiliary/util/u_tile.c
+++ b/mesalib/src/gallium/auxiliary/util/u_tile.c
@@ -214,13 +214,13 @@ s8x24_get_tile_rgba(const unsigned *src,
unsigned i, j;
for (i = 0; i < h; i++) {
- float *pRow = p;
+ uint32_t *pRow = (uint32_t *)p;
for (j = 0; j < w; j++, pRow += 4) {
pRow[0] =
pRow[1] =
pRow[2] =
- pRow[3] = (float)((*src++ >> 24) & 0xff);
+ pRow[3] = ((*src++ >> 24) & 0xff);
}
p += dst_stride;
@@ -241,12 +241,12 @@ x24s8_get_tile_rgba(const unsigned *src,
unsigned i, j;
for (i = 0; i < h; i++) {
- float *pRow = p;
+ uint32_t *pRow = (uint32_t *)p;
for (j = 0; j < w; j++, pRow += 4) {
pRow[0] =
pRow[1] =
pRow[2] =
- pRow[3] = (float)(*src++ & 0xff);
+ pRow[3] = (*src++ & 0xff);
}
p += dst_stride;
}
@@ -265,12 +265,12 @@ s8_get_tile_rgba(const unsigned char *src,
unsigned i, j;
for (i = 0; i < h; i++) {
- float *pRow = p;
+ uint32_t *pRow = (uint32_t *)p;
for (j = 0; j < w; j++, pRow += 4) {
pRow[0] =
pRow[1] =
pRow[2] =
- pRow[3] = (float)(*src++ & 0xff);
+ pRow[3] = (*src++ & 0xff);
}
p += dst_stride;
}