2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS ReactX
4 * FILE: dll/directx/d3d9/d3d9_haldevice.c
5 * PURPOSE: d3d9.dll internal HAL device functions
6 * PROGRAMERS: Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
8 #include "d3d9_haldevice.h"
11 #define LOCK_D3DDEVICE9() if (This->bLockDevice) EnterCriticalSection(&This->CriticalSection);
12 #define UNLOCK_D3DDEVICE9() if (This->bLockDevice) LeaveCriticalSection(&This->CriticalSection);
14 /* Convert a IDirect3D9 pointer safely to the internal implementation struct */
15 /*static LPD3D9HALDEVICE IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
20 return (LPD3D9HALDEVICE)((ULONG_PTR)iface - FIELD_OFFSET(D3D9HALDEVICE, PureDevice.BaseDevice.lpVtbl));
23 /* IDirect3DDevice9 public interface */
24 HRESULT WINAPI
IDirect3DDevice9HAL_GetTransform(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, D3DMATRIX
* pMatrix
)
31 HRESULT WINAPI
IDirect3DDevice9HAL_GetMaterial(LPDIRECT3DDEVICE9 iface
, D3DMATERIAL9
* pMaterial
)
38 HRESULT WINAPI
IDirect3DDevice9HAL_GetLight(LPDIRECT3DDEVICE9 iface
, DWORD Index
, D3DLIGHT9
* pLight
)
45 HRESULT WINAPI
IDirect3DDevice9HAL_GetLightEnable(LPDIRECT3DDEVICE9 iface
, DWORD Index
, BOOL
* pEnable
)
52 HRESULT WINAPI
IDirect3DDevice9HAL_GetClipPlane(LPDIRECT3DDEVICE9 iface
, DWORD Index
, float* pPlane
)
59 HRESULT WINAPI
IDirect3DDevice9HAL_SetRenderState(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD Value
)
66 HRESULT WINAPI
IDirect3DDevice9HAL_GetRenderState(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD
* pValue
)
73 HRESULT WINAPI
IDirect3DDevice9HAL_SetClipStatus(LPDIRECT3DDEVICE9 iface
, CONST D3DCLIPSTATUS9
* pClipStatus
)
80 HRESULT WINAPI
IDirect3DDevice9HAL_GetClipStatus(LPDIRECT3DDEVICE9 iface
, D3DCLIPSTATUS9
* pClipStatus
)
87 HRESULT WINAPI
IDirect3DDevice9HAL_GetTextureStageState(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD
* pValue
)
94 HRESULT WINAPI
IDirect3DDevice9HAL_GetSamplerState(LPDIRECT3DDEVICE9 iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD
* pValue
)
101 HRESULT WINAPI
IDirect3DDevice9HAL_ValidateDevice(LPDIRECT3DDEVICE9 iface
, DWORD
* pNumPasses
)
108 HRESULT WINAPI
IDirect3DDevice9HAL_SetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface
, BOOL bSoftware
)
115 BOOL WINAPI
IDirect3DDevice9HAL_GetSoftwareVertexProcessing(LPDIRECT3DDEVICE9 iface
)
122 HRESULT WINAPI
IDirect3DDevice9HAL_ProcessVertices(LPDIRECT3DDEVICE9 iface
, UINT SrcStartIndex
, UINT DestIndex
, UINT VertexCount
, IDirect3DVertexBuffer9
* pDestBuffer
, IDirect3DVertexDeclaration9
* pVertexDecl
, DWORD Flags
)
129 HRESULT WINAPI
IDirect3DDevice9HAL_GetVertexShader(LPDIRECT3DDEVICE9 iface
, IDirect3DVertexShader9
** ppShader
)
136 HRESULT WINAPI
IDirect3DDevice9HAL_GetPixelShader(LPDIRECT3DDEVICE9 iface
, IDirect3DPixelShader9
** ppShader
)
143 HRESULT WINAPI
IDirect3DDevice9HAL_GetPixelShaderConstantF(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
, float* pConstantData
, UINT Vector4fCount
)
150 HRESULT WINAPI
IDirect3DDevice9HAL_GetPixelShaderConstantI(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
, int* pConstantData
, UINT Vector4iCount
)
157 HRESULT WINAPI
IDirect3DDevice9HAL_GetPixelShaderConstantB(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
, BOOL
* pConstantData
, UINT BoolCount
)
164 /* IDirect3DDevice9 private interface */
165 HRESULT WINAPI
IDirect3DDevice9HAL_SetRenderStateWorker(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD Value
)
172 HRESULT WINAPI
IDirect3DDevice9HAL_SetTextureStageStateInt(LPDIRECT3DDEVICE9 iface
, DWORD Stage
, D3DTEXTURESTAGESTATETYPE Type
, DWORD Value
)
179 HRESULT WINAPI
IDirect3DDevice9HAL_SetSamplerStateInt(LPDIRECT3DDEVICE9 iface
, DWORD Sampler
, D3DSAMPLERSTATETYPE Type
, DWORD Value
)
186 HRESULT WINAPI
IDirect3DDevice9HAL_SetMaterialInt(LPDIRECT3DDEVICE9 iface
, CONST D3DMATERIAL9
* pMaterial
)
193 HRESULT WINAPI
IDirect3DDevice9HAL_SetVertexShaderInt(LPDIRECT3DDEVICE9 iface
, IDirect3DVertexShader9
* pShader
)
200 HRESULT WINAPI
IDirect3DDevice9HAL_SetVertexShaderConstantFInt(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
,CONST
float* pConstantData
,UINT Vector4fCount
)
207 HRESULT WINAPI
IDirect3DDevice9HAL_SetVertexShaderConstantIInt(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
,CONST
int* pConstantData
,UINT Vector4iCount
)
214 HRESULT WINAPI
IDirect3DDevice9HAL_SetVertexShaderConstantBInt(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
,CONST BOOL
* pConstantData
,UINT BoolCount
)
221 HRESULT WINAPI
IDirect3DDevice9HAL_SetPixelShaderInt(LPDIRECT3DDEVICE9 iface
, IDirect3DPixelShader9
* pShader
)
228 HRESULT WINAPI
IDirect3DDevice9HAL_SetPixelShaderConstantFInt(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
,CONST
float* pConstantData
,UINT Vector4fCount
)
235 HRESULT WINAPI
IDirect3DDevice9HAL_SetPixelShaderConstantIInt(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
,CONST
int* pConstantData
,UINT Vector4iCount
)
242 HRESULT WINAPI
IDirect3DDevice9HAL_SetPixelShaderConstantBInt(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
,CONST BOOL
* pConstantData
,UINT BoolCount
)
249 HRESULT WINAPI
IDirect3DDevice9HAL_SetFVFInt(LPDIRECT3DDEVICE9 iface
, DWORD FVF
)
256 HRESULT WINAPI
IDirect3DDevice9HAL_SetTextureInt(LPDIRECT3DDEVICE9 iface
, DWORD Stage
,IDirect3DBaseTexture9
* pTexture
)
263 HRESULT WINAPI
IDirect3DDevice9HAL_SetIndicesInt(LPDIRECT3DDEVICE9 iface
, IDirect3DIndexBuffer9
* pIndexData
)
270 HRESULT WINAPI
IDirect3DDevice9HAL_SetStreamSourceInt(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
,IDirect3DVertexBuffer9
* pStreamData
,UINT OffsetInBytes
,UINT Stride
)
277 HRESULT WINAPI
IDirect3DDevice9HAL_SetStreamSourceFreqInt(LPDIRECT3DDEVICE9 iface
, UINT StreamNumber
,UINT Setting
)
284 VOID WINAPI
IDirect3DDevice9HAL_UpdateRenderState(LPDIRECT3DDEVICE9 iface
, DWORD Unknown1
, DWORD Unknown2
)
289 HRESULT WINAPI
IDirect3DDevice9HAL_SetTransformInt(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
,CONST D3DMATRIX
* pMatrix
)
296 HRESULT WINAPI
IDirect3DDevice9HAL_MultiplyTransformInt(LPDIRECT3DDEVICE9 iface
, D3DTRANSFORMSTATETYPE State
, CONST D3DMATRIX
* pMatrix
)
303 HRESULT WINAPI
IDirect3DDevice9HAL_SetClipPlaneInt(LPDIRECT3DDEVICE9 iface
, DWORD Index
, CONST
float* pPlane
)
310 VOID WINAPI
IDirect3DDevice9HAL_UpdateDriverState(LPDIRECT3DDEVICE9 iface
)
315 HRESULT WINAPI
IDirect3DDevice9HAL_SetViewportInt(LPDIRECT3DDEVICE9 iface
, CONST D3DVIEWPORT9
* pViewport
)
322 VOID WINAPI
IDirect3DDevice9HAL_SetStreamSourceWorker(LPDIRECT3DDEVICE9 iface
, LPVOID UnknownStreamData
)
327 HRESULT WINAPI
IDirect3DDevice9HAL_SetPixelShaderConstantFWorker(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
, CONST
float* pConstantData
, UINT Vector4fCount
)
334 HRESULT WINAPI
IDirect3DDevice9HAL_SetPixelShaderConstantIWorker(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
, CONST
int* pConstantData
, UINT Vector4iCount
)
341 HRESULT WINAPI
IDirect3DDevice9HAL_SetPixelShaderConstantBWorker(LPDIRECT3DDEVICE9 iface
, UINT StartRegister
, CONST BOOL
* pConstantData
, UINT BoolCount
)
348 VOID WINAPI
IDirect3DDevice9HAL_DrawPrimitiveWorker(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT StartVertex
, UINT PrimitiveCount
)
353 HRESULT WINAPI
IDirect3DDevice9HAL_SetLightInt(LPDIRECT3DDEVICE9 iface
, DWORD Index
, CONST D3DLIGHT9
* pLight
)
360 HRESULT WINAPI
IDirect3DDevice9HAL_LightEnableInt(LPDIRECT3DDEVICE9 iface
, DWORD Index
, BOOL Enable
)
367 HRESULT WINAPI
IDirect3DDevice9HAL_SetRenderStateInt(LPDIRECT3DDEVICE9 iface
, D3DRENDERSTATETYPE State
, DWORD Value
)
374 HRESULT WINAPI
IDirect3DDevice9HAL_DrawPrimitiveUPInt(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT PrimitiveCount
)
381 HRESULT WINAPI
IDirect3DDevice9HAL_ClearInt(LPDIRECT3DDEVICE9 iface
, DWORD Count
, CONST D3DRECT
* pRects
, DWORD Flags
, D3DCOLOR Color
, float Z
, DWORD Stencil
)
388 VOID WINAPI
IDirect3DDevice9HAL_DrawPrimitivesWorker(LPDIRECT3DDEVICE9 iface
)
393 VOID WINAPI
IDirect3DDevice9HAL_UpdateVertexShader(LPDIRECT3DDEVICE9 iface
)
398 HRESULT WINAPI
IDirect3DDevice9HAL_ValidateDrawCall(LPDIRECT3DDEVICE9 iface
, D3DPRIMITIVETYPE PrimitiveType
, UINT Unknown1
, UINT Unknown2
, UINT Unknown3
, INT Unknown4
, UINT Unknown5
, INT Unknown6
)
405 HRESULT WINAPI
IDirect3DDevice9HAL_Init(LPDIRECT3DDEVICE9 iface
)
412 VOID WINAPI
IDirect3DDevice9HAL_InitState(LPDIRECT3DDEVICE9 iface
, INT State
)
417 VOID WINAPI
IDirect3DDevice9HAL_Destroy(LPDIRECT3DDEVICE9 iface
)
422 VOID WINAPI
IDirect3DDevice9HAL_VirtualDestructor(LPDIRECT3DDEVICE9 iface
)
427 IDirect3DDevice9Vtbl_INT Direct3DDevice9HAL_Vtbl
=
431 IDirect3DDevice9Base_QueryInterface
,
432 IDirect3DDevice9Base_AddRef
,
433 IDirect3DDevice9Base_Release
,
435 /* IDirect3DDevice9 public */
436 IDirect3DDevice9Base_TestCooperativeLevel
,
437 IDirect3DDevice9Base_GetAvailableTextureMem
,
438 IDirect3DDevice9Base_EvictManagedResources
,
439 IDirect3DDevice9Base_GetDirect3D
,
440 IDirect3DDevice9Base_GetDeviceCaps
,
441 IDirect3DDevice9Base_GetDisplayMode
,
442 IDirect3DDevice9Base_GetCreationParameters
,
443 IDirect3DDevice9Base_SetCursorProperties
,
444 IDirect3DDevice9Base_SetCursorPosition
,
445 IDirect3DDevice9Base_ShowCursor
,
446 IDirect3DDevice9Base_CreateAdditionalSwapChain
,
447 IDirect3DDevice9Base_GetSwapChain
,
448 IDirect3DDevice9Base_GetNumberOfSwapChains
,
449 IDirect3DDevice9Base_Reset
,
450 IDirect3DDevice9Base_Present
,
451 IDirect3DDevice9Base_GetBackBuffer
,
452 IDirect3DDevice9Base_GetRasterStatus
,
453 IDirect3DDevice9Base_SetDialogBoxMode
,
454 IDirect3DDevice9Base_SetGammaRamp
,
455 IDirect3DDevice9Base_GetGammaRamp
,
456 IDirect3DDevice9Base_CreateTexture
,
457 IDirect3DDevice9Base_CreateVolumeTexture
,
458 IDirect3DDevice9Base_CreateCubeTexture
,
459 IDirect3DDevice9Base_CreateVertexBuffer
,
460 IDirect3DDevice9Base_CreateIndexBuffer
,
461 IDirect3DDevice9Base_CreateRenderTarget
,
462 IDirect3DDevice9Base_CreateDepthStencilSurface
,
463 IDirect3DDevice9Base_UpdateSurface
,
464 IDirect3DDevice9Base_UpdateTexture
,
465 IDirect3DDevice9Base_GetRenderTargetData
,
466 IDirect3DDevice9Base_GetFrontBufferData
,
467 IDirect3DDevice9Base_StretchRect
,
468 IDirect3DDevice9Base_ColorFill
,
469 IDirect3DDevice9Base_CreateOffscreenPlainSurface
,
470 IDirect3DDevice9Pure_SetRenderTarget
,
471 IDirect3DDevice9Pure_GetRenderTarget
,
472 IDirect3DDevice9Pure_SetDepthStencilSurface
,
473 IDirect3DDevice9Pure_GetDepthStencilSurface
,
474 IDirect3DDevice9Pure_BeginScene
,
475 IDirect3DDevice9Pure_EndScene
,
476 IDirect3DDevice9Pure_Clear
,
477 IDirect3DDevice9Pure_SetTransform
,
478 IDirect3DDevice9HAL_GetTransform
,
479 IDirect3DDevice9Pure_MultiplyTransform
,
480 IDirect3DDevice9Pure_SetViewport
,
481 IDirect3DDevice9Pure_GetViewport
,
482 IDirect3DDevice9Pure_SetMaterial
,
483 IDirect3DDevice9HAL_GetMaterial
,
484 IDirect3DDevice9Pure_SetLight
,
485 IDirect3DDevice9HAL_GetLight
,
486 IDirect3DDevice9Pure_LightEnable
,
487 IDirect3DDevice9HAL_GetLightEnable
,
488 IDirect3DDevice9Pure_SetClipPlane
,
489 IDirect3DDevice9HAL_GetClipPlane
,
490 IDirect3DDevice9HAL_SetRenderState
,
491 IDirect3DDevice9HAL_GetRenderState
,
492 IDirect3DDevice9Pure_CreateStateBlock
,
493 IDirect3DDevice9Pure_BeginStateBlock
,
494 IDirect3DDevice9Pure_EndStateBlock
,
495 IDirect3DDevice9HAL_SetClipStatus
,
496 IDirect3DDevice9HAL_GetClipStatus
,
497 IDirect3DDevice9Pure_GetTexture
,
498 IDirect3DDevice9Pure_SetTexture
,
499 IDirect3DDevice9HAL_GetTextureStageState
,
500 IDirect3DDevice9Pure_SetTextureStageState
,
501 IDirect3DDevice9HAL_GetSamplerState
,
502 IDirect3DDevice9Pure_SetSamplerState
,
503 IDirect3DDevice9HAL_ValidateDevice
,
504 IDirect3DDevice9Pure_SetPaletteEntries
,
505 IDirect3DDevice9Pure_GetPaletteEntries
,
506 IDirect3DDevice9Pure_SetCurrentTexturePalette
,
507 IDirect3DDevice9Pure_GetCurrentTexturePalette
,
508 IDirect3DDevice9Pure_SetScissorRect
,
509 IDirect3DDevice9Pure_GetScissorRect
,
510 IDirect3DDevice9HAL_SetSoftwareVertexProcessing
,
511 IDirect3DDevice9HAL_GetSoftwareVertexProcessing
,
512 IDirect3DDevice9Pure_SetNPatchMode
,
513 IDirect3DDevice9Pure_GetNPatchMode
,
514 IDirect3DDevice9Pure_DrawPrimitive
,
515 IDirect3DDevice9Pure_DrawIndexedPrimitive
,
516 IDirect3DDevice9Pure_DrawPrimitiveUP
,
517 IDirect3DDevice9Pure_DrawIndexedPrimitiveUP
,
518 IDirect3DDevice9HAL_ProcessVertices
,
519 IDirect3DDevice9Pure_CreateVertexDeclaration
,
520 IDirect3DDevice9Pure_SetVertexDeclaration
,
521 IDirect3DDevice9Pure_GetVertexDeclaration
,
522 IDirect3DDevice9Pure_SetFVF
,
523 IDirect3DDevice9Pure_GetFVF
,
524 IDirect3DDevice9Pure_CreateVertexShader
,
525 IDirect3DDevice9Pure_SetVertexShader
,
526 IDirect3DDevice9HAL_GetVertexShader
,
527 IDirect3DDevice9Pure_SetVertexShaderConstantF
,
528 IDirect3DDevice9Pure_GetVertexShaderConstantF
,
529 IDirect3DDevice9Pure_SetVertexShaderConstantI
,
530 IDirect3DDevice9Pure_GetVertexShaderConstantI
,
531 IDirect3DDevice9Pure_SetVertexShaderConstantB
,
532 IDirect3DDevice9Pure_GetVertexShaderConstantB
,
533 IDirect3DDevice9Pure_SetStreamSource
,
534 IDirect3DDevice9Pure_GetStreamSource
,
535 IDirect3DDevice9Pure_SetStreamSourceFreq
,
536 IDirect3DDevice9Pure_GetStreamSourceFreq
,
537 IDirect3DDevice9Pure_SetIndices
,
538 IDirect3DDevice9Pure_GetIndices
,
539 IDirect3DDevice9Pure_CreatePixelShader
,
540 IDirect3DDevice9Pure_SetPixelShader
,
541 IDirect3DDevice9HAL_GetPixelShader
,
542 IDirect3DDevice9Pure_SetPixelShaderConstantF
,
543 IDirect3DDevice9HAL_GetPixelShaderConstantF
,
544 IDirect3DDevice9Pure_SetPixelShaderConstantI
,
545 IDirect3DDevice9HAL_GetPixelShaderConstantI
,
546 IDirect3DDevice9Pure_SetPixelShaderConstantB
,
547 IDirect3DDevice9HAL_GetPixelShaderConstantB
,
548 IDirect3DDevice9Pure_DrawRectPatch
,
549 IDirect3DDevice9Pure_DrawTriPatch
,
550 IDirect3DDevice9Pure_DeletePatch
,
551 IDirect3DDevice9Pure_CreateQuery
,
554 /* IDirect3DDevice9 private */
555 IDirect3DDevice9HAL_SetRenderStateWorker
,
556 IDirect3DDevice9HAL_SetTextureStageStateInt
,
557 IDirect3DDevice9HAL_SetSamplerStateInt
,
558 IDirect3DDevice9HAL_SetMaterialInt
,
559 IDirect3DDevice9HAL_SetVertexShaderInt
,
560 IDirect3DDevice9HAL_SetVertexShaderConstantFInt
,
561 IDirect3DDevice9HAL_SetVertexShaderConstantIInt
,
562 IDirect3DDevice9HAL_SetVertexShaderConstantBInt
,
563 IDirect3DDevice9HAL_SetPixelShaderInt
,
564 IDirect3DDevice9HAL_SetPixelShaderConstantFInt
,
565 IDirect3DDevice9HAL_SetPixelShaderConstantIInt
,
566 IDirect3DDevice9HAL_SetPixelShaderConstantBInt
,
567 IDirect3DDevice9HAL_SetFVFInt
,
568 IDirect3DDevice9HAL_SetTextureInt
,
569 IDirect3DDevice9HAL_SetIndicesInt
,
570 IDirect3DDevice9HAL_SetStreamSourceInt
,
571 IDirect3DDevice9HAL_SetStreamSourceFreqInt
,
572 IDirect3DDevice9HAL_UpdateRenderState
,
573 IDirect3DDevice9HAL_SetTransformInt
,
574 IDirect3DDevice9HAL_MultiplyTransformInt
,
575 IDirect3DDevice9HAL_SetClipPlaneInt
,
576 IDirect3DDevice9HAL_UpdateDriverState
,
577 IDirect3DDevice9HAL_SetViewportInt
,
578 IDirect3DDevice9HAL_SetStreamSourceWorker
,
579 IDirect3DDevice9HAL_SetPixelShaderConstantFWorker
,
580 IDirect3DDevice9HAL_SetPixelShaderConstantIWorker
,
581 IDirect3DDevice9HAL_SetPixelShaderConstantBWorker
,
582 IDirect3DDevice9HAL_DrawPrimitiveWorker
,
583 IDirect3DDevice9HAL_SetLightInt
,
584 IDirect3DDevice9HAL_LightEnableInt
,
585 IDirect3DDevice9HAL_SetRenderStateInt
,
586 IDirect3DDevice9HAL_DrawPrimitiveUPInt
,
587 IDirect3DDevice9HAL_ClearInt
,
588 IDirect3DDevice9HAL_DrawPrimitivesWorker
,
589 IDirect3DDevice9HAL_UpdateVertexShader
,
590 IDirect3DDevice9HAL_ValidateDrawCall
,
591 IDirect3DDevice9HAL_Init
,
592 IDirect3DDevice9HAL_InitState
,
593 IDirect3DDevice9HAL_Destroy
,
594 IDirect3DDevice9HAL_VirtualDestructor
,