VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h

Last change on this file was 99990, checked in by vboxsync, 13 months ago

WDDM: deferred mob destruction. bugref:9845

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 KB
Line 
1/* $Id: VBoxMPTypes.h 99990 2023-05-26 13:39:41Z vboxsync $ */
2/** @file
3 * VBox WDDM Miniport driver
4 */
5
6/*
7 * Copyright (C) 2011-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 GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPTypes_h
29#define GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPTypes_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34typedef struct _VBOXMP_DEVEXT *PVBOXMP_DEVEXT;
35typedef struct VBOXWDDM_CONTEXT *PVBOXWDDM_CONTEXT;
36typedef struct VBOXWDDM_ALLOCATION *PVBOXWDDM_ALLOCATION;
37
38#include "common/wddm/VBoxMPIf.h"
39#include "VBoxMPMisc.h"
40#include "VBoxMPCm.h"
41#include "VBoxMPVdma.h"
42#include "VBoxMPShgsmi.h"
43#include "VBoxMPVbva.h"
44#include "VBoxMPSa.h"
45#include "VBoxMPVModes.h"
46
47#ifdef DEBUG_sunlover
48#define DEBUG_BREAKPOINT_TEST() do { ASMBreakpoint(); } while (0)
49#else
50#define DEBUG_BREAKPOINT_TEST() do { } while (0)
51#endif
52
53#if 0
54#include <iprt/avl.h>
55#endif
56
57#define VBOXWDDM_DEFAULT_REFRESH_RATE 60
58
59#ifndef VBOX_WITH_VMSVGA
60/* one page size */
61#define VBOXWDDM_C_DMA_BUFFER_SIZE 0x1000
62#define VBOXWDDM_C_DMA_PRIVATEDATA_SIZE 0x4000
63#else
64/* A small buffer fills quickly by commands. A large buffer does not allow effective preemption.
65 * 16K is an aritrary value, which allows to batch enough commands, but not too many.
66 */
67#define VBOXWDDM_C_DMA_BUFFER_SIZE 0x4000
68/* Private data is rather small, so one page is more than enough. */
69#define VBOXWDDM_C_DMA_PRIVATEDATA_SIZE 0x1000
70#endif
71#define VBOXWDDM_C_ALLOC_LIST_SIZE 0xc00
72#define VBOXWDDM_C_PATH_LOCATION_LIST_SIZE 0xc00
73
74#ifndef VBOX_WITH_VMSVGA
75#define VBOXWDDM_C_POINTER_MAX_WIDTH 64
76#define VBOXWDDM_C_POINTER_MAX_HEIGHT 64
77#else
78#define VBOXWDDM_C_POINTER_MAX_WIDTH 256
79#define VBOXWDDM_C_POINTER_MAX_HEIGHT 256
80#define VBOXWDDM_C_POINTER_MAX_WIDTH_LEGACY 64
81#define VBOXWDDM_C_POINTER_MAX_HEIGHT_LEGACY 64
82#endif
83
84#define VBOXWDDM_DUMMY_DMABUFFER_SIZE 4
85
86#define VBOXWDDM_POINTER_ATTRIBUTES_SIZE VBOXWDDM_ROUNDBOUND( \
87 VBOXWDDM_ROUNDBOUND( sizeof (VIDEO_POINTER_ATTRIBUTES), 4 ) + \
88 VBOXWDDM_ROUNDBOUND(VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT * 4, 4) + \
89 VBOXWDDM_ROUNDBOUND((VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT + 7) >> 3, 4) \
90 , 8)
91
92typedef struct _VBOXWDDM_POINTER_INFO
93{
94 uint32_t xPos;
95 uint32_t yPos;
96 union
97 {
98 VIDEO_POINTER_ATTRIBUTES data;
99 char buffer[VBOXWDDM_POINTER_ATTRIBUTES_SIZE];
100 } Attributes;
101} VBOXWDDM_POINTER_INFO, *PVBOXWDDM_POINTER_INFO;
102
103typedef struct _VBOXWDDM_GLOBAL_POINTER_INFO
104{
105 uint32_t iLastReportedScreen;
106} VBOXWDDM_GLOBAL_POINTER_INFO, *PVBOXWDDM_GLOBAL_POINTER_INFO;
107
108#ifdef VBOX_WITH_VIDEOHWACCEL
109typedef struct VBOXWDDM_VHWA
110{
111 VBOXVHWA_INFO Settings;
112 volatile uint32_t cOverlaysCreated;
113} VBOXWDDM_VHWA;
114#endif
115
116typedef struct VBOXWDDM_ADDR
117{
118 /* if SegmentId == NULL - the sysmem data is presented with pvMem */
119 UINT SegmentId;
120 union {
121 VBOXVIDEOOFFSET offVram;
122 void * pvMem;
123 };
124} VBOXWDDM_ADDR, *PVBOXWDDM_ADDR;
125
126typedef struct VBOXWDDM_ALLOC_DATA
127{
128 VBOXWDDM_SURFACE_DESC SurfDesc;
129 VBOXWDDM_ADDR Addr;
130 uint32_t hostID;
131 uint32_t cHostIDRefs;
132} VBOXWDDM_ALLOC_DATA, *PVBOXWDDM_ALLOC_DATA;
133
134#define VBOXWDDM_HGSYNC_F_SYNCED_DIMENSIONS 0x01
135#define VBOXWDDM_HGSYNC_F_SYNCED_LOCATION 0x02
136#define VBOXWDDM_HGSYNC_F_SYNCED_VISIBILITY 0x04
137#define VBOXWDDM_HGSYNC_F_SYNCED_TOPOLOGY 0x08
138#define VBOXWDDM_HGSYNC_F_SYNCED_ALL (VBOXWDDM_HGSYNC_F_SYNCED_DIMENSIONS | VBOXWDDM_HGSYNC_F_SYNCED_LOCATION | VBOXWDDM_HGSYNC_F_SYNCED_VISIBILITY | VBOXWDDM_HGSYNC_F_SYNCED_TOPOLOGY)
139#define VBOXWDDM_HGSYNC_F_CHANGED_LOCATION_ONLY (VBOXWDDM_HGSYNC_F_SYNCED_ALL & ~VBOXWDDM_HGSYNC_F_SYNCED_LOCATION)
140#define VBOXWDDM_HGSYNC_F_CHANGED_TOPOLOGY_ONLY (VBOXWDDM_HGSYNC_F_SYNCED_ALL & ~VBOXWDDM_HGSYNC_F_SYNCED_TOPOLOGY)
141
142typedef struct VBOXWDDM_SOURCE
143{
144 struct VBOXWDDM_ALLOCATION * pPrimaryAllocation;
145 VBOXWDDM_ALLOC_DATA AllocData;
146 uint8_t u8SyncState;
147 BOOLEAN fTargetsReported;
148 BOOLEAN bVisible;
149 BOOLEAN bBlankedByPowerOff;
150 VBOXVBVAINFO Vbva;
151#ifdef VBOX_WITH_VIDEOHWACCEL
152 /* @todo: in our case this seems more like a target property,
153 * but keep it here for now */
154 VBOXWDDM_VHWA Vhwa;
155 volatile uint32_t cOverlays;
156 LIST_ENTRY OverlayList;
157 KSPIN_LOCK OverlayListLock;
158#endif
159 KSPIN_LOCK AllocationLock;
160 POINT VScreenPos;
161 VBOXWDDM_POINTER_INFO PointerInfo;
162 uint32_t cTargets;
163 VBOXCMDVBVA_SCREENMAP_DECL(uint32_t, aTargetMap);
164} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
165
166typedef struct VBOXWDDM_TARGET
167{
168 RTRECTSIZE Size;
169 uint32_t u32Id;
170 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
171 /* since there coul be multiple state changes on auto-resize,
172 * we pend notifying host to avoid flickering */
173 uint8_t u8SyncState;
174 bool fConnected;
175 bool fConfigured;
176 bool fBlankedByPowerOff;
177
178 /* Whether the host has disabled the virtual screen. */
179 /** @todo This should be merged with fConnected. */
180 bool fDisabled;
181} VBOXWDDM_TARGET, *PVBOXWDDM_TARGET;
182
183/* allocation */
184//#define VBOXWDDM_ALLOCATIONINDEX_VOID (~0U)
185typedef struct VBOXWDDM_ALLOCATION
186{
187 VBOXWDDM_ALLOC_TYPE enmType;
188 D3DDDI_RESOURCEFLAGS fRcFlags;
189#ifdef VBOX_WITH_VIDEOHWACCEL
190 VBOXVHWA_SURFHANDLE hHostHandle;
191#endif
192 BOOLEAN fDeleted;
193 BOOLEAN bVisible;
194 BOOLEAN bAssigned;
195#ifdef DEBUG
196 /* current for shared rc handling assumes that once resource has no opens, it can not be openned agaion */
197 BOOLEAN fAssumedDeletion;
198#endif
199 VBOXWDDM_ALLOC_DATA AllocData;
200 struct VBOXWDDM_RESOURCE *pResource;
201 /* to return to the Runtime on DxgkDdiCreateAllocation */
202 DXGK_ALLOCATIONUSAGEHINT UsageHint;
203 uint32_t iIndex;
204 uint32_t cOpens;
205 KSPIN_LOCK OpenLock;
206 LIST_ENTRY OpenList;
207 /* helps tracking when to release wine shared resource */
208 uint32_t cShRcRefs;
209 HANDLE hSharedHandle;
210#if 0
211 AVLPVNODECORE ShRcTreeEntry;
212#endif
213 VBOXUHGSMI_BUFFER_TYPE_FLAGS fUhgsmiType;
214 int CurVidPnSourceId; /* Source index if used for a source, otherwise -1. */
215#ifdef VBOX_WITH_VMSVGA3D_DX
216 /* Direct3D driver data for .enmType == VBOXWDDM_ALLOC_TYPE_D3D. */
217 struct
218 {
219 VBOXDXALLOCATIONDESC desc;
220 uint32_t sid; /* For surfaces. */
221 uint32_t mobid; /* For surfaces and shaders. */
222 uint32_t SegmentId; /* Segment of the allocation. */
223 union
224 {
225 PMDL pMDL; /* Guest backing for aperture segment 2. */
226 struct
227 {
228 struct VMSVGAMOB *pMob; /* Mob for the pages (including RTR0MEMOBJ). */
229 } gb; /** @todo remove the struct */
230 };
231 } dx;
232#endif /* VBOX_WITH_VMSVGA3D_DX */
233} VBOXWDDM_ALLOCATION, *PVBOXWDDM_ALLOCATION;
234
235typedef struct VBOXWDDM_RESOURCE
236{
237 VBOXWDDMDISP_RESOURCE_FLAGS fFlags;
238 volatile uint32_t cRefs;
239 VBOXWDDM_RC_DESC RcDesc;
240 BOOLEAN fDeleted;
241 uint32_t cAllocations;
242 VBOXWDDM_ALLOCATION aAllocations[1];
243} VBOXWDDM_RESOURCE, *PVBOXWDDM_RESOURCE;
244
245typedef struct VBOXWDDM_OVERLAY
246{
247 LIST_ENTRY ListEntry;
248 PVBOXMP_DEVEXT pDevExt;
249 PVBOXWDDM_RESOURCE pResource;
250 PVBOXWDDM_ALLOCATION pCurentAlloc;
251 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
252 RECT DstRect;
253} VBOXWDDM_OVERLAY, *PVBOXWDDM_OVERLAY;
254
255typedef enum
256{
257 VBOXWDDM_DEVICE_TYPE_UNDEFINED = 0,
258 VBOXWDDM_DEVICE_TYPE_SYSTEM
259} VBOXWDDM_DEVICE_TYPE;
260
261typedef struct VBOXWDDM_DEVICE
262{
263 PVBOXMP_DEVEXT pAdapter; /* Adapder info */
264 HANDLE hDevice; /* handle passed to CreateDevice */
265 VBOXWDDM_DEVICE_TYPE enmType; /* device creation flags passed to DxgkDdiCreateDevice, not sure we need it */
266} VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE;
267
268typedef enum
269{
270 VBOXWDDM_OBJSTATE_TYPE_UNKNOWN = 0,
271 VBOXWDDM_OBJSTATE_TYPE_INITIALIZED,
272 VBOXWDDM_OBJSTATE_TYPE_TERMINATED
273} VBOXWDDM_OBJSTATE_TYPE;
274
275#define VBOXWDDM_INVALID_COORD ((LONG)((~0UL) >> 1))
276
277#ifdef VBOX_WITH_VMSVGA
278struct VMSVGACONTEXT;
279#endif
280
281typedef struct VBOXWDDM_CONTEXT
282{
283 struct VBOXWDDM_DEVICE * pDevice;
284 HANDLE hContext;
285 VBOXWDDM_CONTEXT_TYPE enmType;
286 UINT NodeOrdinal;
287 UINT EngineAffinity;
288 BOOLEAN fRenderFromShadowDisabled;
289 VBOXVIDEOCM_CTX CmContext;
290 VBOXVIDEOCM_ALLOC_CONTEXT AllocContext;
291#ifdef VBOX_WITH_VMSVGA
292 struct VMSVGACONTEXT *pSvgaContext;
293#endif
294} VBOXWDDM_CONTEXT, *PVBOXWDDM_CONTEXT;
295
296typedef struct VBOXWDDM_OPENALLOCATION
297{
298 LIST_ENTRY ListEntry;
299 D3DKMT_HANDLE hAllocation;
300 PVBOXWDDM_ALLOCATION pAllocation;
301 PVBOXWDDM_DEVICE pDevice;
302 uint32_t cShRcRefs;
303 uint32_t cOpens;
304 uint32_t cHostIDRefs;
305} VBOXWDDM_OPENALLOCATION, *PVBOXWDDM_OPENALLOCATION;
306
307#define VBOX_VMODES_MAX_COUNT 128
308
309typedef struct VBOX_VMODES
310{
311 uint32_t cTargets;
312 CR_SORTARRAY aTargets[VBOX_VIDEO_MAX_SCREENS];
313} VBOX_VMODES;
314
315typedef struct VBOXWDDM_VMODES
316{
317 VBOX_VMODES Modes;
318 /* note that we not use array indices to indentify modes, because indices may change due to element removal */
319 uint64_t aTransientResolutions[VBOX_VIDEO_MAX_SCREENS];
320 uint64_t aPendingRemoveCurResolutions[VBOX_VIDEO_MAX_SCREENS];
321} VBOXWDDM_VMODES;
322
323typedef struct VBOXVDMADDI_CMD_QUEUE
324{
325 volatile uint32_t cQueuedCmds;
326 LIST_ENTRY CmdQueue;
327} VBOXVDMADDI_CMD_QUEUE, *PVBOXVDMADDI_CMD_QUEUE;
328
329typedef struct VBOXVDMADDI_NODE
330{
331 VBOXVDMADDI_CMD_QUEUE CmdQueue;
332 UINT uLastCompletedFenceId;
333} VBOXVDMADDI_NODE, *PVBOXVDMADDI_NODE;
334
335#endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPTypes_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use