1 | /* $Id: VBoxGaD3DDevice9Ex.cpp 103999 2024-03-22 12:38:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Windows Guest Mesa3D - Gallium driver interface.
|
---|
4 | *
|
---|
5 | * GaDirect3DDevice9Ex implements IDirect3DDevice9Ex wrapper.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2016-2023 Oracle and/or its affiliates.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox base platform packages, as
|
---|
12 | * available from https://www.virtualbox.org.
|
---|
13 | *
|
---|
14 | * This program is free software; you can redistribute it and/or
|
---|
15 | * modify it under the terms of the GNU General Public License
|
---|
16 | * as published by the Free Software Foundation, in version 3 of the
|
---|
17 | * License.
|
---|
18 | *
|
---|
19 | * This program is distributed in the hope that it will be useful, but
|
---|
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | * General Public License for more details.
|
---|
23 | *
|
---|
24 | * You should have received a copy of the GNU General Public License
|
---|
25 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | *
|
---|
27 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
28 | */
|
---|
29 |
|
---|
30 | #include "VBoxGaD3DDevice9Ex.h"
|
---|
31 | #include "VBoxD3DAdapter9.h"
|
---|
32 | #include "GaDrvEnvWddm.h"
|
---|
33 |
|
---|
34 | #include <iprt/asm.h>
|
---|
35 |
|
---|
36 | /*
|
---|
37 | * GaDirect3DDevice9Ex
|
---|
38 | *
|
---|
39 | * IDirect3DDevice9Ex wrapper for implementation in Gallium D3D9 state tracker "nine".
|
---|
40 | */
|
---|
41 |
|
---|
42 | GaDirect3DDevice9Ex::GaDirect3DDevice9Ex(IGaDirect3D9Ex *pD3D9Ex,
|
---|
43 | HANDLE hAdapter,
|
---|
44 | HANDLE hDevice,
|
---|
45 | const D3DDDI_DEVICECALLBACKS *pDeviceCallbacks)
|
---|
46 | :
|
---|
47 | mcRefs(0),
|
---|
48 | mhAdapter(hAdapter),
|
---|
49 | mhDevice(hDevice),
|
---|
50 | mpD3D9Ex(pD3D9Ex),
|
---|
51 | mpStack(0),
|
---|
52 | mpPresentationGroup(0),
|
---|
53 | mpDevice(0)
|
---|
54 | {
|
---|
55 | mpD3D9Ex->AddRef();
|
---|
56 | mDeviceCallbacks = *pDeviceCallbacks;
|
---|
57 | }
|
---|
58 |
|
---|
59 | GaDirect3DDevice9Ex::~GaDirect3DDevice9Ex()
|
---|
60 | {
|
---|
61 | cleanup();
|
---|
62 | }
|
---|
63 |
|
---|
64 | HRESULT GaDirect3DDevice9Ex::Init(D3DDEVTYPE DeviceType,
|
---|
65 | HWND hFocusWindow,
|
---|
66 | DWORD BehaviorFlags,
|
---|
67 | D3DPRESENT_PARAMETERS* pPresentationParameters,
|
---|
68 | D3DDISPLAYMODEEX* pFullscreenDisplayMode)
|
---|
69 | {
|
---|
70 | mpStack = mpD3D9Ex->GetGalliumStack();
|
---|
71 | mpStack->AddRef();
|
---|
72 |
|
---|
73 | HRESULT hr = WDDMPresentGroupCreate(this, &mpPresentationGroup);
|
---|
74 | if (SUCCEEDED(hr))
|
---|
75 | {
|
---|
76 | /** @todo r=bird: The mpPresentationGroup parameter seems to always have been
|
---|
77 | * consumed by the NineDevice9_ctor() code, while for the mpD3D9Ex parameter
|
---|
78 | * it grabs a reference. I've commented out the bogus looking
|
---|
79 | * ID3DPresentGroup_Release call from NineDevice9_ctor() rather than balancing
|
---|
80 | * reference to mpPresentionGroup here based on the hr value. See r153545.
|
---|
81 | * Please verify and rework the fix to your liking.
|
---|
82 | *
|
---|
83 | * (The release call in cleanup() would call into no man's land early during
|
---|
84 | * vlc.exe (v3.0.17.4) video startup on 32-bit w7 rtm.)
|
---|
85 | */
|
---|
86 | hr = D3DAdapter9_CreateDeviceEx(mpD3D9Ex->GetAdapter9(),
|
---|
87 | D3DADAPTER_DEFAULT, DeviceType,
|
---|
88 | hFocusWindow, BehaviorFlags,
|
---|
89 | pPresentationParameters, pFullscreenDisplayMode,
|
---|
90 | mpD3D9Ex, mpPresentationGroup,
|
---|
91 | &mpDevice);
|
---|
92 | }
|
---|
93 |
|
---|
94 | return hr;
|
---|
95 | }
|
---|
96 |
|
---|
97 | void GaDirect3DDevice9Ex::cleanup()
|
---|
98 | {
|
---|
99 | if (mpDevice)
|
---|
100 | {
|
---|
101 | mpDevice->Release();
|
---|
102 | mpDevice = 0;
|
---|
103 | }
|
---|
104 |
|
---|
105 | if (mpPresentationGroup)
|
---|
106 | {
|
---|
107 | mpPresentationGroup->Release();
|
---|
108 | mpPresentationGroup = 0;
|
---|
109 | }
|
---|
110 |
|
---|
111 | if (mpStack)
|
---|
112 | {
|
---|
113 | mpStack->Release();
|
---|
114 | mpStack = 0;
|
---|
115 | }
|
---|
116 |
|
---|
117 | if (mpD3D9Ex)
|
---|
118 | {
|
---|
119 | mpD3D9Ex->Release();
|
---|
120 | mpD3D9Ex = 0;
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | /* IUnknown wrappers. */
|
---|
125 | STDMETHODIMP_(ULONG) GaDirect3DDevice9Ex::AddRef()
|
---|
126 | {
|
---|
127 | ULONG refs = InterlockedIncrement(&mcRefs);
|
---|
128 | return refs;
|
---|
129 | }
|
---|
130 |
|
---|
131 | STDMETHODIMP_(ULONG) GaDirect3DDevice9Ex::Release()
|
---|
132 | {
|
---|
133 | ULONG refs = InterlockedDecrement(&mcRefs);
|
---|
134 | if (refs == 0)
|
---|
135 | {
|
---|
136 | delete this;
|
---|
137 | }
|
---|
138 |
|
---|
139 | return refs;
|
---|
140 | }
|
---|
141 |
|
---|
142 | STDMETHODIMP GaDirect3DDevice9Ex::QueryInterface(REFIID riid,
|
---|
143 | void **ppvObject)
|
---|
144 | {
|
---|
145 | if (!ppvObject)
|
---|
146 | {
|
---|
147 | return E_POINTER;
|
---|
148 | }
|
---|
149 |
|
---|
150 | HRESULT hr = mpDevice?
|
---|
151 | mpDevice->QueryInterface(riid, ppvObject):
|
---|
152 | E_NOINTERFACE;
|
---|
153 | if (FAILED(hr))
|
---|
154 | {
|
---|
155 | if (IsEqualGUID(IID_IGaDirect3DDevice9Ex, riid))
|
---|
156 | {
|
---|
157 | AddRef();
|
---|
158 | *ppvObject = this;
|
---|
159 | hr = S_OK;
|
---|
160 | }
|
---|
161 | else
|
---|
162 | {
|
---|
163 | *ppvObject = NULL;
|
---|
164 | hr = E_NOINTERFACE;
|
---|
165 | }
|
---|
166 | }
|
---|
167 |
|
---|
168 | return hr;
|
---|
169 | }
|
---|
170 |
|
---|
171 | #define GADEVICE9WRAP(name, params, vars) \
|
---|
172 | STDMETHODIMP GaDirect3DDevice9Ex::name params \
|
---|
173 | { \
|
---|
174 | if (mpDevice) \
|
---|
175 | return mpDevice->name vars; \
|
---|
176 | return E_FAIL; \
|
---|
177 | }
|
---|
178 |
|
---|
179 | #define GADEVICE9WRAP_(type, name, params, vars) \
|
---|
180 | STDMETHODIMP_(type) GaDirect3DDevice9Ex::name params \
|
---|
181 | { \
|
---|
182 | if (mpDevice) \
|
---|
183 | return mpDevice->name vars; \
|
---|
184 | return 0; /** @todo retval */ \
|
---|
185 | }
|
---|
186 |
|
---|
187 | #define GADEVICE9WRAPV(name, params, vars) \
|
---|
188 | STDMETHODIMP_(void) GaDirect3DDevice9Ex::name params \
|
---|
189 | { \
|
---|
190 | if (mpDevice) \
|
---|
191 | return mpDevice->name vars; \
|
---|
192 | return; \
|
---|
193 | }
|
---|
194 |
|
---|
195 | GADEVICE9WRAP(TestCooperativeLevel,
|
---|
196 | (THIS),
|
---|
197 | ())
|
---|
198 | GADEVICE9WRAP_(UINT, GetAvailableTextureMem,
|
---|
199 | (THIS),
|
---|
200 | ())
|
---|
201 | GADEVICE9WRAP(EvictManagedResources,
|
---|
202 | (THIS),
|
---|
203 | ())
|
---|
204 | GADEVICE9WRAP(GetDirect3D,
|
---|
205 | (THIS_ IDirect3D9** ppD3D9),
|
---|
206 | (ppD3D9))
|
---|
207 | GADEVICE9WRAP(GetDeviceCaps,
|
---|
208 | (THIS_ D3DCAPS9* pCaps),
|
---|
209 | (pCaps))
|
---|
210 | GADEVICE9WRAP(GetDisplayMode,
|
---|
211 | (THIS_ UINT iSwapChain,D3DDISPLAYMODE* pMode),
|
---|
212 | (iSwapChain, pMode))
|
---|
213 | GADEVICE9WRAP(GetCreationParameters,
|
---|
214 | (THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters),
|
---|
215 | (pParameters))
|
---|
216 | GADEVICE9WRAP(SetCursorProperties,
|
---|
217 | (THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap),
|
---|
218 | (XHotSpot, YHotSpot, pCursorBitmap))
|
---|
219 | GADEVICE9WRAPV(SetCursorPosition,
|
---|
220 | (THIS_ int X,int Y,DWORD Flags),
|
---|
221 | (X, Y, Flags))
|
---|
222 | GADEVICE9WRAP_(BOOL, ShowCursor,
|
---|
223 | (THIS_ BOOL bShow),
|
---|
224 | (bShow))
|
---|
225 | GADEVICE9WRAP(CreateAdditionalSwapChain,
|
---|
226 | (THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain),
|
---|
227 | (pPresentationParameters, pSwapChain))
|
---|
228 | GADEVICE9WRAP(GetSwapChain,
|
---|
229 | (THIS_ UINT iSwapChain,IDirect3DSwapChain9** pSwapChain),
|
---|
230 | (iSwapChain, pSwapChain))
|
---|
231 | GADEVICE9WRAP_(UINT, GetNumberOfSwapChains,
|
---|
232 | (THIS),
|
---|
233 | ())
|
---|
234 | GADEVICE9WRAP(Reset,
|
---|
235 | (THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters),
|
---|
236 | (pPresentationParameters))
|
---|
237 | GADEVICE9WRAP(Present,
|
---|
238 | (THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion),
|
---|
239 | (pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion))
|
---|
240 | GADEVICE9WRAP(GetBackBuffer,
|
---|
241 | (THIS_ UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer),
|
---|
242 | (iSwapChain, iBackBuffer, Type, ppBackBuffer))
|
---|
243 | GADEVICE9WRAP(GetRasterStatus,
|
---|
244 | (THIS_ UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus),
|
---|
245 | (iSwapChain, pRasterStatus))
|
---|
246 | GADEVICE9WRAP(SetDialogBoxMode,
|
---|
247 | (THIS_ BOOL bEnableDialogs),
|
---|
248 | (bEnableDialogs))
|
---|
249 | GADEVICE9WRAPV(SetGammaRamp,
|
---|
250 | (THIS_ UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp),
|
---|
251 | (iSwapChain, Flags, pRamp))
|
---|
252 | GADEVICE9WRAPV(GetGammaRamp,
|
---|
253 | (THIS_ UINT iSwapChain,D3DGAMMARAMP* pRamp),
|
---|
254 | (iSwapChain, pRamp))
|
---|
255 | GADEVICE9WRAP(CreateTexture,
|
---|
256 | (THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,HANDLE* pSharedHandle),
|
---|
257 | (Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle))
|
---|
258 | GADEVICE9WRAP(CreateVolumeTexture,
|
---|
259 | (THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,HANDLE* pSharedHandle),
|
---|
260 | (Width, Height, Depth, Levels, Usage, Format, Pool, ppVolumeTexture, pSharedHandle))
|
---|
261 | GADEVICE9WRAP(CreateCubeTexture,
|
---|
262 | (THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,HANDLE* pSharedHandle),
|
---|
263 | (EdgeLength, Levels, Usage, Format, Pool, ppCubeTexture, pSharedHandle))
|
---|
264 | GADEVICE9WRAP(CreateVertexBuffer,
|
---|
265 | (THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle),
|
---|
266 | (Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle))
|
---|
267 | GADEVICE9WRAP(CreateIndexBuffer,
|
---|
268 | (THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle),
|
---|
269 | (Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle))
|
---|
270 | GADEVICE9WRAP(CreateRenderTarget,
|
---|
271 | (THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle),
|
---|
272 | (Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle))
|
---|
273 | GADEVICE9WRAP(CreateDepthStencilSurface,
|
---|
274 | (THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle),
|
---|
275 | (Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle))
|
---|
276 | GADEVICE9WRAP(UpdateSurface,
|
---|
277 | (THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint),
|
---|
278 | (pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint))
|
---|
279 | GADEVICE9WRAP(UpdateTexture,
|
---|
280 | (THIS_ IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture),
|
---|
281 | (pSourceTexture, pDestinationTexture))
|
---|
282 | GADEVICE9WRAP(GetRenderTargetData,
|
---|
283 | (THIS_ IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface),
|
---|
284 | (pRenderTarget, pDestSurface))
|
---|
285 | GADEVICE9WRAP(GetFrontBufferData,
|
---|
286 | (THIS_ UINT iSwapChain,IDirect3DSurface9* pDestSurface),
|
---|
287 | (iSwapChain, pDestSurface))
|
---|
288 | GADEVICE9WRAP(StretchRect,
|
---|
289 | (THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter),
|
---|
290 | (pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter))
|
---|
291 | GADEVICE9WRAP(ColorFill,
|
---|
292 | (THIS_ IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color),
|
---|
293 | (pSurface, pRect, color))
|
---|
294 | GADEVICE9WRAP(CreateOffscreenPlainSurface,
|
---|
295 | (THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle),
|
---|
296 | (Width, Height, Format, Pool, ppSurface, pSharedHandle))
|
---|
297 | GADEVICE9WRAP(SetRenderTarget,
|
---|
298 | (THIS_ DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget),
|
---|
299 | (RenderTargetIndex, pRenderTarget))
|
---|
300 | GADEVICE9WRAP(GetRenderTarget,
|
---|
301 | (THIS_ DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget),
|
---|
302 | (RenderTargetIndex, ppRenderTarget))
|
---|
303 | GADEVICE9WRAP(SetDepthStencilSurface,
|
---|
304 | (THIS_ IDirect3DSurface9* pNewZStencil),
|
---|
305 | (pNewZStencil))
|
---|
306 | GADEVICE9WRAP(GetDepthStencilSurface,
|
---|
307 | (THIS_ IDirect3DSurface9** ppZStencilSurface),
|
---|
308 | (ppZStencilSurface))
|
---|
309 | GADEVICE9WRAP(BeginScene,
|
---|
310 | (THIS),
|
---|
311 | ())
|
---|
312 | GADEVICE9WRAP(EndScene,
|
---|
313 | (THIS),
|
---|
314 | ())
|
---|
315 | GADEVICE9WRAP(Clear,
|
---|
316 | (THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil),
|
---|
317 | (Count, pRects, Flags, Color, Z, Stencil))
|
---|
318 | GADEVICE9WRAP(SetTransform,
|
---|
319 | (THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix),
|
---|
320 | (State, pMatrix))
|
---|
321 | GADEVICE9WRAP(GetTransform,
|
---|
322 | (THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix),
|
---|
323 | (State, pMatrix))
|
---|
324 | GADEVICE9WRAP(MultiplyTransform,
|
---|
325 | (THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix),
|
---|
326 | (State, pMatrix))
|
---|
327 | GADEVICE9WRAP(SetViewport,
|
---|
328 | (THIS_ CONST D3DVIEWPORT9* pViewport),
|
---|
329 | (pViewport))
|
---|
330 | GADEVICE9WRAP(GetViewport,
|
---|
331 | (THIS_ D3DVIEWPORT9* pViewport),
|
---|
332 | (pViewport))
|
---|
333 | GADEVICE9WRAP(SetMaterial,
|
---|
334 | (THIS_ CONST D3DMATERIAL9* pMaterial),
|
---|
335 | (pMaterial))
|
---|
336 | GADEVICE9WRAP(GetMaterial,
|
---|
337 | (THIS_ D3DMATERIAL9* pMaterial),
|
---|
338 | (pMaterial))
|
---|
339 | GADEVICE9WRAP(SetLight,
|
---|
340 | (THIS_ DWORD Index,CONST D3DLIGHT9* pLight),
|
---|
341 | (Index, pLight))
|
---|
342 | GADEVICE9WRAP(GetLight,
|
---|
343 | (THIS_ DWORD Index,D3DLIGHT9* pLight),
|
---|
344 | (Index, pLight))
|
---|
345 | GADEVICE9WRAP(LightEnable,
|
---|
346 | (THIS_ DWORD Index,BOOL Enable),
|
---|
347 | (Index, Enable))
|
---|
348 | GADEVICE9WRAP(GetLightEnable,
|
---|
349 | (THIS_ DWORD Index,BOOL* pEnable),
|
---|
350 | (Index, pEnable))
|
---|
351 | GADEVICE9WRAP(SetClipPlane,
|
---|
352 | (THIS_ DWORD Index,CONST float* pPlane),
|
---|
353 | (Index, pPlane))
|
---|
354 | GADEVICE9WRAP(GetClipPlane,
|
---|
355 | (THIS_ DWORD Index,float* pPlane),
|
---|
356 | (Index, pPlane))
|
---|
357 | GADEVICE9WRAP(SetRenderState,
|
---|
358 | (THIS_ D3DRENDERSTATETYPE State,DWORD Value),
|
---|
359 | (State, Value))
|
---|
360 | GADEVICE9WRAP(GetRenderState,
|
---|
361 | (THIS_ D3DRENDERSTATETYPE State,DWORD* pValue),
|
---|
362 | (State, pValue))
|
---|
363 | GADEVICE9WRAP(CreateStateBlock,
|
---|
364 | (THIS_ D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB),
|
---|
365 | (Type, ppSB))
|
---|
366 | GADEVICE9WRAP(BeginStateBlock,
|
---|
367 | (THIS),
|
---|
368 | ())
|
---|
369 | GADEVICE9WRAP(EndStateBlock,
|
---|
370 | (THIS_ IDirect3DStateBlock9** ppSB),
|
---|
371 | (ppSB))
|
---|
372 | GADEVICE9WRAP(SetClipStatus,
|
---|
373 | (THIS_ CONST D3DCLIPSTATUS9* pClipStatus),
|
---|
374 | (pClipStatus))
|
---|
375 | GADEVICE9WRAP(GetClipStatus,
|
---|
376 | (THIS_ D3DCLIPSTATUS9* pClipStatus),
|
---|
377 | (pClipStatus))
|
---|
378 | GADEVICE9WRAP(GetTexture,
|
---|
379 | (THIS_ DWORD Stage,IDirect3DBaseTexture9** ppTexture),
|
---|
380 | (Stage, ppTexture))
|
---|
381 | GADEVICE9WRAP(SetTexture,
|
---|
382 | (THIS_ DWORD Stage,IDirect3DBaseTexture9* pTexture),
|
---|
383 | (Stage, pTexture))
|
---|
384 | GADEVICE9WRAP(GetTextureStageState,
|
---|
385 | (THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue),
|
---|
386 | (Stage, Type, pValue))
|
---|
387 | GADEVICE9WRAP(SetTextureStageState,
|
---|
388 | (THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value),
|
---|
389 | (Stage, Type, Value))
|
---|
390 | GADEVICE9WRAP(GetSamplerState,
|
---|
391 | (THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue),
|
---|
392 | (Sampler, Type, pValue))
|
---|
393 | GADEVICE9WRAP(SetSamplerState,
|
---|
394 | (THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value),
|
---|
395 | (Sampler, Type, Value))
|
---|
396 | GADEVICE9WRAP(ValidateDevice,
|
---|
397 | (THIS_ DWORD* pNumPasses),
|
---|
398 | (pNumPasses))
|
---|
399 | GADEVICE9WRAP(SetPaletteEntries,
|
---|
400 | (THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries),
|
---|
401 | (PaletteNumber, pEntries))
|
---|
402 | GADEVICE9WRAP(GetPaletteEntries,
|
---|
403 | (THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries),
|
---|
404 | (PaletteNumber, pEntries))
|
---|
405 | GADEVICE9WRAP(SetCurrentTexturePalette,
|
---|
406 | (THIS_ UINT PaletteNumber),
|
---|
407 | (PaletteNumber))
|
---|
408 | GADEVICE9WRAP(GetCurrentTexturePalette,
|
---|
409 | (THIS_ UINT *PaletteNumber),
|
---|
410 | (PaletteNumber))
|
---|
411 | GADEVICE9WRAP(SetScissorRect,
|
---|
412 | (THIS_ CONST RECT* pRect),
|
---|
413 | (pRect))
|
---|
414 | GADEVICE9WRAP(GetScissorRect,
|
---|
415 | (THIS_ RECT* pRect),
|
---|
416 | (pRect))
|
---|
417 | GADEVICE9WRAP(SetSoftwareVertexProcessing,
|
---|
418 | (THIS_ BOOL bSoftware),
|
---|
419 | (bSoftware))
|
---|
420 | GADEVICE9WRAP_(BOOL, GetSoftwareVertexProcessing,
|
---|
421 | (THIS),
|
---|
422 | ())
|
---|
423 | GADEVICE9WRAP(SetNPatchMode,
|
---|
424 | (THIS_ float nSegments),
|
---|
425 | (nSegments))
|
---|
426 | GADEVICE9WRAP_(float, GetNPatchMode,
|
---|
427 | (THIS),
|
---|
428 | ())
|
---|
429 | GADEVICE9WRAP(DrawPrimitive,
|
---|
430 | (THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount),
|
---|
431 | (PrimitiveType, StartVertex, PrimitiveCount))
|
---|
432 | GADEVICE9WRAP(DrawIndexedPrimitive,
|
---|
433 | (THIS_ D3DPRIMITIVETYPE Primitive,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount),
|
---|
434 | (Primitive, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount))
|
---|
435 | GADEVICE9WRAP(DrawPrimitiveUP,
|
---|
436 | (THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride),
|
---|
437 | (PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride))
|
---|
438 | GADEVICE9WRAP(DrawIndexedPrimitiveUP,
|
---|
439 | (THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride),
|
---|
440 | (PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride))
|
---|
441 | GADEVICE9WRAP(ProcessVertices,
|
---|
442 | (THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags),
|
---|
443 | (SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags))
|
---|
444 | GADEVICE9WRAP(CreateVertexDeclaration,
|
---|
445 | (THIS_ CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl),
|
---|
446 | (pVertexElements, ppDecl))
|
---|
447 | GADEVICE9WRAP(SetVertexDeclaration,
|
---|
448 | (THIS_ IDirect3DVertexDeclaration9* pDecl),
|
---|
449 | (pDecl))
|
---|
450 | GADEVICE9WRAP(GetVertexDeclaration,
|
---|
451 | (THIS_ IDirect3DVertexDeclaration9** ppDecl),
|
---|
452 | (ppDecl))
|
---|
453 | GADEVICE9WRAP(SetFVF,
|
---|
454 | (THIS_ DWORD FVF),
|
---|
455 | (FVF))
|
---|
456 | GADEVICE9WRAP(GetFVF,
|
---|
457 | (THIS_ DWORD* pFVF),
|
---|
458 | (pFVF))
|
---|
459 | GADEVICE9WRAP(CreateVertexShader,
|
---|
460 | (THIS_ CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader),
|
---|
461 | (pFunction, ppShader))
|
---|
462 | GADEVICE9WRAP(SetVertexShader,
|
---|
463 | (THIS_ IDirect3DVertexShader9* pShader),
|
---|
464 | (pShader))
|
---|
465 | GADEVICE9WRAP(GetVertexShader,
|
---|
466 | (THIS_ IDirect3DVertexShader9** ppShader),
|
---|
467 | (ppShader))
|
---|
468 | GADEVICE9WRAP(SetVertexShaderConstantF,
|
---|
469 | (THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount),
|
---|
470 | (StartRegister, pConstantData, Vector4fCount))
|
---|
471 | GADEVICE9WRAP(GetVertexShaderConstantF,
|
---|
472 | (THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount),
|
---|
473 | (StartRegister, pConstantData, Vector4fCount))
|
---|
474 | GADEVICE9WRAP(SetVertexShaderConstantI,
|
---|
475 | (THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount),
|
---|
476 | (StartRegister, pConstantData, Vector4iCount))
|
---|
477 | GADEVICE9WRAP(GetVertexShaderConstantI,
|
---|
478 | (THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount),
|
---|
479 | (StartRegister, pConstantData, Vector4iCount))
|
---|
480 | GADEVICE9WRAP(SetVertexShaderConstantB,
|
---|
481 | (THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount),
|
---|
482 | (StartRegister, pConstantData, BoolCount))
|
---|
483 | GADEVICE9WRAP(GetVertexShaderConstantB,
|
---|
484 | (THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount),
|
---|
485 | (StartRegister, pConstantData, BoolCount))
|
---|
486 | GADEVICE9WRAP(SetStreamSource,
|
---|
487 | (THIS_ UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride),
|
---|
488 | (StreamNumber, pStreamData, OffsetInBytes, Stride))
|
---|
489 | GADEVICE9WRAP(GetStreamSource,
|
---|
490 | (THIS_ UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* pOffsetInBytes,UINT* pStride),
|
---|
491 | (StreamNumber, ppStreamData, pOffsetInBytes, pStride))
|
---|
492 | GADEVICE9WRAP(SetStreamSourceFreq,
|
---|
493 | (THIS_ UINT StreamNumber,UINT Setting),
|
---|
494 | (StreamNumber, Setting))
|
---|
495 | GADEVICE9WRAP(GetStreamSourceFreq,
|
---|
496 | (THIS_ UINT StreamNumber,UINT* pSetting),
|
---|
497 | (StreamNumber, pSetting))
|
---|
498 | GADEVICE9WRAP(SetIndices,
|
---|
499 | (THIS_ IDirect3DIndexBuffer9* pIndexData),
|
---|
500 | (pIndexData))
|
---|
501 | GADEVICE9WRAP(GetIndices,
|
---|
502 | (THIS_ IDirect3DIndexBuffer9** ppIndexData),
|
---|
503 | (ppIndexData))
|
---|
504 | GADEVICE9WRAP(CreatePixelShader,
|
---|
505 | (THIS_ CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader),
|
---|
506 | (pFunction, ppShader))
|
---|
507 | GADEVICE9WRAP(SetPixelShader,
|
---|
508 | (THIS_ IDirect3DPixelShader9* pShader),
|
---|
509 | (pShader))
|
---|
510 | GADEVICE9WRAP(GetPixelShader,
|
---|
511 | (THIS_ IDirect3DPixelShader9** ppShader),
|
---|
512 | (ppShader))
|
---|
513 | GADEVICE9WRAP(SetPixelShaderConstantF,
|
---|
514 | (THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount),
|
---|
515 | (StartRegister, pConstantData, Vector4fCount))
|
---|
516 | GADEVICE9WRAP(GetPixelShaderConstantF,
|
---|
517 | (THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount),
|
---|
518 | (StartRegister, pConstantData, Vector4fCount))
|
---|
519 | GADEVICE9WRAP(SetPixelShaderConstantI,
|
---|
520 | (THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount),
|
---|
521 | (StartRegister, pConstantData, Vector4iCount))
|
---|
522 | GADEVICE9WRAP(GetPixelShaderConstantI,
|
---|
523 | (THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount),
|
---|
524 | (StartRegister, pConstantData, Vector4iCount))
|
---|
525 | GADEVICE9WRAP(SetPixelShaderConstantB,
|
---|
526 | (THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount),
|
---|
527 | (StartRegister, pConstantData, BoolCount))
|
---|
528 | GADEVICE9WRAP(GetPixelShaderConstantB,
|
---|
529 | (THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount),
|
---|
530 | (StartRegister, pConstantData, BoolCount))
|
---|
531 | GADEVICE9WRAP(DrawRectPatch,
|
---|
532 | (THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo),
|
---|
533 | (Handle, pNumSegs, pRectPatchInfo))
|
---|
534 | GADEVICE9WRAP(DrawTriPatch,
|
---|
535 | (THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo),
|
---|
536 | (Handle, pNumSegs, pTriPatchInfo))
|
---|
537 | GADEVICE9WRAP(DeletePatch,
|
---|
538 | (THIS_ UINT Handle),
|
---|
539 | (Handle))
|
---|
540 | GADEVICE9WRAP(CreateQuery,
|
---|
541 | (THIS_ D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery),
|
---|
542 | (Type, ppQuery))
|
---|
543 | GADEVICE9WRAP(SetConvolutionMonoKernel,
|
---|
544 | (THIS_ UINT width,UINT height,float* rows,float* columns),
|
---|
545 | (width, height, rows, columns))
|
---|
546 | GADEVICE9WRAP(ComposeRects,
|
---|
547 | (THIS_ IDirect3DSurface9* pSrc,IDirect3DSurface9* pDst,IDirect3DVertexBuffer9* pSrcRectDescs,UINT NumRects,IDirect3DVertexBuffer9* pDstRectDescs,D3DCOMPOSERECTSOP Operation,int Xoffset,int Yoffset),
|
---|
548 | (pSrc, pDst, pSrcRectDescs, NumRects, pDstRectDescs, Operation, Xoffset, Yoffset))
|
---|
549 | GADEVICE9WRAP(PresentEx,
|
---|
550 | (THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags),
|
---|
551 | (pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags))
|
---|
552 | GADEVICE9WRAP(GetGPUThreadPriority,
|
---|
553 | (THIS_ INT* pPriority),
|
---|
554 | (pPriority))
|
---|
555 | GADEVICE9WRAP(SetGPUThreadPriority,
|
---|
556 | (THIS_ INT Priority),
|
---|
557 | (Priority))
|
---|
558 | GADEVICE9WRAP(WaitForVBlank,
|
---|
559 | (THIS_ UINT iSwapChain),
|
---|
560 | (iSwapChain))
|
---|
561 | GADEVICE9WRAP(CheckResourceResidency,
|
---|
562 | (THIS_ IDirect3DResource9** pResourceArray,UINT32 NumResources),
|
---|
563 | (pResourceArray, NumResources))
|
---|
564 | GADEVICE9WRAP(SetMaximumFrameLatency,
|
---|
565 | (THIS_ UINT MaxLatency),
|
---|
566 | (MaxLatency))
|
---|
567 | GADEVICE9WRAP(GetMaximumFrameLatency,
|
---|
568 | (THIS_ UINT* pMaxLatency),
|
---|
569 | (pMaxLatency))
|
---|
570 | GADEVICE9WRAP(CheckDeviceState,
|
---|
571 | (THIS_ HWND hDestinationWindow),
|
---|
572 | (hDestinationWindow))
|
---|
573 | GADEVICE9WRAP(CreateRenderTargetEx,
|
---|
574 | (THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle,DWORD Usage),
|
---|
575 | (Width, Height, Format, MultiSample, MultisampleQuality, Lockable, ppSurface, pSharedHandle, Usage))
|
---|
576 | GADEVICE9WRAP(CreateOffscreenPlainSurfaceEx,
|
---|
577 | (THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle,DWORD Usage),
|
---|
578 | (Width, Height, Format, Pool, ppSurface, pSharedHandle, Usage))
|
---|
579 | GADEVICE9WRAP(CreateDepthStencilSurfaceEx,
|
---|
580 | (THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle,DWORD Usage),
|
---|
581 | (Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle, Usage))
|
---|
582 | GADEVICE9WRAP(ResetEx,
|
---|
583 | (THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,D3DDISPLAYMODEEX *pFullscreenDisplayMode),
|
---|
584 | (pPresentationParameters, pFullscreenDisplayMode))
|
---|
585 | GADEVICE9WRAP(GetDisplayModeEx,
|
---|
586 | (THIS_ UINT iSwapChain,D3DDISPLAYMODEEX* pMode,D3DDISPLAYROTATION* pRotation),
|
---|
587 | (iSwapChain, pMode, pRotation))
|
---|
588 |
|
---|
589 | #undef GADEVICE9WRAPV
|
---|
590 | #undef GADEVICE9WRAP_
|
---|
591 | #undef GADEVICE9WRAP
|
---|
592 |
|
---|
593 |
|
---|
594 | /*
|
---|
595 | * IGaDirect3DDevice9Ex methods.
|
---|
596 | */
|
---|
597 | STDMETHODIMP GaDirect3DDevice9Ex::GaSurfaceId(IUnknown *pSurface, uint32_t *pu32Sid)
|
---|
598 | {
|
---|
599 | #if VBOX_MESA_V_MAJOR < 24
|
---|
600 | struct pipe_resource *pResource = mpStack->GaNinePipeResourceFromSurface(pSurface);
|
---|
601 | if (pResource)
|
---|
602 | {
|
---|
603 | struct pipe_screen *pScreen = mpD3D9Ex->GetScreen();
|
---|
604 | *pu32Sid = mpStack->GaDrvGetSurfaceId(pScreen, pResource);
|
---|
605 | }
|
---|
606 | #else
|
---|
607 | *pu32Sid = mpStack->GaNineGetSurfaceId(pSurface);
|
---|
608 | #endif
|
---|
609 |
|
---|
610 | return S_OK;
|
---|
611 | }
|
---|
612 |
|
---|
613 | STDMETHODIMP GaDirect3DDevice9Ex::GaWDDMContextHandle(HANDLE *phContext)
|
---|
614 | {
|
---|
615 | #if VBOX_MESA_V_MAJOR < 24
|
---|
616 | struct pipe_context *pPipeContext = mpStack->GaNinePipeContextFromDevice(this->mpDevice);
|
---|
617 | if (pPipeContext)
|
---|
618 | {
|
---|
619 | struct pipe_screen *pScreen = mpD3D9Ex->GetScreen();
|
---|
620 | WDDMGalliumDriverEnv const *pEnv = mpStack->GaDrvGetWDDMEnv(pScreen);
|
---|
621 | if (pEnv)
|
---|
622 | {
|
---|
623 | uint32_t u32Cid = mpStack->GaDrvGetContextId(pPipeContext);
|
---|
624 |
|
---|
625 | GaDrvEnvWddm *pEnvWddm = (GaDrvEnvWddm *)pEnv->pvEnv;
|
---|
626 | *phContext = pEnvWddm->GaDrvEnvWddmContextHandle(u32Cid);
|
---|
627 | }
|
---|
628 | }
|
---|
629 | #else
|
---|
630 | uint32_t u32Cid = mpStack->GaNineGetContextId(mpDevice);
|
---|
631 | WDDMGalliumDriverEnv const *pEnv = mpD3D9Ex->GetWDDMEnv();
|
---|
632 | if (pEnv)
|
---|
633 | {
|
---|
634 | GaDrvEnvWddm *pEnvWddm = (GaDrvEnvWddm *)pEnv->pvEnv;
|
---|
635 | *phContext = pEnvWddm->GaDrvEnvWddmContextHandle(u32Cid);
|
---|
636 | }
|
---|
637 | #endif
|
---|
638 |
|
---|
639 | return S_OK;
|
---|
640 | }
|
---|
641 |
|
---|
642 | STDMETHODIMP GaDirect3DDevice9Ex::GaFlush()
|
---|
643 | {
|
---|
644 | #if VBOX_MESA_V_MAJOR < 24
|
---|
645 | struct pipe_context *pPipeContext = mpStack->GaNinePipeContextFromDevice(this->mpDevice);
|
---|
646 | if (pPipeContext)
|
---|
647 | {
|
---|
648 | mpStack->GaDrvContextFlush(pPipeContext);
|
---|
649 | }
|
---|
650 | #else
|
---|
651 | mpStack->GaNineFlush(this->mpDevice);
|
---|
652 | #endif
|
---|
653 |
|
---|
654 | return S_OK;
|
---|
655 | }
|
---|
656 |
|
---|
657 | STDMETHODIMP GaDirect3DDevice9Ex::EscapeCb(const void *pvData, uint32_t cbData, bool fHardwareAccess)
|
---|
658 | {
|
---|
659 | HANDLE hContext = 0;
|
---|
660 | HRESULT hr = GaWDDMContextHandle(&hContext);
|
---|
661 | if (SUCCEEDED(hr))
|
---|
662 | {
|
---|
663 | D3DDDICB_ESCAPE ddiEscape;
|
---|
664 | ddiEscape.hDevice = mhDevice;
|
---|
665 | ddiEscape.Flags.Value = 0;
|
---|
666 | if (fHardwareAccess)
|
---|
667 | {
|
---|
668 | ddiEscape.Flags.HardwareAccess = 1;
|
---|
669 | }
|
---|
670 | ddiEscape.pPrivateDriverData = (void *)pvData;
|
---|
671 | ddiEscape.PrivateDriverDataSize = cbData;
|
---|
672 | ddiEscape.hContext = hContext;
|
---|
673 |
|
---|
674 | hr = mDeviceCallbacks.pfnEscapeCb(mhAdapter, &ddiEscape);
|
---|
675 | }
|
---|
676 |
|
---|
677 | return hr;
|
---|
678 | }
|
---|