VirtualBox

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

Last change on this file since 95818 was 94101, checked in by vboxsync, 3 years ago

Devices/Graphics: initial code for single device mode, enabled for non Windows hosts: bugref:9830

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.9 KB
Line 
1/* $Id: DevVGA-SVGA-internal.h 94101 2022-03-06 17:43:23Z vboxsync $ */
2/** @file
3 * VMWare SVGA device - internal header for DevVGA-SVGA* source files.
4 */
5
6/*
7 * Copyright (C) 2013-2022 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 */
38typedef struct
39{
40 RTGCPHYS GCPhys;
41 uint64_t numPages;
42} VMSVGAGMRDESCRIPTOR, *PVMSVGAGMRDESCRIPTOR;
43
44/**
45 * GMR slot
46 */
47typedef struct
48{
49 uint32_t cMaxPages;
50 uint32_t cbTotal;
51 uint32_t numDescriptors;
52 PVMSVGAGMRDESCRIPTOR paDesc;
53} GMR, *PGMR;
54
55
56typedef struct VMSVGACMDBUF *PVMSVGACMDBUF;
57typedef struct VMSVGACMDBUFCTX *PVMSVGACMDBUFCTX;
58
59/* Command buffer. */
60typedef struct VMSVGACMDBUF
61{
62 RTLISTNODE nodeBuffer;
63 /* Context of the buffer. */
64 PVMSVGACMDBUFCTX pCmdBufCtx;
65 /* PA of the buffer. */
66 RTGCPHYS GCPhysCB;
67 /* A copy of the buffer header. */
68 SVGACBHeader hdr;
69 /* A copy of the commands. Size of the memory buffer is hdr.length */
70 void *pvCommands;
71} VMSVGACMDBUF;
72
73/* Command buffer context. */
74typedef struct VMSVGACMDBUFCTX
75{
76 /* Buffers submitted to processing for the FIFO thread. */
77 RTLISTANCHOR listSubmitted;
78 /* How many buffers in the queue. */
79 uint32_t cSubmitted;
80} VMSVGACMDBUFCTX;
81
82/**
83 * Internal SVGA ring-3 only state.
84 */
85typedef struct VMSVGAR3STATE
86{
87 PPDMDEVINS pDevIns; /* Stored here to use with PDMDevHlp* */
88 GMR *paGMR; // [VMSVGAState::cGMR]
89 struct
90 {
91 SVGAGuestPtr RT_UNTRUSTED_GUEST ptr;
92 uint32_t RT_UNTRUSTED_GUEST bytesPerLine;
93 SVGAGMRImageFormat RT_UNTRUSTED_GUEST format;
94 } GMRFB;
95 struct
96 {
97 bool fActive;
98 uint32_t xHotspot;
99 uint32_t yHotspot;
100 uint32_t width;
101 uint32_t height;
102 uint32_t cbData;
103 void *pData;
104 } Cursor;
105 SVGAColorBGRX colorAnnotation;
106
107# ifdef VMSVGA_USE_EMT_HALT_CODE
108 /** Number of EMTs in BusyDelayedEmts (quicker than scanning the set). */
109 uint32_t volatile cBusyDelayedEmts;
110 /** Set of EMTs that are */
111 VMCPUSET BusyDelayedEmts;
112# else
113 /** Number of EMTs waiting on hBusyDelayedEmts. */
114 uint32_t volatile cBusyDelayedEmts;
115 /** Semaphore that EMTs wait on when reading SVGA_REG_BUSY and the FIFO is
116 * busy (ugly). */
117 RTSEMEVENTMULTI hBusyDelayedEmts;
118# endif
119
120 /** Information about screens. */
121 VMSVGASCREENOBJECT aScreens[64];
122
123 /** Command buffer contexts. */
124 PVMSVGACMDBUFCTX apCmdBufCtxs[SVGA_CB_CONTEXT_MAX];
125 /** The special Device Context for synchronous commands. */
126 VMSVGACMDBUFCTX CmdBufCtxDC;
127 /** Flag which indicates that there are buffers to be processed. */
128 uint32_t volatile fCmdBuf;
129 /** Critical section for accessing the command buffer data. */
130 RTCRITSECT CritSectCmdBuf;
131
132 /** Write protected GBOs (OTables) access handler type handle. */
133 PGMPHYSHANDLERTYPE hGboAccessHandlerType;
134
135 /** */
136 VMSVGAGBO aGboOTables[SVGA_OTABLE_MAX];
137
138 /** Tree of guest's Memory OBjects. Key is mobid. */
139 AVLU32TREE MOBTree;
140 /** Least Recently Used list of MOBs.
141 * To unmap older MOBs when the guest exceeds SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB (SVGA_REG_GBOBJECT_MEM_SIZE_KB) value. */
142 RTLISTANCHOR MOBLRUList;
143
144# ifdef VBOX_WITH_VMSVGA3D
145# ifdef VMSVGA3D_DX
146 /** DX context of the currently processed command buffer */
147 uint32_t idDXContextCurrent;
148 uint32_t u32Reserved;
149# endif
150 VMSVGA3DBACKENDFUNCS3D *pFuncs3D;
151 VMSVGA3DBACKENDFUNCSVGPU9 *pFuncsVGPU9;
152 VMSVGA3DBACKENDFUNCSMAP *pFuncsMap;
153 VMSVGA3DBACKENDFUNCSGBO *pFuncsGBO;
154 VMSVGA3DBACKENDFUNCSDX *pFuncsDX;
155# endif
156
157 /** Tracks how much time we waste reading SVGA_REG_BUSY with a busy FIFO. */
158 STAMPROFILE StatBusyDelayEmts;
159
160 STAMPROFILE StatR3Cmd3dPresentProf;
161 STAMPROFILE StatR3Cmd3dDrawPrimitivesProf;
162 STAMPROFILE StatR3Cmd3dSurfaceDmaProf;
163 STAMPROFILE StatR3Cmd3dBlitSurfaceToScreenProf;
164 STAMCOUNTER StatR3CmdDefineGmr2;
165 STAMCOUNTER StatR3CmdDefineGmr2Free;
166 STAMCOUNTER StatR3CmdDefineGmr2Modify;
167 STAMCOUNTER StatR3CmdRemapGmr2;
168 STAMCOUNTER StatR3CmdRemapGmr2Modify;
169 STAMCOUNTER StatR3CmdInvalidCmd;
170 STAMCOUNTER StatR3CmdFence;
171 STAMCOUNTER StatR3CmdUpdate;
172 STAMCOUNTER StatR3CmdUpdateVerbose;
173 STAMCOUNTER StatR3CmdDefineCursor;
174 STAMCOUNTER StatR3CmdDefineAlphaCursor;
175 STAMCOUNTER StatR3CmdMoveCursor;
176 STAMCOUNTER StatR3CmdDisplayCursor;
177 STAMCOUNTER StatR3CmdRectFill;
178 STAMCOUNTER StatR3CmdRectCopy;
179 STAMCOUNTER StatR3CmdRectRopCopy;
180 STAMCOUNTER StatR3CmdEscape;
181 STAMCOUNTER StatR3CmdDefineScreen;
182 STAMCOUNTER StatR3CmdDestroyScreen;
183 STAMCOUNTER StatR3CmdDefineGmrFb;
184 STAMCOUNTER StatR3CmdBlitGmrFbToScreen;
185 STAMCOUNTER StatR3CmdBlitScreentoGmrFb;
186 STAMCOUNTER StatR3CmdAnnotationFill;
187 STAMCOUNTER StatR3CmdAnnotationCopy;
188 STAMCOUNTER StatR3Cmd3dSurfaceDefine;
189 STAMCOUNTER StatR3Cmd3dSurfaceDefineV2;
190 STAMCOUNTER StatR3Cmd3dSurfaceDestroy;
191 STAMCOUNTER StatR3Cmd3dSurfaceCopy;
192 STAMCOUNTER StatR3Cmd3dSurfaceStretchBlt;
193 STAMCOUNTER StatR3Cmd3dSurfaceDma;
194 STAMCOUNTER StatR3Cmd3dSurfaceScreen;
195 STAMCOUNTER StatR3Cmd3dContextDefine;
196 STAMCOUNTER StatR3Cmd3dContextDestroy;
197 STAMCOUNTER StatR3Cmd3dSetTransform;
198 STAMCOUNTER StatR3Cmd3dSetZRange;
199 STAMCOUNTER StatR3Cmd3dSetRenderState;
200 STAMCOUNTER StatR3Cmd3dSetRenderTarget;
201 STAMCOUNTER StatR3Cmd3dSetTextureState;
202 STAMCOUNTER StatR3Cmd3dSetMaterial;
203 STAMCOUNTER StatR3Cmd3dSetLightData;
204 STAMCOUNTER StatR3Cmd3dSetLightEnable;
205 STAMCOUNTER StatR3Cmd3dSetViewPort;
206 STAMCOUNTER StatR3Cmd3dSetClipPlane;
207 STAMCOUNTER StatR3Cmd3dClear;
208 STAMCOUNTER StatR3Cmd3dPresent;
209 STAMCOUNTER StatR3Cmd3dPresentReadBack;
210 STAMCOUNTER StatR3Cmd3dShaderDefine;
211 STAMCOUNTER StatR3Cmd3dShaderDestroy;
212 STAMCOUNTER StatR3Cmd3dSetShader;
213 STAMCOUNTER StatR3Cmd3dSetShaderConst;
214 STAMCOUNTER StatR3Cmd3dDrawPrimitives;
215 STAMCOUNTER StatR3Cmd3dSetScissorRect;
216 STAMCOUNTER StatR3Cmd3dBeginQuery;
217 STAMCOUNTER StatR3Cmd3dEndQuery;
218 STAMCOUNTER StatR3Cmd3dWaitForQuery;
219 STAMCOUNTER StatR3Cmd3dGenerateMipmaps;
220 STAMCOUNTER StatR3Cmd3dActivateSurface;
221 STAMCOUNTER StatR3Cmd3dDeactivateSurface;
222
223 STAMCOUNTER StatR3RegConfigDoneWr;
224 STAMCOUNTER StatR3RegGmrDescriptorWr;
225 STAMCOUNTER StatR3RegGmrDescriptorWrErrors;
226 STAMCOUNTER StatR3RegGmrDescriptorWrFree;
227
228 STAMCOUNTER StatFifoCommands;
229 STAMCOUNTER StatFifoErrors;
230 STAMCOUNTER StatFifoUnkCmds;
231 STAMCOUNTER StatFifoTodoTimeout;
232 STAMCOUNTER StatFifoTodoWoken;
233 STAMPROFILE StatFifoStalls;
234 STAMPROFILE StatFifoExtendedSleep;
235# ifdef VMSVGA_USE_FIFO_ACCESS_HANDLER
236 STAMCOUNTER StatFifoAccessHandler;
237# endif
238 STAMCOUNTER StatFifoCursorFetchAgain;
239 STAMCOUNTER StatFifoCursorNoChange;
240 STAMCOUNTER StatFifoCursorPosition;
241 STAMCOUNTER StatFifoCursorVisiblity;
242 STAMCOUNTER StatFifoWatchdogWakeUps;
243} VMSVGAR3STATE, *PVMSVGAR3STATE;
244
245
246/*********************************************************************************************************************************
247* Functions *
248*********************************************************************************************************************************/
249#ifdef DEBUG_GMR_ACCESS
250DECLCALLBACK(int) vmsvgaR3ResetGmrHandlers(PVGASTATE pThis);
251DECLCALLBACK(int) vmsvgaR3DeregisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId);
252#endif
253
254DECLCALLBACK(VBOXSTRICTRC) vmsvgaR3GboAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
255 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser);
256
257void vmsvgaR3ResetScreens(PVGASTATE pThis, PVGASTATECC pThisCC);
258
259int vmsvgaR3ChangeMode(PVGASTATE pThis, PVGASTATECC pThisCC);
260int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
261
262int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
263 uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
264 SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
265 uint32_t cbWidth, uint32_t cHeight);
266void vmsvgaR3GmrFree(PVGASTATECC pThisCC, uint32_t idGMR);
267
268void vmsvgaR3CmdUpdate(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdate const *pCmd);
269void vmsvgaR3CmdUpdateVerbose(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdateVerbose const *pCmd);
270void vmsvgaR3CmdRectFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectFill const *pCmd);
271void vmsvgaR3CmdRectCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectCopy const *pCmd);
272void vmsvgaR3CmdRectRopCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectRopCopy const *pCmd);
273void vmsvgaR3CmdDisplayCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDisplayCursor const *pCmd);
274void vmsvgaR3CmdMoveCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdMoveCursor const *pCmd);
275void vmsvgaR3CmdDefineCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineCursor const *pCmd);
276void vmsvgaR3CmdDefineAlphaCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineAlphaCursor const *pCmd);
277void vmsvgaR3CmdEscape(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdEscape const *pCmd);
278void vmsvgaR3CmdDefineScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineScreen const *pCmd);
279void vmsvgaR3CmdDestroyScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDestroyScreen const *pCmd);
280void vmsvgaR3CmdDefineGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMRFB const *pCmd);
281void vmsvgaR3CmdBlitGMRFBToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitGMRFBToScreen const *pCmd);
282void vmsvgaR3CmdBlitScreenToGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitScreenToGMRFB const *pCmd);
283void vmsvgaR3CmdAnnotationFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationFill const *pCmd);
284void vmsvgaR3CmdAnnotationCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationCopy const *pCmd);
285
286#ifdef VBOX_WITH_VMSVGA3D
287void vmsvgaR3CmdDefineGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMR2 const *pCmd);
288void vmsvgaR3CmdRemapGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRemapGMR2 const *pCmd);
289int vmsvgaR3Process3dCmd(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idDXContext, SVGAFifo3dCmdId enmCmdId, uint32_t cbCmd, void const *pvCmd);
290#endif
291
292#if defined(LOG_ENABLED) || defined(VBOX_STRICT)
293const char *vmsvgaR3FifoCmdToString(uint32_t u32Cmd);
294#endif
295
296
297#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