FF13Fix/d3d9ex/IDirect3DDevice9.h
Robert Krawczyk 3a844cc3ca Changes:
Fixed DXVK window starting in background and required clicking to activate
Added experimental (disabled by default) DiscardUIVertexBuffer option
Improved D3D9 reference counting
Two step initialization, check is correct window was created, then initialize 2s after IDirect3D9::CreateDevice call

Other:
Fix some include hell
Settings.h now include all comments so it will autogenerated ini file
Deleted IDirect3DVertexBuffer9.cpp/h
2021-03-13 03:54:05 +01:00

173 lines
11 KiB
C++

// wrapper for IDirect3DDevice9 in d3d9.h
// generated using wrapper_gen.rb
#pragma once
#include <d3d9.h>
interface hkIDirect3DDevice9 final : public IDirect3DDevice9 {
public:
// original interface
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObj);
ULONG STDMETHODCALLTYPE AddRef() {
uint32_t refCount = m_refCount++;
if (!refCount)
AddRefPrivate();
return refCount + 1;
}
ULONG STDMETHODCALLTYPE Release() {
ULONG refCount = this->m_refCount;
if (refCount != 0ul) {
this->m_refCount--;
refCount--;
if (refCount == 0ul)
this->ReleasePrivate();
}
return refCount;
}
STDMETHOD(TestCooperativeLevel)();
STDMETHOD_(UINT, GetAvailableTextureMem)();
STDMETHOD(EvictManagedResources)();
STDMETHOD(GetDirect3D)(IDirect3D9** ppD3D9);
STDMETHOD(GetDeviceCaps)(D3DCAPS9* pCaps);
STDMETHOD(GetDisplayMode)(UINT iSwapChain, D3DDISPLAYMODE* pMode);
STDMETHOD(GetCreationParameters)(D3DDEVICE_CREATION_PARAMETERS* pParameters);
STDMETHOD(SetCursorProperties)(UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap);
STDMETHOD_(void, SetCursorPosition)(int X, int Y, DWORD Flags);
STDMETHOD_(BOOL, ShowCursor)(BOOL bShow);
STDMETHOD(CreateAdditionalSwapChain)(D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain);
STDMETHOD(GetSwapChain)(UINT iSwapChain, IDirect3DSwapChain9** pSwapChain);
STDMETHOD_(UINT, GetNumberOfSwapChains)();
STDMETHOD(Reset)(D3DPRESENT_PARAMETERS* pPresentationParameters);
STDMETHOD(Present)(CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion);
STDMETHOD(GetBackBuffer)(UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer);
STDMETHOD(GetRasterStatus)(UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus);
STDMETHOD(SetDialogBoxMode)(BOOL bEnableDialogs);
STDMETHOD_(void, SetGammaRamp)(UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp);
STDMETHOD_(void, GetGammaRamp)(UINT iSwapChain, D3DGAMMARAMP* pRamp);
STDMETHOD(CreateTexture)(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle);
STDMETHOD(CreateVolumeTexture)(UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle);
STDMETHOD(CreateCubeTexture)(UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle);
STDMETHOD(CreateVertexBuffer)(UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle);
STDMETHOD(CreateIndexBuffer)(UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle);
STDMETHOD(CreateRenderTarget)(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
STDMETHOD(CreateDepthStencilSurface)(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
STDMETHOD(UpdateSurface)(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint);
STDMETHOD(UpdateTexture)(IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture);
STDMETHOD(GetRenderTargetData)(IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface);
STDMETHOD(GetFrontBufferData)(UINT iSwapChain, IDirect3DSurface9* pDestSurface);
STDMETHOD(StretchRect)(IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter);
STDMETHOD(ColorFill)(IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color);
STDMETHOD(CreateOffscreenPlainSurface)(UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
STDMETHOD(SetRenderTarget)(DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget);
STDMETHOD(GetRenderTarget)(DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget);
STDMETHOD(SetDepthStencilSurface)(IDirect3DSurface9* pNewZStencil);
STDMETHOD(GetDepthStencilSurface)(IDirect3DSurface9** ppZStencilSurface);
STDMETHOD(BeginScene)();
STDMETHOD(EndScene)();
STDMETHOD(Clear)(DWORD Count, CONST D3DRECT* pRects, DWORD Flags, D3DCOLOR Color, float Z, DWORD Stencil);
STDMETHOD(SetTransform)(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
STDMETHOD(GetTransform)(D3DTRANSFORMSTATETYPE State, D3DMATRIX* pMatrix);
STDMETHOD(MultiplyTransform)(D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX* pMatrix);
STDMETHOD(SetViewport)(CONST D3DVIEWPORT9* pViewport);
STDMETHOD(GetViewport)(D3DVIEWPORT9* pViewport);
STDMETHOD(SetMaterial)(CONST D3DMATERIAL9* pMaterial);
STDMETHOD(GetMaterial)(D3DMATERIAL9* pMaterial);
STDMETHOD(SetLight)(DWORD Index, CONST D3DLIGHT9* pLight);
STDMETHOD(GetLight)(DWORD Index, D3DLIGHT9* pLight);
STDMETHOD(LightEnable)(DWORD Index, BOOL Enable);
STDMETHOD(GetLightEnable)(DWORD Index, BOOL* pEnable);
STDMETHOD(SetClipPlane)(DWORD Index, CONST float* pPlane);
STDMETHOD(GetClipPlane)(DWORD Index, float* pPlane);
STDMETHOD(SetRenderState)(D3DRENDERSTATETYPE State, DWORD Value);
STDMETHOD(GetRenderState)(D3DRENDERSTATETYPE State, DWORD* pValue);
STDMETHOD(CreateStateBlock)(D3DSTATEBLOCKTYPE Type, IDirect3DStateBlock9** ppSB);
STDMETHOD(BeginStateBlock)();
STDMETHOD(EndStateBlock)(IDirect3DStateBlock9** ppSB);
STDMETHOD(SetClipStatus)(CONST D3DCLIPSTATUS9* pClipStatus);
STDMETHOD(GetClipStatus)(D3DCLIPSTATUS9* pClipStatus);
STDMETHOD(GetTexture)(DWORD Stage, IDirect3DBaseTexture9** ppTexture);
STDMETHOD(SetTexture)(DWORD Stage, IDirect3DBaseTexture9* pTexture);
STDMETHOD(GetTextureStageState)(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue);
STDMETHOD(SetTextureStageState)(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
STDMETHOD(GetSamplerState)(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD* pValue);
STDMETHOD(SetSamplerState)(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
STDMETHOD(ValidateDevice)(DWORD* pNumPasses);
STDMETHOD(SetPaletteEntries)(UINT PaletteNumber, CONST PALETTEENTRY* pEntries);
STDMETHOD(GetPaletteEntries)(UINT PaletteNumber, PALETTEENTRY* pEntries);
STDMETHOD(SetCurrentTexturePalette)(UINT PaletteNumber);
STDMETHOD(GetCurrentTexturePalette)(UINT* PaletteNumber);
STDMETHOD(SetScissorRect)(CONST RECT* pRect);
STDMETHOD(GetScissorRect)(RECT* pRect);
STDMETHOD(SetSoftwareVertexProcessing)(BOOL bSoftware);
STDMETHOD_(BOOL, GetSoftwareVertexProcessing)();
STDMETHOD(SetNPatchMode)(float nSegments);
STDMETHOD_(float, GetNPatchMode)();
STDMETHOD(DrawPrimitive)(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
STDMETHOD(DrawIndexedPrimitive)(D3DPRIMITIVETYPE, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount);
STDMETHOD(DrawPrimitiveUP)(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
STDMETHOD(DrawIndexedPrimitiveUP)(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertices, UINT PrimitiveCount, CONST void* pIndexData, D3DFORMAT IndexDataFormat, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
STDMETHOD(ProcessVertices)(UINT SrcStartIndex, UINT DestIndex, UINT VertexCount, IDirect3DVertexBuffer9* pDestBuffer, IDirect3DVertexDeclaration9* pVertexDecl, DWORD Flags);
STDMETHOD(CreateVertexDeclaration)(CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl);
STDMETHOD(SetVertexDeclaration)(IDirect3DVertexDeclaration9* pDecl);
STDMETHOD(GetVertexDeclaration)(IDirect3DVertexDeclaration9** ppDecl);
STDMETHOD(SetFVF)(DWORD FVF);
STDMETHOD(GetFVF)(DWORD* pFVF);
STDMETHOD(CreateVertexShader)(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader);
STDMETHOD(SetVertexShader)(IDirect3DVertexShader9* pShader);
STDMETHOD(GetVertexShader)(IDirect3DVertexShader9** ppShader);
STDMETHOD(SetVertexShaderConstantF)(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
STDMETHOD(GetVertexShaderConstantF)(UINT StartRegister, float* pConstantData, UINT Vector4fCount);
STDMETHOD(SetVertexShaderConstantI)(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
STDMETHOD(GetVertexShaderConstantI)(UINT StartRegister, int* pConstantData, UINT Vector4iCount);
STDMETHOD(SetVertexShaderConstantB)(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
STDMETHOD(GetVertexShaderConstantB)(UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
STDMETHOD(SetStreamSource)(UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride);
STDMETHOD(GetStreamSource)(UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* pOffsetInBytes, UINT* pStride);
STDMETHOD(SetStreamSourceFreq)(UINT StreamNumber, UINT Setting);
STDMETHOD(GetStreamSourceFreq)(UINT StreamNumber, UINT* pSetting);
STDMETHOD(SetIndices)(IDirect3DIndexBuffer9* pIndexData);
STDMETHOD(GetIndices)(IDirect3DIndexBuffer9** ppIndexData);
STDMETHOD(CreatePixelShader)(CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader);
STDMETHOD(SetPixelShader)(IDirect3DPixelShader9* pShader);
STDMETHOD(GetPixelShader)(IDirect3DPixelShader9** ppShader);
STDMETHOD(SetPixelShaderConstantF)(UINT StartRegister, CONST float* pConstantData, UINT Vector4fCount);
STDMETHOD(GetPixelShaderConstantF)(UINT StartRegister, float* pConstantData, UINT Vector4fCount);
STDMETHOD(SetPixelShaderConstantI)(UINT StartRegister, CONST int* pConstantData, UINT Vector4iCount);
STDMETHOD(GetPixelShaderConstantI)(UINT StartRegister, int* pConstantData, UINT Vector4iCount);
STDMETHOD(SetPixelShaderConstantB)(UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
STDMETHOD(GetPixelShaderConstantB)(UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
STDMETHOD(DrawRectPatch)(UINT Handle, CONST float* pNumSegs, CONST D3DRECTPATCH_INFO* pRectPatchInfo);
STDMETHOD(DrawTriPatch)(UINT Handle, CONST float* pNumSegs, CONST D3DTRIPATCH_INFO* pTriPatchInfo);
STDMETHOD(DeletePatch)(UINT Handle);
STDMETHOD(CreateQuery)(D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery);
hkIDirect3DDevice9(IDirect3DDevice9* pIDirect3DDevice9)
: m_pWrapped(pIDirect3DDevice9)
{
m_pWrapped->AddRef();
}
virtual ~hkIDirect3DDevice9() { while (m_pWrapped->Release()); }
private:
IDirect3DDevice9* m_pWrapped;
std::atomic<uint32_t> m_refCount = { 0ul };
std::atomic<uint32_t> m_refPrivate = { 1ul };
void AddRefPrivate() {
++m_refPrivate;
}
void ReleasePrivate() {
uint32_t refPrivate = --m_refPrivate;
if (!refPrivate) {
m_refPrivate += 0x80000000;
delete this;
}
}
};