diff --git a/projects/WinDurango.D3D11X/CMakeLists.txt b/projects/WinDurango.D3D11X/CMakeLists.txt index 07b6a17..7594aef 100644 --- a/projects/WinDurango.D3D11X/CMakeLists.txt +++ b/projects/WinDurango.D3D11X/CMakeLists.txt @@ -16,7 +16,7 @@ set(FILES Exports.def ) -add_library(WinDurango.D3D11X SHARED ${FILES} "include/WinDurango.D3D11X/ID3D11DeviceChild.h" "src/ID3D11DeviceChild.cpp" "include/WinDurango.D3D11X/ID3D11Resource.h" "src/ID3D11Resource.cpp" "include/WinDurango.D3D11X/ID3D11Shader.h" "src/ID3D11Shader.cpp" "include/WinDurango.D3D11X/ID3D11State.h" "src/ID3D11State.cpp" "include/WinDurango.D3D11X/ID3D11View.h" "src/ID3D11View.cpp" "include/WinDurango.D3D11X/ID3D11DeviceContext.h" "src/ID3D11DeviceContext.cpp" "include/WinDurango.D3D11X/ID3D11DMAEngineContext.h" "src/ID3D11DMAEngineContext.cpp" "include/WinDurango.D3D11X/ID3D11Device.h" "src/ID3D11Device.cpp" "include/WinDurango.D3D11X/ID3D11Runtime.h" "src/dllmain.cpp" "include/WinDurango.D3D11X/IDXGIAdapter.h" "include/WinDurango.D3D11X/IDXGIDevice.h" "include/WinDurango.D3D11X/IDXGIFactory.h" "include/WinDurango.D3D11X/IDXGISwapChain.h" "src/IDXGIAdapter.cpp" "src/IDXGIDevice.cpp" "src/IDXGIFactory.cpp" "src/IDXGISwapChain.cpp") +add_library(WinDurango.D3D11X SHARED ${FILES} "include/WinDurango.D3D11X/ID3D11DeviceChild.h" "src/ID3D11DeviceChild.cpp" "include/WinDurango.D3D11X/ID3D11Resource.h" "src/ID3D11Resource.cpp" "include/WinDurango.D3D11X/ID3D11Shader.h" "src/ID3D11Shader.cpp" "include/WinDurango.D3D11X/ID3D11State.h" "src/ID3D11State.cpp" "include/WinDurango.D3D11X/ID3D11View.h" "src/ID3D11View.cpp" "include/WinDurango.D3D11X/ID3D11DeviceContext.h" "src/ID3D11DeviceContext.cpp" "include/WinDurango.D3D11X/ID3D11DMAEngineContext.h" "src/ID3D11DMAEngineContext.cpp" "include/WinDurango.D3D11X/ID3D11Device.h" "src/ID3D11Device.cpp" "include/WinDurango.D3D11X/ID3D11Runtime.h" "src/dllmain.cpp" "include/WinDurango.D3D11X/IDXGIAdapter.h" "include/WinDurango.D3D11X/IDXGIDevice.h" "include/WinDurango.D3D11X/IDXGIFactory.h" "include/WinDurango.D3D11X/IDXGISwapChain.h" "src/IDXGIAdapter.cpp" "src/IDXGIDevice.cpp" "src/IDXGIFactory.cpp" "src/IDXGISwapChain.cpp" ) target_link_libraries(WinDurango.D3D11X PRIVATE WinDurango.Common) diff --git a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DMAEngineContext.h b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DMAEngineContext.h index 66013bf..256cc7d 100644 --- a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DMAEngineContext.h +++ b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DMAEngineContext.h @@ -1,9 +1,64 @@ #pragma once +#include "ID3D11DeviceContext.h" #include "d3d11_x.g.h" +#include -template class D3D11DMAEngineContextX : public gfx::ID3D11DMAEngineContextX +BOOL DMAFences[1024]{}; +UINT DMAFenceIndex = 0; + +template struct CopyResourceCommand; + +template struct CopySubresourceRegionCommand; + +template struct DMAInsertFenceCommand; + +template struct DMAInsertWaitOnFenceCommand; + +template struct LZDecompressMemoryCommand; + +template struct FillMemoryWithValueCommand; + +template struct CopyLastErrorCodeToMemoryCommand; + +template struct DMACommands { public: + enum class DMACommandType + { + CopyResource, + CopySubresourceRegion, + DMAInsertFence, + DMAInsertWaitOnFence, + LZDecompressMemory, + FillMemoryWithValue, + CopyLastErrorCodeToMemory, + }; + + union { + CopyResourceCommand CopyResource; + CopySubresourceRegionCommand CopySubresourceRegion; + DMAInsertFenceCommand DMAInsertFence; + DMAInsertWaitOnFenceCommand DMAInsertWaitOnFence; + LZDecompressMemoryCommand LZDecompressMemory; + FillMemoryWithValueCommand FillMemoryWithValue; + CopyLastErrorCodeToMemoryCommand CopyLastErrorCodeToMemory; + }; + + DMACommandType m_DMACommandType; +}; + +template class D3D11DMAEngineContextX : public gfx::ID3D11DMAEngineContextX, ID3D11BackgroundContext +{ + public: + std::vector> m_DMACommandQueue; + D3D11DeviceContextX *m_pImmediateContext; + + D3D11DMAEngineContextX() + { + AddRef(); + m_pImmediateContext = new D3D11DeviceContextX(); + } + // // IUnknown // @@ -19,6 +74,10 @@ template class D3D11DMAEngineContextX : public gfx::ID3D11DMAEngineC HRESULT SetPrivateData(_GUID const &guid, uint32_t DataSize, void const *pData); HRESULT SetPrivateDataInterface(_GUID const &guid, IUnknown const *pData); HRESULT SetPrivateDataInterfaceGraphics(_GUID const &guid, xbox::IGraphicsUnknown const *pData); + HRESULT SetName(LPCWSTR pName) + { + return S_OK; + } // // ID3D11DMAEngineContextX @@ -51,8 +110,102 @@ template class D3D11DMAEngineContextX : public gfx::ID3D11DMAEngineC void WriteTimestampToBuffer(gfx::ID3D11Buffer *v1, uint32_t v2); void WriteValueBottomOfPipe(void *v1, uint32_t v2); void InsertWaitOnMemory(void const *v1, uint32_t v2, D3D11_COMPARISON_FUNC v3, uint32_t v4, uint32_t v5); + + BOOL ExecuteContext() override; + UINT m_CommandIndex = 0; +}; + +template struct CopyResourceCommand +{ + gfx::ID3D11Resource *pDstResource; + gfx::ID3D11Resource *pSrcResource; + UINT Flags; + + BOOL Execute(D3D11DMAEngineContextX *pDmaContext) + { + pDmaContext->m_pImmediateContext->CopyResource(pDstResource, pSrcResource); + return FALSE; + } +}; + +template struct CopySubresourceRegionCommand +{ + gfx::ID3D11Resource *pDstResource; + UINT DstSubresource; + UINT DstX; + UINT DstY; + UINT DstZ; + gfx::ID3D11Resource *pSrcResource; + UINT SrcSubresource; + const D3D11_BOX *pSrcBox; + UINT Flags; + + BOOL Execute(D3D11DMAEngineContextX *pDmaContext) + { + pDmaContext->m_pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, + pSrcResource, SrcSubresource, pSrcBox); + return FALSE; + } +}; + +template struct DMAInsertFenceCommand +{ + UINT Flags; + UINT64 Fence; + + BOOL Execute(D3D11DMAEngineContextX *pDmaContext) + { + return !*reinterpret_cast(Fence); + } +}; + +template struct DMAInsertWaitOnFenceCommand +{ + UINT Flags; + UINT64 Fence; + + BOOL Execute(D3D11DMAEngineContextX *pDmaContext) + { + return !*reinterpret_cast(Fence); + } +}; + +template struct LZDecompressMemoryCommand +{ + void *NextIn; + void *NextOut; + UINT AvailIn; + UINT Flags; + + BOOL Execute(D3D11DMAEngineContextX *pDmaContext) + { + //TODO: Install zlib + return FALSE; + } +}; + +template struct FillMemoryWithValueCommand +{ + void *pDstAddress; + UINT64 SizeBytes; + UINT FillValue; + + BOOL Execute(D3D11DMAEngineContextX *pDmaContext) + { + pDmaContext->m_pImmediateContext->FillMemoryWithValue(pDstAddress, SizeBytes, FillValue); + return FALSE; + } +}; + +template struct CopyLastErrorCodeToMemoryCommand +{ + void *pDstAddress; + BOOL Execute(D3D11DMAEngineContextX *pDmaContext) + { + return FALSE; + } }; #undef ABI_INTERFACE #define ABI_INTERFACE(ABI) D3D11DMAEngineContextX -D3D11_DECLARE_ABI_TEMPLATES(extern); +D3D11_DECLARE_ABI_TEMPLATES(extern); \ No newline at end of file diff --git a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DeviceContext.h b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DeviceContext.h index 2e6fad3..fb95d36 100644 --- a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DeviceContext.h +++ b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11DeviceContext.h @@ -1,5 +1,35 @@ #pragma once #include "d3d11_x.g.h" +#include +#include +#include + +ID3D11DeviceContext2 *g_Context = nullptr; + +static std::map D3D11X_HARDWARE_TO_TOPOLOGY_MAP = { + {0x000001ffc0009e00, 0}, {0x000003ffc0009e00, 1}, {0x000005ffc0009e00, 2}, {0x000007ffc0009e00, 3}, + {0x000009ffc0009e00, 4}, {0x00000dffc0009e00, 5}, {0x00000bffc0009e00, 6}, {0x000001ffc0009e00, 7}, + {0x000001ffc0009e00, 8}, {0x000001ffc0009e00, 9}, {0x0000157fc0009e00, 10}, {0x0000177fc0009e00, 11}, + {0x0000197fc0009e00, 12}, {0x00001b7fc0009e00, 13}, {0x00001dffc0009e00, 14}, {0x00001fffc0009e00, 15}, + {0x000021ffc0009e00, 16}, {0x000023ffc0009e00, 17}, {0x000025ffc0009e00, 18}, {0x000027ffc0009e00, 19}, + {0x000029ffc0009e00, 20}, {0x00002bffc0009e00, 21}, {0x00002dffc0009e00, 22}, {0x00002fffc0009e00, 23}, + {0x000031ffc0009e00, 24}, {0x000033ffc0009e00, 25}, {0x000035ffc0009e00, 26}, {0x000037ffc0009e00, 27}, + {0x000039ffc0009e00, 28}, {0x000001ffc0009e00, 29}, {0x000001ffc0009e00, 30}, {0x000001ffc0009e00, 31}, + {0x000001ffc0009e00, 32}, {0x001013ffc0009e00, 33}, {0x0020137fc0009e00, 34}, {0x00301354c0009e00, 35}, + {0x0040133fc0009e00, 36}, {0x00501332c0009e00, 37}, {0x00601329c0009e00, 38}, {0x00701323c0009e00, 39}, + {0x0080131fc0009e00, 40}, {0x0090131bc0009e00, 41}, {0x00a01318c0009e00, 42}, {0x00b01316c0009e00, 43}, + {0x00c01314c0009e00, 44}, {0x00d01312c0009e00, 45}, {0x00e01311c0009e00, 46}, {0x00f01310c0009e00, 47}, + {0x0100130fc0009e00, 48}, {0x0110130ec0009e00, 49}, {0x0120130dc0009e00, 50}, {0x0130130cc0009e00, 51}, + {0x0140130bc0009e00, 52}, {0x0150130bc0009e00, 53}, {0x0160130ac0009e00, 54}, {0x0170130ac0009e00, 55}, + {0x01801309c0009e00, 56}, {0x01901309c0009e00, 57}, {0x01a01308c0009e00, 58}, {0x01b01308c0009e00, 59}, + {0x01c01308c0009e00, 60}, {0x01d01307c0009e00, 61}, {0x01e01307c0009e00, 62}, {0x01f01307c0009e00, 63}, + {0x02001307c0009e00, 64}}; + +struct ID3D11BackgroundContext : IUnknown +{ + // Returns TRUE if the context has executed all of its commands + virtual BOOL ExecuteContext() = 0; +}; template class D3D11DeviceContextX : public gfx::ID3D11DeviceContextX { @@ -9,6 +39,13 @@ public: D3D11DeviceContextX(ID3D11DeviceContext2 *pContext) { m_pFunction = pContext; + g_Context = m_pFunction; + InterlockedIncrement(&this->m_RefCount); + memcpy(&this->m_Function, *(void ***)this, sizeof(this->m_Function)); + } + D3D11DeviceContextX() + { + m_pFunction = g_Context; InterlockedIncrement(&this->m_RefCount); memcpy(&this->m_Function, *(void ***)this, sizeof(this->m_Function)); } @@ -29,15 +66,23 @@ public: HRESULT SetPrivateDataInterface(_GUID const &guid, IUnknown const *pData); HRESULT SetPrivateDataInterfaceGraphics(_GUID const &guid, xbox::IGraphicsUnknown const *pData); + std::vector m_BkgContexts; + std::mutex m_BkgCtxLock; + // // ID3D11DeviceContext // + void CheckDirtyFlags(); + void ExecuteBackgroundContexts(); + void AddBackgroundContext(ID3D11BackgroundContext *pContext); + void RemoveBackgroundContext(ID3D11BackgroundContext *pContext); void VSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); void PSSetShaderResources(UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); void PSSetShader(gfx::ID3D11PixelShader *pPixelShader); void PSSetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers); void VSSetShader(gfx::ID3D11VertexShader *pVertexShader); + void DrawIndexed(UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation); void DrawIndexed(UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation); void Draw(UINT VertexCount, UINT StartVertexLocation); HRESULT Map(gfx::ID3D11Resource *pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, @@ -49,8 +94,12 @@ public: UINT const *pStrides, UINT const *pOffsets); void IASetIndexBuffer(UINT HardwareIndexFormat, gfx::ID3D11Buffer *pIndexBuffer, UINT Offset); void IASetIndexBuffer(gfx::ID3D11Buffer *pIndexBuffer, UINT hardwareIndexFormat, UINT Offset); - void DrawIndexedInstanced(UINT StartIndexLocationAndIndexCountPerInstance, - UINT64 BaseVertexLocationAndStartInstanceLocation, UINT64 InstanceCount); + void DrawIndexedInstanced(UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, + INT BaseVertexLocation, UINT StartInstanceLocation); + void DrawIndexedInstanced(UINT64 StartIndexLocationAndIndexCountPerInstance, + UINT64 BaseVertexLocationAndStartInstanceLocation, UINT InstanceCount); + void DrawInstanced(UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, + UINT StartInstanceLocation); void DrawInstanced(UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount); void GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); diff --git a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11Runtime.h b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11Runtime.h index ff19a8c..1735b59 100644 --- a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11Runtime.h +++ b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/ID3D11Runtime.h @@ -1,6 +1,7 @@ #pragma once #include "ID3D11Device.h" #include "ID3D11DeviceContext.h" +#include "IDXGISwapChain.h" static ID3D11Device2 *pDev2 = nullptr; static ID3D11DeviceContext2 *pCtx2 = nullptr; @@ -43,4 +44,25 @@ template struct D3D11Runtime : public ID3D11Runtime return hr; }; -}; \ No newline at end of file +}; + + +struct IDXGIXPresentArrayHelper +{ + virtual void PresentArray(void **ppSwapChains, UINT NumSwapChains, UINT SyncInterval) = 0; +}; + +template struct DXGIXPresentArrayHelper : public IDXGIXPresentArrayHelper +{ + void PresentArray(void **ppSwapChains, UINT NumSwapChains, UINT SyncInterval) override + { + for (UINT SwapChainIndex = 0; SwapChainIndex < NumSwapChains; SwapChainIndex++) + { + DXGISwapChain1 *SwapChain = static_cast *>(ppSwapChains[SwapChainIndex]); + SwapChain->Present(SyncInterval, 0); + } + } + +}; + +static IDXGIXPresentArrayHelper *g_PresentArrayHelper = nullptr; \ No newline at end of file diff --git a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11.x.h b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11.x.h index 840e324..667ce27 100644 --- a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11.x.h +++ b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11.x.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include // We use that to know the OS version. abi_t g_ABI{}; @@ -69,3 +71,100 @@ void GetCombaseVersion() g_ABI.Build = build; g_ABI.Revision = revision; } + +inline bool IsBlockCompressed(DXGI_FORMAT format) +{ + switch (format) + { + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + case DXGI_FORMAT_BC5_SNORM: + case DXGI_FORMAT_BC6H_TYPELESS: + case DXGI_FORMAT_BC6H_UF16: + case DXGI_FORMAT_BC6H_SF16: + case DXGI_FORMAT_BC7_TYPELESS: + case DXGI_FORMAT_BC7_UNORM: + case DXGI_FORMAT_BC7_UNORM_SRGB: + return true; + default: + return false; + } +} + +inline uint32_t BytesPerBlock(DXGI_FORMAT format) +{ + switch (format) + { + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: + return 8; + + default: + return 16; + } +} + +inline uint32_t BytesPerPixel(DXGI_FORMAT format) +{ + switch (format) + { + case DXGI_FORMAT_R8_UNORM: + return 1; + case DXGI_FORMAT_R8G8_UNORM: + return 2; + case DXGI_FORMAT_R8G8B8A8_UNORM: + return 4; + case DXGI_FORMAT_B8G8R8A8_UNORM: + return 4; + case DXGI_FORMAT_R16_FLOAT: + return 2; + case DXGI_FORMAT_R16G16_FLOAT: + return 4; + case DXGI_FORMAT_R16G16B16A16_FLOAT: + return 8; + case DXGI_FORMAT_R32_FLOAT: + return 4; + case DXGI_FORMAT_R32G32_FLOAT: + return 8; + case DXGI_FORMAT_R32G32B32A32_FLOAT: + return 16; + default: + return 0; + } +} + +inline void CalculatePitch(uint32_t Width, uint32_t Height, DXGI_FORMAT Format, uint32_t* pRowPitch, uint32_t* pSlicePitch) +{; + if (IsBlockCompressed(Format)) + { + uint32_t BlocksWide = (Width + 3) / 4; + uint32_t BlocksHigh = (Height + 3) / 4; + uint32_t BlockSize = BytesPerBlock(Format); + + (*pRowPitch) = BlocksWide * BlockSize; + (*pSlicePitch) = (*pRowPitch) * BlocksHigh; + } + else + { + uint32_t bpp = BytesPerPixel(Format); + + (*pRowPitch) = Width * bpp; + (*pSlicePitch) = (*pRowPitch) * Height; + } +} diff --git a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11_x.g.h b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11_x.g.h index 61b6db3..a553842 100644 --- a/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11_x.g.h +++ b/projects/WinDurango.D3D11X/include/WinDurango.D3D11X/d3d11_x.g.h @@ -1339,7 +1339,7 @@ enum D3D11X_IMG_NUM_FORMAT virtual void PSSetShader(gfx::ID3D11PixelShader *pPixelShader) = 0; virtual void PSSetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers) = 0; virtual void VSSetShader(gfx::ID3D11VertexShader *pVertexShader) = 0; - virtual void DrawIndexed(UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation) = 0; + virtual void DrawIndexed(UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation) = 0; virtual void Draw(UINT VertexCount, UINT StartVertexLocation) = 0; virtual HRESULT Map(gfx::ID3D11Resource *pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, D3D11_MAPPED_SUBRESOURCE *pMappedResource) = 0; virtual void Unmap(gfx::ID3D11Resource *pResource, UINT Subresource) = 0; @@ -1347,7 +1347,7 @@ enum D3D11X_IMG_NUM_FORMAT virtual void IASetInputLayout(ID3D11InputLayout *pInputLayout) = 0; virtual void IASetVertexBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppVertexBuffers, UINT const *pStrides, UINT const *pOffsets) = 0; virtual void IASetIndexBuffer(gfx::ID3D11Buffer *pIndexBuffer, UINT HardwareIndexFormat, UINT Offset) = 0; - virtual void DrawIndexedInstanced(UINT StartIndexLocationAndIndexCountPerInstance, UINT64 BaseVertexLocationAndStartInstanceLocation, UINT64 InstanceCount) = 0; + virtual void DrawIndexedInstanced(UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, INT BaseVertexLocation, UINT StartInstanceLocation) = 0; virtual void DrawInstanced(UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount) = 0; virtual void GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; virtual void GSSetShader(gfx::ID3D11GeometryShader *pShader) = 0; @@ -1443,6 +1443,189 @@ enum D3D11X_IMG_NUM_FORMAT virtual UINT GetContextFlags() = 0; virtual HRESULT FinishCommandList(BOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList) = 0; }; + + template + requires(ABI >= abi_t{6,2,11064,0} && ABI < abi_t{6,2,11294,0}) + struct ID3D11DeviceContext : gfx::ID3D11DeviceChild, details::ID3D11DeviceContextData + { + virtual void VSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; + virtual void PSSetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews) = 0; + virtual void PSSetShader(gfx::ID3D11PixelShader *pPixelShader) = 0; + virtual void PSSetSamplers(UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers) = 0; + virtual void VSSetShader(gfx::ID3D11VertexShader *pVertexShader) = 0; + virtual void DrawIndexed(UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation) = 0; + virtual void Draw(UINT VertexCount, UINT StartVertexLocation) = 0; + virtual HRESULT Map(gfx::ID3D11Resource *pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, + D3D11_MAPPED_SUBRESOURCE *pMappedResource) = 0; + virtual void Unmap(gfx::ID3D11Resource *pResource, UINT Subresource) = 0; + virtual void PSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; + virtual void IASetInputLayout(ID3D11InputLayout *pInputLayout) = 0; + virtual void IASetVertexBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppVertexBuffers, + UINT const *pStrides, UINT const *pOffsets) = 0; + virtual void IASetIndexBuffer(gfx::ID3D11Buffer *pIndexBuffer, UINT HardwareIndexFormat, UINT Offset) = 0; + virtual void DrawIndexedInstanced(UINT64 StartIndexLocationAndIndexCountPerInstance, + UINT64 BaseVertexLocationAndStartInstanceLocation, UINT InstanceCount) = 0; + virtual void DrawInstanced(UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, + UINT InstanceCount) = 0; + virtual void GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; + virtual void GSSetShader(gfx::ID3D11GeometryShader *pShader) = 0; + virtual void IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY PrimitiveTopology) = 0; + virtual void VSSetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews) = 0; + virtual void VSSetSamplers(UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers) = 0; + virtual void Begin(ID3D11Asynchronous *pAsync) = 0; + virtual void End(ID3D11Asynchronous *pAsync) = 0; + virtual HRESULT GetData(ID3D11Asynchronous *pAsync, void *pData, UINT DataSize, UINT GetDataFlags) = 0; + virtual void SetPredication(ID3D11Predicate *pPredicate, BOOL PredicateValue) = 0; + virtual void GSSetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews) = 0; + virtual void GSSetSamplers(UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers) = 0; + virtual void OMSetRenderTargets(UINT NumViews, gfx::ID3D11RenderTargetView *const *ppRTVs, + gfx::ID3D11DepthStencilView *pDepthStencilView) = 0; + virtual void OMSetRenderTargetsAndUnorderedAccessViews( + UINT NumRTVs, gfx::ID3D11RenderTargetView *const *ppRTVs, + gfx::ID3D11DepthStencilView *pDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, UINT const *pUAVInitialCounts) = 0; + virtual void OMSetBlendState(gfx::ID3D11BlendState *pBlendState, FLOAT const BlendFactor[4], + UINT SampleMask) = 0; + virtual void OMSetDepthStencilState(gfx::ID3D11DepthStencilState *pDepthStencilState, UINT StencilRef) = 0; + virtual void SOSetTargets(UINT NumBuffers, gfx::ID3D11Buffer *const *ppSOTargets, + UINT const *pOffsets) = 0; + virtual void DrawAuto() = 0; + virtual void DrawIndexedInstancedIndirect(gfx::ID3D11Buffer *pBufferForArgs, + UINT AlignedByteOffsetForArgs) = 0; + virtual void DrawInstancedIndirect(gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs) = 0; + virtual void Dispatch(UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ) = 0; + virtual void DispatchIndirect(gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs) = 0; + virtual void RSSetState(gfx::ID3D11RasterizerState *pRasterizerState) = 0; + virtual void RSSetViewports(UINT NumViewports, D3D11_VIEWPORT const *pViewports) = 0; + virtual void RSSetScissorRects(UINT NumRects, D3D11_RECT const *pRects) = 0; + virtual void CopySubresourceRegion(gfx::ID3D11Resource *pDstResource, UINT DstSubresource, UINT DstX, + UINT DstY, UINT DstZ, gfx::ID3D11Resource *pSrcResource, + UINT SrcSubresource, D3D11_BOX const *pSrcBox) = 0; + virtual void CopyResource(gfx::ID3D11Resource *pDstResource, gfx::ID3D11Resource *pSrcResource) = 0; + virtual void UpdateSubresource(gfx::ID3D11Resource *pDstResource, UINT DstSubresource, + D3D11_BOX const *pDstBox, void const *pSrcData, UINT SrcRowPitch, + UINT SrcDepthPitch) = 0; + virtual void CopyStructureCount(gfx::ID3D11Buffer *pDstBuffer, UINT DstAlignedByteOffset, + gfx::ID3D11UnorderedAccessView *pSrcView) = 0; + virtual void ClearRenderTargetView(gfx::ID3D11RenderTargetView *pRenderTargetView, + FLOAT const ColorRGBA[4]) = 0; + virtual void ClearUnorderedAccessViewUint(gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, + UINT const Values[4]) = 0; + virtual void ClearUnorderedAccessViewFloat(gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, + FLOAT const Values[4]) = 0; + virtual void ClearDepthStencilView(gfx::ID3D11DepthStencilView *pDepthStencilView, UINT ClearFlags, + FLOAT Depth, UINT8 Stencil) = 0; + virtual void GenerateMips(gfx::ID3D11ShaderResourceView *pShaderResourceView) = 0; + virtual void SetResourceMinLOD(gfx::ID3D11Resource *pResource, FLOAT MinLOD) = 0; + virtual FLOAT GetResourceMinLOD(gfx::ID3D11Resource *pResource) = 0; + virtual void ResolveSubresource(gfx::ID3D11Resource *pDstResource, UINT DstSubresource, + gfx::ID3D11Resource *pSrcResource, UINT SrcSubresource, + DXGI_FORMAT Format) = 0; + virtual void ExecuteCommandList(ID3D11CommandList *pCommandList, BOOL RestoreContextState) = 0; + virtual void HSSetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews) = 0; + virtual void HSSetShader(gfx::ID3D11HullShader *pHullShader) = 0; + virtual void HSSetSamplers(UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers) = 0; + virtual void HSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; + virtual void DSSetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews) = 0; + virtual void DSSetShader(gfx::ID3D11DomainShader *pDomainShader) = 0; + virtual void DSSetSamplers(UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers) = 0; + virtual void DSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; + virtual void CSSetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews) = 0; + virtual void CSSetUnorderedAccessViews(UINT StartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, + UINT const *pUAVInitialCounts) = 0; + virtual void CSSetShader(gfx::ID3D11ComputeShader *pComputeShader) = 0; + virtual void CSSetSamplers(UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers) = 0; + virtual void CSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; + virtual void VSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers) = 0; + virtual void PSGetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews) = 0; + virtual void PSGetShader(gfx::ID3D11PixelShader **ppPixelShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances) = 0; + virtual void PSGetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers) = 0; + virtual void VSGetShader(gfx::ID3D11VertexShader **ppVertexShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances) = 0; + virtual void PSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers) = 0; + virtual void IAGetInputLayout(ID3D11InputLayout **ppInputLayout) = 0; + virtual void IAGetVertexBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppVertexBuffers, + UINT *pStrides, UINT *pOffsets) = 0; + virtual void IAGetIndexBuffer(gfx::ID3D11Buffer **pIndexBuffer, DXGI_FORMAT *Format, UINT *Offset) = 0; + virtual void GSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers) = 0; + virtual void GSGetShader(gfx::ID3D11GeometryShader **ppGeometryShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances) = 0; + virtual void IAGetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY *pTopology) = 0; + virtual void VSGetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews) = 0; + virtual void VSGetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers) = 0; + virtual void GetPredication(ID3D11Predicate **ppPredicate, BOOL *pPredicateValue) = 0; + virtual void GSGetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews) = 0; + virtual void GSGetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers) = 0; + virtual void OMGetRenderTargets(UINT NumViews, gfx::ID3D11RenderTargetView **ppRenderTargetViews, + gfx::ID3D11DepthStencilView **ppDepthStencilView) = 0; + virtual void OMGetRenderTargetsAndUnorderedAccessViews( + UINT NumRTVs, gfx::ID3D11RenderTargetView **ppRenderTargetViews, + gfx::ID3D11DepthStencilView **ppDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews) = 0; + virtual void OMGetBlendState(gfx::ID3D11BlendState **ppBlendState, FLOAT BlendFactor[4], + UINT *pSampleMask) = 0; + virtual void OMGetDepthStencilState(gfx::ID3D11DepthStencilState **ppDepthStencilState, + UINT *pStencilRef) = 0; + virtual void SOGetTargets(UINT NumBuffers, gfx::ID3D11Buffer **ppSOTargets) = 0; + virtual void RSGetState(gfx::ID3D11RasterizerState **ppRasterizerState) = 0; + virtual void RSGetViewports(UINT *pNumViewports, D3D11_VIEWPORT *pViewports) = 0; + virtual void RSGetScissorRects(UINT *pNumRects, D3D11_RECT *pRects) = 0; + virtual void HSGetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews) = 0; + virtual void HSGetShader(gfx::ID3D11HullShader **ppHullShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances) = 0; + virtual void HSGetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers) = 0; + virtual void HSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers) = 0; + virtual void DSGetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews) = 0; + virtual void DSGetShader(gfx::ID3D11DomainShader **ppDomainShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances) = 0; + virtual void DSGetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers) = 0; + virtual void DSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers) = 0; + virtual void CSGetShaderResources(UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews) = 0; + virtual void CSGetUnorderedAccessViews(UINT StartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews) = 0; + virtual void CSGetShader(gfx::ID3D11ComputeShader **ppComputeShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances) = 0; + virtual void CSGetSamplers(UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers) = 0; + virtual void CSGetConstantBuffers(UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers) = 0; + virtual void ClearState() = 0; + virtual void Flush() = 0; + virtual D3D11_DEVICE_CONTEXT_TYPE GetType() = 0; + virtual UINT GetContextFlags() = 0; + virtual HRESULT FinishCommandList(BOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList) = 0; + }; + template requires (ABI >= abi_t{6,2,11294,0}) @@ -1461,7 +1644,7 @@ enum D3D11X_IMG_NUM_FORMAT virtual void IASetInputLayout(ID3D11InputLayout *pInputLayout) = 0; virtual void IASetVertexBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppVertexBuffers, UINT const *pStrides, UINT const *pOffsets) = 0; virtual void IASetIndexBuffer(UINT HardwareIndexFormat, gfx::ID3D11Buffer *pIndexBuffer, UINT Offset) = 0; - virtual void DrawIndexedInstanced(UINT StartIndexLocationAndIndexCountPerInstance, UINT64 BaseVertexLocationAndStartInstanceLocation, UINT64 InstanceCount) = 0; + virtual void DrawIndexedInstanced(UINT64 StartIndexLocationAndIndexCountPerInstance, UINT64 BaseVertexLocationAndStartInstanceLocation, UINT InstanceCount) = 0; virtual void DrawInstanced(UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount) = 0; virtual void GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers) = 0; virtual void GSSetShader(gfx::ID3D11GeometryShader *pShader) = 0; @@ -1557,117 +1740,365 @@ enum D3D11X_IMG_NUM_FORMAT virtual HRESULT FinishCommandList(BOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList) = 0; }; - template - struct ID3D11DeviceContextVtbl : gfx::ID3D11DeviceChildVtbl + template struct ID3D11DeviceContextVtbl : gfx::ID3D11DeviceChildVtbl { - void(*VSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); - void(*PSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); - void(*PSSetShader)(void *, gfx::ID3D11PixelShader *pPixelShader); - void(*PSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers); - void(*VSSetShader)(void *, gfx::ID3D11VertexShader *pVertexShader); - void(*DrawIndexed)(void *, UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation); - void(*Draw)(void *, UINT VertexCount, UINT StartVertexLocation); - HRESULT(*Map)(void *, gfx::ID3D11Resource *pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, D3D11_MAPPED_SUBRESOURCE *pMappedResource); - void(*Unmap)(void *, gfx::ID3D11Resource *pResource, UINT Subresource); - void(*PSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); - void(*IASetInputLayout)(void *, ID3D11InputLayout *pInputLayout); - void(*IASetVertexBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppVertexBuffers, UINT const *pStrides, UINT const *pOffsets); + void (*VSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*PSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*PSSetShader)(void *, gfx::ID3D11PixelShader *pPixelShader); + void (*PSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*VSSetShader)(void *, gfx::ID3D11VertexShader *pVertexShader); + void (*DrawIndexed)(void *, UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation); + void (*Draw)(void *, UINT VertexCount, UINT StartVertexLocation); + HRESULT (*Map)(void *, gfx::ID3D11Resource *pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, + D3D11_MAPPED_SUBRESOURCE *pMappedResource); + void (*Unmap)(void *, gfx::ID3D11Resource *pResource, UINT Subresource); + void (*PSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*IASetInputLayout)(void *, ID3D11InputLayout *pInputLayout); + void (*IASetVertexBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppVertexBuffers, UINT const *pStrides, + UINT const *pOffsets); void (*IASetIndexBuffer)(void *, gfx::ID3D11Buffer *pIndexBuffer, UINT HardwareIndexFormat, UINT Offset); - void(*DrawIndexedInstanced)(void *, UINT StartIndexLocationAndIndexCountPerInstance, UINT64 BaseVertexLocationAndStartInstanceLocation, UINT64 InstanceCount); - void(*DrawInstanced)(void *, UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount); - void(*GSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); - void(*GSSetShader)(void *, gfx::ID3D11GeometryShader *pShader); - void(*IASetPrimitiveTopology)(void *, D3D_PRIMITIVE_TOPOLOGY PrimitiveTopology); - void(*VSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); - void(*VSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers); - void(*Begin)(void *, ID3D11Asynchronous *pAsync); - void(*End)(void *, ID3D11Asynchronous *pAsync); - HRESULT(*GetData)(void *, ID3D11Asynchronous *pAsync, void *pData, UINT DataSize, UINT GetDataFlags); - void(*SetPredication)(void *, ID3D11Predicate *pPredicate, BOOL PredicateValue); - void(*GSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); - void(*GSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers); - void(*OMSetRenderTargets)(void *, UINT NumViews, gfx::ID3D11RenderTargetView *const *, gfx::ID3D11DepthStencilView *pDepthStencilView); - void(*OMSetRenderTargetsAndUnorderedAccessViews)(void *, UINT NumRTVs, gfx::ID3D11RenderTargetView *const *ppRenderTargetViews, gfx::ID3D11DepthStencilView *pDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, UINT const *pUAVInitialCounts); - void(*OMSetBlendState)(void *, gfx::ID3D11BlendState *pBlendState, FLOAT const BlendFactor[4], UINT SampleMask); - void(*OMSetDepthStencilState)(void *, gfx::ID3D11DepthStencilState *pDepthStencilState, UINT StencilRef); - void(*SOSetTargets)(void *, UINT NumBuffers, gfx::ID3D11Buffer *const *ppSOTargets, UINT const *pOffsets); - void(*DrawAuto)(void *); - void(*DrawIndexedInstancedIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs); - void(*DrawInstancedIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs); - void(*Dispatch)(void *, UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ); - void(*DispatchIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs); - void(*RSSetState)(void *, gfx::ID3D11RasterizerState *pRasterizerState); - void(*RSSetViewports)(void *, UINT NumViewports, D3D11_VIEWPORT const *pViewports); - void(*RSSetScissorRects)(void *, UINT NumRects, D3D11_RECT const *pRects); - void(*CopySubresourceRegion)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, UINT DstX, UINT DstY, UINT DstZ, gfx::ID3D11Resource *pSrcResource, UINT SrcSubresource, D3D11_BOX const *pSrcBox); - void(*CopyResource)(void *, gfx::ID3D11Resource *pDstResource, gfx::ID3D11Resource *pSrcResource); - void(*UpdateSubresource)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, D3D11_BOX const *pDstBox, void const *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch); - void(*CopyStructureCount)(void *, gfx::ID3D11Buffer *pDstBuffer, UINT DstAlignedByteOffset, gfx::ID3D11UnorderedAccessView *pSrcView); - void(*ClearRenderTargetView)(void *, gfx::ID3D11RenderTargetView *pRenderTargetView, FLOAT const ColorRGBA[4]); - void(*ClearUnorderedAccessViewUint)(void *, gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, UINT const Values[4]); - void(*ClearUnorderedAccessViewFloat)(void *, gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, FLOAT const Values[4]); - void(*ClearDepthStencilView)(void *, gfx::ID3D11DepthStencilView *pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil); - void(*GenerateMips)(void *, gfx::ID3D11ShaderResourceView *pShaderResourceView); - void(*SetResourceMinLOD)(void *, gfx::ID3D11Resource *pResource, FLOAT MinLOD); - FLOAT(*GetResourceMinLOD)(void *, gfx::ID3D11Resource *pResource); - void(*ResolveSubresource)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, gfx::ID3D11Resource *pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format); - void(*ExecuteCommandList)(void *, ID3D11CommandList *pCommandList, BOOL RestoreContextState); - void(*HSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); - void(*HSSetShader)(void *, gfx::ID3D11HullShader *pHullShader); - void(*HSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers); - void(*HSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); - void(*DSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); - void(*DSSetShader)(void *, gfx::ID3D11DomainShader *pDomainShader); - void(*DSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers); - void(*DSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); - void(*CSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); - void(*CSSetUnorderedAccessViews)(void *, UINT StartSlot, UINT NumUAVs, gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, UINT const *pUAVInitialCounts); - void(*CSSetShader)(void *, gfx::ID3D11ComputeShader *pComputeShader); - void(*CSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState *const *ppSamplers); - void(*CSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); - void(*VSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppConstantBuffers); - void(*PSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView **ppShaderResourceViews); - void(*PSGetShader)(void *, gfx::ID3D11PixelShader **ppPixelShader, ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); - void(*PSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); - void(*VSGetShader)(void *, gfx::ID3D11VertexShader **ppVertexShader, ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); - void(*PSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppConstantBuffers); - void(*IAGetInputLayout)(void *, ID3D11InputLayout **ppInputLayout); - void(*IAGetVertexBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppVertexBuffers, UINT *pStrides, UINT *pOffsets); - void(*IAGetIndexBuffer)(void *, gfx::ID3D11Buffer **pIndexBuffer, DXGI_FORMAT *Format, UINT *Offset); - void(*GSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppConstantBuffers); - void(*GSGetShader)(void *, gfx::ID3D11GeometryShader **ppGeometryShader, ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); - void(*IAGetPrimitiveTopology)(void *, D3D11_PRIMITIVE_TOPOLOGY *pTopology); - void(*VSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView **ppShaderResourceViews); - void(*VSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); - void(*GetPredication)(void *, ID3D11Predicate **ppPredicate, BOOL *pPredicateValue); - void(*GSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView **ppShaderResourceViews); - void(*GSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); - void(*OMGetRenderTargets)(void *, UINT NumViews, gfx::ID3D11RenderTargetView **ppRenderTargetViews, gfx::ID3D11DepthStencilView **ppDepthStencilView); - void(*OMGetRenderTargetsAndUnorderedAccessViews)(void *, UINT NumRTVs, gfx::ID3D11RenderTargetView **ppRenderTargetViews, gfx::ID3D11DepthStencilView **ppDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews); - void(*OMGetBlendState)(void *, gfx::ID3D11BlendState **ppBlendState, FLOAT BlendFactor[4], UINT *pSampleMask); - void(*OMGetDepthStencilState)(void *, gfx::ID3D11DepthStencilState **ppDepthStencilState, UINT *pStencilRef); - void(*SOGetTargets)(void *, UINT NumBuffers, gfx::ID3D11Buffer **ppSOTargets); - void(*RSGetState)(void *, gfx::ID3D11RasterizerState **ppRasterizerState); - void(*RSGetViewports)(void *, UINT *pNumViewports, D3D11_VIEWPORT *pViewports); - void(*RSGetScissorRects)(void *, UINT *pNumRects, D3D11_RECT *pRects); - void(*HSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView **ppShaderResourceViews); - void(*HSGetShader)(void *, gfx::ID3D11HullShader **ppHullShader, ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); - void(*HSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); - void(*HSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppConstantBuffers); - void(*DSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView **ppShaderResourceViews); - void(*DSGetShader)(void *, gfx::ID3D11DomainShader **ppDomainShader, ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); - void(*DSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); - void(*DSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppConstantBuffers); - void(*CSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, gfx::ID3D11ShaderResourceView **ppShaderResourceViews); - void(*CSGetUnorderedAccessViews)(void *, UINT StartSlot, UINT NumUAVs, gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews); - void(*CSGetShader)(void *, gfx::ID3D11ComputeShader **ppComputeShader, ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); - void(*CSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); - void(*CSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppConstantBuffers); - void(*ClearState)(void *); - void(*Flush)(void *); - D3D11_DEVICE_CONTEXT_TYPE(*GetType)(void *); - UINT(*GetContextFlags)(void *); - HRESULT(*FinishCommandList)(void *, BOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList); + void (*DrawIndexedInstanced)(void *, UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, + INT BaseVertexLocation, UINT StartInstanceLocation); + void (*DrawInstanced)(void *, UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, + UINT StartInstanceLocation); + void (*GSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*GSSetShader)(void *, gfx::ID3D11GeometryShader *pShader); + void (*IASetPrimitiveTopology)(void *, D3D_PRIMITIVE_TOPOLOGY PrimitiveTopology); + void (*VSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*VSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*Begin)(void *, ID3D11Asynchronous *pAsync); + void (*End)(void *, ID3D11Asynchronous *pAsync); + HRESULT (*GetData)(void *, ID3D11Asynchronous *pAsync, void *pData, UINT DataSize, UINT GetDataFlags); + void (*SetPredication)(void *, ID3D11Predicate *pPredicate, BOOL PredicateValue); + void (*GSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*GSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*OMSetRenderTargets)(void *, UINT NumViews, gfx::ID3D11RenderTargetView *const *ppRTVs, + gfx::ID3D11DepthStencilView *pDepthStencilView); + void (*OMSetRenderTargetsAndUnorderedAccessViews)( + void *, UINT NumRTVs, gfx::ID3D11RenderTargetView *const *ppRTVs, + gfx::ID3D11DepthStencilView *pDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, UINT const *pUAVInitialCounts); + void (*OMSetBlendState)(void *, gfx::ID3D11BlendState *pBlendState, FLOAT const BlendFactor[4], + UINT SampleMask); + void (*OMSetDepthStencilState)(void *, gfx::ID3D11DepthStencilState *pDepthStencilState, UINT StencilRef); + void (*SOSetTargets)(void *, UINT NumBuffers, gfx::ID3D11Buffer *const *ppSOTargets, UINT const *pOffsets); + void (*DrawAuto)(void *); + void (*DrawIndexedInstancedIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, + UINT AlignedByteOffsetForArgs); + void (*DrawInstancedIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs); + void (*Dispatch)(void *, UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ); + void (*DispatchIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs); + void (*RSSetState)(void *, gfx::ID3D11RasterizerState *pRasterizerState); + void (*RSSetViewports)(void *, UINT NumViewports, D3D11_VIEWPORT const *pViewports); + void (*RSSetScissorRects)(void *, UINT NumRects, D3D11_RECT const *pRects); + void (*CopySubresourceRegion)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, UINT DstX, + UINT DstY, UINT DstZ, gfx::ID3D11Resource *pSrcResource, UINT SrcSubresource, + D3D11_BOX const *pSrcBox); + void (*CopyResource)(void *, gfx::ID3D11Resource *pDstResource, gfx::ID3D11Resource *pSrcResource); + void (*UpdateSubresource)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, + D3D11_BOX const *pDstBox, void const *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch); + void (*CopyStructureCount)(void *, gfx::ID3D11Buffer *pDstBuffer, UINT DstAlignedByteOffset, + gfx::ID3D11UnorderedAccessView *pSrcView); + void (*ClearRenderTargetView)(void *, gfx::ID3D11RenderTargetView *pRenderTargetView, + FLOAT const ColorRGBA[4]); + void (*ClearUnorderedAccessViewUint)(void *, gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, + UINT const Values[4]); + void (*ClearUnorderedAccessViewFloat)(void *, gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, + FLOAT const Values[4]); + void (*ClearDepthStencilView)(void *, gfx::ID3D11DepthStencilView *pDepthStencilView, UINT ClearFlags, + FLOAT Depth, UINT8 Stencil); + void (*GenerateMips)(void *, gfx::ID3D11ShaderResourceView *pShaderResourceView); + void (*SetResourceMinLOD)(void *, gfx::ID3D11Resource *pResource, FLOAT MinLOD); + FLOAT (*GetResourceMinLOD)(void *, gfx::ID3D11Resource *pResource); + void (*ResolveSubresource)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, + gfx::ID3D11Resource *pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format); + void (*ExecuteCommandList)(void *, ID3D11CommandList *pCommandList, BOOL RestoreContextState); + void (*HSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*HSSetShader)(void *, gfx::ID3D11HullShader *pHullShader); + void (*HSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*HSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*DSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*DSSetShader)(void *, gfx::ID3D11DomainShader *pDomainShader); + void (*DSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*DSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*CSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*CSSetUnorderedAccessViews)(void *, UINT StartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, + UINT const *pUAVInitialCounts); + void (*CSSetShader)(void *, gfx::ID3D11ComputeShader *pComputeShader); + void (*CSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*CSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*VSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*PSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*PSGetShader)(void *, gfx::ID3D11PixelShader **ppPixelShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances); + void (*PSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*VSGetShader)(void *, gfx::ID3D11VertexShader **ppVertexShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*PSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*IAGetInputLayout)(void *, ID3D11InputLayout **ppInputLayout); + void (*IAGetVertexBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppVertexBuffers, + UINT *pStrides, UINT *pOffsets); + void (*IAGetIndexBuffer)(void *, gfx::ID3D11Buffer **pIndexBuffer, DXGI_FORMAT *Format, UINT *Offset); + void (*GSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*GSGetShader)(void *, gfx::ID3D11GeometryShader **ppGeometryShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*IAGetPrimitiveTopology)(void *, D3D11_PRIMITIVE_TOPOLOGY *pTopology); + void (*VSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*VSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*GetPredication)(void *, ID3D11Predicate **ppPredicate, BOOL *pPredicateValue); + void (*GSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*GSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*OMGetRenderTargets)(void *, UINT NumViews, gfx::ID3D11RenderTargetView **ppRenderTargetViews, + gfx::ID3D11DepthStencilView **ppDepthStencilView); + void (*OMGetRenderTargetsAndUnorderedAccessViews)(void *, UINT NumRTVs, + gfx::ID3D11RenderTargetView **ppRenderTargetViews, + gfx::ID3D11DepthStencilView **ppDepthStencilView, + UINT UAVStartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews); + void (*OMGetBlendState)(void *, gfx::ID3D11BlendState **ppBlendState, FLOAT BlendFactor[4], + UINT *pSampleMask); + void (*OMGetDepthStencilState)(void *, gfx::ID3D11DepthStencilState **ppDepthStencilState, + UINT *pStencilRef); + void (*SOGetTargets)(void *, UINT NumBuffers, gfx::ID3D11Buffer **ppSOTargets); + void (*RSGetState)(void *, gfx::ID3D11RasterizerState **ppRasterizerState); + void (*RSGetViewports)(void *, UINT *pNumViewports, D3D11_VIEWPORT *pViewports); + void (*RSGetScissorRects)(void *, UINT *pNumRects, D3D11_RECT *pRects); + void (*HSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*HSGetShader)(void *, gfx::ID3D11HullShader **ppHullShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances); + void (*HSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*HSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*DSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*DSGetShader)(void *, gfx::ID3D11DomainShader **ppDomainShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*DSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*DSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*CSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*CSGetUnorderedAccessViews)(void *, UINT StartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews); + void (*CSGetShader)(void *, gfx::ID3D11ComputeShader **ppComputeShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*CSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*CSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*ClearState)(void *); + void (*Flush)(void *); + D3D11_DEVICE_CONTEXT_TYPE (*GetType)(void *); + UINT (*GetContextFlags)(void *); + HRESULT (*FinishCommandList)(void *, BOOL RestoreDeferredContextState, + ID3D11CommandList **ppCommandList); + }; + + template + requires(ABI >= abi_t{6,2,11064,0} && ABI < abi_t{6,2,11294,0}) + struct ID3D11DeviceContextVtbl : gfx::ID3D11DeviceChildVtbl + { + void (*VSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*PSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*PSSetShader)(void *, gfx::ID3D11PixelShader *pPixelShader); + void (*PSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*VSSetShader)(void *, gfx::ID3D11VertexShader *pVertexShader); + void (*DrawIndexed)(void *, UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation); + void (*Draw)(void *, UINT VertexCount, UINT StartVertexLocation); + HRESULT (*Map)(void *, gfx::ID3D11Resource *pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, + D3D11_MAPPED_SUBRESOURCE *pMappedResource); + void (*Unmap)(void *, gfx::ID3D11Resource *pResource, UINT Subresource); + void (*PSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*IASetInputLayout)(void *, ID3D11InputLayout *pInputLayout); + void (*IASetVertexBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppVertexBuffers, UINT const *pStrides, + UINT const *pOffsets); + void (*IASetIndexBuffer)(void *, gfx::ID3D11Buffer *pIndexBuffer, UINT HardwareIndexFormat, UINT Offset); + void (*DrawIndexedInstanced)(void *, UINT64 StartIndexLocationAndIndexCountPerInstance, + UINT64 BaseVertexLocationAndStartInstanceLocation, UINT InstanceCount); + void (*DrawInstanced)(void *, UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, + UINT InstanceCount); + void (*GSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*GSSetShader)(void *, gfx::ID3D11GeometryShader *pShader); + void (*IASetPrimitiveTopology)(void *, D3D_PRIMITIVE_TOPOLOGY PrimitiveTopology); + void (*VSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*VSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*Begin)(void *, ID3D11Asynchronous *pAsync); + void (*End)(void *, ID3D11Asynchronous *pAsync); + HRESULT (*GetData)(void *, ID3D11Asynchronous *pAsync, void *pData, UINT DataSize, UINT GetDataFlags); + void (*SetPredication)(void *, ID3D11Predicate *pPredicate, BOOL PredicateValue); + void (*GSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*GSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*OMSetRenderTargets)(void *, UINT NumViews, gfx::ID3D11RenderTargetView *const *ppRTVs, + gfx::ID3D11DepthStencilView *pDepthStencilView); + void (*OMSetRenderTargetsAndUnorderedAccessViews)( + void *, UINT NumRTVs, gfx::ID3D11RenderTargetView *const *ppRTVs, + gfx::ID3D11DepthStencilView *pDepthStencilView, UINT UAVStartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, UINT const *pUAVInitialCounts); + void (*OMSetBlendState)(void *, gfx::ID3D11BlendState *pBlendState, FLOAT const BlendFactor[4], + UINT SampleMask); + void (*OMSetDepthStencilState)(void *, gfx::ID3D11DepthStencilState *pDepthStencilState, UINT StencilRef); + void (*SOSetTargets)(void *, UINT NumBuffers, gfx::ID3D11Buffer *const *ppSOTargets, UINT const *pOffsets); + void (*DrawAuto)(void *); + void (*DrawIndexedInstancedIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, + UINT AlignedByteOffsetForArgs); + void (*DrawInstancedIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs); + void (*Dispatch)(void *, UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ); + void (*DispatchIndirect)(void *, gfx::ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs); + void (*RSSetState)(void *, gfx::ID3D11RasterizerState *pRasterizerState); + void (*RSSetViewports)(void *, UINT NumViewports, D3D11_VIEWPORT const *pViewports); + void (*RSSetScissorRects)(void *, UINT NumRects, D3D11_RECT const *pRects); + void (*CopySubresourceRegion)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, UINT DstX, + UINT DstY, UINT DstZ, gfx::ID3D11Resource *pSrcResource, UINT SrcSubresource, + D3D11_BOX const *pSrcBox); + void (*CopyResource)(void *, gfx::ID3D11Resource *pDstResource, gfx::ID3D11Resource *pSrcResource); + void (*UpdateSubresource)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, + D3D11_BOX const *pDstBox, void const *pSrcData, UINT SrcRowPitch, UINT SrcDepthPitch); + void (*CopyStructureCount)(void *, gfx::ID3D11Buffer *pDstBuffer, UINT DstAlignedByteOffset, + gfx::ID3D11UnorderedAccessView *pSrcView); + void (*ClearRenderTargetView)(void *, gfx::ID3D11RenderTargetView *pRenderTargetView, + FLOAT const ColorRGBA[4]); + void (*ClearUnorderedAccessViewUint)(void *, gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, + UINT const Values[4]); + void (*ClearUnorderedAccessViewFloat)(void *, gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, + FLOAT const Values[4]); + void (*ClearDepthStencilView)(void *, gfx::ID3D11DepthStencilView *pDepthStencilView, UINT ClearFlags, + FLOAT Depth, UINT8 Stencil); + void (*GenerateMips)(void *, gfx::ID3D11ShaderResourceView *pShaderResourceView); + void (*SetResourceMinLOD)(void *, gfx::ID3D11Resource *pResource, FLOAT MinLOD); + FLOAT (*GetResourceMinLOD)(void *, gfx::ID3D11Resource *pResource); + void (*ResolveSubresource)(void *, gfx::ID3D11Resource *pDstResource, UINT DstSubresource, + gfx::ID3D11Resource *pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format); + void (*ExecuteCommandList)(void *, ID3D11CommandList *pCommandList, BOOL RestoreContextState); + void (*HSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*HSSetShader)(void *, gfx::ID3D11HullShader *pHullShader); + void (*HSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*HSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*DSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*DSSetShader)(void *, gfx::ID3D11DomainShader *pDomainShader); + void (*DSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*DSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*CSSetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView *const *ppShaderResourceViews); + void (*CSSetUnorderedAccessViews)(void *, UINT StartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, + UINT const *pUAVInitialCounts); + void (*CSSetShader)(void *, gfx::ID3D11ComputeShader *pComputeShader); + void (*CSSetSamplers)(void *, UINT StartSlot, UINT NumSamplers, + gfx::ID3D11SamplerState *const *ppSamplers); + void (*CSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer *const *ppConstantBuffers); + void (*VSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*PSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*PSGetShader)(void *, gfx::ID3D11PixelShader **ppPixelShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances); + void (*PSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*VSGetShader)(void *, gfx::ID3D11VertexShader **ppVertexShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*PSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*IAGetInputLayout)(void *, ID3D11InputLayout **ppInputLayout); + void (*IAGetVertexBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer **ppVertexBuffers, + UINT *pStrides, UINT *pOffsets); + void (*IAGetIndexBuffer)(void *, gfx::ID3D11Buffer **pIndexBuffer, DXGI_FORMAT *Format, UINT *Offset); + void (*GSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*GSGetShader)(void *, gfx::ID3D11GeometryShader **ppGeometryShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*IAGetPrimitiveTopology)(void *, D3D11_PRIMITIVE_TOPOLOGY *pTopology); + void (*VSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*VSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*GetPredication)(void *, ID3D11Predicate **ppPredicate, BOOL *pPredicateValue); + void (*GSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*GSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*OMGetRenderTargets)(void *, UINT NumViews, gfx::ID3D11RenderTargetView **ppRenderTargetViews, + gfx::ID3D11DepthStencilView **ppDepthStencilView); + void (*OMGetRenderTargetsAndUnorderedAccessViews)(void *, UINT NumRTVs, + gfx::ID3D11RenderTargetView **ppRenderTargetViews, + gfx::ID3D11DepthStencilView **ppDepthStencilView, + UINT UAVStartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews); + void (*OMGetBlendState)(void *, gfx::ID3D11BlendState **ppBlendState, FLOAT BlendFactor[4], + UINT *pSampleMask); + void (*OMGetDepthStencilState)(void *, gfx::ID3D11DepthStencilState **ppDepthStencilState, + UINT *pStencilRef); + void (*SOGetTargets)(void *, UINT NumBuffers, gfx::ID3D11Buffer **ppSOTargets); + void (*RSGetState)(void *, gfx::ID3D11RasterizerState **ppRasterizerState); + void (*RSGetViewports)(void *, UINT *pNumViewports, D3D11_VIEWPORT *pViewports); + void (*RSGetScissorRects)(void *, UINT *pNumRects, D3D11_RECT *pRects); + void (*HSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*HSGetShader)(void *, gfx::ID3D11HullShader **ppHullShader, ID3D11ClassInstance **ppClassInstances, + UINT *pNumClassInstances); + void (*HSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*HSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*DSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*DSGetShader)(void *, gfx::ID3D11DomainShader **ppDomainShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*DSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*DSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*CSGetShaderResources)(void *, UINT StartSlot, UINT NumViews, + gfx::ID3D11ShaderResourceView **ppShaderResourceViews); + void (*CSGetUnorderedAccessViews)(void *, UINT StartSlot, UINT NumUAVs, + gfx::ID3D11UnorderedAccessView **ppUnorderedAccessViews); + void (*CSGetShader)(void *, gfx::ID3D11ComputeShader **ppComputeShader, + ID3D11ClassInstance **ppClassInstances, UINT *pNumClassInstances); + void (*CSGetSamplers)(void *, UINT StartSlot, UINT NumSamplers, gfx::ID3D11SamplerState **ppSamplers); + void (*CSGetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, + gfx::ID3D11Buffer **ppConstantBuffers); + void (*ClearState)(void *); + void (*Flush)(void *); + D3D11_DEVICE_CONTEXT_TYPE (*GetType)(void *); + UINT (*GetContextFlags)(void *); + HRESULT (*FinishCommandList)(void *, BOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList); }; template @@ -1687,7 +2118,7 @@ enum D3D11X_IMG_NUM_FORMAT void(*IASetInputLayout)(void *, ID3D11InputLayout *pInputLayout); void(*IASetVertexBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppVertexBuffers, UINT const *pStrides, UINT const *pOffsets); void(*IASetIndexBuffer)(void *, UINT HardwareIndexFormat, gfx::ID3D11Buffer *pIndexBuffer, UINT Offset); - void(*DrawIndexedInstanced)(void *, UINT StartIndexLocationAndIndexCountPerInstance, UINT64 BaseVertexLocationAndStartInstanceLocation, UINT64 InstanceCount); + void(*DrawIndexedInstanced)(void *, UINT64 StartIndexLocationAndIndexCountPerInstance, UINT64 BaseVertexLocationAndStartInstanceLocation, UINT InstanceCount); void(*DrawInstanced)(void *, UINT VertexCountPerInstance, UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount); void(*GSSetConstantBuffers)(void *, UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers); void(*GSSetShader)(void *, gfx::ID3D11GeometryShader *pShader); diff --git a/projects/WinDurango.D3D11X/src/ID3D11DMAEngineContext.cpp b/projects/WinDurango.D3D11X/src/ID3D11DMAEngineContext.cpp index a16aa42..e9ede59 100644 --- a/projects/WinDurango.D3D11X/src/ID3D11DMAEngineContext.cpp +++ b/projects/WinDurango.D3D11X/src/ID3D11DMAEngineContext.cpp @@ -11,14 +11,16 @@ template HRESULT D3D11DMAEngineContextX::QueryInterface(REFIID template ULONG D3D11DMAEngineContextX::AddRef() { - IMPLEMENT_STUB(); - return {}; + return InterlockedIncrement(&this->m_RefCount); } template ULONG D3D11DMAEngineContextX::Release() { - IMPLEMENT_STUB(); - return {}; + m_pImmediateContext->Release(); + ULONG RefCount = InterlockedDecrement(&this->m_RefCount); + if (!RefCount) + delete this; + return RefCount; } // @@ -63,22 +65,39 @@ HRESULT D3D11DMAEngineContextX::SetPrivateDataInterfaceGraphics(_GUID const // template D3D11_DEVICE_CONTEXT_TYPE D3D11DMAEngineContextX::GetType() { - IMPLEMENT_STUB(); - return {}; + return (D3D11_DEVICE_CONTEXT_TYPE)0x2; } template -void D3D11DMAEngineContextX::CopyResource(gfx::ID3D11Resource *v1, gfx::ID3D11Resource *v2, uint32_t v3) +void D3D11DMAEngineContextX::CopyResource(gfx::ID3D11Resource *pDstResource, + gfx::ID3D11Resource *pSrcResource, uint32_t v3) { - IMPLEMENT_STUB(); + DMACommands Command{}; + Command.m_DMACommandType = DMACommands::DMACommandType::CopySubresourceRegion; + Command.CopyResource.pDstResource = pDstResource; + Command.CopyResource.pSrcResource = pSrcResource; + Command.CopyResource.Flags = v3; + m_DMACommandQueue.push_back(Command); } template -void D3D11DMAEngineContextX::CopySubresourceRegion(gfx::ID3D11Resource *v1, uint32_t v2, uint32_t v3, - uint32_t v4, uint32_t v5, gfx::ID3D11Resource *v6, - uint32_t v7, D3D11_BOX const *v8, uint32_t v9) +void D3D11DMAEngineContextX::CopySubresourceRegion(gfx::ID3D11Resource *pDstResource, uint32_t DstSubresource, + uint32_t DstX, uint32_t DstY, uint32_t DstZ, + gfx::ID3D11Resource *pSrcResource, uint32_t SrcSubresource, + D3D11_BOX const *pSrcBox, uint32_t v9) { - IMPLEMENT_STUB(); + DMACommands Command{}; + Command.m_DMACommandType = DMACommands::DMACommandType::CopySubresourceRegion; + Command.CopySubresourceRegion.pDstResource = pDstResource; + Command.CopySubresourceRegion.DstSubresource = DstSubresource; + Command.CopySubresourceRegion.DstX = DstX; + Command.CopySubresourceRegion.DstY = DstY; + Command.CopySubresourceRegion.DstZ = DstZ; + Command.CopySubresourceRegion.pSrcResource = pSrcResource; + Command.CopySubresourceRegion.SrcSubresource = SrcSubresource; + Command.CopySubresourceRegion.pSrcBox = pSrcBox; + Command.CopySubresourceRegion.Flags = v9; + m_DMACommandQueue.push_back(Command); } template @@ -86,7 +105,6 @@ HRESULT D3D11DMAEngineContextX::LZDecompressBuffer(gfx::ID3D11Buffer * gfx::ID3D11Buffer *v3, uint32_t v4, uint32_t v5, uint32_t v6) { - IMPLEMENT_STUB(); return E_NOTIMPL; } @@ -95,7 +113,6 @@ HRESULT D3D11DMAEngineContextX::LZDecompressTexture(gfx::ID3D11Resource *v6, uint32_t v7) { - IMPLEMENT_STUB(); return E_NOTIMPL; } @@ -125,24 +142,46 @@ HRESULT D3D11DMAEngineContextX::JPEGDecode(gfx::ID3D11Resource *v1, ui template uint64_t D3D11DMAEngineContextX::InsertFence(uint32_t v1) { - IMPLEMENT_STUB(); - return {}; + DMACommands Command{}; + Command.m_DMACommandType = DMACommands::DMACommandType::DMAInsertFence; // Signal fence command + Command.DMAInsertFence.Flags = v1; + + if (DMAFenceIndex >= 1024) + { + DMAFenceIndex = 0; + } + + UINT FenceIndex = DMAFenceIndex; + DMAFences[FenceIndex] = TRUE; + DMAFenceIndex++; + Command.DMAInsertFence.Fence = (UINT64)&DMAFences[FenceIndex]; + + m_DMACommandQueue.push_back(Command); + + return (UINT64)&DMAFences[FenceIndex]; } template void D3D11DMAEngineContextX::InsertWaitOnFence(uint32_t v1, uint64_t v2) { - IMPLEMENT_STUB(); + DMACommands Command{}; + Command.m_DMACommandType = DMACommands::DMACommandType::DMAInsertWaitOnFence; + Command.DMAInsertWaitOnFence.Flags = v1; + Command.DMAInsertWaitOnFence.Fence = v2; + m_DMACommandQueue.push_back(Command); } template HRESULT D3D11DMAEngineContextX::Submit() { - IMPLEMENT_STUB(); - return E_NOTIMPL; + m_pImmediateContext->AddBackgroundContext(this); + return S_OK; } template void D3D11DMAEngineContextX::CopyLastErrorCodeToMemory(void *v1) { - IMPLEMENT_STUB(); + DMACommands Command{}; + Command.m_DMACommandType = DMACommands::DMACommandType::CopyLastErrorCodeToMemory; + Command.CopyLastErrorCodeToMemory.pDstAddress = v1; + m_DMACommandQueue.push_back(Command); } template @@ -158,7 +197,12 @@ template void D3D11DMAEngineContextX::CopyMemoryToMemory(void * template void D3D11DMAEngineContextX::FillMemoryWithValue(void *v1, uint64_t v2, uint32_t v3) { - IMPLEMENT_STUB(); + DMACommands Command{}; + Command.m_DMACommandType = DMACommands::DMACommandType::FillMemoryWithValue; + Command.FillMemoryWithValue.pDstAddress = v1; + Command.FillMemoryWithValue.SizeBytes = v2; + Command.FillMemoryWithValue.FillValue = v3; + m_DMACommandQueue.push_back(Command); } template void D3D11DMAEngineContextX::FillResourceWithValue(gfx::ID3D11Resource *v1, uint32_t v2) @@ -169,8 +213,14 @@ template void D3D11DMAEngineContextX::FillResourceWithValue(gfx template HRESULT D3D11DMAEngineContextX::LZDecompressMemory(void *v1, void *v2, uint32_t v3, uint32_t v4) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + DMACommands Command{}; + Command.m_DMACommandType = DMACommands::DMACommandType::LZDecompressMemory; + Command.LZDecompressMemory.NextIn = v1; + Command.LZDecompressMemory.NextOut = v2; + Command.LZDecompressMemory.AvailIn = v3; + Command.LZDecompressMemory.Flags = v4; + m_DMACommandQueue.push_back(Command); + return S_OK; } template HRESULT D3D11DMAEngineContextX::LZCompressMemory(void *v1, void *v2, uint32_t v3, uint32_t v4) @@ -201,6 +251,51 @@ void D3D11DMAEngineContextX::InsertWaitOnMemory(void const *v1, uint32_t v2 IMPLEMENT_STUB(); } +template BOOL D3D11DMAEngineContextX::ExecuteContext() +{ + while (m_CommandIndex < m_DMACommandQueue.size()) + { + auto &Cmd = m_DMACommandQueue[m_CommandIndex]; + BOOL Wait = TRUE; + + switch (Cmd.m_DMACommandType) + { + case DMACommands::DMACommandType::LZDecompressMemory: + Wait = Cmd.LZDecompressMemory.Execute(this); + break; + case DMACommands::DMACommandType::DMAInsertFence: + Wait = Cmd.DMAInsertFence.Execute(this); + break; + case DMACommands::DMACommandType::DMAInsertWaitOnFence: + Wait = Cmd.DMAInsertWaitOnFence.Execute(this); + break; + case DMACommands::DMACommandType::CopyResource: + Wait = Cmd.CopyResource.Execute(this); + break; + case DMACommands::DMACommandType::CopySubresourceRegion: + Wait = Cmd.CopySubresourceRegion.Execute(this); + break; + case DMACommands::DMACommandType::FillMemoryWithValue: + Wait = Cmd.FillMemoryWithValue.Execute(this); + break; + case DMACommands::DMACommandType::CopyLastErrorCodeToMemory: + Wait = Cmd.CopyLastErrorCodeToMemory.Execute(this); + break; + } + + // If the command told us to wait, return 'FALSE' to + // indicate that we still have more commands to execute. + if (Wait) + return FALSE; + + m_CommandIndex++; + } + + m_DMACommandQueue.clear(); + m_CommandIndex = 0; + return TRUE; +} + #undef ABI_INTERFACE #define ABI_INTERFACE(ABI) D3D11DMAEngineContextX D3D11_DECLARE_ABI_TEMPLATES(); \ No newline at end of file diff --git a/projects/WinDurango.D3D11X/src/ID3D11Device.cpp b/projects/WinDurango.D3D11X/src/ID3D11Device.cpp index 430d801..1c3ea5d 100644 --- a/projects/WinDurango.D3D11X/src/ID3D11Device.cpp +++ b/projects/WinDurango.D3D11X/src/ID3D11Device.cpp @@ -6,6 +6,8 @@ #include "ID3D11Shader.h" #include "ID3D11DeviceContext.h" #include "ID3D11Runtime.h" +#include "ID3D11DMAEngineContext.h" +#include "d3d11.x.h" // // IUnknown @@ -787,8 +789,8 @@ template HRESULT D3D11DeviceX::CreateDmaEngineContext(gfx::D3D11_DMA_ENGINE_CONTEXT_DESC const *pDmaEngineContextDesc, gfx::ID3D11DMAEngineContextX **ppDmaDeviceContext) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + *ppDmaDeviceContext = new D3D11DMAEngineContextX(); + return S_OK; } template BOOL D3D11DeviceX::IsFencePending(UINT64 Fence) @@ -807,32 +809,147 @@ template HRESULT D3D11DeviceX::CreatePlacementBuffer(D3D11_BUFFER_DESC const *pDesc, void *pVirtualAddress, gfx::ID3D11Buffer **ppBuffer) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + D3D11_SUBRESOURCE_DATA initialData{}; + initialData.pSysMem = pVirtualAddress; + initialData.SysMemPitch = 0; + initialData.SysMemSlicePitch = 0; + + auto pDesc2 = *pDesc; + if (pDesc2.Usage == D3D11_USAGE_IMMUTABLE) + { + pDesc2.Usage = D3D11_USAGE_DEFAULT; + } + + HRESULT hr = CreateBuffer(&pDesc2, &initialData, ppBuffer); + (*ppBuffer)->m_pAllocationStart = pVirtualAddress; + + return hr; } template HRESULT D3D11DeviceX::CreatePlacementTexture1D(D3D11_TEXTURE1D_DESC const *pDesc, UINT TileModeIndex, UINT Pitch, void *pVirtualAddress, gfx::ID3D11Texture1D **ppTexture1D) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + std::vector initialData(pDesc->ArraySize); + UINT RowPitch = 0; + UINT SlicePitch = 0; + auto pDesc2 = *pDesc; + pDesc2.MipLevels = 1; + if (pDesc2.Usage == D3D11_USAGE_IMMUTABLE) + { + pDesc2.Usage = D3D11_USAGE_DEFAULT; + } + + for (int i = 0; i < initialData.size(); i++) + { + initialData[i].pSysMem = pVirtualAddress; + CalculatePitch(pDesc2.Width, 1, pDesc2.Format, &RowPitch, &SlicePitch); + initialData[i].SysMemPitch = RowPitch; + initialData[i].SysMemSlicePitch = SlicePitch; + } + + MEMORY_BASIC_INFORMATION mbi{}; + if (!VirtualQuery(pVirtualAddress, &mbi, sizeof(mbi)) || mbi.RegionSize < SlicePitch || + (mbi.State & MEM_COMMIT) != MEM_COMMIT || (mbi.Protect & (PAGE_READWRITE | PAGE_READONLY)) == 0) + { + HRESULT hr = CreateTexture1D(&pDesc2, 0, ppTexture1D); + (*ppTexture1D)->m_pAllocationStart = pVirtualAddress; + initialData.clear(); + return hr; + } + else + { + HRESULT hr = CreateTexture1D(&pDesc2, initialData.data(), ppTexture1D); + (*ppTexture1D)->m_pAllocationStart = pVirtualAddress; + initialData.clear(); + return hr; + } + + return S_OK; } template HRESULT D3D11DeviceX::CreatePlacementTexture2D(D3D11_TEXTURE2D_DESC const *pDesc, UINT TileModeIndex, UINT Pitch, void *pVirtualAddress, gfx::ID3D11Texture2D **ppTexture2D) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + std::vector initialData(pDesc->ArraySize); + UINT RowPitch = 0; + UINT SlicePitch = 0; + auto pDesc2 = *pDesc; + pDesc2.MipLevels = 1; + if (pDesc2.Usage == D3D11_USAGE_IMMUTABLE) + { + pDesc2.Usage = D3D11_USAGE_DEFAULT; + } + + for (int i = 0; i < initialData.size(); i++) + { + initialData[i].pSysMem = pVirtualAddress; + CalculatePitch(pDesc2.Width, pDesc2.Height, pDesc2.Format, &RowPitch, &SlicePitch); + initialData[i].SysMemPitch = RowPitch; + initialData[i].SysMemSlicePitch = SlicePitch; + } + + MEMORY_BASIC_INFORMATION mbi{}; + if (!VirtualQuery(pVirtualAddress, &mbi, sizeof(mbi)) || mbi.RegionSize < SlicePitch || + (mbi.State & MEM_COMMIT) != MEM_COMMIT || (mbi.Protect & (PAGE_READWRITE | PAGE_READONLY)) == 0) + { + HRESULT hr = CreateTexture2D(&pDesc2, 0, ppTexture2D); + (*ppTexture2D)->m_pAllocationStart = pVirtualAddress; + initialData.clear(); + return hr; + } + else + { + HRESULT hr = CreateTexture2D(&pDesc2, initialData.data(), ppTexture2D); + (*ppTexture2D)->m_pAllocationStart = pVirtualAddress; + initialData.clear(); + return hr; + } + + return S_OK; } template HRESULT D3D11DeviceX::CreatePlacementTexture3D(D3D11_TEXTURE3D_DESC const *pDesc, UINT TileModeIndex, UINT Pitch, void *pVirtualAddress, gfx::ID3D11Texture3D **ppTexture3D) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + std::vector initialData(1); + UINT RowPitch = 0; + UINT SlicePitch = 0; + auto pDesc2 = *pDesc; + pDesc2.MipLevels = 1; + if (pDesc2.Usage == D3D11_USAGE_IMMUTABLE) + { + pDesc2.Usage = D3D11_USAGE_DEFAULT; + } + + for (int i = 0; i < initialData.size(); i++) + { + initialData[i].pSysMem = pVirtualAddress; + CalculatePitch(pDesc2.Width, pDesc2.Height, pDesc2.Format, &RowPitch, &SlicePitch); + initialData[i].SysMemPitch = RowPitch; + initialData[i].SysMemSlicePitch = SlicePitch; + } + + MEMORY_BASIC_INFORMATION mbi{}; + if (!VirtualQuery(pVirtualAddress, &mbi, sizeof(mbi)) || mbi.RegionSize < SlicePitch || + (mbi.State & MEM_COMMIT) != MEM_COMMIT || (mbi.Protect & (PAGE_READWRITE | PAGE_READONLY)) == 0) + { + HRESULT hr = CreateTexture3D(&pDesc2, 0, ppTexture3D); + (*ppTexture3D)->m_pAllocationStart = pVirtualAddress; + initialData.clear(); + return hr; + } + else + { + HRESULT hr = CreateTexture3D(&pDesc2, initialData.data(), ppTexture3D); + (*ppTexture3D)->m_pAllocationStart = pVirtualAddress; + initialData.clear(); + return hr; + } + + return S_OK; } template void D3D11DeviceX::GetTimestamps(UINT64 *pGpuTimestamp, UINT64 *pCpuRdtscTimestamp) diff --git a/projects/WinDurango.D3D11X/src/ID3D11DeviceContext.cpp b/projects/WinDurango.D3D11X/src/ID3D11DeviceContext.cpp index a70f713..84b2e79 100644 --- a/projects/WinDurango.D3D11X/src/ID3D11DeviceContext.cpp +++ b/projects/WinDurango.D3D11X/src/ID3D11DeviceContext.cpp @@ -4,6 +4,7 @@ #include "ID3D11Resource.h" #include "ID3D11Shader.h" #include "ID3D11State.h" +#include "d3d11.x.h" // // IUnknown @@ -48,7 +49,13 @@ template ULONG D3D11DeviceContextX::Release() // template void D3D11DeviceContextX::GetDevice(gfx::ID3D11Device **ppDevice) { - IMPLEMENT_STUB(); + ID3D11Device *pDevice = nullptr; + ID3D11Device2 *pDevice2 = nullptr; + m_pFunction->GetDevice(&pDevice); + + if (pDevice) pDevice->QueryInterface(IID_PPV_ARGS(&pDevice2)); + + *ppDevice = new D3D11DeviceX(pDevice2); } template @@ -82,6 +89,88 @@ HRESULT D3D11DeviceContextX::SetPrivateDataInterfaceGraphics(_GUID const &g // // ID3D11DeviceContext // + +template +void D3D11DeviceContextX::CheckDirtyFlags() +{ + if constexpr (requires { this->m_ShaderUserDataManagerDraw; }) + { + // Topology + if (this->m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x46) + { + this->m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x46; + int topology = D3D11X_HARDWARE_TO_TOPOLOGY_MAP.at(this->m_ShaderUserDataManagerDraw.m_Topology); + m_pFunction->IASetPrimitiveTopology(static_cast(topology)); + } + + // Input Layout + if (this->m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x89) + { + this->m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x89; + m_pFunction->IASetInputLayout(this->m_ShaderUserDataManagerDraw.m_pInputLayout); + } + + // VS + if (this->m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x91) + { + this->m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x91; + VSSetShader(this->m_ShaderUserDataManagerDraw.m_pVs); + } + + // PS + if (this->m_ShaderUserDataManagerDraw.m_DirtyFlags & 0x121) + { + this->m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x121; + PSSetShader(this->m_ShaderUserDataManagerDraw.m_pPs); + } + } + + ExecuteBackgroundContexts(); +} + +template +void D3D11DeviceContextX::ExecuteBackgroundContexts() +{ + std::lock_guard lock(m_BkgCtxLock); + + for (auto it = m_BkgContexts.begin(); it != m_BkgContexts.end();) + { + if ((*it)->ExecuteContext()) + { + // This background context has finished executing, so we can remove + // it from the array. If it starts executing again it will be re-added. + it = m_BkgContexts.erase(it); + } + else + { + it++; + } + } +} + +template +void D3D11DeviceContextX::AddBackgroundContext(ID3D11BackgroundContext *pContext) +{ + std::lock_guard lock(m_BkgCtxLock); + + for (auto it : m_BkgContexts) + { + if (it == pContext) + { + // Context already exists + return; + } + } + + m_BkgContexts.push_back(pContext); +} + +template +void D3D11DeviceContextX::RemoveBackgroundContext(ID3D11BackgroundContext *pContext) +{ + std::lock_guard lock(m_BkgCtxLock); +} + template void D3D11DeviceContextX::VSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers) @@ -160,15 +249,26 @@ template void D3D11DeviceContextX::VSSetShader(gfx::ID3D11Verte m_pFunction->VSSetShader(Shader, nullptr, 0); } +template +void D3D11DeviceContextX::DrawIndexed(UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation) +{ + CheckDirtyFlags(); + m_pFunction->DrawIndexed(IndexCount, StartIndexLocation, BaseVertexLocation); +} + template void D3D11DeviceContextX::DrawIndexed(UINT64 StartIndexLocationAndIndexCount, INT BaseVertexLocation) { - IMPLEMENT_STUB(); + CheckDirtyFlags(); + UINT StartIndexLocation = StartIndexLocationAndIndexCount & 0xFFFFFFFF; + UINT IndexCount = (StartIndexLocationAndIndexCount >> 32) & 0xFFFFFFFF; + m_pFunction->DrawIndexed(IndexCount, StartIndexLocation, BaseVertexLocation); } template void D3D11DeviceContextX::Draw(UINT VertexCount, UINT StartVertexLocation) { - IMPLEMENT_STUB(); + CheckDirtyFlags(); + m_pFunction->Draw(VertexCount, StartVertexLocation); } template @@ -297,6 +397,48 @@ void D3D11DeviceContextX::IASetIndexBuffer(gfx::ID3D11Buffer *pIndexBu m_pFunction->IASetIndexBuffer(Buffer, (DXGI_FORMAT)HardwareIndexFormat, Offset); } +template +void D3D11DeviceContextX::DrawIndexedInstanced(UINT IndexCountPerInstance, UINT InstanceCount, + UINT StartIndexLocation, INT BaseVertexLocation, + UINT StartInstanceLocation) +{ + CheckDirtyFlags(); + m_pFunction->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation, BaseVertexLocation, + StartInstanceLocation); +} + +template +void D3D11DeviceContextX::DrawIndexedInstanced(UINT64 StartIndexLocationAndIndexCountPerInstance, + UINT64 BaseVertexLocationAndStartInstanceLocation, + UINT InstanceCount) +{ + CheckDirtyFlags(); + UINT StartInstanceLocation = (BaseVertexLocationAndStartInstanceLocation >> 32) & 0xFFFFFFFF; + UINT BaseVertexLocation = BaseVertexLocationAndStartInstanceLocation & 0xFFFFFFFF; + UINT IndexCountPerInstance = (StartIndexLocationAndIndexCountPerInstance >> 32) & 0xFFFFFFFF; + UINT StartIndexLocation = StartIndexLocationAndIndexCountPerInstance & 0xFFFFFFFF; + m_pFunction->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation, BaseVertexLocation, + StartInstanceLocation); +} + +template +void D3D11DeviceContextX::DrawInstanced(UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, + UINT StartInstanceLocation) +{ + CheckDirtyFlags(); + m_pFunction->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation); +} + +template +void D3D11DeviceContextX::DrawInstanced(UINT VertexCountPerInstance, + UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount) +{ + CheckDirtyFlags(); + UINT StartInstanceLocation = (StartVertexLocationAndStartInstanceLocation >> 32) & 0xFFFFFFFF; + UINT StartVertexLocation = StartVertexLocationAndStartInstanceLocation & 0xFFFFFFFF; + m_pFunction->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation); +} + template void D3D11DeviceContextX::IASetIndexBuffer(UINT HardwareIndexFormat, gfx::ID3D11Buffer *pIndexBuffer, UINT Offset) @@ -313,21 +455,6 @@ void D3D11DeviceContextX::IASetIndexBuffer(UINT HardwareIndexFormat, gfx::I m_pFunction->IASetIndexBuffer(Buffer, Format, Offset); } -template -void D3D11DeviceContextX::DrawIndexedInstanced(UINT StartIndexLocationAndIndexCountPerInstance, - UINT64 BaseVertexLocationAndStartInstanceLocation, - UINT64 InstanceCount) -{ - IMPLEMENT_STUB(); -} - -template -void D3D11DeviceContextX::DrawInstanced(UINT VertexCountPerInstance, - UINT64 StartVertexLocationAndStartInstanceLocation, UINT InstanceCount) -{ - IMPLEMENT_STUB(); -} - template void D3D11DeviceContextX::GSSetConstantBuffers(UINT StartSlot, UINT NumBuffers, gfx::ID3D11Buffer *const *ppConstantBuffers) @@ -359,7 +486,7 @@ template void D3D11DeviceContextX::GSSetShader(gfx::ID3D11Geome template void D3D11DeviceContextX::IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY PrimitiveTopology) { - IMPLEMENT_STUB(); + m_pFunction->IASetPrimitiveTopology(PrimitiveTopology); } template @@ -593,7 +720,14 @@ void D3D11DeviceContextX::DispatchIndirect(gfx::ID3D11Buffer *pBufferF template void D3D11DeviceContextX::RSSetState(gfx::ID3D11RasterizerState *pRasterizerState) { - IMPLEMENT_STUB(); + ID3D11RasterizerState *pState = nullptr; + + if (pRasterizerState) + { + pState = static_cast*>(pRasterizerState)->m_pFunction; + } + + m_pFunction->RSSetState(pState); } template void D3D11DeviceContextX::RSSetViewports(UINT NumViewports, D3D11_VIEWPORT const *pViewports) @@ -603,7 +737,7 @@ template void D3D11DeviceContextX::RSSetViewports(UINT NumViewp template void D3D11DeviceContextX::RSSetScissorRects(UINT NumRects, D3D11_RECT const *pRects) { - IMPLEMENT_STUB(); + m_pFunction->RSSetScissorRects(NumRects, pRects); } template @@ -671,28 +805,40 @@ template void D3D11DeviceContextX::ClearRenderTargetView(gfx::ID3D11RenderTargetView *pRenderTargetView, FLOAT const ColorRGBA[4]) { - IMPLEMENT_STUB(); + if (pRenderTargetView) + { + m_pFunction->ClearRenderTargetView(static_cast*>(pRenderTargetView)->m_pFunction, ColorRGBA); + } } template void D3D11DeviceContextX::ClearUnorderedAccessViewUint(gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, UINT const Values[4]) { - IMPLEMENT_STUB(); + if (pUnorderedAccessView) + { + m_pFunction->ClearUnorderedAccessViewUint(static_cast *>(pUnorderedAccessView)->m_pFunction, Values); + } } template void D3D11DeviceContextX::ClearUnorderedAccessViewFloat(gfx::ID3D11UnorderedAccessView *pUnorderedAccessView, FLOAT const Values[4]) { - IMPLEMENT_STUB(); + if (pUnorderedAccessView) + { + m_pFunction->ClearUnorderedAccessViewFloat(static_cast *>(pUnorderedAccessView)->m_pFunction, Values); + } } template void D3D11DeviceContextX::ClearDepthStencilView(gfx::ID3D11DepthStencilView *pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil) { - IMPLEMENT_STUB(); + if (pDepthStencilView) + { + m_pFunction->ClearDepthStencilView(static_cast*>(pDepthStencilView)->m_pFunction, ClearFlags, Depth, Stencil); + } } template @@ -723,7 +869,7 @@ void D3D11DeviceContextX::ResolveSubresource(gfx::ID3D11Resource *pDst template void D3D11DeviceContextX::ExecuteCommandList(ID3D11CommandList *pCommandList, BOOL RestoreContextState) { - IMPLEMENT_STUB(); + m_pFunction->ExecuteCommandList(pCommandList, RestoreContextState); } template @@ -1207,31 +1353,28 @@ void D3D11DeviceContextX::CSGetConstantBuffers(UINT StartSlot, UINT NumBuff template void D3D11DeviceContextX::ClearState() { - IMPLEMENT_STUB(); + m_pFunction->ClearState(); } template void D3D11DeviceContextX::Flush() { - IMPLEMENT_STUB(); + m_pFunction->Flush(); } template D3D11_DEVICE_CONTEXT_TYPE D3D11DeviceContextX::GetType() { - IMPLEMENT_STUB(); - return {}; + return m_pFunction->GetType(); } template UINT D3D11DeviceContextX::GetContextFlags() { - IMPLEMENT_STUB(); - return {}; + return m_pFunction->GetContextFlags(); } template HRESULT D3D11DeviceContextX::FinishCommandList(BOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + return m_pFunction->FinishCommandList(RestoreDeferredContextState, ppCommandList); } // @@ -1525,13 +1668,19 @@ template void D3D11DeviceContextX::InsertWaitUntilIdle(UINT Fla template UINT64 D3D11DeviceContextX::InsertFence(UINT Flags) { - IMPLEMENT_STUB(); - return {}; + ExecuteBackgroundContexts(); + return (UINT64)&m_Fence; } template void D3D11DeviceContextX::InsertWaitOnFence(UINT Flags, UINT64 Fence) { - IMPLEMENT_STUB(); + if (Fence) + { + while (!*reinterpret_cast(Fence)) + { + ExecuteBackgroundContexts(); + } + } } template @@ -1565,121 +1714,124 @@ template void D3D11DeviceContextX::RemapVertexBufferInheritance template void D3D11DeviceContextX::PSSetFastConstantBuffer(UINT Slot, gfx::ID3D11Buffer *pConstantBuffer) { - IMPLEMENT_STUB(); + PSSetConstantBuffers(Slot, 1, &pConstantBuffer); } template void D3D11DeviceContextX::PSSetFastShaderResource(UINT Slot, gfx::ID3D11ShaderResourceView *pShaderResourceView) { - IMPLEMENT_STUB(); + PSSetShaderResources(Slot, 1, &pShaderResourceView); } template void D3D11DeviceContextX::PSSetFastSampler(UINT Slot, gfx::ID3D11SamplerState *pSampler) { - IMPLEMENT_STUB(); + PSSetSamplers(Slot, 1, &pSampler); } template void D3D11DeviceContextX::VSSetFastConstantBuffer(UINT Slot, gfx::ID3D11Buffer *pConstantBuffer) { - IMPLEMENT_STUB(); + VSSetConstantBuffers(Slot, 1, &pConstantBuffer); } template void D3D11DeviceContextX::VSSetFastShaderResource(UINT Slot, gfx::ID3D11ShaderResourceView *pShaderResourceView) { - IMPLEMENT_STUB(); + VSSetShaderResources(Slot, 1, &pShaderResourceView); } template void D3D11DeviceContextX::VSSetFastSampler(UINT Slot, gfx::ID3D11SamplerState *pSampler) { - IMPLEMENT_STUB(); + VSSetSamplers(Slot, 1, &pSampler); } template void D3D11DeviceContextX::GSSetFastConstantBuffer(UINT Slot, gfx::ID3D11Buffer *pConstantBuffer) { - IMPLEMENT_STUB(); + GSSetConstantBuffers(Slot, 1, &pConstantBuffer); } template void D3D11DeviceContextX::GSSetFastShaderResource(UINT Slot, gfx::ID3D11ShaderResourceView *pShaderResourceView) { - IMPLEMENT_STUB(); + GSSetShaderResources(Slot, 1, &pShaderResourceView); } template void D3D11DeviceContextX::GSSetFastSampler(UINT Slot, gfx::ID3D11SamplerState *pSampler) { - IMPLEMENT_STUB(); + GSSetSamplers(Slot, 1, &pSampler); } template void D3D11DeviceContextX::CSSetFastConstantBuffer(UINT Slot, gfx::ID3D11Buffer *pConstantBuffer) { - IMPLEMENT_STUB(); + CSSetConstantBuffers(Slot, 1, &pConstantBuffer); } template void D3D11DeviceContextX::CSSetFastShaderResource(UINT Slot, gfx::ID3D11ShaderResourceView *pShaderResourceView) { - IMPLEMENT_STUB(); + CSSetShaderResources(Slot, 1, &pShaderResourceView); } template void D3D11DeviceContextX::CSSetFastSampler(UINT Slot, gfx::ID3D11SamplerState *pSampler) { - IMPLEMENT_STUB(); + CSSetSamplers(Slot, 1, &pSampler); } template void D3D11DeviceContextX::HSSetFastConstantBuffer(UINT Slot, gfx::ID3D11Buffer *pConstantBuffer) { - IMPLEMENT_STUB(); + HSSetConstantBuffers(Slot, 1, &pConstantBuffer); } template void D3D11DeviceContextX::HSSetFastShaderResource(UINT Slot, gfx::ID3D11ShaderResourceView *pShaderResourceView) { - IMPLEMENT_STUB(); + HSSetShaderResources(Slot, 1, &pShaderResourceView); } template void D3D11DeviceContextX::HSSetFastSampler(UINT Slot, gfx::ID3D11SamplerState *pSampler) { - IMPLEMENT_STUB(); + HSSetSamplers(Slot, 1, &pSampler); } template void D3D11DeviceContextX::DSSetFastConstantBuffer(UINT Slot, gfx::ID3D11Buffer *pConstantBuffer) { - IMPLEMENT_STUB(); + DSSetConstantBuffers(Slot, 1, &pConstantBuffer); } template void D3D11DeviceContextX::DSSetFastShaderResource(UINT Slot, gfx::ID3D11ShaderResourceView *pShaderResourceView) { - IMPLEMENT_STUB(); + DSSetShaderResources(Slot, 1, &pShaderResourceView); } template void D3D11DeviceContextX::DSSetFastSampler(UINT Slot, gfx::ID3D11SamplerState *pSampler) { - IMPLEMENT_STUB(); + DSSetSamplers(Slot, 1, &pSampler); } template void D3D11DeviceContextX::IASetFastVertexBuffer(UINT Slot, gfx::ID3D11Buffer *pVertexBuffer, UINT Stride) { - IMPLEMENT_STUB(); + UINT Offset = 0; + IASetVertexBuffers(Slot, 1, &pVertexBuffer, &Stride, &Offset); } template void D3D11DeviceContextX::IASetFastIndexBuffer(UINT HardwareIndexFormat, gfx::ID3D11Buffer *pIndexBuffer) { - IMPLEMENT_STUB(); + HardwareIndexFormat = HardwareIndexFormat != 0 ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; + + IASetIndexBuffer(pIndexBuffer, HardwareIndexFormat, 0); } template @@ -1802,12 +1954,12 @@ void D3D11DeviceContextX::HSGetLastUsedTessellationParameters( template void D3D11DeviceContextX::CSEnableAutomaticGpuFlush(BOOL Enable) { - IMPLEMENT_STUB(); + } template void D3D11DeviceContextX::GpuSendPipelinedEvent(gfx::D3D11X_GPU_PIPELINED_EVENT Event) { - IMPLEMENT_STUB(); + } template HRESULT D3D11DeviceContextX::Suspend(UINT Flags) diff --git a/projects/WinDurango.D3D11X/src/IDXGIFactory.cpp b/projects/WinDurango.D3D11X/src/IDXGIFactory.cpp index b3ce79d..52c23cb 100644 --- a/projects/WinDurango.D3D11X/src/IDXGIFactory.cpp +++ b/projects/WinDurango.D3D11X/src/IDXGIFactory.cpp @@ -160,6 +160,14 @@ HRESULT DXGIFactory2::CreateSwapChainForCoreWindow(xbox::IGraphicsUnknownSwapEffect == DXGI_SWAP_EFFECT_DISCARD || pDesc->SwapEffect == DXGI_SWAP_EFFECT_SEQUENTIAL) + { + if (pDesc->SwapEffect == DXGI_SWAP_EFFECT_DISCARD) + pDesc2.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; + else if (pDesc->SwapEffect == DXGI_SWAP_EFFECT_SEQUENTIAL) + pDesc2.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; + } + if (pDevice) { pDevice->QueryInterface(__uuidof(xbox::IGraphicsUnwrap), (void **)&dev); diff --git a/projects/WinDurango.D3D11X/src/d3d11.x.cpp b/projects/WinDurango.D3D11X/src/d3d11.x.cpp index 2b18319..416c74f 100644 --- a/projects/WinDurango.D3D11X/src/d3d11.x.cpp +++ b/projects/WinDurango.D3D11X/src/d3d11.x.cpp @@ -130,17 +130,17 @@ struct DXGIX_PRESENTARRAY_PARAMETERS UINT Flags; }; -void PresentArray(UINT NumSwapChains, void **SwapChains, UINT SyncInterval) -{ - // TODO -} - EXTERN_C HRESULT __stdcall DXGIXPresentArray(UINT SyncInterval, UINT PresentImmediateThreshold, UINT Flags, UINT NumSwapChains, void **ppSwapChains, const DXGIX_PRESENTARRAY_PARAMETERS *pPresentParameters) { - IMPLEMENT_STUB(); - return E_NOTIMPL; + if (!g_PresentArrayHelper) + { + d3d11CreateInstance(g_ABI, (void **)&g_PresentArrayHelper); + } + + g_PresentArrayHelper->PresentArray(ppSwapChains, NumSwapChains, SyncInterval); + return S_OK; } EXTERN_C HRESULT __stdcall DXGIXSetVLineNotification(UINT VLineCounter, UINT VLineNum, HANDLE hEvent) diff --git a/projects/WinDurango.KernelX/include/WinDurango.KernelX/Hooks.h b/projects/WinDurango.KernelX/include/WinDurango.KernelX/Hooks.h index f4dbe6f..89a2fc6 100644 --- a/projects/WinDurango.KernelX/include/WinDurango.KernelX/Hooks.h +++ b/projects/WinDurango.KernelX/include/WinDurango.KernelX/Hooks.h @@ -61,4 +61,14 @@ inline BOOL IsXboxAddress(const PVOID Address) HRESULT(STDMETHODCALLTYPE *TrueGetForCurrentThread)(ICoreWindowStatic *staticWindow, CoreWindow **window); -HRESULT STDMETHODCALLTYPE EraGetForCurrentThread(ICoreWindowStatic *pThis, CoreWindow **ppWindow); \ No newline at end of file +HRESULT STDMETHODCALLTYPE EraGetForCurrentThread(ICoreWindowStatic *pThis, CoreWindow **ppWindow); + +typedef HWND(WINAPI *PCreateWindowInBandEx)(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, + int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, + HINSTANCE hInstance, LPVOID lpParam, DWORD dwBand, DWORD dwTypeFlags); + +static PCreateWindowInBandEx TrueCreateWindowInBandEx = 0; + +HWND WINAPI EraCreateWindowInBandEx(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int x, + int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, + LPVOID lpParam, DWORD dwBand, DWORD dwTypeFlags); \ No newline at end of file diff --git a/projects/WinDurango.KernelX/src/Hooks.cpp b/projects/WinDurango.KernelX/src/Hooks.cpp index d90a5cb..1da345a 100644 --- a/projects/WinDurango.KernelX/src/Hooks.cpp +++ b/projects/WinDurango.KernelX/src/Hooks.cpp @@ -148,6 +148,20 @@ HRESULT __stdcall EraGetForCurrentThread(ICoreWindowStatic *pThis, CoreWindow ** return hr; } +HWND __stdcall EraCreateWindowInBandEx(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int x, + int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, + HINSTANCE hInstance, LPVOID lpParam, DWORD dwBand, DWORD dwTypeFlags) +{ + if (dwExStyle & WS_EX_NOREDIRECTIONBITMAP) + { + dwExStyle &= ~WS_EX_NOREDIRECTIONBITMAP; + } + + return TrueCreateWindowInBandEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, + hMenu, hInstance, lpParam, dwBand, dwTypeFlags); +} + + inline HRESULT WINAPI EraRoGetActivationFactory(HSTRING classId, REFIID iid, void **factory) { diff --git a/projects/WinDurango.KernelX/src/dllmain.cpp b/projects/WinDurango.KernelX/src/dllmain.cpp index 78ced6d..4035631 100644 --- a/projects/WinDurango.KernelX/src/dllmain.cpp +++ b/projects/WinDurango.KernelX/src/dllmain.cpp @@ -5,12 +5,31 @@ static DWORD ReasonForCall = 0; void KernelxInitialize(HINSTANCE hinstDLL) { + if (!GetConsoleWindow()) + { + AllocConsole(); + FILE *f; + freopen_s(&f, "CONOUT$", "w", stdout); + freopen_s(&f, "CONOUT$", "w", stderr); + freopen_s(&f, "CONIN$", "r", stdin); + + SetConsoleTitleW(L"WinDurango"); + } + if (ReasonForCall == DLL_PROCESS_ATTACH || ReasonForCall == DLL_THREAD_ATTACH) { XWinePatchImport(GetModuleHandleW(nullptr), GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect); } + + HMODULE User32 = LoadLibraryA("user32.dll"); + if (User32) + { + FARPROC CreateWindowInBandEx = GetProcAddress(User32, "CreateWindowInBandEx"); + TrueCreateWindowInBandEx = reinterpret_cast(CreateWindowInBandEx); + DetourAttach(&reinterpret_cast(TrueCreateWindowInBandEx), EraCreateWindowInBandEx); + } } BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) diff --git a/projects/WinDurango.WinRT/src/Windows/Xbox/Input/Windows.Xbox.Input.Gamepad.cpp b/projects/WinDurango.WinRT/src/Windows/Xbox/Input/Windows.Xbox.Input.Gamepad.cpp index a7a5914..13dc8d7 100644 --- a/projects/WinDurango.WinRT/src/Windows/Xbox/Input/Windows.Xbox.Input.Gamepad.cpp +++ b/projects/WinDurango.WinRT/src/Windows/Xbox/Input/Windows.Xbox.Input.Gamepad.cpp @@ -131,29 +131,19 @@ namespace winrt::Windows::Xbox::Input::implementation p_wd->log.Log("WinDurango::WinRT::Windows::Xbox::Input", "Creating static a_gamepads"); - for (size_t i = 0; i < 4; i++) + for (DWORD gamepad = 0; gamepad < XUSER_MAX_COUNT; gamepad++) { - XINPUT_STATE state{}; - DWORD result = XInputGetState(0, &state); - - if (result == ERROR_SUCCESS) + XINPUT_CAPABILITIES capabilities; + if (XInputGetCapabilities(gamepad, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) { p_wd->log.Log("WinDurango::WinRT::Windows::Xbox::Input", "Creating gamepad"); - winrt::Windows::Xbox::Input::Gamepad gamepad = winrt::make(i, true); - a_gamepads.Append(gamepad); + winrt::Windows::Xbox::Input::Gamepad NewGamepad = winrt::make(gamepad, true); + a_gamepads.Append(NewGamepad); + continue; } } } - if (a_gamepads.Size() == 0) - { - p_wd->log.Log("WinDurango::WinRT::Windows::Xbox::Input", "Creating Virtual gamepad"); - winrt::Windows::Xbox::Input::Gamepad gamepad = winrt::make(0, false); - a_gamepads.Append(gamepad); - } - - // I think I need to add mouse capture here - return a_gamepads.GetView(); } diff --git a/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp b/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp index d26ba55..8043e46 100644 --- a/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp +++ b/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferManager.cpp @@ -20,13 +20,11 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation } winrt::Windows::Xbox::Management::Deployment::PackageTransferManager PackageTransferManager::Current() { - p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: Current"); - throw hresult_not_implemented(); + return winrt::make(); } - winrt::Windows::Xbox::Management::Deployment::PackageTransferManager PackageTransferManager::Create(winrt::Windows::ApplicationModel::Package const& unk) + winrt::Windows::Xbox::Management::Deployment::PackageTransferManager PackageTransferManager::Create(winrt::Windows::ApplicationModel::Package const &package) { - p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: Create"); - throw hresult_not_implemented(); + return winrt::make(); } winrt::Windows::Xbox::Management::Deployment::ChunkSpecifiers PackageTransferManager::AvailableChunkSpecifiers() { @@ -51,7 +49,7 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation winrt::Windows::Foundation::IAsyncAction PackageTransferManager::RemoveChunkSpecifiersAsync(winrt::Windows::Xbox::Management::Deployment::ChunkSpecifiers unk) { p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: RemoveChunkSpecifiersAsync"); - throw hresult_not_implemented(); + return {}; } winrt::Windows::Xbox::Management::Deployment::PackageTransferType PackageTransferManager::TransferType() { @@ -63,20 +61,17 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: UpdateInstallOrder"); throw hresult_not_implemented(); } - bool PackageTransferManager::IsChunkInstalled(uint32_t unk) + bool PackageTransferManager::IsChunkInstalled(uint32_t chunkId) { - p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: IsChunkInstalled"); - throw hresult_not_implemented(); + return true; } - bool PackageTransferManager::AreChunksInstalled(winrt::Windows::Foundation::Collections::IIterable const& unk) + bool PackageTransferManager::AreChunksInstalled(winrt::Windows::Foundation::Collections::IIterable const &chunkIds) { - p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: AreChunksInstalled"); - throw hresult_not_implemented(); + return true; } uint32_t PackageTransferManager::FindChunkFromFile(hstring const& unk) { - p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: FindChunkFromFile"); - throw hresult_not_implemented(); + return 0; } winrt::Windows::Xbox::Management::Deployment::PackageTransferStatus PackageTransferManager::TransferStatus() { diff --git a/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferWatcher.cpp b/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferWatcher.cpp index f0e1d5b..c5ada6d 100644 --- a/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferWatcher.cpp +++ b/projects/WinDurango.WinRT/src/Windows/Xbox/Management/Deployment/Windows.Xbox.Management.Deployment.PackageTransferWatcher.cpp @@ -19,13 +19,11 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation } winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher PackageTransferWatcher::Create(winrt::Windows::ApplicationModel::Package const& unk, winrt::Windows::Foundation::Collections::IIterable const& unka) { - p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: Create"); - throw hresult_not_implemented(); + return winrt::make(); } winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher PackageTransferWatcher::Create(winrt::Windows::ApplicationModel::Package const& unk) { - p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Management::Deployment", "Unimplemented: Create(Package)"); - throw hresult_not_implemented(); + return winrt::make(); } winrt::Windows::Xbox::Management::Deployment::PackageTransferStatus PackageTransferWatcher::TransferStatus() {