VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use