VirtualBox

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

Last change on this file since 53625 was 50754, checked in by vboxsync, 11 years ago

Dev/VGA/crOpenGL/wddm: command thread, more command processing

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/** @file
2 *
3 * VirtualBox 3D common tooling
4 */
5
6/*
7 * Copyright (C) 2011-2012 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 VBOXTLSREFDATA_STATE enmTlsRefState; \
63 PFNVBOXTLSREFDTOR pfnTlsRefDtor; \
64
65struct VBOXTLSREFDATA_DUMMY
66{
67 VBOXTLSREFDATA
68};
69
70#define VBOXTLSREFDATA_OFFSET(_t) RT_OFFSETOF(_t, cTlsRefs)
71#define VBOXTLSREFDATA_SIZE() (sizeof (struct VBOXTLSREFDATA_DUMMY))
72#define VBOXTLSREFDATA_COPY(_pDst, _pSrc) do { \
73 (_pDst)->cTlsRefs = (_pSrc)->cTlsRefs; \
74 (_pDst)->enmTlsRefState = (_pSrc)->enmTlsRefState; \
75 (_pDst)->pfnTlsRefDtor = (_pSrc)->pfnTlsRefDtor; \
76 } while (0)
77
78#define VBOXTLSREFDATA_EQUAL(_pDst, _pSrc) ( \
79 (_pDst)->cTlsRefs == (_pSrc)->cTlsRefs \
80 && (_pDst)->enmTlsRefState == (_pSrc)->enmTlsRefState \
81 && (_pDst)->pfnTlsRefDtor == (_pSrc)->pfnTlsRefDtor \
82 )
83
84
85#define VBoxTlsRefInit(_p, _pfnDtor) do { \
86 (_p)->cTlsRefs = 1; \
87 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_INITIALIZED; \
88 (_p)->pfnTlsRefDtor = (_pfnDtor); \
89 } while (0)
90
91#define VBoxTlsRefIsFunctional(_p) (!!((_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED))
92
93#define VBoxTlsRefAddRef(_p) do { \
94 int cRefs = ASMAtomicIncS32(&(_p)->cTlsRefs); \
95 VBoxTlsRefAssertImpl(cRefs > 1 || (_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_DESTROYING); \
96 } while (0)
97
98#define VBoxTlsRefCountGet(_p) (ASMAtomicReadS32(&(_p)->cTlsRefs))
99
100#define VBoxTlsRefRelease(_p) do { \
101 int cRefs = ASMAtomicDecS32(&(_p)->cTlsRefs); \
102 VBoxTlsRefAssertImpl(cRefs >= 0); \
103 if (!cRefs && (_p)->enmTlsRefState != VBOXTLSREFDATA_STATE_DESTROYING /* <- avoid recursion if VBoxTlsRefAddRef/Release is called from dtor */) { \
104 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_DESTROYING; \
105 (_p)->pfnTlsRefDtor((_p)); \
106 } \
107 } while (0)
108
109#define VBoxTlsRefMarkDestroy(_p) do { \
110 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_TOBE_DESTROYED; \
111 } while (0)
112
113#define VBoxTlsRefGetCurrent(_t, _Tsd) ((_t*) VBoxTlsRefGetImpl((_Tsd)))
114
115#define VBoxTlsRefGetCurrentFunctional(_val, _t, _Tsd) do { \
116 _t * cur = VBoxTlsRefGetCurrent(_t, _Tsd); \
117 if (!cur || VBoxTlsRefIsFunctional(cur)) { \
118 (_val) = cur; \
119 } else { \
120 VBoxTlsRefSetCurrent(_t, _Tsd, NULL); \
121 (_val) = NULL; \
122 } \
123 } while (0)
124
125#define VBoxTlsRefSetCurrent(_t, _Tsd, _p) do { \
126 _t * oldCur = VBoxTlsRefGetCurrent(_t, _Tsd); \
127 if (oldCur != (_p)) { \
128 VBoxTlsRefSetImpl((_Tsd), (_p)); \
129 if (oldCur) { \
130 VBoxTlsRefRelease(oldCur); \
131 } \
132 if ((_p)) { \
133 VBoxTlsRefAddRef((_t*)(_p)); \
134 } \
135 } \
136 } while (0)
137
138
139/* host 3D->Fe[/Qt] notification mechanism defines */
140#define VBOX3D_NOTIFY_EVENT_TYPE_VISIBLE_3DDATA 2
141#define VBOX3D_NOTIFY_EVENT_TYPE_TEST_FUNCTIONAL 3
142
143
144#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