mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
gallium: Make pipe_atomic a regular int32_t.
This commit is contained in:
parent
28486880ca
commit
38f6f23fcf
16 changed files with 67 additions and 134 deletions
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "draw/draw_private.h"
|
||||
#include "draw/draw_pipe.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "tgsi/tgsi_info.h"
|
||||
#include "tgsi/tgsi_dump.h"
|
||||
#include "tgsi/tgsi_sanity.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@
|
|||
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "pipe/p_screen.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "pipe/p_atomic.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
#include "util/u_simple_shaders.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "tgsi/tgsi_ureg.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_refcnt.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
struct brw_winsys;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
#include "lp_bld_type.h"
|
||||
#include "lp_bld_const.h"
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
#include "lp_bld_blend.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@
|
|||
|
||||
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
#include "lp_bld_type.h"
|
||||
#include "lp_bld_arit.h"
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static void trace_dump_reference(const struct pipe_reference *reference)
|
|||
return;
|
||||
|
||||
trace_dump_struct_begin("pipe_reference");
|
||||
trace_dump_member(int, &reference->count, count);
|
||||
trace_dump_member(int, reference, count);
|
||||
trace_dump_struct_end();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,41 +44,37 @@ extern "C" {
|
|||
|
||||
#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)
|
||||
#define p_atomic_set(_v, _i) (*(_v) = (_i))
|
||||
#define p_atomic_read(_v) (*(_v))
|
||||
|
||||
|
||||
static INLINE boolean
|
||||
p_atomic_dec_zero(struct pipe_atomic *v)
|
||||
p_atomic_dec_zero(int32_t *v)
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
__asm__ __volatile__("lock; decl %0; sete %1":"+m"(v->count), "=qm"(c)
|
||||
__asm__ __volatile__("lock; decl %0; sete %1":"+m"(*v), "=qm"(c)
|
||||
::"memory");
|
||||
|
||||
return c != 0;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_inc(struct pipe_atomic *v)
|
||||
p_atomic_inc(int32_t *v)
|
||||
{
|
||||
__asm__ __volatile__("lock; incl %0":"+m"(v->count));
|
||||
__asm__ __volatile__("lock; incl %0":"+m"(*v));
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_dec(struct pipe_atomic *v)
|
||||
p_atomic_dec(int32_t *v)
|
||||
{
|
||||
__asm__ __volatile__("lock; decl %0":"+m"(v->count));
|
||||
__asm__ __volatile__("lock; decl %0":"+m"(*v));
|
||||
}
|
||||
|
||||
static INLINE int32_t
|
||||
p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
|
||||
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
|
||||
{
|
||||
return __sync_val_compare_and_swap(&v->count, old, _new);
|
||||
return __sync_val_compare_and_swap(v, old, _new);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -90,36 +86,32 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
|
|||
|
||||
#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)
|
||||
#define p_atomic_set(_v, _i) (*(_v) = (_i))
|
||||
#define p_atomic_read(_v) (*(_v))
|
||||
|
||||
|
||||
static INLINE boolean
|
||||
p_atomic_dec_zero(struct pipe_atomic *v)
|
||||
p_atomic_dec_zero(int32_t *v)
|
||||
{
|
||||
return (__sync_sub_and_fetch(&v->count, 1) == 0);
|
||||
return (__sync_sub_and_fetch(v, 1) == 0);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_inc(struct pipe_atomic *v)
|
||||
p_atomic_inc(int32_t *v)
|
||||
{
|
||||
(void) __sync_add_and_fetch(&v->count, 1);
|
||||
(void) __sync_add_and_fetch(v, 1);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_dec(struct pipe_atomic *v)
|
||||
p_atomic_dec(int32_t *v)
|
||||
{
|
||||
(void) __sync_sub_and_fetch(&v->count, 1);
|
||||
(void) __sync_sub_and_fetch(v, 1);
|
||||
}
|
||||
|
||||
static INLINE int32_t
|
||||
p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
|
||||
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
|
||||
{
|
||||
return __sync_val_compare_and_swap(&v->count, old, _new);
|
||||
return __sync_val_compare_and_swap(v, old, _new);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -132,17 +124,12 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
|
|||
|
||||
#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)
|
||||
#define p_atomic_set(_v, _i) (*(_v) = (_i))
|
||||
#define p_atomic_read(_v) (*(_v))
|
||||
#define p_atomic_dec_zero(_v) ((boolean) --(*(_v)))
|
||||
#define p_atomic_inc(_v) ((void) (*(_v))++)
|
||||
#define p_atomic_dec(_v) ((void) (*(_v))--)
|
||||
#define p_atomic_cmpxchg(_v, old, _new) (*(_v) == old ? *(_v) = (_new) : *(_v))
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -153,22 +140,16 @@ struct pipe_atomic
|
|||
|
||||
#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)
|
||||
#define p_atomic_set(_v, _i) (*(_v) = (_i))
|
||||
#define p_atomic_read(_v) (*(_v))
|
||||
|
||||
static INLINE boolean
|
||||
p_atomic_dec_zero(struct pipe_atomic *v)
|
||||
p_atomic_dec_zero(int32_t *v)
|
||||
{
|
||||
int32_t *pcount = &v->count;
|
||||
unsigned char c;
|
||||
|
||||
__asm {
|
||||
mov eax, [pcount]
|
||||
mov eax, [v]
|
||||
lock dec dword ptr [eax]
|
||||
sete byte ptr [c]
|
||||
}
|
||||
|
|
@ -177,35 +158,30 @@ p_atomic_dec_zero(struct pipe_atomic *v)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_inc(struct pipe_atomic *v)
|
||||
p_atomic_inc(int32_t *v)
|
||||
{
|
||||
int32_t *pcount = &v->count;
|
||||
|
||||
__asm {
|
||||
mov eax, [pcount]
|
||||
mov eax, [v]
|
||||
lock inc dword ptr [eax]
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_dec(struct pipe_atomic *v)
|
||||
p_atomic_dec(int32_t *v)
|
||||
{
|
||||
int32_t *pcount = &v->count;
|
||||
|
||||
__asm {
|
||||
mov eax, [pcount]
|
||||
mov eax, [v]
|
||||
lock dec dword ptr [eax]
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE int32_t
|
||||
p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
|
||||
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
|
||||
{
|
||||
int32_t *pcount = &v->count;
|
||||
int32_t orig;
|
||||
|
||||
__asm {
|
||||
mov ecx, [pcount]
|
||||
mov ecx, [v]
|
||||
mov eax, [old]
|
||||
mov edx, [_new]
|
||||
lock cmpxchg [ecx], edx
|
||||
|
|
@ -221,42 +197,37 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
|
|||
|
||||
#define PIPE_ATOMIC "MSVC Intrinsics"
|
||||
|
||||
struct pipe_atomic
|
||||
{
|
||||
int32_t count;
|
||||
};
|
||||
|
||||
#include <intrin.h>
|
||||
|
||||
#pragma intrinsic(_InterlockedIncrement)
|
||||
#pragma intrinsic(_InterlockedDecrement)
|
||||
#pragma intrinsic(_InterlockedCompareExchange)
|
||||
|
||||
#define p_atomic_set(_v, _i) ((_v)->count = (_i))
|
||||
#define p_atomic_read(_v) ((_v)->count)
|
||||
#define p_atomic_set(_v, _i) (*(_v) = (_i))
|
||||
#define p_atomic_read(_v) (*(_v))
|
||||
|
||||
static INLINE boolean
|
||||
p_atomic_dec_zero(struct pipe_atomic *v)
|
||||
p_atomic_dec_zero(int32_t *v)
|
||||
{
|
||||
return _InterlockedDecrement(&v->count) == 0;
|
||||
return _InterlockedDecrement(v) == 0;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_inc(struct pipe_atomic *v)
|
||||
p_atomic_inc(int32_t *v)
|
||||
{
|
||||
_InterlockedIncrement(&v->count);
|
||||
_InterlockedIncrement(v);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
p_atomic_dec(struct pipe_atomic *v)
|
||||
p_atomic_dec(int32_t *v)
|
||||
{
|
||||
_InterlockedDecrement(&v->count);
|
||||
_InterlockedDecrement(v);
|
||||
}
|
||||
|
||||
static INLINE int32_t
|
||||
p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
|
||||
p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
|
||||
{
|
||||
return _InterlockedCompareExchange(&v->count, _new, old);
|
||||
return _InterlockedCompareExchange(v, _new, old);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,52 +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"
|
||||
#include "util/u_debug.h" /* FIXME: remove this */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct pipe_reference
|
||||
{
|
||||
struct pipe_atomic count;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* P_REFCNT_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.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#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>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "intel_drm_winsys.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "pipe/p_refcnt.h"
|
||||
#include "pipe/p_atomic.h"
|
||||
|
||||
/**
|
||||
* Because gem does not have fence's we have to create our own fences.
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_atomic.h"
|
||||
#include "pipe/p_refcnt.h"
|
||||
#include "pipe/p_atomic.h"
|
||||
|
||||
#define VMW_MAX_PRESENTS 3
|
||||
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
struct vmw_svga_winsys_surface
|
||||
{
|
||||
struct pipe_atomic validated;
|
||||
int32_t validated; /* atomic */
|
||||
struct pipe_reference refcnt;
|
||||
|
||||
struct vmw_winsys_screen *screen;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue