summaryrefslogtreecommitdiff
path: root/src/gallium/include/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/include/pipe')
-rw-r--r--src/gallium/include/pipe/internal/p_winsys_screen.h190
-rw-r--r--src/gallium/include/pipe/p_atomic.h353
-rw-r--r--src/gallium/include/pipe/p_compiler.h5
-rw-r--r--src/gallium/include/pipe/p_format.h4
-rw-r--r--src/gallium/include/pipe/p_inlines.h224
-rw-r--r--src/gallium/include/pipe/p_refcnt.h95
-rw-r--r--src/gallium/include/pipe/p_state.h39
-rw-r--r--src/gallium/include/pipe/p_thread.h279
-rw-r--r--src/gallium/include/pipe/p_video_state.h4
9 files changed, 13 insertions, 1180 deletions
diff --git a/src/gallium/include/pipe/internal/p_winsys_screen.h b/src/gallium/include/pipe/internal/p_winsys_screen.h
deleted file mode 100644
index a1542dada7..0000000000
--- a/src/gallium/include/pipe/internal/p_winsys_screen.h
+++ /dev/null
@@ -1,190 +0,0 @@
- /**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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, sub license, 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS 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.
- *
- **************************************************************************/
-
-/**
- * \file
- * This is the interface that Gallium3D requires any window system
- * hosting it to implement. This is the only include file in Gallium3D
- * which is public.
- */
-
-#ifndef P_WINSYS_H
-#define P_WINSYS_H
-
-
-#include "pipe/p_format.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** Opaque type */
-struct pipe_fence_handle;
-
-struct pipe_surface;
-
-
-/**
- * Gallium3D drivers are (meant to be!) independent of both GL and the
- * window system. The window system provides a buffer manager and a
- * set of additional hooks for things like command buffer submission,
- * etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-struct pipe_winsys
-{
- void (*destroy)( struct pipe_winsys *ws );
-
- /** Returns name of this winsys interface */
- const char *(*get_name)( struct pipe_winsys *ws );
-
- /**
- * Do any special operations to ensure buffer size is correct
- */
- void (*update_buffer)( struct pipe_winsys *ws,
- void *context_private );
- /**
- * Do any special operations to ensure frontbuffer contents are
- * displayed, eg copy fake frontbuffer.
- */
- void (*flush_frontbuffer)( struct pipe_winsys *ws,
- struct pipe_surface *surf,
- void *context_private );
-
-
- /**
- * Buffer management. Buffer attributes are mostly fixed over its lifetime.
- *
- * Remember that gallium gets to choose the interface it needs, and the
- * window systems must then implement that interface (rather than the
- * other way around...).
- *
- * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
- * usage argument is only an optimization hint, not a guarantee, therefore
- * proper behavior must be observed in all circumstances.
- *
- * alignment indicates the client's alignment requirements, eg for
- * SSE instructions.
- */
- struct pipe_buffer *(*buffer_create)( struct pipe_winsys *ws,
- unsigned alignment,
- unsigned usage,
- unsigned size );
-
- /**
- * Create a buffer that wraps user-space data.
- *
- * Effectively this schedules a delayed call to buffer_create
- * followed by an upload of the data at *some point in the future*,
- * or perhaps never. Basically the allocate/upload is delayed
- * until the buffer is actually passed to hardware.
- *
- * The intention is to provide a quick way to turn regular data
- * into a buffer, and secondly to avoid a copy operation if that
- * data subsequently turns out to be only accessed by the CPU.
- *
- * Common example is OpenGL vertex buffers that are subsequently
- * processed either by software TNL in the driver or by passing to
- * hardware.
- *
- * XXX: What happens if the delayed call to buffer_create() fails?
- *
- * Note that ptr may be accessed at any time upto the time when the
- * buffer is destroyed, so the data must not be freed before then.
- */
- struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *ws,
- void *ptr,
- unsigned bytes);
-
- /**
- * Allocate storage for a display target surface.
- *
- * Often surfaces which are meant to be blitted to the front screen (i.e.,
- * display targets) must be allocated with special characteristics, memory
- * pools, or obtained directly from the windowing system.
- *
- * This callback is invoked by the pipe_screenwhen creating a texture marked
- * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
- * buffer storage.
- */
- struct pipe_buffer *(*surface_buffer_create)(struct pipe_winsys *ws,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride);
-
-
- /**
- * Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
- */
- void *(*buffer_map)( struct pipe_winsys *ws,
- struct pipe_buffer *buf,
- unsigned usage );
-
- void (*buffer_unmap)( struct pipe_winsys *ws,
- struct pipe_buffer *buf );
-
- void (*buffer_destroy)( struct pipe_buffer *buf );
-
-
- /** Set ptr = fence, with reference counting */
- void (*fence_reference)( struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence );
-
- /**
- * Checks whether the fence has been signalled.
- * \param flags driver-specific meaning
- * \return zero on success.
- */
- int (*fence_signalled)( struct pipe_winsys *ws,
- struct pipe_fence_handle *fence,
- unsigned flag );
-
- /**
- * Wait for the fence to finish.
- * \param flags driver-specific meaning
- * \return zero on success.
- */
- int (*fence_finish)( struct pipe_winsys *ws,
- struct pipe_fence_handle *fence,
- unsigned flag );
-
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_WINSYS_H */
diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h
deleted file mode 100644
index 0c3fbae428..0000000000
--- a/src/gallium/include/pipe/p_atomic.h
+++ /dev/null
@@ -1,353 +0,0 @@
-/**
- * Many similar implementations exist. See for example libwsbm
- * or the linux kernel include/atomic.h
- *
- * No copyright claimed on this file.
- *
- */
-
-#ifndef P_ATOMIC_H
-#define P_ATOMIC_H
-
-#include "p_compiler.h"
-#include "p_defines.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Favor OS-provided implementations.
- *
- * Where no OS-provided implementation is available, fall back to
- * locally coded assembly, compiler intrinsic or ultimately a
- * mutex-based implementation.
- */
-#if (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \
- defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT))
-#define PIPE_ATOMIC_OS_UNLOCKED
-#elif (defined(PIPE_CC_MSVC) && defined(PIPE_SUBSYSTEM_WINDOWS_USER))
-#define PIPE_ATOMIC_OS_MS_INTERLOCK
-#elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
-#define PIPE_ATOMIC_ASM_MSVC_X86
-#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86))
-#define PIPE_ATOMIC_ASM_GCC_X86
-#elif defined(PIPE_CC_GCC)
-#define PIPE_ATOMIC_GCC_INTRINSIC
-#else
-#define PIPE_ATOMIC_MUTEX
-#endif
-
-
-
-#if defined(PIPE_ATOMIC_ASM_GCC_X86)
-
-#define PIPE_ATOMIC "GCC x86 assembly"
-
-struct pipe_atomic {
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- unsigned char c;
-
- __asm__ __volatile__("lock; decl %0; sete %1":"+m"(v->count), "=qm"(c)
- ::"memory");
-
- return c != 0;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- __asm__ __volatile__("lock; incl %0":"+m"(v->count));
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- __asm__ __volatile__("lock; decl %0":"+m"(v->count));
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- return __sync_val_compare_and_swap(&v->count, old, _new);
-}
-#endif
-
-
-
-/* Implementation using GCC-provided synchronization intrinsics
- */
-#if defined(PIPE_ATOMIC_GCC_INTRINSIC)
-
-#define PIPE_ATOMIC "GCC Sync Intrinsics"
-
-struct pipe_atomic {
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- return (__sync_sub_and_fetch(&v->count, 1) == 0);
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- (void) __sync_add_and_fetch(&v->count, 1);
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- (void) __sync_sub_and_fetch(&v->count, 1);
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- return __sync_val_compare_and_swap(&v->count, old, _new);
-}
-#endif
-
-
-
-/* Unlocked version for single threaded environments, such as some
- * windows kernel modules.
- */
-#if defined(PIPE_ATOMIC_OS_UNLOCKED)
-
-#define PIPE_ATOMIC "Unlocked"
-
-struct pipe_atomic
-{
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-#define p_atomic_dec_zero(_v) ((boolean) --(_v)->count)
-#define p_atomic_inc(_v) ((void) (_v)->count++)
-#define p_atomic_dec(_v) ((void) (_v)->count--)
-#define p_atomic_cmpxchg(_v, old, _new) ((_v)->count == old ? (_v)->count = (_new) : (_v)->count)
-
-#endif
-
-
-/* Locally coded assembly for MSVC on x86:
- */
-#if defined(PIPE_ATOMIC_ASM_MSVC_X86)
-
-#define PIPE_ATOMIC "MSVC x86 assembly"
-
-struct pipe_atomic
-{
- int32_t count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- int32_t *pcount = &v->count;
- unsigned char c;
-
- __asm {
- mov eax, [pcount]
- lock dec dword ptr [eax]
- sete byte ptr [c]
- }
-
- return c != 0;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- int32_t *pcount = &v->count;
-
- __asm {
- mov eax, [pcount]
- lock inc dword ptr [eax]
- }
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- int32_t *pcount = &v->count;
-
- __asm {
- mov eax, [pcount]
- lock dec dword ptr [eax]
- }
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- int32_t *pcount = &v->count;
- int32_t orig;
-
- __asm {
- mov ecx, [pcount]
- mov eax, [old]
- mov edx, [_new]
- lock cmpxchg [ecx], edx
- mov [orig], eax
- }
-
- return orig;
-}
-#endif
-
-
-#if defined(PIPE_ATOMIC_OS_MS_INTERLOCK)
-
-#define PIPE_ATOMIC "MS userspace interlocks"
-
-#include <windows.h>
-
-struct pipe_atomic
-{
- volatile long count;
-};
-
-#define p_atomic_set(_v, _i) ((_v)->count = (_i))
-#define p_atomic_read(_v) ((_v)->count)
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- return InterlockedDecrement(&v->count) == 0;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- InterlockedIncrement(&v->count);
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- InterlockedDecrement(&v->count);
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- return InterlockedCompareExchange(&v->count, _new, old);
-}
-
-#endif
-
-
-
-#if defined(PIPE_ATOMIC_MUTEX)
-
-#define PIPE_ATOMIC "mutex-based fallback"
-
-#include "pipe/p_thread.h"
-
-/**
- * This implementation should really not be used.
- * Add an assembly port instead. It may abort and
- * doesn't destroy used mutexes.
- */
-
-struct pipe_atomic {
- pipe_mutex mutex;
- int32_t count;
-};
-
-static INLINE void
-p_atomic_set(struct pipe_atomic *v, int32_t i)
-{
- pipe_mutex_init(v->mutex);
- pipe_mutex_lock(v->mutex);
- v->count = i;
- pipe_mutex_unlock(v->mutex);
-}
-
-static INLINE int32_t
-p_atomic_read(struct pipe_atomic *v)
-{
- int32_t ret;
-
- pipe_mutex_lock(v->mutex);
- ret = v->count;
- pipe_mutex_unlock(v->mutex);
- return ret;
-}
-
-static INLINE void
-p_atomic_inc(struct pipe_atomic *v)
-{
- pipe_mutex_lock(v->mutex);
- ++v->count;
- pipe_mutex_unlock(v->mutex);
-}
-
-static INLINE void
-p_atomic_dec(struct pipe_atomic *v)
-{
- pipe_mutex_lock(v->mutex);
- --v->count;
- pipe_mutex_unlock(v->mutex);
-}
-
-static INLINE boolean
-p_atomic_dec_zero(struct pipe_atomic *v)
-{
- boolean ret;
-
- pipe_mutex_lock(v->mutex);
- ret = (--v->count == 0);
- pipe_mutex_unlock(v->mutex);
- return ret;
-}
-
-static INLINE int32_t
-p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
-{
- int32_t ret;
-
- pipe_mutex_lock(v->mutex);
- ret = v->count;
- if (ret == old)
- v->count = _new;
- pipe_mutex_unlock(v->mutex);
-
- return ret;
-}
-
-#endif
-
-
-#ifndef PIPE_ATOMIC
-#error "No pipe_atomic implementation selected"
-#endif
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_ATOMIC_H */
diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h
index 6a9018aa3a..84956a2ba4 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -38,6 +38,8 @@
#include "xf86_ansic.h"
#include "xf86_libc.h"
#endif
+#include <stddef.h>
+#include <stdarg.h>
#if defined(_WIN32) && !defined(__WIN32__)
@@ -125,6 +127,9 @@ typedef unsigned char boolean;
# define __FUNCTION__ "<unknown>"
# endif
# endif
+# if defined(_MSC_VER) && _MSC_VER < 1300
+# define __FUNCTION__ "<unknown>"
+# endif
#endif
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index 6bfff1cc59..2894e13e7d 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -31,10 +31,6 @@
#include "p_compiler.h"
-/* FIXME: remove these header dependencies */
-#include "util/u_debug.h"
-#include "util/u_string.h"
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
deleted file mode 100644
index 72f5c1dc2a..0000000000
--- a/src/gallium/include/pipe/p_inlines.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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, sub license, 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS 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 P_INLINES_H
-#define P_INLINES_H
-
-#include "p_context.h"
-#include "p_defines.h"
-#include "p_screen.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * Convenience wrappers for screen buffer functions.
- */
-
-static INLINE struct pipe_buffer *
-pipe_buffer_create( struct pipe_screen *screen,
- unsigned alignment, unsigned usage, unsigned size )
-{
- return screen->buffer_create(screen, alignment, usage, size);
-}
-
-static INLINE struct pipe_buffer *
-pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size )
-{
- return screen->user_buffer_create(screen, ptr, size);
-}
-
-static INLINE void *
-pipe_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned usage)
-{
- if(screen->buffer_map_range) {
- unsigned offset = 0;
- unsigned length = buf->size;
- return screen->buffer_map_range(screen, buf, offset, length, usage);
- }
- else
- return screen->buffer_map(screen, buf, usage);
-}
-
-static INLINE void
-pipe_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
-{
- screen->buffer_unmap(screen, buf);
-}
-
-static INLINE void *
-pipe_buffer_map_range(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset,
- unsigned length,
- unsigned usage)
-{
- assert(offset < buf->size);
- assert(offset + length <= buf->size);
- assert(length);
- if(screen->buffer_map_range)
- return screen->buffer_map_range(screen, buf, offset, length, usage);
- else
- return screen->buffer_map(screen, buf, usage);
-}
-
-static INLINE void
-pipe_buffer_flush_mapped_range(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset,
- unsigned length)
-{
- assert(offset < buf->size);
- assert(offset + length <= buf->size);
- assert(length);
- if(screen->buffer_flush_mapped_range)
- screen->buffer_flush_mapped_range(screen, buf, offset, length);
-}
-
-static INLINE void
-pipe_buffer_write(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned size,
- const void *data)
-{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD);
- assert(map);
- if(map) {
- memcpy((uint8_t *)map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, size);
- pipe_buffer_unmap(screen, buf);
- }
-}
-
-/**
- * Special case for writing non-overlapping ranges.
- *
- * We can avoid GPU/CPU synchronization when writing range that has never
- * been written before.
- */
-static INLINE void
-pipe_buffer_write_nooverlap(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned size,
- const void *data)
-{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
- assert(map);
- if(map) {
- memcpy((uint8_t *)map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, size);
- pipe_buffer_unmap(screen, buf);
- }
-}
-
-static INLINE void
-pipe_buffer_read(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned size,
- void *data)
-{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ);
- assert(map);
- if(map) {
- memcpy(data, (const uint8_t *)map + offset, size);
- pipe_buffer_unmap(screen, buf);
- }
-}
-
-static INLINE void *
-pipe_transfer_map( struct pipe_transfer *transf )
-{
- struct pipe_screen *screen = transf->texture->screen;
- return screen->transfer_map(screen, transf);
-}
-
-static INLINE void
-pipe_transfer_unmap( struct pipe_transfer *transf )
-{
- struct pipe_screen *screen = transf->texture->screen;
- screen->transfer_unmap(screen, transf);
-}
-
-static INLINE void
-pipe_transfer_destroy( struct pipe_transfer *transf )
-{
- struct pipe_screen *screen = transf->texture->screen;
- screen->tex_transfer_destroy(transf);
-}
-
-static INLINE unsigned
-pipe_transfer_buffer_flags( struct pipe_transfer *transf )
-{
- switch (transf->usage & PIPE_TRANSFER_READ_WRITE) {
- case PIPE_TRANSFER_READ_WRITE:
- return PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE;
- case PIPE_TRANSFER_READ:
- return PIPE_BUFFER_USAGE_CPU_READ;
- case PIPE_TRANSFER_WRITE:
- return PIPE_BUFFER_USAGE_CPU_WRITE;
- default:
- debug_assert(0);
- return 0;
- }
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_INLINES_H */
diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h
deleted file mode 100644
index c1c7415e02..0000000000
--- a/src/gallium/include/pipe/p_refcnt.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * 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, sub license, 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS 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 P_REFCNT_H
-#define P_REFCNT_H
-
-
-#include "p_defines.h"
-#include "p_atomic.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct pipe_reference
-{
- struct pipe_atomic count;
-};
-
-
-static INLINE void
-pipe_reference_init(struct pipe_reference *reference, unsigned count)
-{
- p_atomic_set(&reference->count, count);
-}
-
-
-static INLINE boolean
-pipe_is_referenced(struct pipe_reference *reference)
-{
- return p_atomic_read(&reference->count) != 0;
-}
-
-
-/**
- * Update reference counting.
- * The old thing pointed to, if any, will be unreferenced.
- * Both 'ptr' and 'reference' may be NULL.
- * \return TRUE if the object's refcount hits zero and should be destroyed.
- */
-static INLINE boolean
-pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
-{
- boolean destroy = FALSE;
-
- if(ptr != reference) {
- /* bump the reference.count first */
- if (reference) {
- assert(pipe_is_referenced(reference));
- p_atomic_inc(&reference->count);
- }
-
- if (ptr) {
- assert(pipe_is_referenced(ptr));
- if (p_atomic_dec_zero(&ptr->count)) {
- destroy = TRUE;
- }
- }
- }
-
- return destroy;
-}
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_REFCNT_H */
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 03cd74efed..9ae096ee3c 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -43,7 +43,6 @@
#include "p_compiler.h"
#include "p_defines.h"
#include "p_format.h"
-#include "p_refcnt.h"
#include "p_screen.h"
@@ -66,6 +65,12 @@ extern "C" {
#define PIPE_MAX_TEXTURE_LEVELS 16
+struct pipe_reference
+{
+ int32_t count; /* atomic */
+};
+
+
/**
* The driver will certainly subclass this to include actual memory
* management information.
@@ -383,38 +388,6 @@ struct pipe_vertex_element
};
-/* Reference counting helper functions */
-static INLINE void
-pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf)
-{
- struct pipe_buffer *old_buf = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &buf->reference))
- old_buf->screen->buffer_destroy(old_buf);
- *ptr = buf;
-}
-
-static INLINE void
-pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
-{
- struct pipe_surface *old_surf = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &surf->reference))
- old_surf->texture->screen->tex_surface_destroy(old_surf);
- *ptr = surf;
-}
-
-static INLINE void
-pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
-{
- struct pipe_texture *old_tex = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &tex->reference))
- old_tex->screen->texture_destroy(old_tex);
- *ptr = tex;
-}
-
-
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h
deleted file mode 100644
index 25e4148232..0000000000
--- a/src/gallium/include/pipe/p_thread.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/**************************************************************************
- *
- * Copyright 1999-2006 Brian Paul
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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 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
- * BRIAN PAUL 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.
- *
- **************************************************************************/
-
-
-/**
- * @file
- *
- * Thread, mutex, condition var and thread-specific data functions.
- */
-
-
-#ifndef _P_THREAD2_H_
-#define _P_THREAD2_H_
-
-
-#include "pipe/p_compiler.h"
-#include "util/u_debug.h" /* for assert */
-
-
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
-
-#include <pthread.h> /* POSIX threads headers */
-#include <stdio.h> /* for perror() */
-
-#define PIPE_THREAD_HAVE_CONDVAR
-
-typedef pthread_t pipe_thread;
-
-#define PIPE_THREAD_ROUTINE( name, param ) \
- void *name( void *param )
-
-static INLINE pipe_thread pipe_thread_create( void *(* routine)( void *), void *param )
-{
- pipe_thread thread;
- if (pthread_create( &thread, NULL, routine, param ))
- return 0;
- return thread;
-}
-
-static INLINE int pipe_thread_wait( pipe_thread thread )
-{
- return pthread_join( thread, NULL );
-}
-
-static INLINE int pipe_thread_destroy( pipe_thread thread )
-{
- return pthread_detach( thread );
-}
-
-typedef pthread_mutex_t pipe_mutex;
-typedef pthread_cond_t pipe_condvar;
-
-#define pipe_static_mutex(mutex) \
- static pipe_mutex mutex = PTHREAD_MUTEX_INITIALIZER
-
-#define pipe_mutex_init(mutex) \
- (void) pthread_mutex_init(&(mutex), NULL)
-
-#define pipe_mutex_destroy(mutex) \
- pthread_mutex_destroy(&(mutex))
-
-#define pipe_mutex_lock(mutex) \
- (void) pthread_mutex_lock(&(mutex))
-
-#define pipe_mutex_unlock(mutex) \
- (void) pthread_mutex_unlock(&(mutex))
-
-#define pipe_static_condvar(mutex) \
- static pipe_condvar mutex = PTHREAD_COND_INITIALIZER
-
-#define pipe_condvar_init(cond) \
- pthread_cond_init(&(cond), NULL)
-
-#define pipe_condvar_destroy(cond) \
- pthread_cond_destroy(&(cond))
-
-#define pipe_condvar_wait(cond, mutex) \
- pthread_cond_wait(&(cond), &(mutex))
-
-#define pipe_condvar_signal(cond) \
- pthread_cond_signal(&(cond))
-
-#define pipe_condvar_broadcast(cond) \
- pthread_cond_broadcast(&(cond))
-
-
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-
-#include <windows.h>
-
-typedef HANDLE pipe_thread;
-
-#define PIPE_THREAD_ROUTINE( name, param ) \
- void * WINAPI name( void *param )
-
-static INLINE pipe_thread pipe_thread_create( void *(WINAPI * routine)( void *), void *param )
-{
- DWORD id;
- return CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) routine, param, 0, &id );
-}
-
-static INLINE int pipe_thread_wait( pipe_thread thread )
-{
- if (WaitForSingleObject( thread, INFINITE ) == WAIT_OBJECT_0)
- return 0;
- return -1;
-}
-
-static INLINE int pipe_thread_destroy( pipe_thread thread )
-{
- if (CloseHandle( thread ))
- return 0;
- return -1;
-}
-
-typedef CRITICAL_SECTION pipe_mutex;
-
-#define pipe_static_mutex(mutex) \
- /*static*/ pipe_mutex mutex = {0,0,0,0,0,0}
-
-#define pipe_mutex_init(mutex) \
- InitializeCriticalSection(&mutex)
-
-#define pipe_mutex_destroy(mutex) \
- DeleteCriticalSection(&mutex)
-
-#define pipe_mutex_lock(mutex) \
- EnterCriticalSection(&mutex)
-
-#define pipe_mutex_unlock(mutex) \
- LeaveCriticalSection(&mutex)
-
-/* XXX: dummy definitions, make it compile */
-
-typedef unsigned pipe_condvar;
-
-#define pipe_condvar_init(condvar) \
- (void) condvar
-
-#define pipe_condvar_broadcast(condvar) \
- (void) condvar
-
-#else
-
-/** Dummy definitions */
-
-typedef unsigned pipe_thread;
-typedef unsigned pipe_mutex;
-typedef unsigned pipe_condvar;
-
-#define pipe_static_mutex(mutex) \
- static pipe_mutex mutex = 0
-
-#define pipe_mutex_init(mutex) \
- (void) mutex
-
-#define pipe_mutex_destroy(mutex) \
- (void) mutex
-
-#define pipe_mutex_lock(mutex) \
- (void) mutex
-
-#define pipe_mutex_unlock(mutex) \
- (void) mutex
-
-#define pipe_static_condvar(condvar) \
- static unsigned condvar = 0
-
-#define pipe_condvar_init(condvar) \
- (void) condvar
-
-#define pipe_condvar_destroy(condvar) \
- (void) condvar
-
-#define pipe_condvar_wait(condvar, mutex) \
- (void) condvar
-
-#define pipe_condvar_signal(condvar) \
- (void) condvar
-
-#define pipe_condvar_broadcast(condvar) \
- (void) condvar
-
-
-#endif /* PIPE_OS_? */
-
-
-
-/*
- * Thread-specific data.
- */
-
-typedef struct {
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- pthread_key_t key;
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- DWORD key;
-#endif
- int initMagic;
-} pipe_tsd;
-
-
-#define PIPE_TSD_INIT_MAGIC 0xff8adc98
-
-
-static INLINE void
-pipe_tsd_init(pipe_tsd *tsd)
-{
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
- perror("pthread_key_create(): failed to allocate key for thread specific data");
- exit(-1);
- }
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- assert(0);
-#endif
- tsd->initMagic = PIPE_TSD_INIT_MAGIC;
-}
-
-static INLINE void *
-pipe_tsd_get(pipe_tsd *tsd)
-{
- if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
- pipe_tsd_init(tsd);
- }
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- return pthread_getspecific(tsd->key);
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- assert(0);
- return NULL;
-#else
- assert(0);
- return NULL;
-#endif
-}
-
-static INLINE void
-pipe_tsd_set(pipe_tsd *tsd, void *value)
-{
- if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
- pipe_tsd_init(tsd);
- }
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
- if (pthread_setspecific(tsd->key, value) != 0) {
- perror("pthread_set_specific() failed");
- exit(-1);
- }
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
- assert(0);
-#else
- assert(0);
-#endif
-}
-
-
-
-#endif /* _P_THREAD2_H_ */
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
index b85f01c2b0..77e22d0a56 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -30,12 +30,12 @@
/* u_reduce_video_profile() needs these */
#include <pipe/p_compiler.h>
-#include <util/u_debug.h>
#include <pipe/p_defines.h>
#include <pipe/p_format.h>
-#include <pipe/p_refcnt.h>
+#include <pipe/p_state.h>
#include <pipe/p_screen.h>
+#include <util/u_inlines.h>
#ifdef __cplusplus
extern "C" {