VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-internal.h@ 86838

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

Devices/Graphics: A couple of new commands; a more generic handler for creating a surface; cleaned saved state data for a surface; increased saved state version; possibility to build DX11 backend. bugref:9830

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.6 KB
Line 
1/* $Id: DevVGA-SVGA-internal.h 86838 2020-11-09 23:16:50Z 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#include <iprt/avl.h>
32#include <iprt/list.h>
33
34
35/*********************************************************************************************************************************
36* Structures and Typedefs *
37*********************************************************************************************************************************/
38/**
39 * 64-bit GMR descriptor.
40 */
41typedef struct
42{
43 RTGCPHYS GCPhys;
44 uint64_t numPages;
45} VMSVGAGMRDESCRIPTOR, *PVMSVGAGMRDESCRIPTOR;
46
47/**
48 * GMR slot
49 */
50typedef struct
51{
52 uint32_t cMaxPages;
53 uint32_t cbTotal;
54 uint32_t numDescriptors;
55 PVMSVGAGMRDESCRIPTOR paDesc;
56} GMR, *PGMR;
57
58/*
59 * GBO (Guest Backed Object).
60 * A GBO is a list of the guest pages. GBOs are used for VMSVGA MOBs (Memory OBjects)
61 * and Object Tables which the guest shares with the host.
62 *
63 * A GBO is similar to a GMR. Nevertheless I'll create a new code for GBOs in order
64 * to avoid tweaking and possibly breaking existing code. Moreover it will be probably possible to
65 * map the guest pages into the host R3 memory and access them directly.
66 */
67
68/* GBO descriptor. */
69typedef struct VMSVGAGBODESCRIPTOR
70{
71 RTGCPHYS GCPhys;
72 uint64_t cPages;
73} VMSVGAGBODESCRIPTOR, *PVMSVGAGBODESCRIPTOR;
74typedef VMSVGAGBODESCRIPTOR const *PCVMSVGAGBODESCRIPTOR;
75
76/* GBO.
77 */
78typedef struct VMSVGAGBO
79{
80 uint32_t u32Reserved;
81 uint32_t cTotalPages;
82 uint32_t cbTotal;
83 uint32_t cDescriptors;
84 PVMSVGAGBODESCRIPTOR paDescriptors;
85} VMSVGAGBO, *PVMSVGAGBO;
86typedef VMSVGAGBO const *PCVMSVGAGBO;
87
88#define VMSVGA_IS_GBO_CREATED(a_Gbo) ((a_Gbo)->paDescriptors != NULL)
89
90/* MOB is also a GBO.
91 */
92typedef struct VMSVGAMOB
93{
94 AVLU32NODECORE Core; /* Key is the mobid. */
95 RTLISTNODE nodeLRU;
96 VMSVGAGBO Gbo;
97} VMSVGAMOB, *PVMSVGAMOB;
98typedef VMSVGAMOB const *PCVMSVGAMOB;
99
100
101typedef struct VMSVGACMDBUF *PVMSVGACMDBUF;
102typedef struct VMSVGACMDBUFCTX *PVMSVGACMDBUFCTX;
103
104/* Command buffer. */
105typedef struct VMSVGACMDBUF
106{
107 RTLISTNODE nodeBuffer;
108 /* Context of the buffer. */
109 PVMSVGACMDBUFCTX pCmdBufCtx;
110 /* PA of the buffer. */
111 RTGCPHYS GCPhysCB;
112 /* A copy of the buffer header. */
113 SVGACBHeader hdr;
114 /* A copy of the commands. Size of the memory buffer is hdr.length */
115 void *pvCommands;
116} VMSVGACMDBUF;
117
118/* Command buffer context. */
119typedef struct VMSVGACMDBUFCTX
120{
121 /* Buffers submitted to processing for the FIFO thread. */
122 RTLISTANCHOR listSubmitted;
123 /* How many buffers in the queue. */
124 uint32_t cSubmitted;
125} VMSVGACMDBUFCTX;
126
127/**
128 * Internal SVGA ring-3 only state.
129 */
130typedef struct VMSVGAR3STATE
131{
132 PPDMDEVINS pDevIns; /* Stored here to use with PDMDevHlp* */
133 GMR *paGMR; // [VMSVGAState::cGMR]
134 struct
135 {
136 SVGAGuestPtr RT_UNTRUSTED_GUEST ptr;
137 uint32_t RT_UNTRUSTED_GUEST bytesPerLine;
138 SVGAGMRImageFormat RT_UNTRUSTED_GUEST format;
139 } GMRFB;
140 struct
141 {
142 bool fActive;
143 uint32_t xHotspot;
144 uint32_t yHotspot;
145 uint32_t width;
146 uint32_t height;
147 uint32_t cbData;
148 void *pData;
149 } Cursor;
150 SVGAColorBGRX colorAnnotation;
151
152# ifdef VMSVGA_USE_EMT_HALT_CODE
153 /** Number of EMTs in BusyDelayedEmts (quicker than scanning the set). */
154 uint32_t volatile cBusyDelayedEmts;
155 /** Set of EMTs that are */
156 VMCPUSET BusyDelayedEmts;
157# else
158 /** Number of EMTs waiting on hBusyDelayedEmts. */
159 uint32_t volatile cBusyDelayedEmts;
160 /** Semaphore that EMTs wait on when reading SVGA_REG_BUSY and the FIFO is
161 * busy (ugly). */
162 RTSEMEVENTMULTI hBusyDelayedEmts;
163# endif
164
165 /** Information about screens. */
166 VMSVGASCREENOBJECT aScreens[64];
167
168 /** Command buffer contexts. */
169 PVMSVGACMDBUFCTX apCmdBufCtxs[SVGA_CB_CONTEXT_MAX];
170 /** The special Device Context for synchronous commands. */
171 VMSVGACMDBUFCTX CmdBufCtxDC;
172 /** Flag which indicates that there are buffers to be processed. */
173 uint32_t volatile fCmdBuf;
174 /** Critical section for accessing the command buffer data. */
175 RTCRITSECT CritSectCmdBuf;
176
177 /** */
178 VMSVGAGBO GboOTableMob;
179 VMSVGAGBO GboOTableSurface;
180 VMSVGAGBO GboOTableContext;
181 VMSVGAGBO GboOTableShader;
182 VMSVGAGBO GboOTableScreenTarget;
183
184 /** Tree of guest's Memory OBjects. Key is mobid. */
185 AVLU32TREE MOBTree;
186 /** Least Recently Used list of MOBs.
187 * To unmap older MOBs when the guest exceeds SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB (SVGA_REG_GBOBJECT_MEM_SIZE_KB) value. */
188 RTLISTANCHOR MOBLRUList;
189
190 /** Tracks how much time we waste reading SVGA_REG_BUSY with a busy FIFO. */
191 STAMPROFILE StatBusyDelayEmts;
192
193 STAMPROFILE StatR3Cmd3dPresentProf;
194 STAMPROFILE StatR3Cmd3dDrawPrimitivesProf;
195 STAMPROFILE StatR3Cmd3dSurfaceDmaProf;
196 STAMPROFILE StatR3Cmd3dBlitSurfaceToScreenProf;
197 STAMCOUNTER StatR3CmdDefineGmr2;
198 STAMCOUNTER StatR3CmdDefineGmr2Free;
199 STAMCOUNTER StatR3CmdDefineGmr2Modify;
200 STAMCOUNTER StatR3CmdRemapGmr2;
201 STAMCOUNTER StatR3CmdRemapGmr2Modify;
202 STAMCOUNTER StatR3CmdInvalidCmd;
203 STAMCOUNTER StatR3CmdFence;
204 STAMCOUNTER StatR3CmdUpdate;
205 STAMCOUNTER StatR3CmdUpdateVerbose;
206 STAMCOUNTER StatR3CmdDefineCursor;
207 STAMCOUNTER StatR3CmdDefineAlphaCursor;
208 STAMCOUNTER StatR3CmdMoveCursor;
209 STAMCOUNTER StatR3CmdDisplayCursor;
210 STAMCOUNTER StatR3CmdRectFill;
211 STAMCOUNTER StatR3CmdRectCopy;
212 STAMCOUNTER StatR3CmdRectRopCopy;
213 STAMCOUNTER StatR3CmdEscape;
214 STAMCOUNTER StatR3CmdDefineScreen;
215 STAMCOUNTER StatR3CmdDestroyScreen;
216 STAMCOUNTER StatR3CmdDefineGmrFb;
217 STAMCOUNTER StatR3CmdBlitGmrFbToScreen;
218 STAMCOUNTER StatR3CmdBlitScreentoGmrFb;
219 STAMCOUNTER StatR3CmdAnnotationFill;
220 STAMCOUNTER StatR3CmdAnnotationCopy;
221 STAMCOUNTER StatR3Cmd3dSurfaceDefine;
222 STAMCOUNTER StatR3Cmd3dSurfaceDefineV2;
223 STAMCOUNTER StatR3Cmd3dSurfaceDestroy;
224 STAMCOUNTER StatR3Cmd3dSurfaceCopy;
225 STAMCOUNTER StatR3Cmd3dSurfaceStretchBlt;
226 STAMCOUNTER StatR3Cmd3dSurfaceDma;
227 STAMCOUNTER StatR3Cmd3dSurfaceScreen;
228 STAMCOUNTER StatR3Cmd3dContextDefine;
229 STAMCOUNTER StatR3Cmd3dContextDestroy;
230 STAMCOUNTER StatR3Cmd3dSetTransform;
231 STAMCOUNTER StatR3Cmd3dSetZRange;
232 STAMCOUNTER StatR3Cmd3dSetRenderState;
233 STAMCOUNTER StatR3Cmd3dSetRenderTarget;
234 STAMCOUNTER StatR3Cmd3dSetTextureState;
235 STAMCOUNTER StatR3Cmd3dSetMaterial;
236 STAMCOUNTER StatR3Cmd3dSetLightData;
237 STAMCOUNTER StatR3Cmd3dSetLightEnable;
238 STAMCOUNTER StatR3Cmd3dSetViewPort;
239 STAMCOUNTER StatR3Cmd3dSetClipPlane;
240 STAMCOUNTER StatR3Cmd3dClear;
241 STAMCOUNTER StatR3Cmd3dPresent;
242 STAMCOUNTER StatR3Cmd3dPresentReadBack;
243 STAMCOUNTER StatR3Cmd3dShaderDefine;
244 STAMCOUNTER StatR3Cmd3dShaderDestroy;
245 STAMCOUNTER StatR3Cmd3dSetShader;
246 STAMCOUNTER StatR3Cmd3dSetShaderConst;
247 STAMCOUNTER StatR3Cmd3dDrawPrimitives;
248 STAMCOUNTER StatR3Cmd3dSetScissorRect;
249 STAMCOUNTER StatR3Cmd3dBeginQuery;
250 STAMCOUNTER StatR3Cmd3dEndQuery;
251 STAMCOUNTER StatR3Cmd3dWaitForQuery;
252 STAMCOUNTER StatR3Cmd3dGenerateMipmaps;
253 STAMCOUNTER StatR3Cmd3dActivateSurface;
254 STAMCOUNTER StatR3Cmd3dDeactivateSurface;
255
256 STAMCOUNTER StatR3RegConfigDoneWr;
257 STAMCOUNTER StatR3RegGmrDescriptorWr;
258 STAMCOUNTER StatR3RegGmrDescriptorWrErrors;
259 STAMCOUNTER StatR3RegGmrDescriptorWrFree;
260
261 STAMCOUNTER StatFifoCommands;
262 STAMCOUNTER StatFifoErrors;
263 STAMCOUNTER StatFifoUnkCmds;
264 STAMCOUNTER StatFifoTodoTimeout;
265 STAMCOUNTER StatFifoTodoWoken;
266 STAMPROFILE StatFifoStalls;
267 STAMPROFILE StatFifoExtendedSleep;
268# ifdef VMSVGA_USE_FIFO_ACCESS_HANDLER
269 STAMCOUNTER StatFifoAccessHandler;
270# endif
271 STAMCOUNTER StatFifoCursorFetchAgain;
272 STAMCOUNTER StatFifoCursorNoChange;
273 STAMCOUNTER StatFifoCursorPosition;
274 STAMCOUNTER StatFifoCursorVisiblity;
275 STAMCOUNTER StatFifoWatchdogWakeUps;
276} VMSVGAR3STATE, *PVMSVGAR3STATE;
277
278
279/*********************************************************************************************************************************
280* Functions *
281*********************************************************************************************************************************/
282#ifdef DEBUG_GMR_ACCESS
283DECLCALLBACK(int) vmsvgaR3ResetGmrHandlers(PVGASTATE pThis);
284DECLCALLBACK(int) vmsvgaR3DeregisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId);
285#endif
286
287void vmsvgaR3ResetScreens(PVGASTATE pThis, PVGASTATECC pThisCC);
288
289int vmsvgaR3ChangeMode(PVGASTATE pThis, PVGASTATECC pThisCC);
290int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
291
292int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
293 uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
294 SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
295 uint32_t cbWidth, uint32_t cHeight);
296void vmsvgaR3GmrFree(PVGASTATECC pThisCC, uint32_t idGMR);
297
298void vmsvgaR3CmdUpdate(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdate const *pCmd);
299void vmsvgaR3CmdUpdateVerbose(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdateVerbose const *pCmd);
300void vmsvgaR3CmdRectFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectFill const *pCmd);
301void vmsvgaR3CmdRectCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectCopy const *pCmd);
302void vmsvgaR3CmdRectRopCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectRopCopy const *pCmd);
303void vmsvgaR3CmdDisplayCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDisplayCursor const *pCmd);
304void vmsvgaR3CmdMoveCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdMoveCursor const *pCmd);
305void vmsvgaR3CmdDefineCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineCursor const *pCmd);
306void vmsvgaR3CmdDefineAlphaCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineAlphaCursor const *pCmd);
307void vmsvgaR3CmdEscape(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdEscape const *pCmd);
308void vmsvgaR3CmdDefineScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineScreen const *pCmd);
309void vmsvgaR3CmdDestroyScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDestroyScreen const *pCmd);
310void vmsvgaR3CmdDefineGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMRFB const *pCmd);
311void vmsvgaR3CmdBlitGMRFBToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitGMRFBToScreen const *pCmd);
312void vmsvgaR3CmdBlitScreenToGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitScreenToGMRFB const *pCmd);
313void vmsvgaR3CmdAnnotationFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationFill const *pCmd);
314void vmsvgaR3CmdAnnotationCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationCopy const *pCmd);
315
316#ifdef VBOX_WITH_VMSVGA3D
317void vmsvgaR3CmdDefineGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMR2 const *pCmd);
318void vmsvgaR3CmdRemapGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRemapGMR2 const *pCmd);
319int vmsvgaR3Process3dCmd(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifo3dCmdId enmCmdId, uint32_t cbCmd, void const *pvCmd);
320#endif
321
322#if defined(LOG_ENABLED) || defined(VBOX_STRICT)
323const char *vmsvgaR3FifoCmdToString(uint32_t u32Cmd);
324#endif
325
326
327#endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA_internal_h */
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