VirtualBox

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

Last change on this file since 100157 was 99688, checked in by vboxsync, 19 months ago

Devices/Graphics: common code for 3D backend initialization and termination. bugref:9830

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