VirtualBox

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

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

Devices/Graphics: a few DX commands. bugref:9830

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.6 KB
Line 
1/* $Id: DevVGA-SVGA-internal.h 88787 2021-04-29 15:51:13Z 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 */
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 VMSVGA3DBACKENDFUNCSMAP *pFuncsMap;
146 VMSVGA3DBACKENDFUNCSGBO *pFuncsGBO;
147 VMSVGA3DBACKENDFUNCSDX *pFuncsDX;
148# endif
149
150 /** Tracks how much time we waste reading SVGA_REG_BUSY with a busy FIFO. */
151 STAMPROFILE StatBusyDelayEmts;
152
153 STAMPROFILE StatR3Cmd3dPresentProf;
154 STAMPROFILE StatR3Cmd3dDrawPrimitivesProf;
155 STAMPROFILE StatR3Cmd3dSurfaceDmaProf;
156 STAMPROFILE StatR3Cmd3dBlitSurfaceToScreenProf;
157 STAMCOUNTER StatR3CmdDefineGmr2;
158 STAMCOUNTER StatR3CmdDefineGmr2Free;
159 STAMCOUNTER StatR3CmdDefineGmr2Modify;
160 STAMCOUNTER StatR3CmdRemapGmr2;
161 STAMCOUNTER StatR3CmdRemapGmr2Modify;
162 STAMCOUNTER StatR3CmdInvalidCmd;
163 STAMCOUNTER StatR3CmdFence;
164 STAMCOUNTER StatR3CmdUpdate;
165 STAMCOUNTER StatR3CmdUpdateVerbose;
166 STAMCOUNTER StatR3CmdDefineCursor;
167 STAMCOUNTER StatR3CmdDefineAlphaCursor;
168 STAMCOUNTER StatR3CmdMoveCursor;
169 STAMCOUNTER StatR3CmdDisplayCursor;
170 STAMCOUNTER StatR3CmdRectFill;
171 STAMCOUNTER StatR3CmdRectCopy;
172 STAMCOUNTER StatR3CmdRectRopCopy;
173 STAMCOUNTER StatR3CmdEscape;
174 STAMCOUNTER StatR3CmdDefineScreen;
175 STAMCOUNTER StatR3CmdDestroyScreen;
176 STAMCOUNTER StatR3CmdDefineGmrFb;
177 STAMCOUNTER StatR3CmdBlitGmrFbToScreen;
178 STAMCOUNTER StatR3CmdBlitScreentoGmrFb;
179 STAMCOUNTER StatR3CmdAnnotationFill;
180 STAMCOUNTER StatR3CmdAnnotationCopy;
181 STAMCOUNTER StatR3Cmd3dSurfaceDefine;
182 STAMCOUNTER StatR3Cmd3dSurfaceDefineV2;
183 STAMCOUNTER StatR3Cmd3dSurfaceDestroy;
184 STAMCOUNTER StatR3Cmd3dSurfaceCopy;
185 STAMCOUNTER StatR3Cmd3dSurfaceStretchBlt;
186 STAMCOUNTER StatR3Cmd3dSurfaceDma;
187 STAMCOUNTER StatR3Cmd3dSurfaceScreen;
188 STAMCOUNTER StatR3Cmd3dContextDefine;
189 STAMCOUNTER StatR3Cmd3dContextDestroy;
190 STAMCOUNTER StatR3Cmd3dSetTransform;
191 STAMCOUNTER StatR3Cmd3dSetZRange;
192 STAMCOUNTER StatR3Cmd3dSetRenderState;
193 STAMCOUNTER StatR3Cmd3dSetRenderTarget;
194 STAMCOUNTER StatR3Cmd3dSetTextureState;
195 STAMCOUNTER StatR3Cmd3dSetMaterial;
196 STAMCOUNTER StatR3Cmd3dSetLightData;
197 STAMCOUNTER StatR3Cmd3dSetLightEnable;
198 STAMCOUNTER StatR3Cmd3dSetViewPort;
199 STAMCOUNTER StatR3Cmd3dSetClipPlane;
200 STAMCOUNTER StatR3Cmd3dClear;
201 STAMCOUNTER StatR3Cmd3dPresent;
202 STAMCOUNTER StatR3Cmd3dPresentReadBack;
203 STAMCOUNTER StatR3Cmd3dShaderDefine;
204 STAMCOUNTER StatR3Cmd3dShaderDestroy;
205 STAMCOUNTER StatR3Cmd3dSetShader;
206 STAMCOUNTER StatR3Cmd3dSetShaderConst;
207 STAMCOUNTER StatR3Cmd3dDrawPrimitives;
208 STAMCOUNTER StatR3Cmd3dSetScissorRect;
209 STAMCOUNTER StatR3Cmd3dBeginQuery;
210 STAMCOUNTER StatR3Cmd3dEndQuery;
211 STAMCOUNTER StatR3Cmd3dWaitForQuery;
212 STAMCOUNTER StatR3Cmd3dGenerateMipmaps;
213 STAMCOUNTER StatR3Cmd3dActivateSurface;
214 STAMCOUNTER StatR3Cmd3dDeactivateSurface;
215
216 STAMCOUNTER StatR3RegConfigDoneWr;
217 STAMCOUNTER StatR3RegGmrDescriptorWr;
218 STAMCOUNTER StatR3RegGmrDescriptorWrErrors;
219 STAMCOUNTER StatR3RegGmrDescriptorWrFree;
220
221 STAMCOUNTER StatFifoCommands;
222 STAMCOUNTER StatFifoErrors;
223 STAMCOUNTER StatFifoUnkCmds;
224 STAMCOUNTER StatFifoTodoTimeout;
225 STAMCOUNTER StatFifoTodoWoken;
226 STAMPROFILE StatFifoStalls;
227 STAMPROFILE StatFifoExtendedSleep;
228# ifdef VMSVGA_USE_FIFO_ACCESS_HANDLER
229 STAMCOUNTER StatFifoAccessHandler;
230# endif
231 STAMCOUNTER StatFifoCursorFetchAgain;
232 STAMCOUNTER StatFifoCursorNoChange;
233 STAMCOUNTER StatFifoCursorPosition;
234 STAMCOUNTER StatFifoCursorVisiblity;
235 STAMCOUNTER StatFifoWatchdogWakeUps;
236} VMSVGAR3STATE, *PVMSVGAR3STATE;
237
238
239/*********************************************************************************************************************************
240* Functions *
241*********************************************************************************************************************************/
242#ifdef DEBUG_GMR_ACCESS
243DECLCALLBACK(int) vmsvgaR3ResetGmrHandlers(PVGASTATE pThis);
244DECLCALLBACK(int) vmsvgaR3DeregisterGmr(PPDMDEVINS pDevIns, uint32_t gmrId);
245#endif
246
247DECLCALLBACK(VBOXSTRICTRC) vmsvgaR3GboAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
248 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser);
249
250void vmsvgaR3ResetScreens(PVGASTATE pThis, PVGASTATECC pThisCC);
251
252int vmsvgaR3ChangeMode(PVGASTATE pThis, PVGASTATECC pThisCC);
253int vmsvgaR3UpdateScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen, int x, int y, int w, int h);
254
255int vmsvgaR3GmrTransfer(PVGASTATE pThis, PVGASTATECC pThisCC, const SVGA3dTransferType enmTransferType,
256 uint8_t *pbHstBuf, uint32_t cbHstBuf, uint32_t offHst, int32_t cbHstPitch,
257 SVGAGuestPtr gstPtr, uint32_t offGst, int32_t cbGstPitch,
258 uint32_t cbWidth, uint32_t cHeight);
259void vmsvgaR3GmrFree(PVGASTATECC pThisCC, uint32_t idGMR);
260
261void vmsvgaR3CmdUpdate(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdate const *pCmd);
262void vmsvgaR3CmdUpdateVerbose(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdUpdateVerbose const *pCmd);
263void vmsvgaR3CmdRectFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectFill const *pCmd);
264void vmsvgaR3CmdRectCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectCopy const *pCmd);
265void vmsvgaR3CmdRectRopCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRectRopCopy const *pCmd);
266void vmsvgaR3CmdDisplayCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDisplayCursor const *pCmd);
267void vmsvgaR3CmdMoveCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdMoveCursor const *pCmd);
268void vmsvgaR3CmdDefineCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineCursor const *pCmd);
269void vmsvgaR3CmdDefineAlphaCursor(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineAlphaCursor const *pCmd);
270void vmsvgaR3CmdEscape(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdEscape const *pCmd);
271void vmsvgaR3CmdDefineScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineScreen const *pCmd);
272void vmsvgaR3CmdDestroyScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDestroyScreen const *pCmd);
273void vmsvgaR3CmdDefineGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMRFB const *pCmd);
274void vmsvgaR3CmdBlitGMRFBToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitGMRFBToScreen const *pCmd);
275void vmsvgaR3CmdBlitScreenToGMRFB(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdBlitScreenToGMRFB const *pCmd);
276void vmsvgaR3CmdAnnotationFill(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationFill const *pCmd);
277void vmsvgaR3CmdAnnotationCopy(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdAnnotationCopy const *pCmd);
278
279#ifdef VBOX_WITH_VMSVGA3D
280void vmsvgaR3CmdDefineGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdDefineGMR2 const *pCmd);
281void vmsvgaR3CmdRemapGMR2(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAFifoCmdRemapGMR2 const *pCmd);
282int vmsvgaR3Process3dCmd(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idDXContext, SVGAFifo3dCmdId enmCmdId, uint32_t cbCmd, void const *pvCmd);
283#endif
284
285#if defined(LOG_ENABLED) || defined(VBOX_STRICT)
286const char *vmsvgaR3FifoCmdToString(uint32_t u32Cmd);
287#endif
288
289
290#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