VirtualBox

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

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

Devices/Graphics: Function tables for 3D backends. bugref:9830

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