VirtualBox

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

Last change on this file since 76364 was 76181, checked in by vboxsync, 6 years ago

DevVGA-SVGA: process the three GMRFB related commands when VBOX_WITH_VMSVGA3D is not defined.

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