VirtualBox

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

Last change on this file since 86611 was 86024, checked in by vboxsync, 4 years ago

Devices/Graphics: use current VMSVGA headers

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