1 | /* $Id: DevVGA-SVGA-internal.h 86265 2020-09-24 12:42:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMWare SVGA device - internal header for DevVGA-SVGA* source files.
|
---|
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_SVGA_internal_h
|
---|
19 | #define VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA_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 "DevVGA-SVGA-internal.h is only for ring-3 code"
|
---|
29 | #endif
|
---|
30 |
|
---|
31 |
|
---|
32 | /*********************************************************************************************************************************
|
---|
33 | * Structures and Typedefs *
|
---|
34 | *********************************************************************************************************************************/
|
---|
35 | /**
|
---|
36 | * 64-bit GMR descriptor.
|
---|
37 | */
|
---|
38 | typedef struct
|
---|
39 | {
|
---|
40 | RTGCPHYS GCPhys;
|
---|
41 | uint64_t numPages;
|
---|
42 | } VMSVGAGMRDESCRIPTOR, *PVMSVGAGMRDESCRIPTOR;
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * GMR slot
|
---|
46 | */
|
---|
47 | typedef struct
|
---|
48 | {
|
---|
49 | uint32_t cMaxPages;
|
---|
50 | uint32_t cbTotal;
|
---|
51 | uint32_t numDescriptors;
|
---|
52 | PVMSVGAGMRDESCRIPTOR paDesc;
|
---|
53 | } GMR, *PGMR;
|
---|
54 |
|
---|
55 | typedef struct VMSVGACMDBUF *PVMSVGACMDBUF;
|
---|
56 | typedef struct VMSVGACMDBUFCTX *PVMSVGACMDBUFCTX;
|
---|
57 |
|
---|
58 | /* Command buffer. */
|
---|
59 | typedef struct VMSVGACMDBUF
|
---|
60 | {
|
---|
61 | RTLISTNODE nodeBuffer;
|
---|
62 | /* Context of the buffer. */
|
---|
63 | PVMSVGACMDBUFCTX pCmdBufCtx;
|
---|
64 | /* PA of the buffer. */
|
---|
65 | RTGCPHYS GCPhysCB;
|
---|
66 | /* A copy of the buffer header. */
|
---|
67 | SVGACBHeader hdr;
|
---|
68 | /* A copy of the commands. Size of the memory buffer is hdr.length */
|
---|
69 | void *pvCommands;
|
---|
70 | } VMSVGACMDBUF;
|
---|
71 |
|
---|
72 | /* Command buffer context. */
|
---|
73 | typedef struct VMSVGACMDBUFCTX
|
---|
74 | {
|
---|
75 | /* Buffers submitted to processing for the FIFO thread. */
|
---|
76 | RTLISTANCHOR listSubmitted;
|
---|
77 | /* How many buffers in the queue. */
|
---|
78 | uint32_t cSubmitted;
|
---|
79 | } VMSVGACMDBUFCTX;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Internal SVGA ring-3 only state.
|
---|
83 | */
|
---|
84 | typedef struct VMSVGAR3STATE
|
---|
85 | {
|
---|
86 | GMR *paGMR; // [VMSVGAState::cGMR]
|
---|
87 | struct
|
---|
88 | {
|
---|
89 | SVGAGuestPtr RT_UNTRUSTED_GUEST ptr;
|
---|
90 | uint32_t RT_UNTRUSTED_GUEST bytesPerLine;
|
---|
91 | SVGAGMRImageFormat RT_UNTRUSTED_GUEST format;
|
---|
92 | } GMRFB;
|
---|
93 | struct
|
---|
94 | {
|
---|
95 | bool fActive;
|
---|
96 | uint32_t xHotspot;
|
---|
97 | uint32_t yHotspot;
|
---|
98 | uint32_t width;
|
---|
99 | uint32_t height;
|
---|
100 | uint32_t cbData;
|
---|
101 | void *pData;
|
---|
102 | } Cursor;
|
---|
103 | SVGAColorBGRX colorAnnotation;
|
---|
104 |
|
---|
105 | # ifdef VMSVGA_USE_EMT_HALT_CODE
|
---|
106 | /** Number of EMTs in BusyDelayedEmts (quicker than scanning the set). */
|
---|
107 | uint32_t volatile cBusyDelayedEmts;
|
---|
108 | /** Set of EMTs that are */
|
---|
109 | VMCPUSET BusyDelayedEmts;
|
---|
110 | # else
|
---|
111 | /** Number of EMTs waiting on hBusyDelayedEmts. */
|
---|
112 | uint32_t volatile cBusyDelayedEmts;
|
---|
113 | /** Semaphore that EMTs wait on when reading SVGA_REG_BUSY and the FIFO is
|
---|
114 | * busy (ugly). */
|
---|
115 | RTSEMEVENTMULTI hBusyDelayedEmts;
|
---|
116 | # endif
|
---|
117 |
|
---|
118 | /** Information about screens. */
|
---|
119 | VMSVGASCREENOBJECT aScreens[64];
|
---|
120 |
|
---|
121 | /** Command buffer contexts. */
|
---|
122 | PVMSVGACMDBUFCTX apCmdBufCtxs[SVGA_CB_CONTEXT_MAX];
|
---|
123 | /** The special Device Context for synchronous commands. */
|
---|
124 | VMSVGACMDBUFCTX CmdBufCtxDC;
|
---|
125 | /** Flag which indicates that there are buffers to be processed. */
|
---|
126 | uint32_t volatile fCmdBuf;
|
---|
127 | /** Critical section for accessing the command buffer data. */
|
---|
128 | RTCRITSECT CritSectCmdBuf;
|
---|
129 |
|
---|
130 | /** Tracks how much time we waste reading SVGA_REG_BUSY with a busy FIFO. */
|
---|
131 | STAMPROFILE StatBusyDelayEmts;
|
---|
132 |
|
---|
133 | STAMPROFILE StatR3Cmd3dPresentProf;
|
---|
134 | STAMPROFILE StatR3Cmd3dDrawPrimitivesProf;
|
---|
135 | STAMPROFILE StatR3Cmd3dSurfaceDmaProf;
|
---|
136 | STAMPROFILE StatR3Cmd3dBlitSurfaceToScreenProf;
|
---|
137 | STAMCOUNTER StatR3CmdDefineGmr2;
|
---|
138 | STAMCOUNTER StatR3CmdDefineGmr2Free;
|
---|
139 | STAMCOUNTER StatR3CmdDefineGmr2Modify;
|
---|
140 | STAMCOUNTER StatR3CmdRemapGmr2;
|
---|
141 | STAMCOUNTER StatR3CmdRemapGmr2Modify;
|
---|
142 | STAMCOUNTER StatR3CmdInvalidCmd;
|
---|
143 | STAMCOUNTER StatR3CmdFence;
|
---|
144 | STAMCOUNTER StatR3CmdUpdate;
|
---|
145 | STAMCOUNTER StatR3CmdUpdateVerbose;
|
---|
146 | STAMCOUNTER StatR3CmdDefineCursor;
|
---|
147 | STAMCOUNTER StatR3CmdDefineAlphaCursor;
|
---|
148 | STAMCOUNTER StatR3CmdMoveCursor;
|
---|
149 | STAMCOUNTER StatR3CmdDisplayCursor;
|
---|
150 | STAMCOUNTER StatR3CmdRectFill;
|
---|
151 | STAMCOUNTER StatR3CmdRectCopy;
|
---|
152 | STAMCOUNTER StatR3CmdRectRopCopy;
|
---|
153 | STAMCOUNTER StatR3CmdEscape;
|
---|
154 | STAMCOUNTER StatR3CmdDefineScreen;
|
---|
155 | STAMCOUNTER StatR3CmdDestroyScreen;
|
---|
156 | STAMCOUNTER StatR3CmdDefineGmrFb;
|
---|
157 | STAMCOUNTER StatR3CmdBlitGmrFbToScreen;
|
---|
158 | STAMCOUNTER StatR3CmdBlitScreentoGmrFb;
|
---|
159 | STAMCOUNTER StatR3CmdAnnotationFill;
|
---|
160 | STAMCOUNTER StatR3CmdAnnotationCopy;
|
---|
161 | STAMCOUNTER StatR3Cmd3dSurfaceDefine;
|
---|
162 | STAMCOUNTER StatR3Cmd3dSurfaceDefineV2;
|
---|
163 | STAMCOUNTER StatR3Cmd3dSurfaceDestroy;
|
---|
164 | STAMCOUNTER StatR3Cmd3dSurfaceCopy;
|
---|
165 | STAMCOUNTER StatR3Cmd3dSurfaceStretchBlt;
|
---|
166 | STAMCOUNTER StatR3Cmd3dSurfaceDma;
|
---|
167 | STAMCOUNTER StatR3Cmd3dSurfaceScreen;
|
---|
168 | STAMCOUNTER StatR3Cmd3dContextDefine;
|
---|
169 | STAMCOUNTER StatR3Cmd3dContextDestroy;
|
---|
170 | STAMCOUNTER StatR3Cmd3dSetTransform;
|
---|
171 | STAMCOUNTER StatR3Cmd3dSetZRange;
|
---|
172 | STAMCOUNTER StatR3Cmd3dSetRenderState;
|
---|
173 | STAMCOUNTER StatR3Cmd3dSetRenderTarget;
|
---|
174 | STAMCOUNTER StatR3Cmd3dSetTextureState;
|
---|
175 | STAMCOUNTER StatR3Cmd3dSetMaterial;
|
---|
176 | STAMCOUNTER StatR3Cmd3dSetLightData;
|
---|
177 | STAMCOUNTER StatR3Cmd3dSetLightEnable;
|
---|
178 | STAMCOUNTER StatR3Cmd3dSetViewPort;
|
---|
179 | STAMCOUNTER StatR3Cmd3dSetClipPlane;
|
---|
180 | STAMCOUNTER StatR3Cmd3dClear;
|
---|
181 | STAMCOUNTER StatR3Cmd3dPresent;
|
---|
182 | STAMCOUNTER StatR3Cmd3dPresentReadBack;
|
---|
183 | STAMCOUNTER StatR3Cmd3dShaderDefine;
|
---|
184 | STAMCOUNTER StatR3Cmd3dShaderDestroy;
|
---|
185 | STAMCOUNTER StatR3Cmd3dSetShader;
|
---|
186 | STAMCOUNTER StatR3Cmd3dSetShaderConst;
|
---|
187 | STAMCOUNTER StatR3Cmd3dDrawPrimitives;
|
---|
188 | STAMCOUNTER StatR3Cmd3dSetScissorRect;
|
---|
189 | STAMCOUNTER StatR3Cmd3dBeginQuery;
|
---|
190 | STAMCOUNTER StatR3Cmd3dEndQuery;
|
---|
191 | STAMCOUNTER StatR3Cmd3dWaitForQuery;
|
---|
192 | STAMCOUNTER StatR3Cmd3dGenerateMipmaps;
|
---|
193 | STAMCOUNTER StatR3Cmd3dActivateSurface;
|
---|
194 | STAMCOUNTER StatR3Cmd3dDeactivateSurface;
|
---|
195 |
|
---|
196 | STAMCOUNTER StatR3RegConfigDoneWr;
|
---|
197 | STAMCOUNTER StatR3RegGmrDescriptorWr;
|
---|
198 | STAMCOUNTER StatR3RegGmrDescriptorWrErrors;
|
---|
199 | STAMCOUNTER StatR3RegGmrDescriptorWrFree;
|
---|
200 |
|
---|
201 | STAMCOUNTER StatFifoCommands;
|
---|
202 | STAMCOUNTER StatFifoErrors;
|
---|
203 | STAMCOUNTER StatFifoUnkCmds;
|
---|
204 | STAMCOUNTER StatFifoTodoTimeout;
|
---|
205 | STAMCOUNTER StatFifoTodoWoken;
|
---|
206 | STAMPROFILE StatFifoStalls;
|
---|
207 | STAMPROFILE StatFifoExtendedSleep;
|
---|
208 | # ifdef VMSVGA_USE_FIFO_ACCESS_HANDLER
|
---|
209 | STAMCOUNTER StatFifoAccessHandler;
|
---|
210 | # endif
|
---|
211 | STAMCOUNTER StatFifoCursorFetchAgain;
|
---|
212 | STAMCOUNTER StatFifoCursorNoChange;
|
---|
213 | STAMCOUNTER StatFifoCursorPosition;
|
---|
214 | STAMCOUNTER StatFifoCursorVisiblity;
|
---|
215 | STAMCOUNTER StatFifoWatchdogWakeUps;
|
---|
216 | } VMSVGAR3STATE, *PVMSVGAR3STATE;
|
---|
217 |
|
---|
218 |
|
---|
219 | /*********************************************************************************************************************************
|
---|
220 | * Functions *
|
---|
221 | *********************************************************************************************************************************/
|
---|
222 | #ifdef DEBUG_GMR_ACCESS
|
---|
223 | DECLCALLBACK(int) vmsvgaR3ResetGmrHandlers(PVGASTATE pThis);
|
---|
224 | DECLCALLBACK(int) vmsvgaR3DeregisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId);
|
---|
225 | #endif
|
---|
226 |
|
---|
227 | void vmsvgaR3ResetScreens(PVGASTATE pThis, PVGASTATECC pThisCC);
|
---|
228 |
|
---|
229 | int vmsvgaR3ChangeMode(PVGASTATE pThis, PVGASTATECC pThisCC);
|
---|
230 | int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
|
---|
231 |
|
---|
232 | int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
|
---|
233 | uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
|
---|
234 | SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
|
---|
235 | uint32_t cbWidth, uint32_t cHeight);
|
---|
236 | void vmsvgaR3GmrFree(PVGASTATECC pThisCC, uint32_t idGMR);
|
---|
237 |
|
---|
238 | void vmsvgaR3CmdUpdate(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdate const *pCmd);
|
---|
239 | void vmsvgaR3CmdUpdateVerbose(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdateVerbose const *pCmd);
|
---|
240 | void vmsvgaR3CmdRectFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectFill const *pCmd);
|
---|
241 | void vmsvgaR3CmdRectCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectCopy const *pCmd);
|
---|
242 | void vmsvgaR3CmdRectRopCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectRopCopy const *pCmd);
|
---|
243 | void vmsvgaR3CmdDisplayCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDisplayCursor const *pCmd);
|
---|
244 | void vmsvgaR3CmdMoveCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdMoveCursor const *pCmd);
|
---|
245 | void vmsvgaR3CmdDefineCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineCursor const *pCmd);
|
---|
246 | void vmsvgaR3CmdDefineAlphaCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineAlphaCursor const *pCmd);
|
---|
247 | void vmsvgaR3CmdEscape(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdEscape const *pCmd);
|
---|
248 | void vmsvgaR3CmdDefineScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineScreen const *pCmd);
|
---|
249 | void vmsvgaR3CmdDestroyScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDestroyScreen const *pCmd);
|
---|
250 | void vmsvgaR3CmdDefineGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMRFB const *pCmd);
|
---|
251 | void vmsvgaR3CmdBlitGMRFBToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitGMRFBToScreen const *pCmd);
|
---|
252 | void vmsvgaR3CmdBlitScreenToGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitScreenToGMRFB const *pCmd);
|
---|
253 | void vmsvgaR3CmdAnnotationFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationFill const *pCmd);
|
---|
254 | void vmsvgaR3CmdAnnotationCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationCopy const *pCmd);
|
---|
255 |
|
---|
256 | #ifdef VBOX_WITH_VMSVGA3D
|
---|
257 | void vmsvgaR3CmdDefineGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMR2 const *pCmd);
|
---|
258 | void vmsvgaR3CmdRemapGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRemapGMR2 const *pCmd);
|
---|
259 | int vmsvgaR3Process3dCmd(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifo3dCmdId enmCmdId, uint32_t cbCmd, void const *pvCmd);
|
---|
260 | #endif
|
---|
261 |
|
---|
262 | #if defined(LOG_ENABLED) || defined(VBOX_STRICT)
|
---|
263 | const char *vmsvgaR3FifoCmdToString(uint32_t u32Cmd);
|
---|
264 | #endif
|
---|
265 |
|
---|
266 |
|
---|
267 | #endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA_internal_h */
|
---|