VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h@ 83222

Last change on this file since 83222 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.7 KB
Line 
1/* $Id: VBoxDispD3D.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VBoxVideo Display D3D User mode dll
4 */
5
6/*
7 * Copyright (C) 2011-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_wddm_VBoxDispD3D_h
19#define GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_wddm_VBoxDispD3D_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "VBoxDispD3DIf.h"
25#include "../../common/wddm/VBoxMPIf.h"
26
27#include <iprt/cdefs.h>
28#include <iprt/list.h>
29
30#define VBOXWDDMDISP_MAX_VERTEX_STREAMS 16
31#define VBOXWDDMDISP_MAX_TEX_SAMPLERS 16
32#define VBOXWDDMDISP_TOTAL_SAMPLERS VBOXWDDMDISP_MAX_TEX_SAMPLERS + 5
33#define VBOXWDDMDISP_SAMPLER_IDX_IS_SPECIAL(_i) ((_i) >= D3DDMAPSAMPLER && (_i) <= D3DVERTEXTEXTURESAMPLER3)
34#define VBOXWDDMDISP_SAMPLER_IDX_SPECIAL(_i) (VBOXWDDMDISP_SAMPLER_IDX_IS_SPECIAL(_i) ? (int)((_i) - D3DDMAPSAMPLER + VBOXWDDMDISP_MAX_TEX_SAMPLERS) : (int)-1)
35#define VBOXWDDMDISP_SAMPLER_IDX(_i) (((_i) < VBOXWDDMDISP_MAX_TEX_SAMPLERS) ? (int)(_i) : VBOXWDDMDISP_SAMPLER_IDX_SPECIAL(_i))
36
37
38/* maximum number of direct render targets to be used before
39 * switching to offscreen rendering */
40#ifdef VBOXWDDMDISP_DEBUG
41# define VBOXWDDMDISP_MAX_DIRECT_RTS g_VBoxVDbgCfgMaxDirectRts
42#else
43# define VBOXWDDMDISP_MAX_DIRECT_RTS 3
44#endif
45
46#define VBOXWDDMDISP_IS_TEXTURE(_f) ((_f).Texture || (_f).Value == 0)
47
48#ifdef VBOX_WITH_VIDEOHWACCEL
49typedef struct VBOXDISPVHWA_INFO
50{
51 VBOXVHWA_INFO Settings;
52}VBOXDISPVHWA_INFO;
53
54/* represents settings secific to
55 * display device (head) on the multiple-head graphics card
56 * currently used for 2D (overlay) only since in theory its settings
57 * can differ per each frontend's framebuffer. */
58typedef struct VBOXWDDMDISP_HEAD
59{
60 VBOXDISPVHWA_INFO Vhwa;
61} VBOXWDDMDISP_HEAD;
62#endif
63
64typedef struct VBOXWDDMDISP_ADAPTER
65{
66 HANDLE hAdapter;
67 UINT uIfVersion;
68 UINT uRtVersion;
69 D3DDDI_ADAPTERCALLBACKS RtCallbacks;
70
71 VBOXVIDEO_HWTYPE enmHwType; /* VBOXVIDEO_HWTYPE_* */
72
73 VBOXWDDMDISP_D3D D3D;
74 VBOXWDDMDISP_FORMATS Formats;
75 uint32_t u32VBox3DCaps;
76 bool f3D;
77 bool fReserved[3];
78
79 VBOXWDDM_QAI AdapterInfo;
80
81#ifdef VBOX_WITH_VIDEOHWACCEL
82 uint32_t cHeads;
83 VBOXWDDMDISP_HEAD aHeads[1];
84#endif
85} VBOXWDDMDISP_ADAPTER, *PVBOXWDDMDISP_ADAPTER;
86
87typedef struct VBOXWDDMDISP_CONTEXT
88{
89 RTLISTNODE ListNode;
90 struct VBOXWDDMDISP_DEVICE *pDevice;
91 D3DDDICB_CREATECONTEXT ContextInfo;
92} VBOXWDDMDISP_CONTEXT, *PVBOXWDDMDISP_CONTEXT;
93
94typedef struct VBOXWDDMDISP_STREAMSOURCEUM
95{
96 CONST VOID* pvBuffer;
97 UINT cbStride;
98} VBOXWDDMDISP_STREAMSOURCEUM, *PVBOXWDDMDISP_STREAMSOURCEUM;
99
100typedef struct VBOXWDDMDISP_INDICIESUM
101{
102 CONST VOID* pvBuffer;
103 UINT cbSize;
104} VBOXWDDMDISP_INDICIESUM, *PVBOXWDDMDISP_INDICIESUM;
105
106struct VBOXWDDMDISP_ALLOCATION;
107
108typedef struct VBOXWDDMDISP_STREAM_SOURCE_INFO
109{
110 UINT uiOffset;
111 UINT uiStride;
112} VBOXWDDMDISP_STREAM_SOURCE_INFO;
113
114typedef struct VBOXWDDMDISP_INDICES_INFO
115{
116 struct VBOXWDDMDISP_ALLOCATION *pIndicesAlloc;
117 const void *pvIndicesUm;
118 UINT uiStride;
119} VBOXWDDMDISP_INDICES_INFO;
120
121typedef struct VBOXWDDMDISP_RENDERTGT_FLAGS
122{
123 union
124 {
125 struct
126 {
127 UINT bAdded : 1;
128 UINT bRemoved : 1;
129 UINT Reserved : 30;
130 };
131 uint32_t Value;
132 };
133}VBOXWDDMDISP_RENDERTGT_FLAGS;
134
135typedef struct VBOXWDDMDISP_RENDERTGT
136{
137 struct VBOXWDDMDISP_ALLOCATION *pAlloc;
138 UINT cNumFlips;
139 VBOXWDDMDISP_RENDERTGT_FLAGS fFlags;
140} VBOXWDDMDISP_RENDERTGT, *PVBOXWDDMDISP_RENDERTGT;
141
142typedef struct VBOXWDDMDISP_DEVICE *PVBOXWDDMDISP_DEVICE;
143typedef HRESULT FNVBOXWDDMCREATEDIRECT3DDEVICE(PVBOXWDDMDISP_DEVICE pDevice);
144typedef FNVBOXWDDMCREATEDIRECT3DDEVICE *PFNVBOXWDDMCREATEDIRECT3DDEVICE;
145
146typedef IUnknown* FNVBOXWDDMCREATESHAREDPRIMARY(struct VBOXWDDMDISP_ALLOCATION *pAlloc);
147typedef FNVBOXWDDMCREATESHAREDPRIMARY *PFNVBOXWDDMCREATESHAREDPRIMARY;
148
149typedef struct VBOXWDDMDISP_DEVICE
150{
151 HANDLE hDevice;
152 PVBOXWDDMDISP_ADAPTER pAdapter;
153 PFNVBOXWDDMCREATEDIRECT3DDEVICE pfnCreateDirect3DDevice;
154 PFNVBOXWDDMCREATESHAREDPRIMARY pfnCreateSharedPrimary;
155 IDirect3DDevice9 *pDevice9If;
156 UINT u32IfVersion;
157 UINT uRtVersion;
158 D3DDDI_DEVICECALLBACKS RtCallbacks;
159 VOID *pvCmdBuffer;
160 UINT cbCmdBuffer;
161 D3DDDI_CREATEDEVICEFLAGS fFlags;
162 /* number of StreamSources set */
163 UINT cStreamSources;
164 UINT cStreamSourcesUm;
165 VBOXWDDMDISP_STREAMSOURCEUM aStreamSourceUm[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
166 struct VBOXWDDMDISP_ALLOCATION *aStreamSource[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
167 VBOXWDDMDISP_STREAM_SOURCE_INFO StreamSourceInfo[VBOXWDDMDISP_MAX_VERTEX_STREAMS];
168 VBOXWDDMDISP_INDICES_INFO IndiciesInfo;
169 /* Need to cache the ViewPort data because IDirect3DDevice9::SetViewport
170 * is split into two calls: SetViewport & SetZRange.
171 * Also the viewport must be restored after IDirect3DDevice9::SetRenderTarget.
172 */
173 D3DVIEWPORT9 ViewPort;
174 /* The scissor rectangle must be restored after IDirect3DDevice9::SetRenderTarget. */
175 RECT ScissorRect;
176 /* Whether the ViewPort field is valid, i.e. GaDdiSetViewport has been called. */
177 bool fViewPort : 1;
178 /* Whether the ScissorRect field is valid, i.e. GaDdiSetScissorRect has been called. */
179 bool fScissorRect : 1;
180 VBOXWDDMDISP_CONTEXT DefaultContext;
181
182 /* no lock is needed for this since we're guaranteed the per-device calls are not reentrant */
183 RTLISTANCHOR DirtyAllocList;
184
185 UINT cSamplerTextures;
186 struct VBOXWDDMDISP_RESOURCE *aSamplerTextures[VBOXWDDMDISP_TOTAL_SAMPLERS];
187
188 struct VBOXWDDMDISP_RESOURCE *pDepthStencilRc;
189
190 HMODULE hHgsmiTransportModule;
191
192 UINT cRTs;
193 struct VBOXWDDMDISP_ALLOCATION * apRTs[1];
194} VBOXWDDMDISP_DEVICE, *PVBOXWDDMDISP_DEVICE;
195
196typedef struct VBOXWDDMDISP_LOCKINFO
197{
198 uint32_t cLocks;
199 union {
200 D3DDDIRANGE Range;
201 RECT Area;
202 D3DDDIBOX Box;
203 };
204 D3DDDI_LOCKFLAGS fFlags;
205 union {
206 D3DLOCKED_RECT LockedRect;
207 D3DLOCKED_BOX LockedBox;
208 };
209#ifdef VBOXWDDMDISP_DEBUG
210 PVOID pvData;
211#endif
212} VBOXWDDMDISP_LOCKINFO;
213
214typedef enum
215{
216 VBOXDISP_D3DIFTYPE_UNDEFINED = 0,
217 VBOXDISP_D3DIFTYPE_SURFACE,
218 VBOXDISP_D3DIFTYPE_TEXTURE,
219 VBOXDISP_D3DIFTYPE_CUBE_TEXTURE,
220 VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE,
221 VBOXDISP_D3DIFTYPE_VERTEXBUFFER,
222 VBOXDISP_D3DIFTYPE_INDEXBUFFER
223} VBOXDISP_D3DIFTYPE;
224
225typedef struct VBOXWDDMDISP_ALLOCATION
226{
227 D3DKMT_HANDLE hAllocation;
228 VBOXWDDM_ALLOC_TYPE enmType;
229 UINT iAlloc;
230 struct VBOXWDDMDISP_RESOURCE *pRc;
231 void* pvMem;
232 /* object type is defined by enmD3DIfType enum */
233 IUnknown *pD3DIf;
234 VBOXDISP_D3DIFTYPE enmD3DIfType;
235 /* list entry used to add allocation to the dirty alloc list */
236 RTLISTNODE DirtyAllocListEntry;
237 BOOLEAN fEverWritten;
238 BOOLEAN fDirtyWrite;
239 BOOLEAN fAllocLocked;
240 HANDLE hSharedHandle;
241 VBOXWDDMDISP_LOCKINFO LockInfo;
242 VBOXWDDM_DIRTYREGION DirtyRegion; /* <- dirty region to notify host about */
243 VBOXWDDM_SURFACE_DESC SurfDesc;
244#ifdef VBOX_WITH_MESA3D
245 uint32_t hostID;
246#endif
247} VBOXWDDMDISP_ALLOCATION, *PVBOXWDDMDISP_ALLOCATION;
248
249typedef struct VBOXWDDMDISP_RESOURCE
250{
251 HANDLE hResource;
252 D3DKMT_HANDLE hKMResource;
253 PVBOXWDDMDISP_DEVICE pDevice;
254 VBOXWDDMDISP_RESOURCE_FLAGS fFlags;
255 VBOXWDDM_RC_DESC RcDesc;
256 UINT cAllocations;
257 VBOXWDDMDISP_ALLOCATION aAllocations[1];
258} VBOXWDDMDISP_RESOURCE, *PVBOXWDDMDISP_RESOURCE;
259
260typedef struct VBOXWDDMDISP_QUERY
261{
262 D3DDDIQUERYTYPE enmType;
263 D3DDDI_ISSUEQUERYFLAGS fQueryState;
264 IDirect3DQuery9 *pQueryIf;
265} VBOXWDDMDISP_QUERY, *PVBOXWDDMDISP_QUERY;
266
267typedef struct VBOXWDDMDISP_TSS_LOOKUP
268{
269 BOOL bSamplerState;
270 DWORD dType;
271} VBOXWDDMDISP_TSS_LOOKUP;
272
273typedef struct VBOXWDDMDISP_OVERLAY
274{
275 D3DKMT_HANDLE hOverlay;
276 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
277 PVBOXWDDMDISP_RESOURCE *pResource;
278} VBOXWDDMDISP_OVERLAY, *PVBOXWDDMDISP_OVERLAY;
279
280#define VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc) (((pRc)->cAllocations)/6)
281#define VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, idx) ((D3DCUBEMAP_FACES)(D3DCUBEMAP_FACE_POSITIVE_X+(idx)/VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc)))
282#define VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, idx) ((idx)%VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc))
283
284void vboxWddmResourceInit(PVBOXWDDMDISP_RESOURCE pRc, UINT cAllocs);
285
286#endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_wddm_VBoxDispD3D_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