VirtualBox

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

Last change on this file since 75111 was 69904, checked in by vboxsync, 7 years ago

Devices/Graphics: VMSVGA: take screen offset into account; saved state for occlusion query; increase saved state version.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.5 KB
Line 
1/* $Id: DevVGA-SVGA.h 69904 2017-12-01 20:29:24Z vboxsync $ */
2/** @file
3 * VMware SVGA device
4 */
5/*
6 * Copyright (C) 2013-2017 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___DevVGA_SVGA_h___
18#define ___DevVGA_SVGA_h___
19
20#ifndef VBOX_WITH_VMSVGA
21# error "VBOX_WITH_VMSVGA is not defined"
22#endif
23
24#include <VBox/vmm/pdmthread.h>
25
26
27/** Default FIFO size. */
28#define VMSVGA_FIFO_SIZE _2M
29/** The old FIFO size. */
30#define VMSVGA_FIFO_SIZE_OLD _128K
31
32/** Default scratch region size. */
33#define VMSVGA_SCRATCH_SIZE 0x100
34/** Surface memory available to the guest. */
35#define VMSVGA_SURFACE_SIZE (512*1024*1024)
36/** Maximum GMR pages. */
37#define VMSVGA_MAX_GMR_PAGES 0x100000
38/** Maximum nr of GMR ids. */
39#define VMSVGA_MAX_GMR_IDS _8K
40/** Maximum number of GMR descriptors. */
41#define VMSVGA_MAX_GMR_DESC_LOOP_COUNT VMSVGA_MAX_GMR_PAGES
42
43#define VMSVGA_VAL_UNINITIALIZED (unsigned)-1
44
45/** For validating X and width values.
46 * The code assumes it's at least an order of magnitude less than UINT32_MAX. */
47#define VMSVGA_MAX_X _1M
48/** For validating Y and height values.
49 * The code assumes it's at least an order of magnitude less than UINT32_MAX. */
50#define VMSVGA_MAX_Y _1M
51
52/* u32ActionFlags */
53#define VMSVGA_ACTION_CHANGEMODE_BIT 0
54#define VMSVGA_ACTION_CHANGEMODE RT_BIT(VMSVGA_ACTION_CHANGEMODE_BIT)
55
56
57#ifdef DEBUG
58/* Enable to log FIFO register accesses. */
59//# define DEBUG_FIFO_ACCESS
60/* Enable to log GMR page accesses. */
61//# define DEBUG_GMR_ACCESS
62#endif
63
64#define VMSVGA_FIFO_EXTCMD_NONE 0
65#define VMSVGA_FIFO_EXTCMD_TERMINATE 1
66#define VMSVGA_FIFO_EXTCMD_SAVESTATE 2
67#define VMSVGA_FIFO_EXTCMD_LOADSTATE 3
68#define VMSVGA_FIFO_EXTCMD_RESET 4
69#define VMSVGA_FIFO_EXTCMD_UPDATE_SURFACE_HEAP_BUFFERS 5
70
71/** Size of the region to backup when switching into svga mode. */
72#define VMSVGA_VGA_FB_BACKUP_SIZE _512K
73
74/** @def VMSVGA_WITH_VGA_FB_BACKUP
75 * Enables correct VGA MMIO read/write handling when VMSVGA is enabled. It
76 * is SLOW and probably not entirely right, but it helps with getting 3dmark
77 * output and other stuff. */
78#define VMSVGA_WITH_VGA_FB_BACKUP 1
79
80/** @def VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
81 * defined(VMSVGA_WITH_VGA_FB_BACKUP) && defined(IN_RING3) */
82#if (defined(VMSVGA_WITH_VGA_FB_BACKUP) && defined(IN_RING3)) || defined(DOXYGEN_RUNNING)
83# define VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3 1
84#else
85# undef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RING3
86#endif
87
88/** @def VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ
89 * defined(VMSVGA_WITH_VGA_FB_BACKUP) && !defined(IN_RING3) */
90#if (defined(VMSVGA_WITH_VGA_FB_BACKUP) && !defined(IN_RING3)) || defined(DOXYGEN_RUNNING)
91# define VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ 1
92#else
93# undef VMSVGA_WITH_VGA_FB_BACKUP_AND_IN_RZ
94#endif
95
96
97typedef struct
98{
99 PSSMHANDLE pSSM;
100 uint32_t uVersion;
101 uint32_t uPass;
102} VMSVGA_STATE_LOAD;
103typedef VMSVGA_STATE_LOAD *PVMSVGA_STATE_LOAD;
104
105/** Host screen viewport.
106 * (4th quadrant with negated Y values - usual Windows and X11 world view.) */
107typedef struct VMSVGAVIEWPORT
108{
109 uint32_t x; /**< x coordinate (left). */
110 uint32_t y; /**< y coordinate (top). */
111 uint32_t cx; /**< width. */
112 uint32_t cy; /**< height. */
113 /** Right side coordinate (exclusive). Same as x + cx. */
114 uint32_t xRight;
115 /** First quadrant low y coordinate.
116 * Same as y + cy - 1 in window coordinates. */
117 uint32_t yLowWC;
118 /** First quadrant high y coordinate (exclusive) - yLowWC + cy.
119 * Same as y - 1 in window coordinates. */
120 uint32_t yHighWC;
121 /** Alignment padding. */
122 uint32_t uAlignment;
123} VMSVGAVIEWPORT;
124
125/** Pointer to the private VMSVGA ring-3 state structure.
126 * @todo Still not entirely satisfired with the type name, but better than
127 * the previous lower/upper case only distinction. */
128typedef struct VMSVGAR3STATE *PVMSVGAR3STATE;
129/** Pointer to the private (implementation specific) VMSVGA3d state. */
130typedef struct VMSVGA3DSTATE *PVMSVGA3DSTATE;
131
132
133/**
134 * The VMSVGA device state.
135 *
136 * This instantatiated as VGASTATE::svga.
137 */
138typedef struct VMSVGAState
139{
140 /** The host window handle */
141 uint64_t u64HostWindowId;
142 /** The R3 FIFO pointer. */
143 R3PTRTYPE(uint32_t *) pFIFOR3;
144 /** The R0 FIFO pointer. */
145 R0PTRTYPE(uint32_t *) pFIFOR0;
146 /** R3 Opaque pointer to svga state. */
147 R3PTRTYPE(PVMSVGAR3STATE) pSvgaR3State;
148 /** R3 Opaque pointer to 3d state. */
149 R3PTRTYPE(PVMSVGA3DSTATE) p3dState;
150 /** The separate VGA frame buffer in svga mode.
151 * Unlike the the boch-based VGA device implementation, VMSVGA seems to have a
152 * separate frame buffer for VGA and allows concurrent use of both. The SVGA
153 * SDK is making use of this to do VGA text output while testing other things in
154 * SVGA mode, displaying the result by switching back to VGA text mode. So,
155 * when entering SVGA mode we copy the first part of the frame buffer here and
156 * direct VGA accesses here instead. It is copied back when leaving SVGA mode. */
157 R3PTRTYPE(uint8_t *) pbVgaFrameBufferR3;
158 /** R3 Opaque pointer to an external fifo cmd parameter. */
159 R3PTRTYPE(void * volatile) pvFIFOExtCmdParam;
160
161 /** Guest physical address of the FIFO memory range. */
162 RTGCPHYS GCPhysFIFO;
163 /** Size in bytes of the FIFO memory range.
164 * This may be smaller than cbFIFOConfig after restoring an old VM state. */
165 uint32_t cbFIFO;
166 /** The configured FIFO size. */
167 uint32_t cbFIFOConfig;
168 /** SVGA id. */
169 uint32_t u32SVGAId;
170 /** SVGA extensions enabled or not. */
171 uint32_t fEnabled;
172 /** SVGA memory area configured status. */
173 uint32_t fConfigured;
174 /** Device is busy handling FIFO requests (VMSVGA_BUSY_F_FIFO,
175 * VMSVGA_BUSY_F_EMT_FORCE). */
176 uint32_t volatile fBusy;
177#define VMSVGA_BUSY_F_FIFO RT_BIT_32(0) /**< The normal true/false busy FIFO bit. */
178#define VMSVGA_BUSY_F_EMT_FORCE RT_BIT_32(1) /**< Bit preventing race status flickering when EMT kicks the FIFO thread. */
179 /** Traces (dirty page detection) enabled or not. */
180 uint32_t fTraces;
181 /** Guest OS identifier. */
182 uint32_t u32GuestId;
183 /** Scratch region size (VMSVGAState::au32ScratchRegion). */
184 uint32_t cScratchRegion;
185 /** Irq status. */
186 uint32_t u32IrqStatus;
187 /** Irq mask. */
188 uint32_t u32IrqMask;
189 /** Pitch lock. */
190 uint32_t u32PitchLock;
191 /** Current GMR id. (SVGA_REG_GMR_ID) */
192 uint32_t u32CurrentGMRId;
193 /** Register caps. */
194 uint32_t u32RegCaps;
195 /** Physical address of command mmio range. */
196 RTIOPORT BasePort;
197 RTIOPORT Padding0;
198 /** Port io index register. */
199 uint32_t u32IndexReg;
200 /** The support driver session handle for use with FIFORequestSem. */
201 R3R0PTRTYPE(PSUPDRVSESSION) pSupDrvSession;
202 /** FIFO request semaphore. */
203 SUPSEMEVENT FIFORequestSem;
204 /** FIFO external command semaphore. */
205 R3PTRTYPE(RTSEMEVENT) FIFOExtCmdSem;
206 /** FIFO IO Thread. */
207 R3PTRTYPE(PPDMTHREAD) pFIFOIOThread;
208 uint32_t uWidth;
209 uint32_t uHeight;
210 uint32_t uBpp;
211 uint32_t cbScanline;
212 uint32_t uScreenOffset;
213 uint32_t uLastScreenOffset;
214 /** Maximum width supported. */
215 uint32_t u32MaxWidth;
216 /** Maximum height supported. */
217 uint32_t u32MaxHeight;
218 /** Viewport rectangle, i.e. what's currently visible of the target host
219 * window. This is usually (0,0)(uWidth,uHeight), but if the window is
220 * shrunk and scrolling applied, both the origin and size may differ. */
221 VMSVGAVIEWPORT viewport;
222 /** Action flags */
223 uint32_t u32ActionFlags;
224 /** SVGA 3d extensions enabled or not. */
225 bool f3DEnabled;
226 /** VRAM page monitoring enabled or not. */
227 bool fVRAMTracking;
228 /** External command to be executed in the FIFO thread. */
229 uint8_t volatile u8FIFOExtCommand;
230 /** Set by vmsvgaR3RunExtCmdOnFifoThread when it temporarily resumes the FIFO
231 * thread and does not want it do anything but the command. */
232 bool volatile fFifoExtCommandWakeup;
233#if defined(DEBUG_GMR_ACCESS) || defined(DEBUG_FIFO_ACCESS)
234 /** GMR debug access handler type handle. */
235 PGMPHYSHANDLERTYPE hGmrAccessHandlerType;
236 /** FIFO debug access handler type handle. */
237 PGMPHYSHANDLERTYPE hFifoAccessHandlerType;
238#endif
239 /** Number of GMRs. */
240 uint32_t cGMR;
241 uint32_t u32Padding1;
242
243 /** Scratch array.
244 * Putting this at the end since it's big it probably not . */
245 uint32_t au32ScratchRegion[VMSVGA_SCRATCH_SIZE];
246
247 STAMCOUNTER StatRegBitsPerPixelWr;
248 STAMCOUNTER StatRegBusyWr;
249 STAMCOUNTER StatRegCursorXxxxWr;
250 STAMCOUNTER StatRegDepthWr;
251 STAMCOUNTER StatRegDisplayHeightWr;
252 STAMCOUNTER StatRegDisplayIdWr;
253 STAMCOUNTER StatRegDisplayIsPrimaryWr;
254 STAMCOUNTER StatRegDisplayPositionXWr;
255 STAMCOUNTER StatRegDisplayPositionYWr;
256 STAMCOUNTER StatRegDisplayWidthWr;
257 STAMCOUNTER StatRegEnableWr;
258 STAMCOUNTER StatRegGmrIdWr;
259 STAMCOUNTER StatRegGuestIdWr;
260 STAMCOUNTER StatRegHeightWr;
261 STAMCOUNTER StatRegIdWr;
262 STAMCOUNTER StatRegIrqMaskWr;
263 STAMCOUNTER StatRegNumDisplaysWr;
264 STAMCOUNTER StatRegNumGuestDisplaysWr;
265 STAMCOUNTER StatRegPaletteWr;
266 STAMCOUNTER StatRegPitchLockWr;
267 STAMCOUNTER StatRegPseudoColorWr;
268 STAMCOUNTER StatRegReadOnlyWr;
269 STAMCOUNTER StatRegScratchWr;
270 STAMCOUNTER StatRegSyncWr;
271 STAMCOUNTER StatRegTopWr;
272 STAMCOUNTER StatRegTracesWr;
273 STAMCOUNTER StatRegUnknownWr;
274 STAMCOUNTER StatRegWidthWr;
275
276 STAMCOUNTER StatRegBitsPerPixelRd;
277 STAMCOUNTER StatRegBlueMaskRd;
278 STAMCOUNTER StatRegBusyRd;
279 STAMCOUNTER StatRegBytesPerLineRd;
280 STAMCOUNTER StatRegCapabilitesRd;
281 STAMCOUNTER StatRegConfigDoneRd;
282 STAMCOUNTER StatRegCursorXxxxRd;
283 STAMCOUNTER StatRegDepthRd;
284 STAMCOUNTER StatRegDisplayHeightRd;
285 STAMCOUNTER StatRegDisplayIdRd;
286 STAMCOUNTER StatRegDisplayIsPrimaryRd;
287 STAMCOUNTER StatRegDisplayPositionXRd;
288 STAMCOUNTER StatRegDisplayPositionYRd;
289 STAMCOUNTER StatRegDisplayWidthRd;
290 STAMCOUNTER StatRegEnableRd;
291 STAMCOUNTER StatRegFbOffsetRd;
292 STAMCOUNTER StatRegFbSizeRd;
293 STAMCOUNTER StatRegFbStartRd;
294 STAMCOUNTER StatRegGmrIdRd;
295 STAMCOUNTER StatRegGmrMaxDescriptorLengthRd;
296 STAMCOUNTER StatRegGmrMaxIdsRd;
297 STAMCOUNTER StatRegGmrsMaxPagesRd;
298 STAMCOUNTER StatRegGreenMaskRd;
299 STAMCOUNTER StatRegGuestIdRd;
300 STAMCOUNTER StatRegHeightRd;
301 STAMCOUNTER StatRegHostBitsPerPixelRd;
302 STAMCOUNTER StatRegIdRd;
303 STAMCOUNTER StatRegIrqMaskRd;
304 STAMCOUNTER StatRegMaxHeightRd;
305 STAMCOUNTER StatRegMaxWidthRd;
306 STAMCOUNTER StatRegMemorySizeRd;
307 STAMCOUNTER StatRegMemRegsRd;
308 STAMCOUNTER StatRegMemSizeRd;
309 STAMCOUNTER StatRegMemStartRd;
310 STAMCOUNTER StatRegNumDisplaysRd;
311 STAMCOUNTER StatRegNumGuestDisplaysRd;
312 STAMCOUNTER StatRegPaletteRd;
313 STAMCOUNTER StatRegPitchLockRd;
314 STAMCOUNTER StatRegPsuedoColorRd;
315 STAMCOUNTER StatRegRedMaskRd;
316 STAMCOUNTER StatRegScratchRd;
317 STAMCOUNTER StatRegScratchSizeRd;
318 STAMCOUNTER StatRegSyncRd;
319 STAMCOUNTER StatRegTopRd;
320 STAMCOUNTER StatRegTracesRd;
321 STAMCOUNTER StatRegUnknownRd;
322 STAMCOUNTER StatRegVramSizeRd;
323 STAMCOUNTER StatRegWidthRd;
324 STAMCOUNTER StatRegWriteOnlyRd;
325} VMSVGAState;
326
327
328DECLCALLBACK(int) vmsvgaR3IORegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
329 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType);
330
331DECLCALLBACK(void) vmsvgaPortSetViewport(PPDMIDISPLAYPORT pInterface, uint32_t uScreenId,
332 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
333
334int vmsvgaInit(PPDMDEVINS pDevIns);
335int vmsvgaReset(PPDMDEVINS pDevIns);
336int vmsvgaDestruct(PPDMDEVINS pDevIns);
337int vmsvgaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
338int vmsvgaLoadDone(PPDMDEVINS pDevIns);
339int vmsvgaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
340DECLCALLBACK(void) vmsvgaR3PowerOn(PPDMDEVINS pDevIns);
341DECLCALLBACK(void) vmsvgaR3PowerOff(PPDMDEVINS pDevIns);
342
343#endif
344
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