VirtualBox

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

Last change on this file since 106165 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: VBoxVideo3D.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VirtualBox 3D common tooling
4 */
5
6/*
7 * Copyright (C) 2011-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef VBOX_INCLUDED_Graphics_VBoxVideo3D_h
38#define VBOX_INCLUDED_Graphics_VBoxVideo3D_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/cdefs.h>
44#include <iprt/asm.h>
45#ifndef VBoxTlsRefGetImpl
46# ifdef VBoxTlsRefSetImpl
47# error "VBoxTlsRefSetImpl is defined, unexpected!"
48# endif
49# include <iprt/thread.h>
50# define VBoxTlsRefGetImpl(_tls) (RTTlsGet((RTTLS)(_tls)))
51# define VBoxTlsRefSetImpl(_tls, _val) (RTTlsSet((RTTLS)(_tls), (_val)))
52#else
53# ifndef VBoxTlsRefSetImpl
54# error "VBoxTlsRefSetImpl is NOT defined, unexpected!"
55# endif
56#endif
57
58#ifndef VBoxTlsRefAssertImpl
59# define VBoxTlsRefAssertImpl(_a) do {} while (0)
60#endif
61
62typedef DECLCALLBACKTYPE(void, FNVBOXTLSREFDTOR,(void *));
63typedef FNVBOXTLSREFDTOR *PFNVBOXTLSREFDTOR;
64
65typedef enum {
66 VBOXTLSREFDATA_STATE_UNDEFINED = 0,
67 VBOXTLSREFDATA_STATE_INITIALIZED,
68 VBOXTLSREFDATA_STATE_TOBE_DESTROYED,
69 VBOXTLSREFDATA_STATE_DESTROYING,
70 VBOXTLSREFDATA_STATE_32BIT_HACK = 0x7fffffff
71} VBOXTLSREFDATA_STATE;
72
73#define VBOXTLSREFDATA \
74 volatile int32_t cTlsRefs; \
75 VBOXTLSREFDATA_STATE enmTlsRefState; \
76 PFNVBOXTLSREFDTOR pfnTlsRefDtor; \
77
78struct VBOXTLSREFDATA_DUMMY
79{
80 VBOXTLSREFDATA
81};
82
83#define VBOXTLSREFDATA_OFFSET(_t) RT_OFFSETOF(_t, cTlsRefs)
84#define VBOXTLSREFDATA_ASSERT_OFFSET(_t) RTASSERT_OFFSET_OF(_t, cTlsRefs)
85#define VBOXTLSREFDATA_SIZE() (sizeof (struct VBOXTLSREFDATA_DUMMY))
86#define VBOXTLSREFDATA_COPY(_pDst, _pSrc) do { \
87 (_pDst)->cTlsRefs = (_pSrc)->cTlsRefs; \
88 (_pDst)->enmTlsRefState = (_pSrc)->enmTlsRefState; \
89 (_pDst)->pfnTlsRefDtor = (_pSrc)->pfnTlsRefDtor; \
90 } while (0)
91
92#define VBOXTLSREFDATA_EQUAL(_pDst, _pSrc) ( \
93 (_pDst)->cTlsRefs == (_pSrc)->cTlsRefs \
94 && (_pDst)->enmTlsRefState == (_pSrc)->enmTlsRefState \
95 && (_pDst)->pfnTlsRefDtor == (_pSrc)->pfnTlsRefDtor \
96 )
97
98
99#define VBoxTlsRefInit(_p, _pfnDtor) do { \
100 (_p)->cTlsRefs = 1; \
101 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_INITIALIZED; \
102 (_p)->pfnTlsRefDtor = (_pfnDtor); \
103 } while (0)
104
105#define VBoxTlsRefIsFunctional(_p) (!!((_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED))
106
107#define VBoxTlsRefAddRef(_p) do { \
108 int cRefs = ASMAtomicIncS32(&(_p)->cTlsRefs); \
109 VBoxTlsRefAssertImpl(cRefs > 1 || (_p)->enmTlsRefState == VBOXTLSREFDATA_STATE_DESTROYING); \
110 RT_NOREF(cRefs); \
111 } while (0)
112
113#define VBoxTlsRefCountGet(_p) (ASMAtomicReadS32(&(_p)->cTlsRefs))
114
115#define VBoxTlsRefRelease(_p) do { \
116 int cRefs = ASMAtomicDecS32(&(_p)->cTlsRefs); \
117 VBoxTlsRefAssertImpl(cRefs >= 0); \
118 if (!cRefs && (_p)->enmTlsRefState != VBOXTLSREFDATA_STATE_DESTROYING /* <- avoid recursion if VBoxTlsRefAddRef/Release is called from dtor */) { \
119 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_DESTROYING; \
120 (_p)->pfnTlsRefDtor((_p)); \
121 } \
122 } while (0)
123
124#define VBoxTlsRefMarkDestroy(_p) do { \
125 (_p)->enmTlsRefState = VBOXTLSREFDATA_STATE_TOBE_DESTROYED; \
126 } while (0)
127
128#define VBoxTlsRefGetCurrent(_t, _Tsd) ((_t*) VBoxTlsRefGetImpl((_Tsd)))
129
130#define VBoxTlsRefGetCurrentFunctional(_val, _t, _Tsd) do { \
131 _t * cur = VBoxTlsRefGetCurrent(_t, _Tsd); \
132 if (!cur || VBoxTlsRefIsFunctional(cur)) { \
133 (_val) = cur; \
134 } else { \
135 VBoxTlsRefSetCurrent(_t, _Tsd, NULL); \
136 (_val) = NULL; \
137 } \
138 } while (0)
139
140#define VBoxTlsRefSetCurrent(_t, _Tsd, _p) do { \
141 _t * oldCur = VBoxTlsRefGetCurrent(_t, _Tsd); \
142 if (oldCur != (_p)) { \
143 VBoxTlsRefSetImpl((_Tsd), (_p)); \
144 if (oldCur) { \
145 VBoxTlsRefRelease(oldCur); \
146 } \
147 if ((_p)) { \
148 VBoxTlsRefAddRef((_t*)(_p)); \
149 } \
150 } \
151 } while (0)
152
153
154/* host 3D->Fe[/Qt] notification mechanism defines */
155typedef enum
156{
157 VBOX3D_NOTIFY_TYPE_TEST_FUNCTIONAL = 3,
158 VBOX3D_NOTIFY_TYPE_3DDATA_VISIBLE = 4,
159 VBOX3D_NOTIFY_TYPE_3DDATA_HIDDEN = 5,
160
161 VBOX3D_NOTIFY_TYPE_HW_SCREEN_FIRST = 100,
162 VBOX3D_NOTIFY_TYPE_HW_SCREEN_IS_SUPPORTED = 100,
163 VBOX3D_NOTIFY_TYPE_HW_SCREEN_CREATED = 101,
164 VBOX3D_NOTIFY_TYPE_HW_SCREEN_DESTROYED = 102,
165 VBOX3D_NOTIFY_TYPE_HW_SCREEN_UPDATE_BEGIN = 103,
166 VBOX3D_NOTIFY_TYPE_HW_SCREEN_UPDATE_END = 104,
167 VBOX3D_NOTIFY_TYPE_HW_SCREEN_BIND_SURFACE = 105,
168 VBOX3D_NOTIFY_TYPE_HW_SCREEN_LAST = 105,
169
170 VBOX3D_NOTIFY_TYPE_HW_OVERLAY_CREATED = 200,
171 VBOX3D_NOTIFY_TYPE_HW_OVERLAY_DESTROYED = 201,
172 VBOX3D_NOTIFY_TYPE_HW_OVERLAY_GET_ID = 202,
173
174 VBOX3D_NOTIFY_TYPE_32BIT_HACK = 0x7fffffff
175} VBOX3D_NOTIFY_TYPE;
176
177typedef struct VBOX3DNOTIFY
178{
179 VBOX3D_NOTIFY_TYPE enmNotification;
180 int32_t iDisplay;
181 uint32_t u32Reserved;
182 uint32_t cbData;
183 uint8_t au8Data[sizeof(uint64_t)];
184} VBOX3DNOTIFY;
185
186#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