1 | /* $Id: DevVGA-SVGA3d.h 82114 2019-11-22 23:05:31Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DevVMWare - VMWare SVGA device - 3D part.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2019 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_h
|
---|
19 | #define VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA3d_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "vmsvga/svga3d_reg.h"
|
---|
25 | #include "vmsvga/svga_escape.h"
|
---|
26 | #include "vmsvga/svga_overlay.h"
|
---|
27 |
|
---|
28 |
|
---|
29 | /** Arbitrary limit */
|
---|
30 | #define SVGA3D_MAX_SHADER_IDS 0x800
|
---|
31 | /** D3D allows up to 8 texture stages. */
|
---|
32 | #define SVGA3D_MAX_TEXTURE_STAGES 8
|
---|
33 | /** Samplers: 16 Pixel Shader + 1 Displacement Map + 4 Vertex Shader */
|
---|
34 | #define SVGA3D_MAX_SAMPLERS_PS 16
|
---|
35 | #define SVGA3D_MAX_SAMPLERS_DMAP 1
|
---|
36 | #define SVGA3D_MAX_SAMPLERS_VS 4
|
---|
37 | #define SVGA3D_MAX_SAMPLERS (SVGA3D_MAX_SAMPLERS_PS + SVGA3D_MAX_SAMPLERS_DMAP + SVGA3D_MAX_SAMPLERS_VS)
|
---|
38 | /** Arbitrary upper limit; seen 8 so far. */
|
---|
39 | #define SVGA3D_MAX_LIGHTS 32
|
---|
40 | /** Arbitrary upper limit; 2GB enough for 32768x16384*4. */
|
---|
41 | #define SVGA3D_MAX_SURFACE_MEM_SIZE 0x80000000
|
---|
42 |
|
---|
43 |
|
---|
44 | /**@def FLOAT_FMT_STR
|
---|
45 | * Format string bits to go with FLOAT_FMT_ARGS. */
|
---|
46 | #define FLOAT_FMT_STR "%s%u.%06u"
|
---|
47 | /** @def FLOAT_FMT_ARGS
|
---|
48 | * Format arguments for a float value, corresponding to FLOAT_FMT_STR.
|
---|
49 | * @param r The floating point value to format. */
|
---|
50 | #define FLOAT_FMT_ARGS(r) (r) >= 0.0f ? "" : "-", (unsigned)RT_ABS(r), (unsigned)(RT_ABS((r) - (unsigned)(r)) * 1000000.0f)
|
---|
51 |
|
---|
52 |
|
---|
53 | /* DevVGA-SVGA.cpp: */
|
---|
54 | void vmsvgaR33dSurfaceUpdateHeapBuffersOnFifoThread(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t sid);
|
---|
55 |
|
---|
56 |
|
---|
57 | /* DevVGA-SVGA3d-ogl.cpp & DevVGA-SVGA3d-win.cpp: */
|
---|
58 | int vmsvga3dInit(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
|
---|
59 | int vmsvga3dPowerOn(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC);
|
---|
60 | int vmsvga3dLoadExec(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
|
---|
61 | int vmsvga3dSaveExec(PPDMDEVINS pDevIns, PVGASTATECC pThisCC, PSSMHANDLE pSSM);
|
---|
62 | int vmsvga3dTerminate(PVGASTATECC pThisCC);
|
---|
63 | int vmsvga3dReset(PVGASTATECC pThisCC);
|
---|
64 | void vmsvga3dUpdateHostScreenViewport(PVGASTATECC pThisCC, uint32_t idScreen, VMSVGAVIEWPORT const *pOldViewport);
|
---|
65 | int vmsvga3dQueryCaps(PVGASTATECC pThisCC, uint32_t idx3dCaps, uint32_t *pu32Val);
|
---|
66 |
|
---|
67 | int vmsvga3dSurfaceDefine(PVGASTATECC pThisCC, uint32_t sid, uint32_t surfaceFlags, SVGA3dSurfaceFormat format,
|
---|
68 | SVGA3dSurfaceFace face[SVGA3D_MAX_SURFACE_FACES], uint32_t multisampleCount,
|
---|
69 | SVGA3dTextureFilter autogenFilter, uint32_t cMipLevels, SVGA3dSize *pMipLevelSize);
|
---|
70 | int vmsvga3dSurfaceDestroy(PVGASTATECC pThisCC, uint32_t sid);
|
---|
71 | int vmsvga3dSurfaceCopy(PVGASTATECC pThisCC, SVGA3dSurfaceImageId dest, SVGA3dSurfaceImageId src,
|
---|
72 | uint32_t cCopyBoxes, SVGA3dCopyBox *pBox);
|
---|
73 | int vmsvga3dSurfaceStretchBlt(PVGASTATE pThis, PVGASTATECC pThisCC,
|
---|
74 | SVGA3dSurfaceImageId const *pDstSfcImg, SVGA3dBox const *pDstBox,
|
---|
75 | SVGA3dSurfaceImageId const *pSrcSfcImg, SVGA3dBox const *pSrcBox, SVGA3dStretchBltMode enmMode);
|
---|
76 | int vmsvga3dSurfaceDMA(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer, uint32_t cCopyBoxes, SVGA3dCopyBox *pBoxes);
|
---|
77 | int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t dest, SVGASignedRect destRect, SVGA3dSurfaceImageId src, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect);
|
---|
78 |
|
---|
79 | int vmsvga3dContextDefine(PVGASTATECC pThisCC, uint32_t cid);
|
---|
80 | int vmsvga3dContextDestroy(PVGASTATECC pThisCC, uint32_t cid);
|
---|
81 |
|
---|
82 | int vmsvga3dChangeMode(PVGASTATECC pThisCC);
|
---|
83 |
|
---|
84 | int vmsvga3dSetTransform(PVGASTATECC pThisCC, uint32_t cid, SVGA3dTransformType type, float matrix[16]);
|
---|
85 | int vmsvga3dSetZRange(PVGASTATECC pThisCC, uint32_t cid, SVGA3dZRange zRange);
|
---|
86 | int vmsvga3dSetRenderState(PVGASTATECC pThisCC, uint32_t cid, uint32_t cRenderStates, SVGA3dRenderState *pRenderState);
|
---|
87 | int vmsvga3dSetRenderTarget(PVGASTATECC pThisCC, uint32_t cid, SVGA3dRenderTargetType type, SVGA3dSurfaceImageId target);
|
---|
88 | int vmsvga3dSetTextureState(PVGASTATECC pThisCC, uint32_t cid, uint32_t cTextureStates, SVGA3dTextureState *pTextureState);
|
---|
89 | int vmsvga3dSetMaterial(PVGASTATECC pThisCC, uint32_t cid, SVGA3dFace face, SVGA3dMaterial *pMaterial);
|
---|
90 | int vmsvga3dSetLightData(PVGASTATECC pThisCC, uint32_t cid, uint32_t index, SVGA3dLightData *pData);
|
---|
91 | int vmsvga3dSetLightEnabled(PVGASTATECC pThisCC, uint32_t cid, uint32_t index, uint32_t enabled);
|
---|
92 | int vmsvga3dSetViewPort(PVGASTATECC pThisCC, uint32_t cid, SVGA3dRect *pRect);
|
---|
93 | int vmsvga3dSetClipPlane(PVGASTATECC pThisCC, uint32_t cid, uint32_t index, float plane[4]);
|
---|
94 | int vmsvga3dCommandClear(PVGASTATECC pThisCC, uint32_t cid, SVGA3dClearFlag clearFlag, uint32_t color, float depth, uint32_t stencil, uint32_t cRects, SVGA3dRect *pRect);
|
---|
95 | int vmsvga3dCommandPresent(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t sid, uint32_t cRects, SVGA3dCopyRect *pRect);
|
---|
96 | int vmsvga3dDrawPrimitives(PVGASTATECC pThisCC, uint32_t cid, uint32_t numVertexDecls, SVGA3dVertexDecl *pVertexDecl, uint32_t numRanges, SVGA3dPrimitiveRange *pNumRange, uint32_t cVertexDivisor, SVGA3dVertexDivisor *pVertexDivisor);
|
---|
97 | int vmsvga3dSetScissorRect(PVGASTATECC pThisCC, uint32_t cid, SVGA3dRect *pRect);
|
---|
98 | int vmsvga3dGenerateMipmaps(PVGASTATECC pThisCC, uint32_t sid, SVGA3dTextureFilter filter);
|
---|
99 |
|
---|
100 | int vmsvga3dShaderDefine(PVGASTATECC pThisCC, uint32_t cid, uint32_t shid, SVGA3dShaderType type, uint32_t cbData, uint32_t *pShaderData);
|
---|
101 | int vmsvga3dShaderDestroy(PVGASTATECC pThisCC, uint32_t cid, uint32_t shid, SVGA3dShaderType type);
|
---|
102 | int vmsvga3dShaderSet(PVGASTATECC pThisCC, struct VMSVGA3DCONTEXT *pContext, uint32_t cid, SVGA3dShaderType type, uint32_t shid);
|
---|
103 | int vmsvga3dShaderSetConst(PVGASTATECC pThisCC, uint32_t cid, uint32_t reg, SVGA3dShaderType type, SVGA3dShaderConstType ctype, uint32_t cRegisters, uint32_t *pValues);
|
---|
104 |
|
---|
105 | int vmsvga3dQueryBegin(PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type);
|
---|
106 | int vmsvga3dQueryEnd(PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult);
|
---|
107 | int vmsvga3dQueryWait(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult);
|
---|
108 |
|
---|
109 | /* DevVGA-SVGA3d-shared.h: */
|
---|
110 | #if defined(RT_OS_WINDOWS) && defined(IN_RING3)
|
---|
111 | # include <iprt/win/windows.h>
|
---|
112 |
|
---|
113 | # define WM_VMSVGA3D_WAKEUP (WM_APP+1)
|
---|
114 | # define WM_VMSVGA3D_CREATEWINDOW (WM_APP+2)
|
---|
115 | # define WM_VMSVGA3D_DESTROYWINDOW (WM_APP+3)
|
---|
116 | # define WM_VMSVGA3D_EXIT (WM_APP+5)
|
---|
117 |
|
---|
118 | DECLCALLBACK(int) vmsvga3dWindowThread(RTTHREAD ThreadSelf, void *pvUser);
|
---|
119 | int vmsvga3dSendThreadMessage(RTTHREAD pWindowThread, RTSEMEVENT WndRequestSem, UINT msg, WPARAM wParam, LPARAM lParam);
|
---|
120 | int vmsvga3dContextWindowCreate(HINSTANCE hInstance, RTTHREAD pWindowThread, RTSEMEVENT WndRequestSem, HWND *pHwnd);
|
---|
121 |
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | void vmsvga3dUpdateHeapBuffersForSurfaces(PVGASTATECC pThisCC, uint32_t sid);
|
---|
125 | void vmsvga3dInfoContextWorker(PVGASTATECC pThisCC, PCDBGFINFOHLP pHlp, uint32_t cid, bool fVerbose);
|
---|
126 | void vmsvga3dInfoSurfaceWorker(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PCDBGFINFOHLP pHlp, uint32_t sid,
|
---|
127 | bool fVerbose, uint32_t cxAscii, bool fInvY, const char *pszBitmapPath);
|
---|
128 |
|
---|
129 | /* DevVGA-SVGA3d-shared.cpp: */
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * Structure for use with vmsvga3dInfoU32Flags.
|
---|
133 | */
|
---|
134 | typedef struct VMSVGAINFOFLAGS32
|
---|
135 | {
|
---|
136 | /** The flags. */
|
---|
137 | uint32_t fFlags;
|
---|
138 | /** The corresponding mnemonic. */
|
---|
139 | const char *pszJohnny;
|
---|
140 | } VMSVGAINFOFLAGS32;
|
---|
141 | /** Pointer to a read-only flag translation entry. */
|
---|
142 | typedef VMSVGAINFOFLAGS32 const *PCVMSVGAINFOFLAGS32;
|
---|
143 | void vmsvga3dInfoU32Flags(PCDBGFINFOHLP pHlp, uint32_t fFlags, const char *pszPrefix, PCVMSVGAINFOFLAGS32 paFlags, uint32_t cFlags);
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Structure for use with vmsvgaFormatEnumValueEx and vmsvgaFormatEnumValue.
|
---|
147 | */
|
---|
148 | typedef struct VMSVGAINFOENUM
|
---|
149 | {
|
---|
150 | /** The enum value. */
|
---|
151 | int32_t iValue;
|
---|
152 | /** The corresponding value name. */
|
---|
153 | const char *pszName;
|
---|
154 | } VMSVGAINFOENUM;
|
---|
155 | /** Pointer to a read-only enum value translation entry. */
|
---|
156 | typedef VMSVGAINFOENUM const *PCVMSVGAINFOENUM;
|
---|
157 | /**
|
---|
158 | * Structure for use with vmsvgaFormatEnumValueEx and vmsvgaFormatEnumValue.
|
---|
159 | */
|
---|
160 | typedef struct VMSVGAINFOENUMMAP
|
---|
161 | {
|
---|
162 | /** Pointer to the value mapping array. */
|
---|
163 | PCVMSVGAINFOENUM paValues;
|
---|
164 | /** The number of value mappings. */
|
---|
165 | size_t cValues;
|
---|
166 | /** The prefix. */
|
---|
167 | const char *pszPrefix;
|
---|
168 | #ifdef RT_STRICT
|
---|
169 | /** Indicates whether we've checked that it's sorted or not. */
|
---|
170 | bool *pfAsserted;
|
---|
171 | #endif
|
---|
172 | } VMSVGAINFOENUMMAP;
|
---|
173 | typedef VMSVGAINFOENUMMAP const *PCVMSVGAINFOENUMMAP;
|
---|
174 | /** @def VMSVGAINFOENUMMAP_MAKE
|
---|
175 | * Macro for defining a VMSVGAINFOENUMMAP, silently dealing with pfAsserted.
|
---|
176 | *
|
---|
177 | * @param a_Scope The scope. RT_NOTHING or static.
|
---|
178 | * @param a_VarName The variable name for this map.
|
---|
179 | * @param a_aValues The variable name of the value mapping array.
|
---|
180 | * @param a_pszPrefix The value name prefix.
|
---|
181 | */
|
---|
182 | #ifdef VBOX_STRICT
|
---|
183 | # define VMSVGAINFOENUMMAP_MAKE(a_Scope, a_VarName, a_aValues, a_pszPrefix) \
|
---|
184 | static bool RT_CONCAT(a_VarName,_AssertedSorted) = false; \
|
---|
185 | a_Scope VMSVGAINFOENUMMAP const a_VarName = { \
|
---|
186 | a_aValues, RT_ELEMENTS(a_aValues), a_pszPrefix, &RT_CONCAT(a_VarName,_AssertedSorted) \
|
---|
187 | }
|
---|
188 | #else
|
---|
189 | # define VMSVGAINFOENUMMAP_MAKE(a_Scope, a_VarName, a_aValues, a_pszPrefix) \
|
---|
190 | a_Scope VMSVGAINFOENUMMAP const a_VarName = { a_aValues, RT_ELEMENTS(a_aValues), a_pszPrefix }
|
---|
191 | #endif
|
---|
192 | extern VMSVGAINFOENUMMAP const g_SVGA3dSurfaceFormat2String;
|
---|
193 | const char *vmsvgaLookupEnum(int32_t iValue, PCVMSVGAINFOENUMMAP pEnumMap);
|
---|
194 | char *vmsvgaFormatEnumValueEx(char *pszBuffer, size_t cbBuffer, const char *pszName, int32_t iValue,
|
---|
195 | bool fPrefix, PCVMSVGAINFOENUMMAP pEnumMap);
|
---|
196 | char *vmsvgaFormatEnumValue(char *pszBuffer, size_t cbBuffer, const char *pszName, uint32_t uValue,
|
---|
197 | const char *pszPrefix, const char * const *papszValues, size_t cValues);
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * ASCII "art" scanline printer callback.
|
---|
201 | *
|
---|
202 | * @param pszLine The line to output.
|
---|
203 | * @param pvUser The user argument.
|
---|
204 | */
|
---|
205 | typedef DECLCALLBACK(void) FMVMSVGAASCIIPRINTLN(const char *pszLine, void *pvUser);
|
---|
206 | /** Pointer to an ASCII "art" print line callback. */
|
---|
207 | typedef FMVMSVGAASCIIPRINTLN *PFMVMSVGAASCIIPRINTLN;
|
---|
208 | void vmsvga3dAsciiPrint(PFMVMSVGAASCIIPRINTLN pfnPrintLine, void *pvUser, void const *pvImage, size_t cbImage,
|
---|
209 | uint32_t cx, uint32_t cy, uint32_t cbScanline, SVGA3dSurfaceFormat enmFormat, bool fInvY,
|
---|
210 | uint32_t cchMaxX, uint32_t cchMaxY);
|
---|
211 | DECLCALLBACK(void) vmsvga3dAsciiPrintlnInfo(const char *pszLine, void *pvUser);
|
---|
212 | DECLCALLBACK(void) vmsvga3dAsciiPrintlnLog(const char *pszLine, void *pvUser);
|
---|
213 |
|
---|
214 | char *vmsvga3dFormatRenderState(char *pszBuffer, size_t cbBuffer, SVGA3dRenderState const *pRenderState);
|
---|
215 | char *vmsvga3dFormatTextureState(char *pszBuffer, size_t cbBuffer, SVGA3dTextureState const *pTextureState);
|
---|
216 | void vmsvga3dInfoHostWindow(PCDBGFINFOHLP pHlp, uint64_t idHostWindow);
|
---|
217 |
|
---|
218 | uint32_t vmsvga3dSurfaceFormatSize(SVGA3dSurfaceFormat format,
|
---|
219 | uint32_t *pu32BlockWidth,
|
---|
220 | uint32_t *pu32BlockHeight);
|
---|
221 |
|
---|
222 | #ifdef LOG_ENABLED
|
---|
223 | const char *vmsvga3dGetCapString(uint32_t idxCap);
|
---|
224 | const char *vmsvga3dGet3dFormatString(uint32_t format);
|
---|
225 | const char *vmsvga3dGetRenderStateName(uint32_t state);
|
---|
226 | const char *vmsvga3dTextureStateToString(SVGA3dTextureStateName textureState);
|
---|
227 | const char *vmsvgaTransformToString(SVGA3dTransformType type);
|
---|
228 | const char *vmsvgaDeclUsage2String(SVGA3dDeclUsage usage);
|
---|
229 | const char *vmsvgaDeclType2String(SVGA3dDeclType type);
|
---|
230 | const char *vmsvgaDeclMethod2String(SVGA3dDeclMethod method);
|
---|
231 | const char *vmsvgaSurfaceType2String(SVGA3dSurfaceFormat format);
|
---|
232 | const char *vmsvga3dPrimitiveType2String(SVGA3dPrimitiveType PrimitiveType);
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | #endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA3d_h */
|
---|
236 |
|
---|