VirtualBox

source: vbox/trunk/include/VBox/Graphics/VBoxVideo3D.h@ 93115

Last change on this file since 93115 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/* $Id: VBoxVideo3D.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * VirtualBox 3D common tooling
4 */
5
6/*
7 * Copyright (C) 2011-2022 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_INCLUDED_Graphics_VBoxVideo3D_h
28#define VBOX_INCLUDED_Graphics_VBoxVideo3D_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/cdefs.h>
34#include <iprt/asm.h>
35#ifndef VBoxTlsRefGetImpl
36# ifdef VBoxTlsRefSetImpl
37# error "VBoxTlsRefSetImpl is defined, unexpected!"
38# endif
39# include <iprt/thread.h>
40# define VBoxTlsRefGetImpl(_tls) (RTTlsGet((RTTLS)(_tls)))
41# define VBoxTlsRefSetImpl(_tls, _val) (RTTlsSet((RTTLS)(_tls), (_val)))
42#else
43# ifndef VBoxTlsRefSetImpl
44# error "VBoxTlsRefSetImpl is NOT defined, unexpected!"
45# endif
46#endif
47
48#ifndef VBoxTlsRefAssertImpl
49# define VBoxTlsRefAssertImpl(_a) do {} while (0)
50#endif
51
52typedef DECLCALLBACKTYPE(void, FNVBOXTLSREFDTOR,(void *));
53typedef FNVBOXTLSREFDTOR *PFNVBOXTLSREFDTOR;
54
55typedef enum {
56 VBOXTLSREFDATA_STATE_UNDEFINED = 0,
57 VBOXTLSREFDATA_STATE_INITIALIZED,
58 VBOXTLSREFDATA_STATE_TOBE_DESTROYED,
59 VBOXTLSREFDATA_STATE_DESTROYING,
60 VBOXTLSREFDATA_STATE_32BIT_HACK = 0x7fffffff
61} VBOXTLSREFDATA_STATE;
62
63#define VBOXTLSREFDATA \
64 volatile int32_t cTlsRefs; \
65 VBOXTLSREFDATA_STATE enmTlsRefState; \
66 PFNVBOXTLSREFDTOR pfnTlsRefDtor; \
67
68struct VBOXTLSREFDATA_DUMMY
69{
70 VBOXTLSREFDATA
71};
72
73#define VBOXTLSREFDATA_OFFSET(_t) RT_OFFSETOF(_t, cTlsRefs)
74#define VBOXTLSREFDATA_ASSERT_OFFSET(_t) RTASSERT_OFFSET_OF(_t, cTlsRefs)
75#define VBOXTLSREFDATA_SIZE() (sizeof (struct VBOXTLSREFDATA_DUMMY))
76#define VBOXTLSREFDATA_COPY(_pDst, _pSrc) do { \
77 (_pDst)->cTlsRefs = (_pSrc)->cTlsRefs; \
78 (_pDst)->enmTlsRefState = (_pSrc)->enmTlsRefState; \
79 (_pDst)->pfnTlsRefDtor = (_pSrc)->pfnTlsRefDtor; \
80 } while (0)
81
82#define VBOXTLSREFDATA_EQUAL(_pDst, _pSrc) ( \
83 (_pDst)->cTlsRefs == (_pSrc)->cTlsRefs \
84 && (_pDst)->enmTlsRefState == (_pSrc)->enmTlsRefState \
85 && (_pDst)->pfnTlsRefDtor == (_pSrc)->pfnTlsRefDtor \
86 )
87
88
89#define VBoxTlsRefInit(_p, _pfnDtor) do { \
90 (_p)->cTlsRefs = 1; \
91 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_INITIALIZED; \
92 (_p)->pfnTlsRefDtor = (_pfnDtor); \
93 } while (0)
94
95#define VBoxTlsRefIsFunctional(_p) (!!((_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED))
96
97#define VBoxTlsRefAddRef(_p) do { \
98 int cRefs = ASMAtomicIncS32(&(_p)->cTlsRefs); \
99 VBoxTlsRefAssertImpl(cRefs > 1 || (_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_DESTROYING); \
100 RT_NOREF(cRefs); \
101 } while (0)
102
103#define VBoxTlsRefCountGet(_p) (ASMAtomicReadS32(&(_p)->cTlsRefs))
104
105#define VBoxTlsRefRelease(_p) do { \
106 int cRefs = ASMAtomicDecS32(&(_p)->cTlsRefs); \
107 VBoxTlsRefAssertImpl(cRefs >= 0); \
108 if (!cRefs && (_p)->enmTlsRefState != VBOXTLSREFDATA_STATE_DESTROYING /* <- avoid recursion if VBoxTlsRefAddRef/Release is called from dtor */) { \
109 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_DESTROYING; \
110 (_p)->pfnTlsRefDtor((_p)); \
111 } \
112 } while (0)
113
114#define VBoxTlsRefMarkDestroy(_p) do { \
115 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_TOBE_DESTROYED; \
116 } while (0)
117
118#define VBoxTlsRefGetCurrent(_t, _Tsd) ((_t*) VBoxTlsRefGetImpl((_Tsd)))
119
120#define VBoxTlsRefGetCurrentFunctional(_val, _t, _Tsd) do { \
121 _t * cur = VBoxTlsRefGetCurrent(_t, _Tsd); \
122 if (!cur || VBoxTlsRefIsFunctional(cur)) { \
123 (_val) = cur; \
124 } else { \
125 VBoxTlsRefSetCurrent(_t, _Tsd, NULL); \
126 (_val) = NULL; \
127 } \
128 } while (0)
129
130#define VBoxTlsRefSetCurrent(_t, _Tsd, _p) do { \
131 _t * oldCur = VBoxTlsRefGetCurrent(_t, _Tsd); \
132 if (oldCur != (_p)) { \
133 VBoxTlsRefSetImpl((_Tsd), (_p)); \
134 if (oldCur) { \
135 VBoxTlsRefRelease(oldCur); \
136 } \
137 if ((_p)) { \
138 VBoxTlsRefAddRef((_t*)(_p)); \
139 } \
140 } \
141 } while (0)
142
143
144/* host 3D->Fe[/Qt] notification mechanism defines */
145typedef enum
146{
147 VBOX3D_NOTIFY_TYPE_TEST_FUNCTIONAL = 3,
148 VBOX3D_NOTIFY_TYPE_3DDATA_VISIBLE = 4,
149 VBOX3D_NOTIFY_TYPE_3DDATA_HIDDEN = 5,
150
151 VBOX3D_NOTIFY_TYPE_HW_SCREEN_FIRST = 100,
152 VBOX3D_NOTIFY_TYPE_HW_SCREEN_IS_SUPPORTED = 100,
153 VBOX3D_NOTIFY_TYPE_HW_SCREEN_CREATED = 101,
154 VBOX3D_NOTIFY_TYPE_HW_SCREEN_DESTROYED = 102,
155 VBOX3D_NOTIFY_TYPE_HW_SCREEN_UPDATE_BEGIN = 103,
156 VBOX3D_NOTIFY_TYPE_HW_SCREEN_UPDATE_END = 104,
157 VBOX3D_NOTIFY_TYPE_HW_SCREEN_BIND_SURFACE = 105,
158 VBOX3D_NOTIFY_TYPE_HW_SCREEN_LAST = 105,
159
160 VBOX3D_NOTIFY_TYPE_HW_OVERLAY_CREATED = 200,
161 VBOX3D_NOTIFY_TYPE_HW_OVERLAY_DESTROYED = 201,
162 VBOX3D_NOTIFY_TYPE_HW_OVERLAY_GET_ID = 202,
163
164 VBOX3D_NOTIFY_TYPE_32BIT_HACK = 0x7fffffff
165} VBOX3D_NOTIFY_TYPE;
166
167typedef struct VBOX3DNOTIFY
168{
169 VBOX3D_NOTIFY_TYPE enmNotification;
170 int32_t iDisplay;
171 uint32_t u32Reserved;
172 uint32_t cbData;
173 uint8_t au8Data[sizeof(uint64_t)];
174} VBOX3DNOTIFY;
175
176#endif /* !VBOX_INCLUDED_Graphics_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