VirtualBox

source: vbox/trunk/include/VBox/VBoxVideo3D.h@ 39798

Last change on this file since 39798 was 39602, checked in by vboxsync, 13 years ago

wine/XPDM: 1. Additional swapchain creation fixes 2. De-libwine'ize wined3d 3. Single context per swapchain 4. wine & crOgl current context sync fixes 5. Proper Get/ReleaseDC handling

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/** @file
2 *
3 * VirtualBox 3D common tooling
4 */
5
6/*
7 * Copyright (C) 2011 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___VBox_VBoxVideo3D_h
28#define ___VBox_VBoxVideo3D_h
29
30#include <iprt/cdefs.h>
31#include <iprt/asm.h>
32#ifndef VBoxTlsRefGetImpl
33# ifdef VBoxTlsRefSetImpl
34# error "VBoxTlsRefSetImpl is defined, unexpected!"
35# endif
36# include <iprt/thread.h>
37# define VBoxTlsRefGetImpl(_tls) (RTTlsGet((RTTLS)(_tls)))
38# define VBoxTlsRefSetImpl(_tls, _val) (RTTlsSet((RTTLS)(_tls), (_val)))
39#else
40# ifndef VBoxTlsRefSetImpl
41# error "VBoxTlsRefSetImpl is NOT defined, unexpected!"
42# endif
43#endif
44
45#ifndef VBoxTlsRefAssertImpl
46# define VBoxTlsRefAssertImpl(_a) do {} while (0)
47#endif
48
49typedef DECLCALLBACK(void) FNVBOXTLSREFDTOR(void*);
50typedef FNVBOXTLSREFDTOR *PFNVBOXTLSREFDTOR;
51
52typedef enum {
53 VBOXTLSREFDATA_STATE_UNDEFINED = 0,
54 VBOXTLSREFDATA_STATE_INITIALIZED,
55 VBOXTLSREFDATA_STATE_TOBE_DESTROYED,
56 VBOXTLSREFDATA_STATE_DESTROYING,
57 VBOXTLSREFDATA_STATE_32BIT_HACK = 0x7fffffff
58} VBOXTLSREFDATA_STATE;
59
60#define VBOXTLSREFDATA \
61 volatile int32_t cTlsRefs; \
62 uint32_t enmTlsRefState; \
63 PFNVBOXTLSREFDTOR pfnTlsRefDtor; \
64
65#define VBoxTlsRefInit(_p, _pfnDtor) do { \
66 (_p)->cTlsRefs = 1; \
67 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_INITIALIZED; \
68 (_p)->pfnTlsRefDtor = (_pfnDtor); \
69 } while (0)
70
71#define VBoxTlsRefIsFunctional(_p) (!!((_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED))
72
73#define VBoxTlsRefAddRef(_p) do { \
74 int cRefs = ASMAtomicIncS32(&(_p)->cTlsRefs); \
75 VBoxTlsRefAssertImpl(cRefs > 1 || (_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_DESTROYING); \
76 } while (0)
77
78#define VBoxTlsRefRelease(_p) do { \
79 int cRefs = ASMAtomicDecS32(&(_p)->cTlsRefs); \
80 VBoxTlsRefAssertImpl(cRefs >= 0); \
81 if (!cRefs && (_p)->enmTlsRefState != VBOXTLSREFDATA_STATE_DESTROYING /* <- avoid recursion if VBoxTlsRefAddRef/Release is called from dtor */) { \
82 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_DESTROYING; \
83 (_p)->pfnTlsRefDtor((_p)); \
84 } \
85 } while (0)
86
87#define VBoxTlsRefReleaseMarkDestroy(_p) do { \
88 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_TOBE_DESTROYED; \
89 } while (0)
90
91#define VBoxTlsRefGetCurrent(_t, _Tsd) ((_t*) VBoxTlsRefGetImpl((_Tsd)))
92
93#define VBoxTlsRefSetCurrent(_t, _Tsd, _p) do { \
94 _t * oldCur = VBoxTlsRefGetCurrent(_t, _Tsd); \
95 if (oldCur != (_p)) { \
96 VBoxTlsRefSetImpl((_Tsd), (_p)); \
97 if (oldCur) { \
98 VBoxTlsRefRelease(oldCur); \
99 } \
100 if ((_p)) { \
101 VBoxTlsRefAddRef((_t*)(_p)); \
102 } \
103 } \
104 } while (0)
105
106#endif /* #ifndef ___VBox_VBoxVideo3D_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette