VirtualBox

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

Last change on this file since 103914 was 102520, checked in by vboxsync, 10 months ago

Devices/Graphics: planar textures; video commands. bugref:10529

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