VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h@ 30215

Last change on this file since 30215 was 30215, checked in by vboxsync, 15 years ago

wddm/2d: overlay create/update in UMD

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1/** @file
2 * Contains base definitions of constants & structures used
3 * to control & perform rendering,
4 * such as DMA commands types, allocation types, escape codes, etc.
5 * used by both miniport & display drivers.
6 *
7 * The latter uses these and only these defs to communicate with the former
8 * by posting appropriate requests via D3D RT Krnl Svc accessing callbacks.
9 */
10/*
11 * Copyright (C) 2010 Oracle Corporation
12 *
13 * This file is part of VirtualBox Open Source Edition (OSE), as
14 * available from http://www.virtualbox.org. This file is free software;
15 * you can redistribute it and/or modify it under the terms of the GNU
16 * General Public License (GPL) as published by the Free Software
17 * Foundation, in version 2 as it comes in the "COPYING" file of the
18 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20 */
21#ifndef ___VBoxVideoIf_h___
22#define ___VBoxVideoIf_h___
23
24#include <VBox/VBoxVideo.h>
25
26/* @todo: implement a check to ensure display & miniport versions match.
27 * One would increase this whenever definitions in this file are changed */
28#define VBOXVIDEOIF_VERSION 2
29
30/* create allocation func */
31typedef enum
32{
33 VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
34 VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
35 VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
36 VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
37 /* this one is win 7-specific and hence unused for now */
38 VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
39 /* custom allocation types requested from user-mode d3d module will go here */
40 , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC
41} VBOXWDDM_ALLOC_TYPE;
42
43typedef struct VBOXWDDM_SURFACE_DESC
44{
45 UINT width;
46 UINT height;
47 D3DDDIFORMAT format;
48 UINT bpp;
49 UINT pitch;
50 UINT depth;
51 UINT slicePitch;
52 UINT cbSize;
53 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
54 D3DDDI_RATIONAL RefreshRate;
55} VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
56
57typedef struct VBOXWDDM_ALLOCINFO
58{
59 VBOXWDDM_ALLOC_TYPE enmType;
60 VBOXWDDM_SURFACE_DESC SurfDesc;
61} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
62
63//#define VBOXWDDM_ALLOCINFO_HEADSIZE() (sizeof (VBOXWDDM_ALLOCINFO))
64//#define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s))
65//#define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
66//#define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ( (_t*)(((uint8_t*)(_p)) + VBOXWDDM_ALLOCINFO_HEADSIZE()) )
67//#define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - VBOXWDDM_ALLOCATION_HEADSIZE()))
68
69/* this resource is OpenResource'd rather than CreateResource'd */
70#define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001
71/* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
72#define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002
73
74typedef struct VBOXWDDM_RC_DESC
75{
76 D3DDDI_RESOURCEFLAGS fFlags;
77 D3DDDIFORMAT enmFormat;
78 D3DDDI_POOL enmPool;
79 D3DDDIMULTISAMPLE_TYPE enmMultisampleType;
80 UINT MultisampleQuality;
81 UINT MipLevels;
82 UINT Fvf;
83 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
84 D3DDDI_RATIONAL RefreshRate;
85 D3DDDI_ROTATION enmRotation;
86} VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC;
87
88typedef struct VBOXWDDM_RCINFO
89{
90 uint32_t fFlags;
91 VBOXWDDM_RC_DESC RcDesc;
92 uint32_t cAllocInfos;
93// VBOXWDDM_ALLOCINFO aAllocInfos[1];
94} VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO;
95
96#define VBOXVHWA_F_ENABLED 0x00000001
97#define VBOXVHWA_F_CKEY_DST 0x00000002
98#define VBOXVHWA_F_CKEY_SRC 0x00000004
99
100#define VBOXVHWA_MAX_FORMATS 8
101
102typedef struct VBOXVHWA_INFO
103{
104 uint32_t fFlags;
105 uint32_t cOverlaysSupported;
106 uint32_t cFormats;
107 D3DDDIFORMAT aFormats[VBOXVHWA_MAX_FORMATS];
108} VBOXVHWA_INFO;
109
110#define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
111#define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
112#define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
113#define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
114#define VBOXWDDM_OVERLAY_F_BOB 0x00000010
115#define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
116#define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
117#define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
118#define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
119
120typedef struct VBOXWDDM_OVERLAY_DESC
121{
122 uint32_t fFlags;
123 UINT DstColorKeyLow;
124 UINT DstColorKeyHigh;
125 UINT SrcColorKeyLow;
126 UINT SrcColorKeyHigh;
127} VBOXWDDM_OVERLAY_DESC, *PVBOXWDDM_OVERLAY_DESC;
128
129/* the dirty rect info is valid */
130#define VBOXWDDM_DIRTYREGION_F_VALID 0x00000001
131#define VBOXWDDM_DIRTYREGION_F_RECT_VALID 0x00000002
132
133typedef struct VBOXWDDM_DIRTYREGION
134{
135 uint32_t fFlags; /* <-- see VBOXWDDM_DIRTYREGION_F_xxx flags above */
136 RECT Rect;
137} VBOXWDDM_DIRTYREGION, *PVBOXWDDM_DIRTYREGION;
138
139typedef struct VBOXWDDM_OVERLAY_INFO
140{
141 VBOXWDDM_OVERLAY_DESC OverlayDesc;
142 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
143} VBOXWDDM_OVERLAY_INFO, *PVBOXWDDM_OVERLAY_INFO;
144
145typedef struct VBOXWDDM_OVERLAYFLIP_INFO
146{
147 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- the dirty region of the overlay surface */
148} VBOXWDDM_OVERLAYFLIP_INFO, *PVBOXWDDM_OVERLAYFLIP_INFO;
149
150/* query info func */
151typedef struct VBOXWDDM_QI
152{
153 uint32_t u32Version;
154 uint32_t cInfos;
155 VBOXVHWA_INFO aInfos[VBOX_VIDEO_MAX_SCREENS];
156} VBOXWDDM_QI;
157
158/* submit cmd func */
159
160
161
162
163/* tooling */
164DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
165{
166 switch (format)
167 {
168 case D3DDDIFMT_R8G8B8:
169 return 24;
170 case D3DDDIFMT_A8R8G8B8:
171 case D3DDDIFMT_X8R8G8B8:
172 return 32;
173 case D3DDDIFMT_R5G6B5:
174 case D3DDDIFMT_X1R5G5B5:
175 case D3DDDIFMT_A1R5G5B5:
176 case D3DDDIFMT_A4R4G4B4:
177 return 16;
178 case D3DDDIFMT_R3G3B2:
179 case D3DDDIFMT_A8:
180 return 8;
181 case D3DDDIFMT_A8R3G3B2:
182 case D3DDDIFMT_X4R4G4B4:
183 return 16;
184 case D3DDDIFMT_A2B10G10R10:
185 case D3DDDIFMT_A8B8G8R8:
186 case D3DDDIFMT_X8B8G8R8:
187 case D3DDDIFMT_G16R16:
188 case D3DDDIFMT_A2R10G10B10:
189 return 32;
190 case D3DDDIFMT_A16B16G16R16:
191 return 64;
192 case D3DDDIFMT_A8P8:
193 return 16;
194 case D3DDDIFMT_P8:
195 return 8;
196 case D3DDDIFMT_D16_LOCKABLE:
197 case D3DDDIFMT_D16:
198 case D3DDDIFMT_D15S1:
199 return 16;
200 case D3DDDIFMT_D32:
201 case D3DDDIFMT_D24S8:
202 case D3DDDIFMT_D24X8:
203 case D3DDDIFMT_D24X4S4:
204 case D3DDDIFMT_D24FS8:
205 case D3DDDIFMT_D32_LOCKABLE:
206 return 32;
207 case D3DDDIFMT_S8_LOCKABLE:
208 return 8;
209 default:
210 AssertBreakpoint();
211 return 0;
212 }
213}
214
215DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
216{
217 uint32_t uFormat = (uint32_t)format;
218 /* assume that in case both four bytes are non-zero, this is a fourcc */
219 if ((format & 0xff000000)
220 && (format & 0x00ff0000)
221 && (format & 0x0000ff00)
222 && (format & 0x000000ff)
223 )
224 return uFormat;
225 return 0;
226}
227
228#define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
229
230DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
231{
232 UINT Pitch = bitsPerPixel * w;
233 /* pitch is now in bits, translate in bytes */
234 return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3;
235}
236
237DECLINLINE(void) vboxWddmRectUnite(RECT *pR, const RECT *pR2Unite)
238{
239 pR->left = RT_MIN(pR->left, pR2Unite->left);
240 pR->top = RT_MIN(pR->top, pR2Unite->top);
241 pR->right = RT_MAX(pR->right, pR2Unite->right);
242 pR->bottom = RT_MAX(pR->bottom, pR2Unite->bottom);
243}
244
245DECLINLINE(void) vboxWddmDirtyRegionAddRect(PVBOXWDDM_DIRTYREGION pInfo, const RECT *pRect)
246{
247 if (!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_VALID))
248 {
249 pInfo->fFlags = VBOXWDDM_DIRTYREGION_F_VALID;
250 if (pRect)
251 {
252 pInfo->fFlags |= VBOXWDDM_DIRTYREGION_F_RECT_VALID;
253 pInfo->Rect = *pRect;
254 }
255 }
256 else if (!!(pInfo->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID))
257 {
258 if (pRect)
259 vboxWddmRectUnite(&pInfo->Rect, pRect);
260 else
261 pInfo->fFlags &= ~VBOXWDDM_DIRTYREGION_F_RECT_VALID;
262 }
263}
264
265DECLINLINE(void) vboxWddmDirtyRegionUnite(PVBOXWDDM_DIRTYREGION pInfo, const PVBOXWDDM_DIRTYREGION pInfo2)
266{
267 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_VALID)
268 {
269 if (pInfo2->fFlags & VBOXWDDM_DIRTYREGION_F_RECT_VALID)
270 vboxWddmDirtyRegionAddRect(pInfo, &pInfo2->Rect);
271 else
272 vboxWddmDirtyRegionAddRect(pInfo, NULL);
273 }
274}
275
276DECLINLINE(void) vboxWddmDirtyRegionClear(PVBOXWDDM_DIRTYREGION pInfo)
277{
278 pInfo->fFlags = 0;
279}
280
281#endif /* #ifndef ___VBoxVideoIf_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette