VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/VBoxGaD3DDevice9Ex.cpp

Last change on this file was 103999, checked in by vboxsync, 6 weeks ago

Addition/3D,Additions/WINNT/Graphics: Updates for mesa-24.0.2 (not enabled yet). bugref:10606

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.5 KB
Line 
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
42GaDirect3DDevice9Ex::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
59GaDirect3DDevice9Ex::~GaDirect3DDevice9Ex()
60{
61 cleanup();
62}
63
64HRESULT 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
97void 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. */
125STDMETHODIMP_(ULONG) GaDirect3DDevice9Ex::AddRef()
126{
127 ULONG refs = InterlockedIncrement(&mcRefs);
128 return refs;
129}
130
131STDMETHODIMP_(ULONG) GaDirect3DDevice9Ex::Release()
132{
133 ULONG refs = InterlockedDecrement(&mcRefs);
134 if (refs == 0)
135 {
136 delete this;
137 }
138
139 return refs;
140}
141
142STDMETHODIMP 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) \
172STDMETHODIMP 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) \
180STDMETHODIMP_(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) \
188STDMETHODIMP_(void) GaDirect3DDevice9Ex::name params \
189{ \
190 if (mpDevice) \
191 return mpDevice->name vars; \
192 return; \
193}
194
195GADEVICE9WRAP(TestCooperativeLevel,
196 (THIS),
197 ())
198GADEVICE9WRAP_(UINT, GetAvailableTextureMem,
199 (THIS),
200 ())
201GADEVICE9WRAP(EvictManagedResources,
202 (THIS),
203 ())
204GADEVICE9WRAP(GetDirect3D,
205 (THIS_ IDirect3D9** ppD3D9),
206 (ppD3D9))
207GADEVICE9WRAP(GetDeviceCaps,
208 (THIS_ D3DCAPS9* pCaps),
209 (pCaps))
210GADEVICE9WRAP(GetDisplayMode,
211 (THIS_ UINT iSwapChain,D3DDISPLAYMODE* pMode),
212 (iSwapChain, pMode))
213GADEVICE9WRAP(GetCreationParameters,
214 (THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters),
215 (pParameters))
216GADEVICE9WRAP(SetCursorProperties,
217 (THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface9* pCursorBitmap),
218 (XHotSpot, YHotSpot, pCursorBitmap))
219GADEVICE9WRAPV(SetCursorPosition,
220 (THIS_ int X,int Y,DWORD Flags),
221 (X, Y, Flags))
222GADEVICE9WRAP_(BOOL, ShowCursor,
223 (THIS_ BOOL bShow),
224 (bShow))
225GADEVICE9WRAP(CreateAdditionalSwapChain,
226 (THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain9** pSwapChain),
227 (pPresentationParameters, pSwapChain))
228GADEVICE9WRAP(GetSwapChain,
229 (THIS_ UINT iSwapChain,IDirect3DSwapChain9** pSwapChain),
230 (iSwapChain, pSwapChain))
231GADEVICE9WRAP_(UINT, GetNumberOfSwapChains,
232 (THIS),
233 ())
234GADEVICE9WRAP(Reset,
235 (THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters),
236 (pPresentationParameters))
237GADEVICE9WRAP(Present,
238 (THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion),
239 (pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion))
240GADEVICE9WRAP(GetBackBuffer,
241 (THIS_ UINT iSwapChain,UINT iBackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface9** ppBackBuffer),
242 (iSwapChain, iBackBuffer, Type, ppBackBuffer))
243GADEVICE9WRAP(GetRasterStatus,
244 (THIS_ UINT iSwapChain,D3DRASTER_STATUS* pRasterStatus),
245 (iSwapChain, pRasterStatus))
246GADEVICE9WRAP(SetDialogBoxMode,
247 (THIS_ BOOL bEnableDialogs),
248 (bEnableDialogs))
249GADEVICE9WRAPV(SetGammaRamp,
250 (THIS_ UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp),
251 (iSwapChain, Flags, pRamp))
252GADEVICE9WRAPV(GetGammaRamp,
253 (THIS_ UINT iSwapChain,D3DGAMMARAMP* pRamp),
254 (iSwapChain, pRamp))
255GADEVICE9WRAP(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))
258GADEVICE9WRAP(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))
261GADEVICE9WRAP(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))
264GADEVICE9WRAP(CreateVertexBuffer,
265 (THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,HANDLE* pSharedHandle),
266 (Length, Usage, FVF, Pool, ppVertexBuffer, pSharedHandle))
267GADEVICE9WRAP(CreateIndexBuffer,
268 (THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,HANDLE* pSharedHandle),
269 (Length, Usage, Format, Pool, ppIndexBuffer, pSharedHandle))
270GADEVICE9WRAP(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))
273GADEVICE9WRAP(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))
276GADEVICE9WRAP(UpdateSurface,
277 (THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestinationSurface,CONST POINT* pDestPoint),
278 (pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint))
279GADEVICE9WRAP(UpdateTexture,
280 (THIS_ IDirect3DBaseTexture9* pSourceTexture,IDirect3DBaseTexture9* pDestinationTexture),
281 (pSourceTexture, pDestinationTexture))
282GADEVICE9WRAP(GetRenderTargetData,
283 (THIS_ IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface),
284 (pRenderTarget, pDestSurface))
285GADEVICE9WRAP(GetFrontBufferData,
286 (THIS_ UINT iSwapChain,IDirect3DSurface9* pDestSurface),
287 (iSwapChain, pDestSurface))
288GADEVICE9WRAP(StretchRect,
289 (THIS_ IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter),
290 (pSourceSurface, pSourceRect, pDestSurface, pDestRect, Filter))
291GADEVICE9WRAP(ColorFill,
292 (THIS_ IDirect3DSurface9* pSurface,CONST RECT* pRect,D3DCOLOR color),
293 (pSurface, pRect, color))
294GADEVICE9WRAP(CreateOffscreenPlainSurface,
295 (THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,HANDLE* pSharedHandle),
296 (Width, Height, Format, Pool, ppSurface, pSharedHandle))
297GADEVICE9WRAP(SetRenderTarget,
298 (THIS_ DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget),
299 (RenderTargetIndex, pRenderTarget))
300GADEVICE9WRAP(GetRenderTarget,
301 (THIS_ DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget),
302 (RenderTargetIndex, ppRenderTarget))
303GADEVICE9WRAP(SetDepthStencilSurface,
304 (THIS_ IDirect3DSurface9* pNewZStencil),
305 (pNewZStencil))
306GADEVICE9WRAP(GetDepthStencilSurface,
307 (THIS_ IDirect3DSurface9** ppZStencilSurface),
308 (ppZStencilSurface))
309GADEVICE9WRAP(BeginScene,
310 (THIS),
311 ())
312GADEVICE9WRAP(EndScene,
313 (THIS),
314 ())
315GADEVICE9WRAP(Clear,
316 (THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil),
317 (Count, pRects, Flags, Color, Z, Stencil))
318GADEVICE9WRAP(SetTransform,
319 (THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix),
320 (State, pMatrix))
321GADEVICE9WRAP(GetTransform,
322 (THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix),
323 (State, pMatrix))
324GADEVICE9WRAP(MultiplyTransform,
325 (THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix),
326 (State, pMatrix))
327GADEVICE9WRAP(SetViewport,
328 (THIS_ CONST D3DVIEWPORT9* pViewport),
329 (pViewport))
330GADEVICE9WRAP(GetViewport,
331 (THIS_ D3DVIEWPORT9* pViewport),
332 (pViewport))
333GADEVICE9WRAP(SetMaterial,
334 (THIS_ CONST D3DMATERIAL9* pMaterial),
335 (pMaterial))
336GADEVICE9WRAP(GetMaterial,
337 (THIS_ D3DMATERIAL9* pMaterial),
338 (pMaterial))
339GADEVICE9WRAP(SetLight,
340 (THIS_ DWORD Index,CONST D3DLIGHT9* pLight),
341 (Index, pLight))
342GADEVICE9WRAP(GetLight,
343 (THIS_ DWORD Index,D3DLIGHT9* pLight),
344 (Index, pLight))
345GADEVICE9WRAP(LightEnable,
346 (THIS_ DWORD Index,BOOL Enable),
347 (Index, Enable))
348GADEVICE9WRAP(GetLightEnable,
349 (THIS_ DWORD Index,BOOL* pEnable),
350 (Index, pEnable))
351GADEVICE9WRAP(SetClipPlane,
352 (THIS_ DWORD Index,CONST float* pPlane),
353 (Index, pPlane))
354GADEVICE9WRAP(GetClipPlane,
355 (THIS_ DWORD Index,float* pPlane),
356 (Index, pPlane))
357GADEVICE9WRAP(SetRenderState,
358 (THIS_ D3DRENDERSTATETYPE State,DWORD Value),
359 (State, Value))
360GADEVICE9WRAP(GetRenderState,
361 (THIS_ D3DRENDERSTATETYPE State,DWORD* pValue),
362 (State, pValue))
363GADEVICE9WRAP(CreateStateBlock,
364 (THIS_ D3DSTATEBLOCKTYPE Type,IDirect3DStateBlock9** ppSB),
365 (Type, ppSB))
366GADEVICE9WRAP(BeginStateBlock,
367 (THIS),
368 ())
369GADEVICE9WRAP(EndStateBlock,
370 (THIS_ IDirect3DStateBlock9** ppSB),
371 (ppSB))
372GADEVICE9WRAP(SetClipStatus,
373 (THIS_ CONST D3DCLIPSTATUS9* pClipStatus),
374 (pClipStatus))
375GADEVICE9WRAP(GetClipStatus,
376 (THIS_ D3DCLIPSTATUS9* pClipStatus),
377 (pClipStatus))
378GADEVICE9WRAP(GetTexture,
379 (THIS_ DWORD Stage,IDirect3DBaseTexture9** ppTexture),
380 (Stage, ppTexture))
381GADEVICE9WRAP(SetTexture,
382 (THIS_ DWORD Stage,IDirect3DBaseTexture9* pTexture),
383 (Stage, pTexture))
384GADEVICE9WRAP(GetTextureStageState,
385 (THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue),
386 (Stage, Type, pValue))
387GADEVICE9WRAP(SetTextureStageState,
388 (THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value),
389 (Stage, Type, Value))
390GADEVICE9WRAP(GetSamplerState,
391 (THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD* pValue),
392 (Sampler, Type, pValue))
393GADEVICE9WRAP(SetSamplerState,
394 (THIS_ DWORD Sampler,D3DSAMPLERSTATETYPE Type,DWORD Value),
395 (Sampler, Type, Value))
396GADEVICE9WRAP(ValidateDevice,
397 (THIS_ DWORD* pNumPasses),
398 (pNumPasses))
399GADEVICE9WRAP(SetPaletteEntries,
400 (THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries),
401 (PaletteNumber, pEntries))
402GADEVICE9WRAP(GetPaletteEntries,
403 (THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries),
404 (PaletteNumber, pEntries))
405GADEVICE9WRAP(SetCurrentTexturePalette,
406 (THIS_ UINT PaletteNumber),
407 (PaletteNumber))
408GADEVICE9WRAP(GetCurrentTexturePalette,
409 (THIS_ UINT *PaletteNumber),
410 (PaletteNumber))
411GADEVICE9WRAP(SetScissorRect,
412 (THIS_ CONST RECT* pRect),
413 (pRect))
414GADEVICE9WRAP(GetScissorRect,
415 (THIS_ RECT* pRect),
416 (pRect))
417GADEVICE9WRAP(SetSoftwareVertexProcessing,
418 (THIS_ BOOL bSoftware),
419 (bSoftware))
420GADEVICE9WRAP_(BOOL, GetSoftwareVertexProcessing,
421 (THIS),
422 ())
423GADEVICE9WRAP(SetNPatchMode,
424 (THIS_ float nSegments),
425 (nSegments))
426GADEVICE9WRAP_(float, GetNPatchMode,
427 (THIS),
428 ())
429GADEVICE9WRAP(DrawPrimitive,
430 (THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount),
431 (PrimitiveType, StartVertex, PrimitiveCount))
432GADEVICE9WRAP(DrawIndexedPrimitive,
433 (THIS_ D3DPRIMITIVETYPE Primitive,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount),
434 (Primitive, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount))
435GADEVICE9WRAP(DrawPrimitiveUP,
436 (THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride),
437 (PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride))
438GADEVICE9WRAP(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))
441GADEVICE9WRAP(ProcessVertices,
442 (THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer9* pDestBuffer,IDirect3DVertexDeclaration9* pVertexDecl,DWORD Flags),
443 (SrcStartIndex, DestIndex, VertexCount, pDestBuffer, pVertexDecl, Flags))
444GADEVICE9WRAP(CreateVertexDeclaration,
445 (THIS_ CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl),
446 (pVertexElements, ppDecl))
447GADEVICE9WRAP(SetVertexDeclaration,
448 (THIS_ IDirect3DVertexDeclaration9* pDecl),
449 (pDecl))
450GADEVICE9WRAP(GetVertexDeclaration,
451 (THIS_ IDirect3DVertexDeclaration9** ppDecl),
452 (ppDecl))
453GADEVICE9WRAP(SetFVF,
454 (THIS_ DWORD FVF),
455 (FVF))
456GADEVICE9WRAP(GetFVF,
457 (THIS_ DWORD* pFVF),
458 (pFVF))
459GADEVICE9WRAP(CreateVertexShader,
460 (THIS_ CONST DWORD* pFunction,IDirect3DVertexShader9** ppShader),
461 (pFunction, ppShader))
462GADEVICE9WRAP(SetVertexShader,
463 (THIS_ IDirect3DVertexShader9* pShader),
464 (pShader))
465GADEVICE9WRAP(GetVertexShader,
466 (THIS_ IDirect3DVertexShader9** ppShader),
467 (ppShader))
468GADEVICE9WRAP(SetVertexShaderConstantF,
469 (THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount),
470 (StartRegister, pConstantData, Vector4fCount))
471GADEVICE9WRAP(GetVertexShaderConstantF,
472 (THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount),
473 (StartRegister, pConstantData, Vector4fCount))
474GADEVICE9WRAP(SetVertexShaderConstantI,
475 (THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount),
476 (StartRegister, pConstantData, Vector4iCount))
477GADEVICE9WRAP(GetVertexShaderConstantI,
478 (THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount),
479 (StartRegister, pConstantData, Vector4iCount))
480GADEVICE9WRAP(SetVertexShaderConstantB,
481 (THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount),
482 (StartRegister, pConstantData, BoolCount))
483GADEVICE9WRAP(GetVertexShaderConstantB,
484 (THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount),
485 (StartRegister, pConstantData, BoolCount))
486GADEVICE9WRAP(SetStreamSource,
487 (THIS_ UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride),
488 (StreamNumber, pStreamData, OffsetInBytes, Stride))
489GADEVICE9WRAP(GetStreamSource,
490 (THIS_ UINT StreamNumber,IDirect3DVertexBuffer9** ppStreamData,UINT* pOffsetInBytes,UINT* pStride),
491 (StreamNumber, ppStreamData, pOffsetInBytes, pStride))
492GADEVICE9WRAP(SetStreamSourceFreq,
493 (THIS_ UINT StreamNumber,UINT Setting),
494 (StreamNumber, Setting))
495GADEVICE9WRAP(GetStreamSourceFreq,
496 (THIS_ UINT StreamNumber,UINT* pSetting),
497 (StreamNumber, pSetting))
498GADEVICE9WRAP(SetIndices,
499 (THIS_ IDirect3DIndexBuffer9* pIndexData),
500 (pIndexData))
501GADEVICE9WRAP(GetIndices,
502 (THIS_ IDirect3DIndexBuffer9** ppIndexData),
503 (ppIndexData))
504GADEVICE9WRAP(CreatePixelShader,
505 (THIS_ CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader),
506 (pFunction, ppShader))
507GADEVICE9WRAP(SetPixelShader,
508 (THIS_ IDirect3DPixelShader9* pShader),
509 (pShader))
510GADEVICE9WRAP(GetPixelShader,
511 (THIS_ IDirect3DPixelShader9** ppShader),
512 (ppShader))
513GADEVICE9WRAP(SetPixelShaderConstantF,
514 (THIS_ UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount),
515 (StartRegister, pConstantData, Vector4fCount))
516GADEVICE9WRAP(GetPixelShaderConstantF,
517 (THIS_ UINT StartRegister,float* pConstantData,UINT Vector4fCount),
518 (StartRegister, pConstantData, Vector4fCount))
519GADEVICE9WRAP(SetPixelShaderConstantI,
520 (THIS_ UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount),
521 (StartRegister, pConstantData, Vector4iCount))
522GADEVICE9WRAP(GetPixelShaderConstantI,
523 (THIS_ UINT StartRegister,int* pConstantData,UINT Vector4iCount),
524 (StartRegister, pConstantData, Vector4iCount))
525GADEVICE9WRAP(SetPixelShaderConstantB,
526 (THIS_ UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount),
527 (StartRegister, pConstantData, BoolCount))
528GADEVICE9WRAP(GetPixelShaderConstantB,
529 (THIS_ UINT StartRegister,BOOL* pConstantData,UINT BoolCount),
530 (StartRegister, pConstantData, BoolCount))
531GADEVICE9WRAP(DrawRectPatch,
532 (THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo),
533 (Handle, pNumSegs, pRectPatchInfo))
534GADEVICE9WRAP(DrawTriPatch,
535 (THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo),
536 (Handle, pNumSegs, pTriPatchInfo))
537GADEVICE9WRAP(DeletePatch,
538 (THIS_ UINT Handle),
539 (Handle))
540GADEVICE9WRAP(CreateQuery,
541 (THIS_ D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery),
542 (Type, ppQuery))
543GADEVICE9WRAP(SetConvolutionMonoKernel,
544 (THIS_ UINT width,UINT height,float* rows,float* columns),
545 (width, height, rows, columns))
546GADEVICE9WRAP(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))
549GADEVICE9WRAP(PresentEx,
550 (THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion,DWORD dwFlags),
551 (pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags))
552GADEVICE9WRAP(GetGPUThreadPriority,
553 (THIS_ INT* pPriority),
554 (pPriority))
555GADEVICE9WRAP(SetGPUThreadPriority,
556 (THIS_ INT Priority),
557 (Priority))
558GADEVICE9WRAP(WaitForVBlank,
559 (THIS_ UINT iSwapChain),
560 (iSwapChain))
561GADEVICE9WRAP(CheckResourceResidency,
562 (THIS_ IDirect3DResource9** pResourceArray,UINT32 NumResources),
563 (pResourceArray, NumResources))
564GADEVICE9WRAP(SetMaximumFrameLatency,
565 (THIS_ UINT MaxLatency),
566 (MaxLatency))
567GADEVICE9WRAP(GetMaximumFrameLatency,
568 (THIS_ UINT* pMaxLatency),
569 (pMaxLatency))
570GADEVICE9WRAP(CheckDeviceState,
571 (THIS_ HWND hDestinationWindow),
572 (hDestinationWindow))
573GADEVICE9WRAP(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))
576GADEVICE9WRAP(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))
579GADEVICE9WRAP(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))
582GADEVICE9WRAP(ResetEx,
583 (THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,D3DDISPLAYMODEEX *pFullscreenDisplayMode),
584 (pPresentationParameters, pFullscreenDisplayMode))
585GADEVICE9WRAP(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 */
597STDMETHODIMP 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
613STDMETHODIMP 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
642STDMETHODIMP 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
657STDMETHODIMP 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}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use