summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/p_debug.c14
-rw-r--r--src/gallium/auxiliary/util/p_debug_mem.c6
-rw-r--r--src/gallium/auxiliary/util/p_tile.c52
-rw-r--r--src/gallium/auxiliary/util/u_blit.h8
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c2
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.h10
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h38
-rw-r--r--src/gallium/auxiliary/util/u_time.c38
-rw-r--r--src/gallium/auxiliary/util/u_time.h8
9 files changed, 151 insertions, 25 deletions
diff --git a/src/gallium/auxiliary/util/p_debug.c b/src/gallium/auxiliary/util/p_debug.c
index 25b132b40c..cd612e23b3 100644
--- a/src/gallium/auxiliary/util/p_debug.c
+++ b/src/gallium/auxiliary/util/p_debug.c
@@ -26,9 +26,11 @@
**************************************************************************/
+#include "pipe/p_config.h"
+
#include <stdarg.h>
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#include <windows.h>
#include <winddi.h>
#else
@@ -42,7 +44,7 @@
#include "util/u_string.h"
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
static INLINE void
_EngDebugPrint(const char *format, ...)
{
@@ -56,7 +58,7 @@ _EngDebugPrint(const char *format, ...)
void _debug_vprintf(const char *format, va_list ap)
{
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#ifndef WINCE
/* EngDebugPrint does not handle float point arguments, so we need to use
* our own vsnprintf implementation. It is also very slow, so buffer until
@@ -101,7 +103,7 @@ void _debug_break(void)
__asm("int3");
#elif (defined(__i386__) || defined(__386__)) && defined(__MSC__)
_asm {int 3};
-#elif defined(WIN32) && !defined(WINCE)
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
EngDebugBreak();
#else
abort();
@@ -109,7 +111,7 @@ void _debug_break(void)
}
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
static const char *
find(const char *start, const char *end, char c)
{
@@ -150,7 +152,7 @@ const char *
debug_get_option(const char *name, const char *dfault)
{
const char *result;
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
ULONG_PTR iFile = 0;
const void *pMap = NULL;
const char *sol, *eol, *sep;
diff --git a/src/gallium/auxiliary/util/p_debug_mem.c b/src/gallium/auxiliary/util/p_debug_mem.c
index aba69c0294..9321cf71bb 100644
--- a/src/gallium/auxiliary/util/p_debug_mem.c
+++ b/src/gallium/auxiliary/util/p_debug_mem.c
@@ -32,7 +32,9 @@
* @author José Fonseca <jrfonseca@tungstengraphics.com>
*/
-#ifdef WIN32
+#include "pipe/p_config.h"
+
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#include <windows.h>
#include <winddi.h>
#else
@@ -47,7 +49,7 @@
#define DEBUG_MEMORY_MAGIC 0x6e34090aU
-#if defined(WIN32) && !defined(WINCE)
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
#define real_malloc(_size) EngAllocMem(0, _size, 'D3AG')
#define real_free(_ptr) EngFreeMem(_ptr)
#else
diff --git a/src/gallium/auxiliary/util/p_tile.c b/src/gallium/auxiliary/util/p_tile.c
index 520da5cecd..91283a9ab0 100644
--- a/src/gallium/auxiliary/util/p_tile.c
+++ b/src/gallium/auxiliary/util/p_tile.c
@@ -169,6 +169,52 @@ a8r8g8b8_put_tile_rgba(unsigned *dst,
}
+/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/
+
+static void
+x8r8g8b8_get_tile_rgba(unsigned *src,
+ unsigned w, unsigned h,
+ float *p,
+ unsigned dst_stride)
+{
+ unsigned i, j;
+
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++, pRow += 4) {
+ const unsigned pixel = *src++;
+ pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
+ pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff);
+ pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff);
+ pRow[3] = UBYTE_TO_FLOAT(0xff);
+ }
+ p += dst_stride;
+ }
+}
+
+
+static void
+x8r8g8b8_put_tile_rgba(unsigned *dst,
+ unsigned w, unsigned h,
+ const float *p,
+ unsigned src_stride)
+{
+ unsigned i, j;
+
+ for (i = 0; i < h; i++) {
+ const float *pRow = p;
+ for (j = 0; j < w; j++, pRow += 4) {
+ unsigned r, g, b;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
+ *dst++ = (0xff << 24) | (r << 16) | (g << 8) | b;
+ }
+ p += src_stride;
+ }
+}
+
+
/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/
static void
@@ -647,6 +693,9 @@ pipe_get_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
break;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ x8r8g8b8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
+ break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
break;
@@ -723,6 +772,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ x8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
+ break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h
index 61f1d9bb32..0ce9732e62 100644
--- a/src/gallium/auxiliary/util/u_blit.h
+++ b/src/gallium/auxiliary/util/u_blit.h
@@ -30,7 +30,11 @@
#define U_BLIT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct pipe_context;
struct pipe_surface;
struct cso_context;
@@ -58,4 +62,8 @@ util_blit_pixels(struct blit_state *ctx,
float z, uint filter);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index dfdb5f16fe..b8dc6c66c0 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -475,7 +475,9 @@ format_to_type_comps(enum pipe_format pformat,
{
switch (pformat) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
*datatype = UBYTE;
*comps = 4;
return;
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.h b/src/gallium/auxiliary/util/u_gen_mipmap.h
index bd9af54fb7..3277024f07 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.h
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.h
@@ -31,6 +31,11 @@
#include "pipe/p_state.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct pipe_context;
struct pipe_texture;
struct cso_context;
@@ -52,4 +57,9 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
struct pipe_texture *pt,
uint face, uint baseLevel, uint lastLevel, uint filter);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 1f6604c554..50ef44992b 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -53,18 +53,36 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
*d = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
+ case PIPE_FORMAT_R8G8B8X8_UNORM:
+ {
+ uint *d = (uint *) dest;
+ *d = (r << 24) | (g << 16) | (b << 8) | 0xff;
+ }
+ return;
case PIPE_FORMAT_A8R8G8B8_UNORM:
{
uint *d = (uint *) dest;
*d = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ {
+ uint *d = (uint *) dest;
+ *d = (0xff << 24) | (r << 16) | (g << 8) | b;
+ }
+ return;
case PIPE_FORMAT_B8G8R8A8_UNORM:
{
uint *d = (uint *) dest;
*d = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ {
+ uint *d = (uint *) dest;
+ *d = (b << 24) | (g << 16) | (r << 8) | 0xff;
+ }
+ return;
case PIPE_FORMAT_R5G6B5_UNORM:
{
ushort *d = (ushort *) dest;
@@ -101,18 +119,36 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
*d = (r << 24) | (g << 16) | (b << 8) | a;
}
return;
+ case PIPE_FORMAT_R8G8B8X8_UNORM:
+ {
+ uint *d = (uint *) dest;
+ *d = (r << 24) | (g << 16) | (b << 8) | 0xff;
+ }
+ return;
case PIPE_FORMAT_A8R8G8B8_UNORM:
{
uint *d = (uint *) dest;
*d = (a << 24) | (r << 16) | (g << 8) | b;
}
return;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ {
+ uint *d = (uint *) dest;
+ *d = (0xff << 24) | (r << 16) | (g << 8) | b;
+ }
+ return;
case PIPE_FORMAT_B8G8R8A8_UNORM:
{
uint *d = (uint *) dest;
*d = (b << 24) | (g << 16) | (r << 8) | a;
}
return;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ {
+ uint *d = (uint *) dest;
+ *d = (b << 24) | (g << 16) | (r << 8) | 0xff;
+ }
+ return;
case PIPE_FORMAT_R5G6B5_UNORM:
{
ushort *d = (ushort *) dest;
@@ -159,8 +195,10 @@ util_pack_z(enum pipe_format format, double z)
else
return (uint) (z * 0xffffffff);
case PIPE_FORMAT_S8Z24_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
return (uint) (z * 0xffffff);
case PIPE_FORMAT_Z24S8_UNORM:
+ case PIPE_FORMAT_Z24X8_UNORM:
return ((uint) (z * 0xffffff)) << 8;
default:
debug_printf("gallium: unhandled fomrat in util_pack_z()");
diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c
index 01112ebe5a..dd28ff4134 100644
--- a/src/gallium/auxiliary/util/u_time.c
+++ b/src/gallium/auxiliary/util/u_time.c
@@ -33,27 +33,35 @@
*/
-#ifndef WIN32
+#include "util/u_time.h"
+
+#if defined(PIPE_OS_LINUX)
#include <sys/time.h>
-#else
+#elif defined(PIPE_OS_WINDOWS)
#include <windows.h>
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <winddi.h>
#endif
-
-#include "util/u_time.h"
+#else
+#error Unsupported OS
+#endif
-#ifdef WIN32
+#if defined(PIPE_OS_WINDOWS)
static LONGLONG frequency = 0;
+#if !defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+#define EngQueryPerformanceFrequency(p) QueryPerformanceFrequency((LARGE_INTEGER*)(p))
+#define EngQueryPerformanceCounter(p) QueryPerformanceCounter((LARGE_INTEGER*)(p))
+#endif
#endif
void
util_time_get(struct util_time *t)
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
gettimeofday(&t->tv, NULL);
-#else
+#elif defined(PIPE_OS_WINDOWS)
EngQueryPerformanceCounter(&t->counter);
#endif
}
@@ -64,10 +72,10 @@ util_time_add(const struct util_time *t1,
int64_t usecs,
struct util_time *t2)
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
t2->tv.tv_sec = t1->tv.tv_sec + usecs / 1000000;
t2->tv.tv_usec = t1->tv.tv_usec + usecs % 1000000;
-#else
+#elif defined(PIPE_OS_WINDOWS)
if(!frequency)
EngQueryPerformanceFrequency(&frequency);
t2->counter = t1->counter + (usecs * frequency + 999999LL)/1000000LL;
@@ -79,10 +87,12 @@ int64_t
util_time_diff(const struct util_time *t1,
const struct util_time *t2)
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
return (t2->tv.tv_usec - t1->tv.tv_usec) +
(t2->tv.tv_sec - t1->tv.tv_sec)*1000000;
-#else
+#elif defined(PIPE_OS_WINDOWS)
+ if(!frequency)
+ EngQueryPerformanceFrequency(&frequency);
return (t2->counter - t1->counter)*1000000LL/frequency;
#endif
}
@@ -98,7 +108,7 @@ static INLINE int
util_time_compare(const struct util_time *t1,
const struct util_time *t2)
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
if (t1->tv.tv_sec < t2->tv.tv_sec)
return -1;
else if(t1->tv.tv_sec > t2->tv.tv_sec)
@@ -109,7 +119,7 @@ util_time_compare(const struct util_time *t1,
return 1;
else
return 0;
-#else
+#elif defined(PIPE_OS_WINDOWS)
if (t1->counter < t2->counter)
return -1;
else if(t1->counter > t2->counter)
@@ -132,7 +142,7 @@ util_time_timeout(const struct util_time *start,
}
-#ifdef WIN32
+#if defined(PIPE_OS_WINDOWS)
void util_time_sleep(unsigned usecs)
{
LONGLONG start, curr, end;
diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h
index c8836c137f..48ec7a4a96 100644
--- a/src/gallium/auxiliary/util/u_time.h
+++ b/src/gallium/auxiliary/util/u_time.h
@@ -36,7 +36,9 @@
#define U_TIME_H_
-#ifndef WIN32
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_LINUX)
#include <time.h> /* timeval */
#include <unistd.h> /* usleep */
#endif
@@ -56,7 +58,7 @@ extern "C" {
*/
struct util_time
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
struct timeval tv;
#else
long long counter;
@@ -84,7 +86,7 @@ util_time_timeout(const struct util_time *start,
const struct util_time *end,
const struct util_time *curr);
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
#define util_time_sleep usleep
#else
void