VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h@ 43233

最後變更 在這個檔案從43233是 43182,由 vboxsync 提交於 12 年 前

crOpenGL: 1. VRDP+3D fixes, 2. Generic bugfixes, 3. Intel GPU-related fixes

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 9.5 KB
 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_RENDERSPU_H
8#define CR_RENDERSPU_H
9
10#ifdef WINDOWS
11#define WIN32_LEAN_AND_MEAN
12#include <windows.h>
13#define RENDER_APIENTRY __stdcall
14#define snprintf _snprintf
15#elif defined(DARWIN)
16# ifndef VBOX_WITH_COCOA_QT
17# include <AGL/AGL.h>
18# else
19# include "renderspu_cocoa_helper.h"
20# endif
21#define RENDER_APIENTRY
22#else
23#include <GL/glx.h>
24#define RENDER_APIENTRY
25#endif
26#include "cr_threads.h"
27#include "cr_spu.h"
28#include "cr_hash.h"
29#include "cr_server.h"
30
31#include <iprt/cdefs.h>
32
33#define MAX_VISUALS 32
34
35#ifdef RT_OS_DARWIN
36# ifndef VBOX_WITH_COCOA_QT
37enum
38{
39 /* Event classes */
40 kEventClassVBox = 'vbox',
41 /* Event kinds */
42 kEventVBoxShowWindow = 'swin',
43 kEventVBoxHideWindow = 'hwin',
44 kEventVBoxMoveWindow = 'mwin',
45 kEventVBoxResizeWindow = 'rwin',
46 kEventVBoxDisposeWindow = 'dwin',
47 kEventVBoxUpdateDock = 'udck',
48 kEventVBoxUpdateContext = 'uctx',
49 kEventVBoxBoundsChanged = 'bchg'
50};
51pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void* userData);
52# endif
53#endif /* RT_OS_DARWIN */
54
55/**
56 * Visual info
57 */
58typedef struct {
59 GLbitfield visAttribs;
60 const char *displayName;
61#if defined(WINDOWS)
62// HDC device_context;
63#elif defined(DARWIN)
64# ifndef VBOX_WITH_COCOA_QT
65 WindowRef window;
66# endif
67#elif defined(GLX)
68 Display *dpy;
69 XVisualInfo *visual;
70#ifdef GLX_VERSION_1_3
71 GLXFBConfig fbconfig;
72#endif /* GLX_VERSION_1_3 */
73#endif
74} VisualInfo;
75
76/**
77 * Window info
78 */
79typedef struct {
80 int x, y;
81 int width, height;
82 int id; /**< integer window ID */
83 VisualInfo *visual;
84 GLboolean mapPending;
85 GLboolean visible;
86 GLboolean everCurrent; /**< has this window ever been bound? */
87 char *title;
88#if defined(WINDOWS)
89 HDC nativeWindow; /**< for render_to_app_window */
90 HWND hWnd;
91 HDC device_context;
92 HRGN hRgn;
93#elif defined(DARWIN)
94# ifndef VBOX_WITH_COCOA_QT
95 WindowRef window;
96 WindowRef nativeWindow; /**< for render_to_app_window */
97 WindowRef appWindow;
98 EventHandlerUPP event_handler;
99 GLint bufferName;
100 AGLContext dummyContext;
101 RgnHandle hVisibleRegion;
102 /* unsigned long context_ptr; */
103# else
104 NativeNSViewRef window;
105 NativeNSViewRef nativeWindow; /**< for render_to_app_window */
106 NativeNSOpenGLContextRef *currentCtx;
107# endif
108#elif defined(GLX)
109 Window window;
110 Window nativeWindow; /**< for render_to_app_window */
111 Window appWindow; /**< Same as nativeWindow but for garbage collections purposes */
112#endif
113 int nvSwapGroup;
114
115#ifdef USE_OSMESA
116 GLubyte *buffer; /**< for rendering to off screen buffer. */
117 int in_buffer_width;
118 int in_buffer_height;
119#endif
120
121} WindowInfo;
122
123/**
124 * Context Info
125 */
126typedef struct _ContextInfo {
127 int id; /**< integer context ID */
128 VisualInfo *visual;
129 GLboolean everCurrent;
130 GLboolean haveWindowPosARB;
131 WindowInfo *currentWindow;
132#if defined(WINDOWS)
133 HGLRC hRC;
134#elif defined(DARWIN)
135# ifndef VBOX_WITH_COCOA_QT
136 AGLContext context;
137# else
138 NativeNSOpenGLContextRef context;
139# endif
140#elif defined(GLX)
141 GLXContext context;
142#endif
143 struct _ContextInfo *shared;
144 char *extensionString;
145} ContextInfo;
146
147/**
148 * Barrier info
149 */
150typedef struct {
151 CRbarrier barrier;
152 GLuint count;
153} Barrier;
154
155/**
156 * Renderspu state info
157 */
158typedef struct {
159 SPUDispatchTable self;
160 int id;
161
162 unsigned int window_id;
163 unsigned int context_id;
164
165 /** config options */
166 /*@{*/
167 char *window_title;
168 int defaultX, defaultY;
169 unsigned int defaultWidth, defaultHeight;
170 int default_visual;
171 int use_L2;
172 int fullscreen, ontop;
173 char display_string[100];
174#if defined(GLX)
175 int try_direct;
176 int force_direct;
177 int sync;
178#endif
179 int render_to_app_window;
180 int render_to_crut_window;
181 int crut_drawable;
182 int resizable;
183 int use_lut8, lut8[3][256];
184 int borderless;
185 int nvSwapGroup;
186 int ignore_papi;
187 int ignore_window_moves;
188 int pbufferWidth, pbufferHeight;
189 int use_glxchoosevisual;
190 int draw_bbox;
191 /*@}*/
192
193 CRServer *server;
194 int gather_port;
195 int gather_userbuf_size;
196 CRConnection **gather_conns;
197
198 GLint drawCursor;
199 GLint cursorX, cursorY;
200
201 int numVisuals;
202 VisualInfo visuals[MAX_VISUALS];
203
204 CRHashTable *windowTable;
205 CRHashTable *contextTable;
206
207#ifndef CHROMIUM_THREADSAFE
208 ContextInfo *currentContext;
209#endif
210
211 crOpenGLInterface ws; /**< Window System interface */
212
213 CRHashTable *barrierHash;
214
215 int is_swap_master, num_swap_clients;
216 int swap_mtu;
217 char *swap_master_url;
218 CRConnection **swap_conns;
219
220#ifdef USE_OSMESA
221 /** Off screen rendering hooks. */
222 int use_osmesa;
223
224 OSMesaContext (*OSMesaCreateContext)( GLenum format, OSMesaContext sharelist );
225 GLboolean (* OSMesaMakeCurrent)( OSMesaContext ctx,
226 GLubyte *buffer,
227 GLenum type,
228 GLsizei width,
229 GLsizei height );
230 void (*OSMesaDestroyContext)( OSMesaContext ctx );
231#endif
232
233#ifdef RT_OS_WINDOWS
234 DWORD dwWinThreadId;
235 HANDLE hWinThreadReadyEvent;
236#endif
237
238#ifdef RT_OS_DARWIN
239# ifndef VBOX_WITH_COCOA_QT
240 RgnHandle hRootVisibleRegion;
241 RTSEMFASTMUTEX syncMutex;
242 EventHandlerUPP hParentEventHandler;
243 WindowGroupRef pParentGroup;
244 WindowGroupRef pMasterGroup;
245 GLint currentBufferName;
246 uint64_t uiDockUpdateTS;
247 bool fInit;
248# endif
249#endif /* RT_OS_DARWIN */
250
251 int force_hidden_wdn_create;
252} RenderSPU;
253
254#ifdef RT_OS_WINDOWS
255
256/* Asks window thread to create new window.
257 msg.lParam - holds pointer to CREATESTRUCT structure
258 note that lpCreateParams is used to specify address to store handle of created window
259 msg.wParam - unused, should be NULL
260*/
261#define WM_VBOX_RENDERSPU_CREATE_WINDOW (WM_APP+1)
262
263typedef struct _VBOX_RENDERSPU_DESTROY_WINDOW {
264 HWND hWnd; /* handle to window to destroy */
265} VBOX_RENDERSPU_DESTROY_WINDOW;
266
267/* Asks window thread to destroy previously created window.
268 msg.lParam - holds pointer to RENDERSPU_VBOX_WINDOW_DESTROY structure
269 msg.wParam - unused, should be NULL
270*/
271#define WM_VBOX_RENDERSPU_DESTROY_WINDOW (WM_APP+2)
272
273#endif
274
275extern RenderSPU render_spu;
276
277/* @todo remove this hack */
278extern uint64_t render_spu_parent_window_id;
279
280#ifdef CHROMIUM_THREADSAFE
281extern CRtsd _RenderTSD;
282#define GET_CONTEXT(T) ContextInfo *T = (ContextInfo *) crGetTSD(&_RenderTSD)
283#else
284#define GET_CONTEXT(T) ContextInfo *T = render_spu.currentContext
285#endif
286
287extern void renderspuSetVBoxConfiguration( RenderSPU *spu );
288extern void renderspuMakeVisString( GLbitfield visAttribs, char *s );
289extern VisualInfo *renderspuFindVisual(const char *displayName, GLbitfield visAttribs );
290extern GLboolean renderspu_SystemInitVisual( VisualInfo *visual );
291extern GLboolean renderspu_SystemCreateContext( VisualInfo *visual, ContextInfo *context, ContextInfo *sharedContext );
292extern void renderspu_SystemDestroyContext( ContextInfo *context );
293extern GLboolean renderspu_SystemCreateWindow( VisualInfo *visual, GLboolean showIt, WindowInfo *window );
294extern GLboolean renderspu_SystemVBoxCreateWindow( VisualInfo *visual, GLboolean showIt, WindowInfo *window );
295extern void renderspu_SystemDestroyWindow( WindowInfo *window );
296extern void renderspu_SystemWindowSize( WindowInfo *window, GLint w, GLint h );
297extern void renderspu_SystemGetWindowGeometry( WindowInfo *window, GLint *x, GLint *y, GLint *w, GLint *h );
298extern void renderspu_SystemGetMaxWindowSize( WindowInfo *window, GLint *w, GLint *h );
299extern void renderspu_SystemWindowPosition( WindowInfo *window, GLint x, GLint y );
300extern void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, GLint* pRects);
301extern void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window);
302#ifdef RT_OS_DARWIN
303extern void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects);
304# ifdef VBOX_WITH_COCOA_QT
305extern void renderspu_SystemFlush();
306extern void renderspu_SystemFinish();
307extern void renderspu_SystemBindFramebufferEXT(GLenum target, GLuint framebuffer);
308extern void renderspu_SystemCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
309extern void renderspu_SystemGetIntegerv(GLenum pname, GLint *params);
310extern void renderspu_SystemReadBuffer(GLenum mode);
311extern void renderspu_SystemDrawBuffer(GLenum mode);
312# endif
313#endif
314extern void renderspu_SystemShowWindow( WindowInfo *window, GLboolean showIt );
315extern void renderspu_SystemMakeCurrent( WindowInfo *window, GLint windowInfor, ContextInfo *context );
316extern void renderspu_SystemSwapBuffers( WindowInfo *window, GLint flags );
317extern void renderspu_SystemReparentWindow(WindowInfo *window);
318extern void renderspu_GCWindow(void);
319extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] );
320
321extern GLint RENDER_APIENTRY renderspuWindowCreate( const char *dpyName, GLint visBits );
322void RENDER_APIENTRY renderspuWindowDestroy( GLint win );
323extern GLint RENDER_APIENTRY renderspuCreateContext( const char *dpyname, GLint visBits, GLint shareCtx );
324extern void RENDER_APIENTRY renderspuMakeCurrent(GLint crWindow, GLint nativeWindow, GLint ctx);
325extern void RENDER_APIENTRY renderspuSwapBuffers( GLint window, GLint flags );
326
327#ifdef __cplusplus
328extern "C" {
329#endif
330DECLEXPORT(void) renderspuSetWindowId(uint64_t winId);
331DECLEXPORT(void) renderspuSetRootVisibleRegion(GLint cRects, GLint *pRects);
332DECLEXPORT(void) renderspuReparentWindow(GLint window);
333#ifdef __cplusplus
334}
335#endif
336
337#endif /* CR_RENDERSPU_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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