VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h@ 93956

Last change on this file since 93956 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: 57.3 KB
Line 
1/* $Id: DevVGA-SVGA3d-internal.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * DevVMWare - VMWare SVGA device - 3D part, internal header.
4 */
5
6/*
7 * Copyright (C) 2013-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
18#ifndef VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA3d_internal_h
19#define VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA3d_internal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/*
25 * Assert sane compilation environment.
26 */
27#ifndef IN_RING3
28# error "VMSVGA3D_INCL_INTERNALS is only for ring-3 code"
29#endif
30#ifdef VMSVGA3D_OPENGL
31# if defined(VMSVGA3D_DIRECT3D)
32# error "Both VMSVGA3D_DIRECT3D and VMSVGA3D_OPENGL cannot be defined at the same time."
33# endif
34#elif !defined(VMSVGA3D_DIRECT3D)
35# error "Either VMSVGA3D_OPENGL or VMSVGA3D_DIRECT3D must be defined."
36#endif
37
38
39/*********************************************************************************************************************************
40* Header Files *
41*********************************************************************************************************************************/
42#include "DevVGA-SVGA3d.h"
43
44#if defined(VMSVGA3D_DYNAMIC_LOAD) && defined(VMSVGA3D_OPENGL)
45# include "DevVGA-SVGA3d-glLdr.h"
46#endif
47
48#ifdef RT_OS_WINDOWS
49# include <iprt/win/windows.h>
50# ifdef VMSVGA3D_DIRECT3D
51# include <d3d9.h>
52# include <iprt/avl.h>
53# else
54# include <GL/gl.h>
55# include "vmsvga_glext/wglext.h"
56# endif
57
58#elif defined(RT_OS_DARWIN)
59# include <OpenGL/OpenGL.h>
60# include <OpenGL/gl3.h>
61# include <OpenGL/gl3ext.h>
62# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
63# include <OpenGL/gl.h>
64# include <OpenGL/glext.h>
65# include "DevVGA-SVGA3d-cocoa.h"
66/* work around conflicting definition of GLhandleARB in VMware's glext.h */
67//#define GL_ARB_shader_objects
68// HACK
69typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
70typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
71typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
72# define GL_RGBA_S3TC 0x83A2
73# define GL_ALPHA8_EXT 0x803c
74# define GL_LUMINANCE8_EXT 0x8040
75# define GL_LUMINANCE16_EXT 0x8042
76# define GL_LUMINANCE4_ALPHA4_EXT 0x8043
77# define GL_LUMINANCE8_ALPHA8_EXT 0x8045
78# define GL_INT_2_10_10_10_REV 0x8D9F
79
80#else
81# include <X11/Xlib.h>
82# include <X11/Xatom.h>
83# include <GL/gl.h>
84# include <GL/glx.h>
85# include <GL/glext.h>
86# define VBOX_VMSVGA3D_GL_HACK_LEVEL 0x103
87#endif
88
89#ifdef VMSVGA3D_OPENGL
90# include "vmsvga_glext/glext.h"
91# include "shaderlib/shaderlib.h"
92#endif
93
94#ifdef VMSVGA3D_DX
95#include "DevVGA-SVGA3d-dx-shader.h"
96#endif
97
98
99/*********************************************************************************************************************************
100* Defined Constants And Macros *
101*********************************************************************************************************************************/
102#ifdef VMSVGA3D_OPENGL
103/** OpenGL: Create a dedicated context for handling surfaces in, thus
104 * avoiding orphaned surfaces after context destruction.
105 *
106 * This cures, for instance, an assertion on fedora 21 that happens in
107 * vmsvga3dSurfaceStretchBlt if the login screen and the desktop has different
108 * sizes. The context of the login screen seems to have just been destroyed
109 * earlier and I believe the driver/X/whoever is attemting to strech the old
110 * screen content onto the new sized screen.
111 *
112 * @remarks This probably comes at a slight preformance expense, as we currently
113 * switches context when setting up the surface the first time. Not sure
114 * if we really need to, but as this is an experiment, I'm playing it safe.
115 * @remarks The define has been made default, thus should no longer be used.
116 */
117# define VMSVGA3D_OGL_WITH_SHARED_CTX
118/** Fake surface ID for the shared context. */
119# define VMSVGA3D_SHARED_CTX_ID UINT32_C(0xffffeeee)
120
121/** @def VBOX_VMSVGA3D_GL_HACK_LEVEL
122 * Turns out that on Linux gl.h may often define the first 2-4 OpenGL versions
123 * worth of extensions, but missing out on a function pointer of fifteen. This
124 * causes headache for us when we use the function pointers below. This hack
125 * changes the code to call the known problematic functions directly.
126 * The value is ((x)<<16 | (y)) where x and y are taken from the GL_VERSION_x_y.
127 */
128# ifndef VBOX_VMSVGA3D_GL_HACK_LEVEL
129# define VBOX_VMSVGA3D_GL_HACK_LEVEL 0
130# endif
131
132/** Invalid OpenGL ID. */
133# define OPENGL_INVALID_ID 0
134
135# define VMSVGA3D_CLEAR_CURRENT_CONTEXT(pState) \
136 do { (pState)->idActiveContext = OPENGL_INVALID_ID; } while (0)
137
138/** @def VMSVGA3D_SET_CURRENT_CONTEXT
139 * Makes sure the @a pContext is the active OpenGL context.
140 * @parm pState The VMSVGA3d state.
141 * @parm pContext The new context.
142 */
143# ifdef RT_OS_WINDOWS
144# define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \
145 do { \
146 if ((pState)->idActiveContext != (pContext)->id) \
147 { \
148 BOOL fMakeCurrentRc = wglMakeCurrent((pContext)->hdc, (pContext)->hglrc); \
149 Assert(fMakeCurrentRc == TRUE); RT_NOREF_PV(fMakeCurrentRc); \
150 LogFlowFunc(("Changing context: %#x -> %#x\n", (pState)->idActiveContext, (pContext)->id)); \
151 (pState)->idActiveContext = (pContext)->id; \
152 } \
153 } while (0)
154
155# elif defined(RT_OS_DARWIN)
156# define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \
157 do { \
158 if ((pState)->idActiveContext != (pContext)->id) \
159 { \
160 vmsvga3dCocoaViewMakeCurrentContext((pContext)->cocoaView, (pContext)->cocoaContext); \
161 LogFlowFunc(("Changing context: %#x -> %#x\n", (pState)->idActiveContext, (pContext)->id)); \
162 (pState)->idActiveContext = (pContext)->id; \
163 } \
164 } while (0)
165# else
166# define VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext) \
167 do { \
168 if ((pState)->idActiveContext != (pContext)->id) \
169 { \
170 Bool fMakeCurrentRc = glXMakeCurrent((pState)->display, \
171 (pContext)->window, \
172 (pContext)->glxContext); \
173 Assert(fMakeCurrentRc == True); RT_NOREF_PV(fMakeCurrentRc); \
174 LogFlowFunc(("Changing context: %#x -> %#x\n", (pState)->idActiveContext, (pContext)->id)); \
175 (pState)->idActiveContext = (pContext)->id; \
176 } \
177 } while (0)
178# endif
179
180/** @def VMSVGA3D_CLEAR_GL_ERRORS
181 * Clears all pending OpenGL errors.
182 *
183 * If I understood this correctly, OpenGL maintains a bitmask internally and
184 * glGetError gets the next bit (clearing it) from the bitmap and translates it
185 * into a GL_XXX constant value which it then returns. A single OpenGL call can
186 * set more than one bit, and they stick around across calls, from what I
187 * understand.
188 *
189 * So in order to be able to use glGetError to check whether a function
190 * succeeded, we need to call glGetError until all error bits have been cleared.
191 * This macro does that (in all types of builds).
192 *
193 * @sa VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS
194 */
195# define VMSVGA3D_CLEAR_GL_ERRORS() \
196 do { \
197 if (RT_UNLIKELY(glGetError() != GL_NO_ERROR)) /* predict no errors pending */ \
198 { \
199 uint32_t iErrorClearingLoopsLeft = 64; \
200 while (glGetError() != GL_NO_ERROR && iErrorClearingLoopsLeft > 0) \
201 iErrorClearingLoopsLeft--; \
202 } \
203 } while (0)
204
205/** @def VMSVGA3D_GET_LAST_GL_ERROR
206 * Gets the last OpenGL error, stores it in a_pContext->lastError and returns
207 * it.
208 *
209 * @returns Same as glGetError.
210 * @param a_pContext The context to store the error in.
211 *
212 * @sa VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN
213 */
214# define VMSVGA3D_GET_GL_ERROR(a_pContext) ((a_pContext)->lastError = glGetError())
215
216/** @def VMSVGA3D_GL_SUCCESS
217 * Checks whether VMSVGA3D_GET_LAST_GL_ERROR() return GL_NO_ERROR.
218 *
219 * Will call glGetError() and store the result in a_pContext->lastError.
220 * Will predict GL_NO_ERROR outcome.
221 *
222 * @returns True on success, false on error.
223 * @parm a_pContext The context to store the error in.
224 *
225 * @sa VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_COMPLAIN
226 */
227# define VMSVGA3D_GL_IS_SUCCESS(a_pContext) RT_LIKELY((((a_pContext)->lastError = glGetError()) == GL_NO_ERROR))
228
229/** @def VMSVGA3D_GL_COMPLAIN
230 * Complains about one or more OpenGL errors (first in a_pContext->lastError).
231 *
232 * Strict builds will trigger an assertion, while other builds will put the
233 * first few occurences in the release log.
234 *
235 * All GL errors will be cleared after invocation. Assumes lastError
236 * is an error, will not check for GL_NO_ERROR.
237 *
238 * @param a_pState The 3D state structure.
239 * @param a_pContext The context that holds the first error.
240 * @param a_LogRelDetails Argument list for LogRel or similar that describes
241 * the operation in greater detail.
242 *
243 * @sa VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS
244 */
245# ifdef VBOX_STRICT
246# define VMSVGA3D_GL_COMPLAIN(a_pState, a_pContext, a_LogRelDetails) \
247 do { \
248 AssertMsg((a_pState)->idActiveContext == (a_pContext)->id, \
249 ("idActiveContext=%#x id=%x\n", (a_pState)->idActiveContext, (a_pContext)->id)); \
250 RTAssertMsg2Weak a_LogRelDetails; \
251 GLenum iNextError; \
252 while ((iNextError = glGetError()) != GL_NO_ERROR) \
253 RTAssertMsg2Weak("next error: %#x\n", iNextError); \
254 AssertMsgFailed(("first error: %#x (idActiveContext=%#x)\n", (a_pContext)->lastError, (a_pContext)->id)); \
255 } while (0)
256# else
257# define VMSVGA3D_GL_COMPLAIN(a_pState, a_pContext, a_LogRelDetails) \
258 do { \
259 LogRelMax(32, ("VMSVGA3d: OpenGL error %#x (idActiveContext=%#x) on line %u ", (a_pContext)->lastError, (a_pContext)->id, __LINE__)); \
260 GLenum iNextError; \
261 while ((iNextError = glGetError()) != GL_NO_ERROR) \
262 LogRelMax(32, (" - also error %#x ", iNextError)); \
263 LogRelMax(32, a_LogRelDetails); \
264 } while (0)
265# endif
266
267/** @def VMSVGA3D_GL_GET_AND_COMPLAIN
268 * Combination of VMSVGA3D_GET_GL_ERROR and VMSVGA3D_GL_COMPLAIN, assuming that
269 * there is a pending error.
270 *
271 * @param a_pState The 3D state structure.
272 * @param a_pContext The context that holds the first error.
273 * @param a_LogRelDetails Argument list for LogRel or similar that describes
274 * the operation in greater detail.
275 *
276 * @sa VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN
277 */
278# define VMSVGA3D_GL_GET_AND_COMPLAIN(a_pState, a_pContext, a_LogRelDetails) \
279 do { \
280 VMSVGA3D_GET_GL_ERROR(a_pContext); \
281 VMSVGA3D_GL_COMPLAIN(a_pState, a_pContext, a_LogRelDetails); \
282 } while (0)
283
284/** @def VMSVGA3D_GL_ASSERT_SUCCESS
285 * Asserts that VMSVGA3D_GL_IS_SUCCESS is true, complains if not.
286 *
287 * Uses VMSVGA3D_GL_COMPLAIN for complaining, so check it out wrt to release
288 * logging in non-strict builds.
289 *
290 * @param a_pState The 3D state structure.
291 * @param a_pContext The context that holds the first error.
292 * @param a_LogRelDetails Argument list for LogRel or similar that describes
293 * the operation in greater detail.
294 *
295 * @sa VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN
296 */
297# define VMSVGA3D_GL_ASSERT_SUCCESS(a_pState, a_pContext, a_LogRelDetails) \
298 if (VMSVGA3D_GL_IS_SUCCESS(a_pContext)) \
299 { /* likely */ } \
300 else do { \
301 VMSVGA3D_GL_COMPLAIN(a_pState, a_pContext, a_LogRelDetails); \
302 } while (0)
303
304/** @def VMSVGA3D_ASSERT_GL_CALL_EX
305 * Executes the specified OpenGL API call and asserts that it succeeded, variant
306 * with extra logging flexibility.
307 *
308 * ASSUMES no GL errors pending prior to invocation - caller should use
309 * VMSVGA3D_CLEAR_GL_ERRORS if uncertain.
310 *
311 * Uses VMSVGA3D_GL_COMPLAIN for complaining, so check it out wrt to release
312 * logging in non-strict builds.
313 *
314 * @param a_GlCall Expression making an OpenGL call.
315 * @param a_pState The 3D state structure.
316 * @param a_pContext The context that holds the first error.
317 * @param a_LogRelDetails Argument list for LogRel or similar that describes
318 * the operation in greater detail.
319 *
320 * @sa VMSVGA3D_ASSERT_GL_CALL, VMSVGA3D_GL_ASSERT_SUCCESS,
321 * VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN
322 */
323# define VMSVGA3D_ASSERT_GL_CALL_EX(a_GlCall, a_pState, a_pContext, a_LogRelDetails) \
324 do { \
325 (a_GlCall); \
326 VMSVGA3D_GL_ASSERT_SUCCESS(a_pState, a_pContext, a_LogRelDetails); \
327 } while (0)
328
329/** @def VMSVGA3D_ASSERT_GL_CALL
330 * Executes the specified OpenGL API call and asserts that it succeeded.
331 *
332 * ASSUMES no GL errors pending prior to invocation - caller should use
333 * VMSVGA3D_CLEAR_GL_ERRORS if uncertain.
334 *
335 * Uses VMSVGA3D_GL_COMPLAIN for complaining, so check it out wrt to release
336 * logging in non-strict builds.
337 *
338 * @param a_GlCall Expression making an OpenGL call.
339 * @param a_pState The 3D state structure.
340 * @param a_pContext The context that holds the first error.
341 *
342 * @sa VMSVGA3D_ASSERT_GL_CALL_EX, VMSVGA3D_GL_ASSERT_SUCCESS,
343 * VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN
344 */
345# define VMSVGA3D_ASSERT_GL_CALL(a_GlCall, a_pState, a_pContext) \
346 VMSVGA3D_ASSERT_GL_CALL_EX(a_GlCall, a_pState, a_pContext, ("%s\n", #a_GlCall))
347
348
349/** @def VMSVGA3D_CHECK_LAST_ERROR
350 * Checks that the last OpenGL error code indicates success.
351 *
352 * Will assert and return VERR_INTERNAL_ERROR in strict builds, in other
353 * builds it will do nothing and is a NOOP.
354 *
355 * @parm pState The VMSVGA3d state.
356 * @parm pContext The context.
357 *
358 * @todo Replace with proper error handling, it's crazy to return
359 * VERR_INTERNAL_ERROR in strict builds and just barge on ahead in
360 * release builds.
361 */
362/** @todo Rename to VMSVGA3D_CHECK_LAST_ERROR_RETURN */
363# ifdef VBOX_STRICT
364# define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) do { \
365 Assert((pState)->idActiveContext == (pContext)->id); \
366 (pContext)->lastError = glGetError(); \
367 AssertMsgReturn((pContext)->lastError == GL_NO_ERROR, \
368 ("%s (%d): last error 0x%x\n", __FUNCTION__, __LINE__, (pContext)->lastError), \
369 VERR_INTERNAL_ERROR); \
370 } while (0)
371# else
372# define VMSVGA3D_CHECK_LAST_ERROR(pState, pContext) do { } while (0)
373# endif
374
375/** @def VMSVGA3D_CHECK_LAST_ERROR_WARN
376 * Checks that the last OpenGL error code indicates success.
377 *
378 * Will assert in strict builds, otherwise it's a NOOP.
379 *
380 * @parm pState The VMSVGA3d state.
381 * @parm pContext The new context.
382 */
383# ifdef VBOX_STRICT
384# define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) do { \
385 Assert((pState)->idActiveContext == (pContext)->id); \
386 (pContext)->lastError = glGetError(); \
387 AssertMsg((pContext)->lastError == GL_NO_ERROR, ("%s (%d): last error 0x%x\n", __FUNCTION__, __LINE__, (pContext)->lastError)); \
388 } while (0)
389# else
390# define VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext) do { } while (0)
391# endif
392
393#endif /* VMSVGA3D_OPENGL */
394
395
396/*********************************************************************************************************************************
397* Structures and Typedefs *
398*********************************************************************************************************************************/
399/**
400 * Mipmap level.
401 */
402typedef struct VMSVGA3DMIPMAPLEVEL
403{
404 /** The mipmap size: width, height and depth. */
405 SVGA3dSize mipmapSize;
406 /** Width in blocks: (width + cxBlock - 1) / cxBlock. SSM: not saved, recalculated on load. */
407 uint32_t cBlocksX;
408 /** Height in blocks: (height + cyBlock - 1) / cyBlock. SSM: not saved, recalculated on load. */
409 uint32_t cBlocksY;
410 /** Number of blocks: cBlocksX * cBlocksY * mipmapSize.depth. SSM: not saved, recalculated on load. */
411 uint32_t cBlocks;
412 /** The scanline/pitch size in bytes: at least cBlocksX * cbBlock. */
413 uint32_t cbSurfacePitch;
414 /** The size (in bytes) of the mipmap plane: cbSurfacePitch * cBlocksY */
415 uint32_t cbSurfacePlane;
416 /** The size (in bytes) of the mipmap data when using the format the surface was
417 * defined with: cbSurfacePlane * mipmapSize.z */
418 uint32_t cbSurface;
419 /** Pointer to the mipmap bytes (cbSurface). Often NULL. If the surface has
420 * been realized in hardware, this may be outdated. */
421 void *pSurfaceData;
422 /** Set if pvSurfaceData contains data not realized in hardware or pushed to the
423 * hardware surface yet. */
424 bool fDirty;
425} VMSVGA3DMIPMAPLEVEL;
426/** Pointer to a mipmap level. */
427typedef VMSVGA3DMIPMAPLEVEL *PVMSVGA3DMIPMAPLEVEL;
428
429
430#ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
431/**
432 * SSM descriptor table for the VMSVGA3DMIPMAPLEVEL structure.
433 */
434static SSMFIELD const g_aVMSVGA3DMIPMAPLEVELFields[] =
435{
436 SSMFIELD_ENTRY( VMSVGA3DMIPMAPLEVEL, mipmapSize),
437 SSMFIELD_ENTRY( VMSVGA3DMIPMAPLEVEL, cbSurface),
438 SSMFIELD_ENTRY( VMSVGA3DMIPMAPLEVEL, cbSurfacePitch),
439 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DMIPMAPLEVEL, pSurfaceData),
440 SSMFIELD_ENTRY_IGNORE( VMSVGA3DMIPMAPLEVEL, fDirty),
441 SSMFIELD_ENTRY_TERM()
442};
443#endif
444
445typedef struct VMSVGATRANSFORMSTATE
446{
447 bool fValid;
448 float matrix[16];
449} VMSVGATRANSFORMSTATE;
450typedef VMSVGATRANSFORMSTATE *PVMSVGATRANSFORMSTATE;
451
452typedef struct VMSVGAMATERIALSTATE
453{
454 bool fValid;
455 SVGA3dMaterial material;
456} VMSVGAMATERIALSTATE;
457typedef VMSVGAMATERIALSTATE *PVMSVGAMATERIALSTATE;
458
459typedef struct VMSVGACLIPPLANESTATE
460{
461 bool fValid;
462 float plane[4];
463} VMSVGACLIPPLANESTATE;
464typedef VMSVGACLIPPLANESTATE *PVMSVGACLIPPLANESTATE;
465
466typedef struct VMSVGALIGHTSTATE
467{
468 bool fEnabled;
469 bool fValidData;
470 SVGA3dLightData data;
471} VMSVGALIGHTSTATE;
472typedef VMSVGALIGHTSTATE *PVMSVGALIGHTSTATE;
473
474typedef struct VMSVGASHADERCONST
475{
476 bool fValid;
477 SVGA3dShaderConstType ctype;
478 uint32_t value[4];
479} VMSVGASHADERCONST;
480typedef VMSVGASHADERCONST *PVMSVGASHADERCONST;
481
482#ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
483/**
484 * SSM descriptor table for the VMSVGASHADERCONST structure.
485 */
486static SSMFIELD const g_aVMSVGASHADERCONSTFields[] =
487{
488 SSMFIELD_ENTRY( VMSVGASHADERCONST, fValid),
489 SSMFIELD_ENTRY( VMSVGASHADERCONST, ctype),
490 SSMFIELD_ENTRY( VMSVGASHADERCONST, value),
491 SSMFIELD_ENTRY_TERM()
492};
493#endif
494
495#ifdef VMSVGA3D_DIRECT3D
496
497/* What kind of Direct3D resource has been created for the VMSVGA3D surface. */
498typedef enum VMSVGA3DD3DRESTYPE
499{
500 VMSVGA3D_D3DRESTYPE_NONE = 0,
501 VMSVGA3D_D3DRESTYPE_SURFACE = 1,
502 VMSVGA3D_D3DRESTYPE_TEXTURE = 2,
503 VMSVGA3D_D3DRESTYPE_CUBE_TEXTURE = 3,
504 VMSVGA3D_D3DRESTYPE_VOLUME_TEXTURE = 4,
505 VMSVGA3D_D3DRESTYPE_VERTEX_BUFFER = 5,
506 VMSVGA3D_D3DRESTYPE_INDEX_BUFFER = 6
507} VMSVGA3DD3DRESTYPE;
508
509/**
510 *
511 */
512typedef struct
513{
514 /** Key is context id. */
515 AVLU32NODECORE Core;
516 union
517 {
518 IDirect3DTexture9 *pTexture;
519 IDirect3DCubeTexture9 *pCubeTexture;
520 IDirect3DVolumeTexture9 *pVolumeTexture;
521 } u;
522} VMSVGA3DSHAREDSURFACE;
523typedef VMSVGA3DSHAREDSURFACE *PVMSVGA3DSHAREDSURFACE;
524#endif /* VMSVGA3D_DIRECT3D */
525
526#ifdef VMSVGA3D_OPENGL
527/* What kind of OpenGL resource has been created for the VMSVGA3D surface. */
528typedef enum VMSVGA3DOGLRESTYPE
529{
530 VMSVGA3D_OGLRESTYPE_NONE = 0,
531 VMSVGA3D_OGLRESTYPE_BUFFER = 1,
532 VMSVGA3D_OGLRESTYPE_TEXTURE = 2,
533 VMSVGA3D_OGLRESTYPE_RENDERBUFFER = 3
534} VMSVGA3DOGLRESTYPE;
535#endif
536
537/* The 3D backend surface. The actual structure is 3D API specific. */
538typedef struct VMSVGA3DBACKENDSURFACE *PVMSVGA3DBACKENDSURFACE;
539
540/**
541 * VMSVGA3d surface.
542 */
543typedef struct VMSVGA3DSURFACE
544{
545 PVMSVGA3DBACKENDSURFACE pBackendSurface;
546
547 uint32_t id; /** @todo sid */
548 /* Which context created the corresponding resource.
549 * SVGA_ID_INVALID means that resource has not been created yet.
550 * A resource has been created if VMSVGA3DSURFACE_HAS_HW_SURFACE is true.
551 *
552 */
553 uint32_t idAssociatedContext;
554
555 SVGA3dSurface1Flags surfaceFlags; /** @todo SVGA3dSurfaceAllFlags as an union. */
556 SVGA3dSurfaceFormat format;
557#ifdef VMSVGA3D_OPENGL
558 GLint internalFormatGL;
559 GLint formatGL;
560 GLint typeGL;
561 VMSVGA3DOGLRESTYPE enmOGLResType; /* Which resource was created for the surface. */
562 union
563 {
564 GLuint texture;
565 GLuint buffer;
566 GLuint renderbuffer;
567 } oglId;
568 GLenum targetGL; /* GL_TEXTURE_* */
569 GLenum bindingGL; /* GL_TEXTURE_BINDING_* */
570 /* Emulated formats */
571 bool fEmulated; /* Whether the texture format is emulated. */
572 GLuint idEmulated; /* GL name of the intermediate texture. */
573#endif
574 uint32_t cFaces; /* Number of faces: 6 for cubemaps, 1 for everything else. */
575 uint32_t cLevels; /* Number of mipmap levels per face. */
576 PVMSVGA3DMIPMAPLEVEL paMipmapLevels; /* cFaces * cLevels elements. */
577 uint32_t multiSampleCount;
578 SVGA3dTextureFilter autogenFilter;
579#ifdef VMSVGA3D_DIRECT3D
580 D3DFORMAT formatD3D;
581 DWORD fUsageD3D;
582 D3DMULTISAMPLE_TYPE multiSampleTypeD3D;
583#endif
584
585 uint32_t cbBlock; /* block/pixel size in bytes */
586 /* Dimensions of the surface block, usually 1x1 except for compressed formats. */
587 uint32_t cxBlock; /* Block width in pixels. SSM: not saved, recalculated on load. */
588 uint32_t cyBlock; /* Block height in pixels. SSM: not saved, recalculated on load. */
589#ifdef VMSVGA3D_OPENGL
590 uint32_t cbBlockGL; /* Block size of the OpenGL texture, same as cbBlock for not-emulated formats. */
591#endif
592
593 /* Dirty state; surface was manually updated. */
594 bool fDirty;
595
596#ifdef VMSVGA3D_DIRECT3D
597 /* Handle for shared objects (currently only textures & render targets). */
598 HANDLE hSharedObject;
599 /** Event query inserted after each GPU operation that updates or uses this surface. */
600 IDirect3DQuery9 *pQuery;
601 /** The context id where the query has been created. */
602 uint32_t idQueryContext;
603 /** The type of actually created D3D resource. */
604 VMSVGA3DD3DRESTYPE enmD3DResType;
605 union
606 {
607 IDirect3DSurface9 *pSurface;
608 IDirect3DTexture9 *pTexture;
609 IDirect3DCubeTexture9 *pCubeTexture;
610 IDirect3DVolumeTexture9 *pVolumeTexture;
611 IDirect3DVertexBuffer9 *pVertexBuffer;
612 IDirect3DIndexBuffer9 *pIndexBuffer;
613 } u;
614 union
615 {
616 IDirect3DTexture9 *pTexture;
617 IDirect3DCubeTexture9 *pCubeTexture;
618 IDirect3DVolumeTexture9 *pVolumeTexture;
619 } bounce;
620 /** AVL tree containing VMSVGA3DSHAREDSURFACE structures. */
621 AVLU32TREE pSharedObjectTree;
622 bool fStencilAsTexture;
623 D3DFORMAT d3dfmtRequested;
624 union
625 {
626 IDirect3DTexture9 *pTexture;
627 IDirect3DCubeTexture9 *pCubeTexture;
628 IDirect3DVolumeTexture9 *pVolumeTexture;
629 } emulated;
630#endif
631} VMSVGA3DSURFACE;
632/** Pointer to a 3d surface. */
633typedef VMSVGA3DSURFACE *PVMSVGA3DSURFACE;
634
635#ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
636/**
637 * SSM descriptor table for the VMSVGA3DSURFACE structure.
638 */
639static SSMFIELD const g_aVMSVGA3DSURFACEFields[] =
640{
641 SSMFIELD_ENTRY( VMSVGA3DSURFACE, id),
642 SSMFIELD_ENTRY( VMSVGA3DSURFACE, idAssociatedContext),
643 SSMFIELD_ENTRY( VMSVGA3DSURFACE, surfaceFlags),
644 SSMFIELD_ENTRY( VMSVGA3DSURFACE, format),
645# ifdef VMSVGA3D_OPENGL
646 SSMFIELD_ENTRY( VMSVGA3DSURFACE, internalFormatGL),
647 SSMFIELD_ENTRY( VMSVGA3DSURFACE, formatGL),
648 SSMFIELD_ENTRY( VMSVGA3DSURFACE, typeGL),
649# endif
650 SSMFIELD_ENTRY( VMSVGA3DSURFACE, cFaces),
651 SSMFIELD_ENTRY( VMSVGA3DSURFACE, cLevels),
652 SSMFIELD_ENTRY( VMSVGA3DSURFACE, multiSampleCount),
653 SSMFIELD_ENTRY( VMSVGA3DSURFACE, autogenFilter),
654 SSMFIELD_ENTRY( VMSVGA3DSURFACE, cbBlock),
655 SSMFIELD_ENTRY_TERM()
656};
657#endif
658
659/** Mask we frequently apply to VMSVGA3DSURFACE::flags for decing what kind
660 * of surface we're dealing. */
661#define VMSVGA3D_SURFACE_HINT_SWITCH_MASK \
662 ( SVGA3D_SURFACE_HINT_INDEXBUFFER | SVGA3D_SURFACE_HINT_VERTEXBUFFER \
663 | SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_HINT_RENDERTARGET \
664 | SVGA3D_SURFACE_HINT_DEPTHSTENCIL | SVGA3D_SURFACE_CUBEMAP )
665
666/** @def VMSVGA3DSURFACE_HAS_HW_SURFACE
667 * Checks whether the surface has a host hardware/library surface.
668 * @returns true/false
669 * @param a_pSurface The VMSVGA3d surface.
670 */
671#ifdef VMSVGA3D_DIRECT3D
672# define VMSVGA3DSURFACE_HAS_HW_SURFACE(a_pSurface) ((a_pSurface)->pBackendSurface != NULL || (a_pSurface)->u.pSurface != NULL)
673#else
674# define VMSVGA3DSURFACE_HAS_HW_SURFACE(a_pSurface) ((a_pSurface)->pBackendSurface != NULL || (a_pSurface)->oglId.texture != OPENGL_INVALID_ID)
675#endif
676
677/** @def VMSVGA3DSURFACE_NEEDS_DATA
678 * Checks whether SurfaceDMA transfers must always update pSurfaceData,
679 * even if the surface has a host hardware resource.
680 * @returns true/false
681 * @param a_pSurface The VMSVGA3d surface.
682 */
683#ifdef VMSVGA3D_DIRECT3D
684# define VMSVGA3DSURFACE_NEEDS_DATA(a_pSurface) \
685 ( (a_pSurface)->enmD3DResType == VMSVGA3D_D3DRESTYPE_VERTEX_BUFFER \
686 || (a_pSurface)->enmD3DResType == VMSVGA3D_D3DRESTYPE_INDEX_BUFFER)
687#else
688# define VMSVGA3DSURFACE_NEEDS_DATA(a_pSurface) \
689 ((a_pSurface)->enmOGLResType == VMSVGA3D_OGLRESTYPE_BUFFER)
690#endif
691
692
693typedef struct VMSVGA3DSHADER
694{
695 uint32_t id; /** @todo Rename to shid. */
696 uint32_t cid;
697 SVGA3dShaderType type;
698 uint32_t cbData;
699 void *pShaderProgram;
700 union
701 {
702#ifdef VMSVGA3D_DIRECT3D
703 IDirect3DVertexShader9 *pVertexShader;
704 IDirect3DPixelShader9 *pPixelShader;
705#else
706 void *pVertexShader;
707 void *pPixelShader;
708#endif
709 void *pvBackendShader;
710 } u;
711#ifdef VMSVGA3D_DX
712 DXShaderInfo shaderInfo;
713#endif
714} VMSVGA3DSHADER;
715typedef VMSVGA3DSHADER *PVMSVGA3DSHADER;
716
717#ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
718/**
719 * SSM descriptor table for the VMSVGA3DSHADER structure.
720 */
721static SSMFIELD const g_aVMSVGA3DSHADERFields[] =
722{
723 SSMFIELD_ENTRY( VMSVGA3DSHADER, id),
724 SSMFIELD_ENTRY( VMSVGA3DSHADER, cid),
725 SSMFIELD_ENTRY( VMSVGA3DSHADER, type),
726 SSMFIELD_ENTRY( VMSVGA3DSHADER, cbData),
727 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSHADER, pShaderProgram),
728 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSHADER, u.pvBackendShader),
729 SSMFIELD_ENTRY_TERM()
730};
731#endif
732
733/** @name VMSVGA3D_UPDATE_XXX - ...
734 * @{ */
735#define VMSVGA3D_UPDATE_SCISSORRECT RT_BIT_32(0)
736#define VMSVGA3D_UPDATE_ZRANGE RT_BIT_32(1)
737#define VMSVGA3D_UPDATE_VIEWPORT RT_BIT_32(2)
738#define VMSVGA3D_UPDATE_VERTEXSHADER RT_BIT_32(3)
739#define VMSVGA3D_UPDATE_PIXELSHADER RT_BIT_32(4)
740#define VMSVGA3D_UPDATE_TRANSFORM RT_BIT_32(5)
741#define VMSVGA3D_UPDATE_MATERIAL RT_BIT_32(6)
742/** @} */
743
744/* Query states. Mostly used for saved state. */
745typedef enum VMSVGA3DQUERYSTATE
746{
747 VMSVGA3DQUERYSTATE_NULL = 0, /* Not created. */
748 VMSVGA3DQUERYSTATE_SIGNALED = 1, /* Result obtained. The guest may or may not read the result yet. */
749 VMSVGA3DQUERYSTATE_BUILDING = 2, /* In process of collecting data. */
750 VMSVGA3DQUERYSTATE_ISSUED = 3, /* Data collected, but result is not yet obtained. */
751 VMSVGA3DQUERYSTATE_32BIT = 0x7fffffff
752} VMSVGA3DQUERYSTATE;
753AssertCompileSize(VMSVGA3DQUERYSTATE, sizeof(uint32_t));
754
755typedef struct VMSVGA3DQUERY
756{
757#ifdef VMSVGA3D_DIRECT3D
758 IDirect3DQuery9 *pQuery;
759#else /* VMSVGA3D_OPENGL */
760 GLuint idQuery;
761#endif
762 VMSVGA3DQUERYSTATE enmQueryState; /* VMSVGA3DQUERYSTATE_*. State is implicitly _NULL if pQuery is NULL. */
763 uint32_t u32QueryResult; /* Generic result. Enough for all VGPU9 queries. */
764} VMSVGA3DQUERY;
765
766#ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
767/**
768 * SSM descriptor table for the VMSVGA3DQUERY structure.
769 */
770static SSMFIELD const g_aVMSVGA3DQUERYFields[] =
771{
772#ifdef VMSVGA3D_DIRECT3D
773 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DQUERY, pQuery),
774#else /* VMSVGA3D_OPENGL */
775 SSMFIELD_ENTRY_IGNORE( VMSVGA3DQUERY, idQuery),
776#endif
777 SSMFIELD_ENTRY( VMSVGA3DQUERY, enmQueryState),
778 SSMFIELD_ENTRY( VMSVGA3DQUERY, u32QueryResult),
779 SSMFIELD_ENTRY_TERM()
780};
781#endif
782
783#ifdef VMSVGA3D_DIRECT3D
784#define VMSVGA3DQUERY_EXISTS(p) ((p)->pQuery && (p)->enmQueryState != VMSVGA3DQUERYSTATE_NULL)
785#else
786#define VMSVGA3DQUERY_EXISTS(p) ((p)->idQuery && (p)->enmQueryState != VMSVGA3DQUERYSTATE_NULL)
787#endif
788
789/**
790 * VMSVGA3d context.
791 */
792typedef struct VMSVGA3DCONTEXT
793{
794 /** @todo Legacy contexts with DX backend. */
795
796 uint32_t id;
797#ifdef RT_OS_WINDOWS
798# ifdef VMSVGA3D_DIRECT3D
799 IDirect3DDevice9Ex *pDevice;
800# else
801 /* Device context of the context window. */
802 HDC hdc;
803 /* OpenGL rendering context handle. */
804 HGLRC hglrc;
805# endif
806 /* Device context window handle. */
807 HWND hwnd;
808#elif defined(RT_OS_DARWIN)
809 /* OpenGL rendering context */
810 NativeNSOpenGLContextRef cocoaContext;
811 NativeNSViewRef cocoaView;
812 bool fOtherProfile;
813#else
814 /** XGL rendering context handle */
815 GLXContext glxContext;
816 /** Device context window handle */
817 Window window;
818#endif
819
820#ifdef VMSVGA3D_OPENGL
821 /* Framebuffer object associated with this context. */
822 GLuint idFramebuffer;
823 /* Read and draw framebuffer objects for various operations. */
824 GLuint idReadFramebuffer;
825 GLuint idDrawFramebuffer;
826 /* Last GL error recorded. */
827 GLenum lastError;
828 void *pShaderContext;
829#endif
830
831 /* Current selected texture surfaces (if any) */
832 uint32_t aSidActiveTextures[SVGA3D_MAX_SAMPLERS];
833 /* Per context pixel and vertex shaders. */
834 uint32_t cPixelShaders;
835 PVMSVGA3DSHADER paPixelShader;
836 uint32_t cVertexShaders;
837 PVMSVGA3DSHADER paVertexShader;
838 /* Keep track of the internal state to be able to recreate the context properly (save/restore, window resize). */
839 struct
840 {
841 /** VMSVGA3D_UPDATE_XXX */
842 uint32_t u32UpdateFlags;
843
844 SVGA3dRenderState aRenderState[SVGA3D_RS_MAX];
845 /* aTextureStates contains both TextureStageStates and SamplerStates, therefore [SVGA3D_MAX_SAMPLERS]. */
846 SVGA3dTextureState aTextureStates[SVGA3D_MAX_SAMPLERS][SVGA3D_TS_MAX];
847 VMSVGATRANSFORMSTATE aTransformState[SVGA3D_TRANSFORM_MAX];
848 VMSVGAMATERIALSTATE aMaterial[SVGA3D_FACE_MAX];
849 /* The aClipPlane array has a wrong (greater) size. Keep it for now because the array is a part of the saved state. */
850 /** @todo Replace SVGA3D_CLIPPLANE_5 with SVGA3D_NUM_CLIPPLANES and increase the saved state version. */
851 VMSVGACLIPPLANESTATE aClipPlane[SVGA3D_CLIPPLANE_5];
852 VMSVGALIGHTSTATE aLightData[SVGA3D_MAX_LIGHTS];
853
854 uint32_t aRenderTargets[SVGA3D_RT_MAX];
855 SVGA3dRect RectScissor;
856 SVGA3dRect RectViewPort;
857 SVGA3dZRange zRange;
858 uint32_t shidPixel;
859 uint32_t shidVertex;
860
861 uint32_t cPixelShaderConst;
862 PVMSVGASHADERCONST paPixelShaderConst;
863 uint32_t cVertexShaderConst;
864 PVMSVGASHADERCONST paVertexShaderConst;
865 } state;
866
867 /* Occlusion query. */
868 VMSVGA3DQUERY occlusion;
869
870#ifdef VMSVGA3D_DIRECT3D
871 /* State which is currently applied to the D3D device. It is recreated as needed and not saved.
872 * The purpose is to remember the currently applied state and do not re-apply it if it has not changed.
873 * Unnecessary state changes are very bad for performance.
874 */
875 struct
876 {
877 /* Vertex declaration. */
878 IDirect3DVertexDeclaration9 *pVertexDecl;
879 uint32_t cVertexElements;
880 D3DVERTEXELEMENT9 aVertexElements[SVGA3D_MAX_VERTEX_ARRAYS + 1];
881 } d3dState;
882#endif
883} VMSVGA3DCONTEXT;
884/** Pointer to a VMSVGA3d context. */
885typedef VMSVGA3DCONTEXT *PVMSVGA3DCONTEXT;
886
887#ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
888/**
889 * SSM descriptor table for the VMSVGA3DCONTEXT structure.
890 */
891static SSMFIELD const g_aVMSVGA3DCONTEXTFields[] =
892{
893 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, id),
894
895# ifdef RT_OS_WINDOWS
896# ifdef VMSVGA3D_DIRECT3D
897 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DCONTEXT, pDevice),
898# else
899 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, hdc),
900 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, hglrc),
901# endif
902 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, hwnd),
903# elif defined(RT_OS_DARWIN)
904 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, cocoaContext),
905 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, cocoaView),
906 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, fOtherProfile),
907# else
908 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, glxContext),
909 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, window),
910# endif
911
912#ifdef VMSVGA3D_OPENGL
913 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, idFramebuffer),
914 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, idReadFramebuffer),
915 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, idDrawFramebuffer),
916 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, lastError),
917 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DCONTEXT, pShaderContext),
918#endif
919
920 SSMFIELD_ENTRY_IGNORE( VMSVGA3DCONTEXT, aSidActiveTextures),
921 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, cPixelShaders),
922 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DCONTEXT, paPixelShader),
923 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, cVertexShaders),
924 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DCONTEXT, paVertexShader),
925 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.u32UpdateFlags),
926
927 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.aRenderState),
928 SSMFIELD_ENTRY_OLD( state.aTextureStates,
929 sizeof(SVGA3dTextureState) * /*SVGA3D_MAX_TEXTURE_STAGE=*/ 8 * /*SVGA3D_TS_MAX=*/ 30),
930 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.aTransformState),
931 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.aMaterial),
932 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.aClipPlane),
933 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.aLightData),
934
935 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.aRenderTargets),
936 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.RectScissor),
937 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.RectViewPort),
938 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.zRange),
939 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.shidPixel),
940 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.shidVertex),
941 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.cPixelShaderConst),
942 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DCONTEXT, state.paPixelShaderConst),
943 SSMFIELD_ENTRY( VMSVGA3DCONTEXT, state.cVertexShaderConst),
944 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DCONTEXT, state.paVertexShaderConst),
945 SSMFIELD_ENTRY_TERM()
946};
947#endif /* VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS */
948
949
950#ifdef VMSVGA3D_DX
951/* The 3D backend DX context. The actual structure is 3D API specific. */
952typedef struct VMSVGA3DBACKENDDXCONTEXT *PVMSVGA3DBACKENDDXCONTEXT;
953
954/**
955 * VMSVGA3D DX context (VGPU10+). DX contexts ids are a separate namespace from legacy context ids.
956 */
957typedef struct VMSVGA3DDXCONTEXT
958{
959 /** The DX context id. */
960 uint32_t cid;
961 /** . */
962 uint32_t u32Reserved;
963 /** Backend specific data. */
964 PVMSVGA3DBACKENDDXCONTEXT pBackendDXContext;
965 /** Copy of the guest memory for this context. The guest will be updated on unbind. */
966 SVGADXContextMobFormat svgaDXContext;
967 /* Context-Object Tables bound to this context. */
968 PVMSVGAMOB aCOTMobs[SVGA_COTABLE_MAX];
969 struct
970 {
971 SVGACOTableDXRTViewEntry *paRTView;
972 SVGACOTableDXDSViewEntry *paDSView;
973 SVGACOTableDXSRViewEntry *paSRView;
974 SVGACOTableDXElementLayoutEntry *paElementLayout;
975 SVGACOTableDXBlendStateEntry *paBlendState;
976 SVGACOTableDXDepthStencilEntry *paDepthStencil;
977 SVGACOTableDXRasterizerStateEntry *paRasterizerState;
978 SVGACOTableDXSamplerEntry *paSampler;
979 SVGACOTableDXStreamOutputEntry *paStreamOutput;
980 SVGACOTableDXQueryEntry *paQuery;
981 SVGACOTableDXShaderEntry *paShader;
982 SVGACOTableDXUAViewEntry *paUAView;
983 uint32_t cRTView;
984 uint32_t cDSView;
985 uint32_t cSRView;
986 uint32_t cElementLayout;
987 uint32_t cBlendState;
988 uint32_t cDepthStencil;
989 uint32_t cRasterizerState;
990 uint32_t cSampler;
991 uint32_t cStreamOutput;
992 uint32_t cQuery;
993 uint32_t cShader;
994 uint32_t cUAView;
995 } cot;
996 /* Shader information. The array has cot.cShader elements. Some data is dublicated in cot.paShader. */
997 PVMSVGA3DSHADER paShader;
998} VMSVGA3DDXCONTEXT;
999/** Pointer to a VMSVGA3D DX context. */
1000typedef VMSVGA3DDXCONTEXT *PVMSVGA3DDXCONTEXT;
1001#endif /* VMSVGA3D_DX */
1002
1003
1004#ifdef VMSVGA3D_OPENGL
1005typedef struct VMSVGA3DFORMATCONVERTER *PVMSVGA3DFORMATCONVERTER;
1006#endif
1007
1008/* The 3D backend. The actual structure is 3D API specific. */
1009typedef struct VMSVGA3DBACKEND *PVMSVGA3DBACKEND;
1010
1011/**
1012 * VMSVGA3d state data.
1013 *
1014 * Allocated on the heap and pointed to by VMSVGAState::p3dState.
1015 */
1016typedef struct VMSVGA3DSTATE
1017{
1018 /** Backend specific data. */
1019 PVMSVGA3DBACKEND pBackend;
1020
1021 /** The size of papContexts. */
1022 uint32_t cContexts;
1023 /** The size of papSurfaces. */
1024 uint32_t cSurfaces;
1025#ifdef VMSVGA3D_DX
1026 /** The size of papDXContexts. */
1027 uint32_t cDXContexts;
1028 /** Reserved. */
1029 uint32_t u32Reserved;
1030#endif
1031 /** Contexts indexed by ID. Grown as needed. */
1032 PVMSVGA3DCONTEXT *papContexts;
1033 /** Surfaces indexed by ID. Grown as needed. */
1034 PVMSVGA3DSURFACE *papSurfaces;
1035#ifdef VMSVGA3D_DX
1036 /** DX contexts indexed by ID. Grown as needed. */
1037 PVMSVGA3DDXCONTEXT *papDXContexts;
1038#endif
1039
1040#ifdef RT_OS_WINDOWS
1041# ifdef VMSVGA3D_DIRECT3D
1042 IDirect3D9Ex *pD3D9;
1043 D3DCAPS9 caps;
1044 bool fSupportedSurfaceINTZ;
1045 bool fSupportedSurfaceNULL;
1046 bool fSupportedFormatUYVY : 1;
1047 bool fSupportedFormatYUY2 : 1;
1048 bool fSupportedFormatA8B8G8R8 : 1;
1049# endif
1050 /** Window Thread. */
1051 R3PTRTYPE(RTTHREAD) pWindowThread;
1052 DWORD idWindowThread;
1053 HMODULE hInstance;
1054 /** Window request semaphore. */
1055 RTSEMEVENT WndRequestSem;
1056#elif defined(RT_OS_DARWIN)
1057#else
1058 /* The X display */
1059 Display *display;
1060 R3PTRTYPE(RTTHREAD) pWindowThread;
1061 bool bTerminate;
1062#endif
1063
1064#ifdef VMSVGA3D_OPENGL
1065 float rsGLVersion;
1066 /* Current active context. */
1067 uint32_t idActiveContext;
1068
1069 struct
1070 {
1071 PFNGLISRENDERBUFFERPROC glIsRenderbuffer;
1072 PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
1073 PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
1074 PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
1075 PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
1076 PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv;
1077 PFNGLISFRAMEBUFFERPROC glIsFramebuffer;
1078 PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
1079 PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
1080 PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
1081 PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
1082 PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
1083 PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
1084 PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
1085 PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
1086 PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv;
1087 PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
1088 PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
1089 PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample;
1090 PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer;
1091 PFNGLPOINTPARAMETERFPROC glPointParameterf;
1092#if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x102
1093 PFNGLBLENDCOLORPROC glBlendColor;
1094 PFNGLBLENDEQUATIONPROC glBlendEquation;
1095#endif
1096 PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate;
1097 PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate;
1098 PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate;
1099 PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate;
1100 PFNGLBINDBUFFERPROC glBindBuffer;
1101 PFNGLDELETEBUFFERSPROC glDeleteBuffers;
1102 PFNGLGENBUFFERSPROC glGenBuffers;
1103 PFNGLBUFFERDATAPROC glBufferData;
1104 PFNGLMAPBUFFERPROC glMapBuffer;
1105 PFNGLUNMAPBUFFERPROC glUnmapBuffer;
1106 PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
1107 PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
1108 PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
1109 PFNGLFOGCOORDPOINTERPROC glFogCoordPointer;
1110 PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedBaseVertex;
1111 PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex;
1112 PFNGLACTIVETEXTUREPROC glActiveTexture;
1113#if VBOX_VMSVGA3D_GL_HACK_LEVEL < 0x103
1114 PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture;
1115#endif
1116 PFNGLGETPROGRAMIVARBPROC glGetProgramivARB;
1117 PFNGLPROVOKINGVERTEXPROC glProvokingVertex;
1118 PFNGLGENQUERIESPROC glGenQueries;
1119 PFNGLDELETEQUERIESPROC glDeleteQueries;
1120 PFNGLBEGINQUERYPROC glBeginQuery;
1121 PFNGLENDQUERYPROC glEndQuery;
1122 PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
1123 PFNGLTEXIMAGE3DPROC glTexImage3D;
1124 PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
1125 PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
1126 PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
1127 PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced;
1128 PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage;
1129 PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
1130 PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D;
1131 PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D;
1132 PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D;
1133 PFNGLDRAWBUFFERSPROC glDrawBuffers;
1134 PFNGLCREATESHADERPROC glCreateShader;
1135 PFNGLSHADERSOURCEPROC glShaderSource;
1136 PFNGLCOMPILESHADERPROC glCompileShader;
1137 PFNGLGETSHADERIVPROC glGetShaderiv;
1138 PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
1139 PFNGLCREATEPROGRAMPROC glCreateProgram;
1140 PFNGLATTACHSHADERPROC glAttachShader;
1141 PFNGLLINKPROGRAMPROC glLinkProgram;
1142 PFNGLGETPROGRAMIVPROC glGetProgramiv;
1143 PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
1144 PFNGLUSEPROGRAMPROC glUseProgram;
1145 PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
1146 PFNGLUNIFORM1IPROC glUniform1i;
1147 PFNGLUNIFORM4FVPROC glUniform4fv;
1148 PFNGLDETACHSHADERPROC glDetachShader;
1149 PFNGLDELETESHADERPROC glDeleteShader;
1150 PFNGLDELETEPROGRAMPROC glDeleteProgram;
1151 PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv;
1152 PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv;
1153 PFNGLVERTEXATTRIB4NUBVPROC glVertexAttrib4Nubv;
1154 PFNGLVERTEXATTRIB4SVPROC glVertexAttrib4sv;
1155 PFNGLVERTEXATTRIB4NSVPROC glVertexAttrib4Nsv;
1156 PFNGLVERTEXATTRIB4NUSVPROC glVertexAttrib4Nusv;
1157 } ext;
1158
1159 struct
1160 {
1161 bool fS3TCSupported : 1;
1162 bool fTextureFilterAnisotropicSupported : 1;
1163 GLint maxActiveLights;
1164 GLint maxTextures;
1165 GLint maxClipDistances;
1166 GLint maxColorAttachments;
1167 GLint maxRectangleTextureSize;
1168 GLint maxTextureAnisotropy;
1169 GLint maxVertexShaderInstructions;
1170 GLint maxFragmentShaderInstructions;
1171 GLint maxVertexShaderTemps;
1172 GLint maxFragmentShaderTemps;
1173 GLfloat flPointSize[2];
1174 SVGA3dPixelShaderVersion fragmentShaderVersion;
1175 SVGA3dVertexShaderVersion vertexShaderVersion;
1176 } caps;
1177
1178 /** The GL_EXTENSIONS value (space padded) for the default OpenGL profile.
1179 * Free with RTStrFree. */
1180 R3PTRTYPE(char *) pszExtensions;
1181
1182 /** The GL_EXTENSIONS value (space padded) for the other OpenGL profile.
1183 * Free with RTStrFree.
1184 *
1185 * This is used to detect shader model version since some implementations
1186 * (darwin) hides extensions that have made it into core and probably a
1187 * bunch of others when using a OpenGL core profile instead of a legacy one */
1188 R3PTRTYPE(char *) pszOtherExtensions;
1189 /** The version of the other GL profile. */
1190 float rsOtherGLVersion;
1191
1192 /** Shader talk back interface. */
1193 VBOXVMSVGASHADERIF ShaderIf;
1194
1195# ifdef VMSVGA3D_OPENGL
1196 /** The shared context. */
1197 VMSVGA3DCONTEXT SharedCtx;
1198
1199 /** Conversion of emulated formats. Resources are created on the SharedCtx. */
1200 PVMSVGA3DFORMATCONVERTER pConv;
1201# endif
1202#endif /* VMSVGA3D_OPENGL */
1203} VMSVGA3DSTATE;
1204
1205#ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
1206/**
1207 * SSM descriptor table for the VMSVGA3DSTATE structure.
1208 *
1209 * @remarks This isn't a complete structure markup, only fields with state.
1210 */
1211static SSMFIELD const g_aVMSVGA3DSTATEFields[] =
1212{
1213# ifdef VMSVGA3D_OPENGL
1214 SSMFIELD_ENTRY( VMSVGA3DSTATE, rsGLVersion), /** @todo Why are we saving the GL version?? */
1215# endif
1216 SSMFIELD_ENTRY( VMSVGA3DSTATE, cContexts),
1217 SSMFIELD_ENTRY( VMSVGA3DSTATE, cSurfaces),
1218 SSMFIELD_ENTRY_TERM()
1219};
1220#endif /* VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS */
1221
1222
1223#ifdef VMSVGA3D_DIRECT3D
1224D3DFORMAT vmsvga3dSurfaceFormat2D3D(SVGA3dSurfaceFormat format);
1225D3DMULTISAMPLE_TYPE vmsvga3dMultipeSampleCount2D3D(uint32_t multisampleCount);
1226DECLCALLBACK(int) vmsvga3dSharedSurfaceDestroyTree(PAVLU32NODECORE pNode, void *pvParam);
1227int vmsvga3dSurfaceFlush(PVMSVGA3DSURFACE pSurface);
1228#endif /* VMSVGA3D_DIRECT3D */
1229
1230
1231#ifdef VMSVGA3D_OPENGL
1232/** Save and setup everything. */
1233# define VMSVGA3D_PARANOID_TEXTURE_PACKING
1234
1235/** @name VMSVGAPACKPARAMS_* - which packing parameters were set.
1236 * @{ */
1237# define VMSVGAPACKPARAMS_ALIGNMENT RT_BIT_32(0)
1238# define VMSVGAPACKPARAMS_ROW_LENGTH RT_BIT_32(1)
1239# define VMSVGAPACKPARAMS_IMAGE_HEIGHT RT_BIT_32(2)
1240# define VMSVGAPACKPARAMS_SWAP_BYTES RT_BIT_32(3)
1241# define VMSVGAPACKPARAMS_LSB_FIRST RT_BIT_32(4)
1242# define VMSVGAPACKPARAMS_SKIP_ROWS RT_BIT_32(5)
1243# define VMSVGAPACKPARAMS_SKIP_PIXELS RT_BIT_32(6)
1244# define VMSVGAPACKPARAMS_SKIP_IMAGES RT_BIT_32(7)
1245/** @} */
1246
1247/**
1248 * Saved texture packing parameters (shared by both pack and unpack).
1249 */
1250typedef struct VMSVGAPACKPARAMS
1251{
1252 uint32_t fChanged;
1253 GLint iAlignment;
1254 GLint cxRow;
1255 GLint cyImage;
1256# ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING
1257 GLboolean fSwapBytes;
1258 GLboolean fLsbFirst;
1259 GLint cSkipRows;
1260 GLint cSkipPixels;
1261 GLint cSkipImages;
1262# endif
1263} VMSVGAPACKPARAMS;
1264/** Pointer to saved texture packing parameters. */
1265typedef VMSVGAPACKPARAMS *PVMSVGAPACKPARAMS;
1266/** Pointer to const saved texture packing parameters. */
1267typedef VMSVGAPACKPARAMS const *PCVMSVGAPACKPARAMS;
1268
1269void vmsvga3dOglSetPackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
1270 PVMSVGAPACKPARAMS pSave);
1271void vmsvga3dOglRestorePackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface,
1272 PCVMSVGAPACKPARAMS pSave);
1273void vmsvga3dOglSetUnpackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, GLint cxRow, GLint cyImage,
1274 PVMSVGAPACKPARAMS pSave);
1275void vmsvga3dOglRestoreUnpackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext,
1276 PCVMSVGAPACKPARAMS pSave);
1277
1278/** @name VMSVGA3D_DEF_CTX_F_XXX - vmsvga3dContextDefineOgl flags.
1279 * @{ */
1280/** When clear, the context is created using the default OpenGL profile.
1281 * When set, it's created using the alternative profile. The latter is only
1282 * allowed if the VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE is set. */
1283# define VMSVGA3D_DEF_CTX_F_OTHER_PROFILE RT_BIT_32(0)
1284/** Defining the shared context. */
1285# define VMSVGA3D_DEF_CTX_F_SHARED_CTX RT_BIT_32(1)
1286/** Defining the init time context (EMT). */
1287# define VMSVGA3D_DEF_CTX_F_INIT RT_BIT_32(2)
1288/** @} */
1289int vmsvga3dContextDefineOgl(PVGASTATECC pThisCC, uint32_t cid, uint32_t fFlags);
1290void vmsvga3dSurfaceFormat2OGL(PVMSVGA3DSURFACE pSurface, SVGA3dSurfaceFormat format);
1291
1292#endif /* VMSVGA3D_OPENGL */
1293
1294
1295/* DevVGA-SVGA3d-shared.cpp: */
1296int vmsvga3dSaveShaderConst(PVMSVGA3DCONTEXT pContext, uint32_t reg, SVGA3dShaderType type, SVGA3dShaderConstType ctype,
1297 uint32_t val1, uint32_t val2, uint32_t val3, uint32_t val4);
1298
1299
1300DECLINLINE(int) vmsvga3dContextFromCid(PVMSVGA3DSTATE pState, uint32_t cid, PVMSVGA3DCONTEXT *ppContext)
1301{
1302 AssertReturn(cid < pState->cContexts, VERR_INVALID_PARAMETER);
1303 PVMSVGA3DCONTEXT const pContext = pState->papContexts[cid];
1304 if (RT_LIKELY(pContext && pContext->id == cid))
1305 {
1306 *ppContext = pContext;
1307 return VINF_SUCCESS;
1308 }
1309 LogRelMax(64, ("VMSVGA: unknown cid=%u (%s cid=%u)\n", cid, pContext ? "expected" : "null", pContext ? pContext->id : -1));
1310 return VERR_INVALID_PARAMETER;
1311}
1312
1313#ifdef VMSVGA3D_DX
1314DECLINLINE(int) vmsvga3dDXContextFromCid(PVMSVGA3DSTATE pState, uint32_t cid, PVMSVGA3DDXCONTEXT *ppDXContext)
1315{
1316 *ppDXContext = NULL;
1317 AssertReturn(cid < pState->cDXContexts, VERR_INVALID_PARAMETER);
1318 PVMSVGA3DDXCONTEXT const pDXContext = pState->papDXContexts[cid];
1319 if (RT_LIKELY(pDXContext && pDXContext->cid == cid))
1320 {
1321 *ppDXContext = pDXContext;
1322 return VINF_SUCCESS;
1323 }
1324 LogRelMax(64, ("VMSVGA: unknown DX cid=%u (%s cid=%u)\n", cid, pDXContext ? "expected" : "null", pDXContext ? pDXContext->cid : -1));
1325 return VERR_INVALID_PARAMETER;
1326}
1327#endif
1328
1329DECLINLINE(int) vmsvga3dSurfaceFromSid(PVMSVGA3DSTATE pState, uint32_t sid, PVMSVGA3DSURFACE *ppSurface)
1330{
1331 AssertReturn(sid < pState->cSurfaces, VERR_INVALID_PARAMETER);
1332 PVMSVGA3DSURFACE const pSurface = pState->papSurfaces[sid];
1333 if (RT_LIKELY(pSurface && pSurface->id == sid))
1334 {
1335 *ppSurface = pSurface;
1336 return VINF_SUCCESS;
1337 }
1338 LogRelMax(64, ("VMSVGA: unknown sid=%u (%s sid=%u)\n", sid, pSurface ? "expected" : "null", pSurface ? pSurface->id : -1));
1339 return VERR_INVALID_PARAMETER;
1340}
1341
1342DECLINLINE(int) vmsvga3dMipmapLevel(PVMSVGA3DSURFACE pSurface, uint32_t face, uint32_t mipmap,
1343 PVMSVGA3DMIPMAPLEVEL *ppMipmapLevel)
1344{
1345 AssertMsgReturn(face < pSurface->cFaces,
1346 ("cFaces %d, face %d\n", pSurface->cFaces, face),
1347 VERR_INVALID_PARAMETER);
1348 AssertMsgReturn(mipmap < pSurface->cLevels,
1349 ("numMipLevels %d, mipmap %d", pSurface->cLevels, mipmap),
1350 VERR_INVALID_PARAMETER);
1351
1352 *ppMipmapLevel = &pSurface->paMipmapLevels[face * pSurface->cLevels + mipmap];
1353 return VINF_SUCCESS;
1354}
1355
1356void vmsvga3dInfoSurfaceToBitmap(PCDBGFINFOHLP pHlp, PVMSVGA3DSURFACE pSurface,
1357 const char *pszPath, const char *pszNamePrefix, const char *pszNameSuffix);
1358
1359#if defined(RT_OS_WINDOWS)
1360#define D3D_RELEASE(ptr) do { \
1361 if (ptr) \
1362 { \
1363 (ptr)->Release(); \
1364 (ptr) = 0; \
1365 } \
1366} while (0)
1367#endif
1368
1369#if defined(VMSVGA3D_DIRECT3D)
1370HRESULT D3D9UpdateTexture(PVMSVGA3DCONTEXT pContext,
1371 PVMSVGA3DSURFACE pSurface);
1372HRESULT D3D9GetRenderTargetData(PVMSVGA3DCONTEXT pContext,
1373 PVMSVGA3DSURFACE pSurface,
1374 uint32_t uFace,
1375 uint32_t uMipmap);
1376HRESULT D3D9GetSurfaceLevel(PVMSVGA3DSURFACE pSurface,
1377 uint32_t uFace,
1378 uint32_t uMipmap,
1379 bool fBounce,
1380 IDirect3DSurface9 **ppD3DSurface);
1381D3DFORMAT D3D9GetActualFormat(PVMSVGA3DSTATE pState,
1382 D3DFORMAT d3dfmt);
1383bool D3D9CheckDeviceFormat(IDirect3D9 *pD3D9,
1384 DWORD Usage,
1385 D3DRESOURCETYPE RType,
1386 D3DFORMAT CheckFormat);
1387#endif
1388
1389#ifdef VMSVGA3D_OPENGL
1390void vmsvga3dOnSharedContextDefine(PVMSVGA3DSTATE pState);
1391void vmsvga3dOnSharedContextDestroy(PVMSVGA3DSTATE pState);
1392
1393DECLINLINE(GLuint) GLTextureId(PVMSVGA3DSURFACE pSurface)
1394{
1395 return pSurface->fEmulated ? pSurface->idEmulated : pSurface->oglId.texture;
1396}
1397
1398void FormatConvUpdateTexture(PVMSVGA3DSTATE pState,
1399 PVMSVGA3DCONTEXT pCurrentContext,
1400 PVMSVGA3DSURFACE pSurface,
1401 uint32_t iMipmap);
1402void FormatConvReadTexture(PVMSVGA3DSTATE pState,
1403 PVMSVGA3DCONTEXT pCurrentContext,
1404 PVMSVGA3DSURFACE pSurface,
1405 uint32_t iMipmap);
1406#endif
1407
1408int vmsvga3dShaderParse(SVGA3dShaderType type, uint32_t cbShaderData, uint32_t *pShaderData);
1409void vmsvga3dShaderLogRel(char const *pszMsg, SVGA3dShaderType type, uint32_t cbShaderData, uint32_t const *pShaderData);
1410
1411#endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA3d_internal_h */
1412
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