#include "ID3D11Device.h" #include "IDXGIDevice.h" #include "ID3D11Resource.h" #include "ID3D11View.h" #include "ID3D11State.h" #include "ID3D11Shader.h" #include "ID3D11DeviceContext.h" #include "ID3D11Runtime.h" #include "ID3D11DMAEngineContext.h" #include "d3d11.x.h" // // IUnknown // template HRESULT D3D11DeviceX::QueryInterface(REFIID riid, void **ppvObject) { if (riid == xcom::guid_of() || riid == xcom::guid_of() || riid == xcom::guid_of() || riid == xcom::guid_of() || riid == xcom::guid_of()) { *ppvObject = this; AddRef(); return S_OK; } if (riid == xcom::guid_of() || riid == xcom::guid_of() || riid == xcom::guid_of()) { m_pFunction->QueryInterface(__uuidof(IDXGIDevice2), ppvObject); *ppvObject = new DXGIDevice2(static_cast(*ppvObject)); return S_OK; } if (riid == xcom::guid_of()) { *ppvObject = m_pFunction; return S_OK; } if (riid == __uuidof(ID3D11InfoQueue)) { *ppvObject = nullptr; return E_NOINTERFACE; } IMPLEMENT_STUB(); *ppvObject = nullptr; return E_NOINTERFACE; } template ULONG D3D11DeviceX::AddRef() { m_pFunction->AddRef(); return InterlockedIncrement(&this->m_RefCount); } template ULONG D3D11DeviceX::Release() { m_pFunction->Release(); ULONG RefCount = InterlockedDecrement(&this->m_RefCount); if (!RefCount) delete this; return RefCount; } // // ID3D11Device // template HRESULT D3D11DeviceX::CreateBuffer(D3D11_BUFFER_DESC const *pDesc, D3D11_SUBRESOURCE_DATA const *pData, gfx::ID3D11Buffer **ppBuffer) { auto pDesc2 = *pDesc; pDesc2.MiscFlags = ConvertMiscFlags(pDesc->MiscFlags); HRESULT hr = 0; ID3D11Buffer *Buffer = nullptr; hr = m_pFunction->CreateBuffer(&pDesc2, pData, &Buffer); if (Buffer) { *ppBuffer = new D3D11Buffer(Buffer); } return hr; } template HRESULT D3D11DeviceX::CreateTexture1D(D3D11_TEXTURE1D_DESC const *pDesc, D3D11_SUBRESOURCE_DATA const *pData, gfx::ID3D11Texture1D **ppTexture1D) { auto pDesc2 = *pDesc; pDesc2.MiscFlags = ConvertMiscFlags(pDesc->MiscFlags); HRESULT hr = 0; ID3D11Texture1D *Tex = nullptr; hr = m_pFunction->CreateTexture1D(&pDesc2, pData, &Tex); if (Tex) { *ppTexture1D = new D3D11Texture1D(Tex); } return hr; } template HRESULT D3D11DeviceX::CreateTexture2D(D3D11_TEXTURE2D_DESC const *pDesc, D3D11_SUBRESOURCE_DATA const *pData, gfx::ID3D11Texture2D **ppTexture2D) { auto pDesc2 = *pDesc; pDesc2.MiscFlags = ConvertMiscFlags(pDesc->MiscFlags); pDesc2.SampleDesc.Quality = 0; HRESULT hr = 0; ID3D11Texture2D *Tex = nullptr; hr = m_pFunction->CreateTexture2D(&pDesc2, pData, &Tex); if (Tex) { *ppTexture2D = new D3D11Texture2D(Tex); } return hr; } template HRESULT D3D11DeviceX::CreateTexture3D(D3D11_TEXTURE3D_DESC const *pDesc, D3D11_SUBRESOURCE_DATA const *pData, gfx::ID3D11Texture3D **ppTexture3D) { auto pDesc2 = *pDesc; pDesc2.MiscFlags = ConvertMiscFlags(pDesc->MiscFlags); HRESULT hr = 0; ID3D11Texture3D *Tex = nullptr; hr = m_pFunction->CreateTexture3D(&pDesc2, pData, &Tex); if (Tex) { *ppTexture3D = new D3D11Texture3D(Tex); } return hr; } template HRESULT D3D11DeviceX::CreateShaderResourceView(gfx::ID3D11Resource *pResource, D3D11_SHADER_RESOURCE_VIEW_DESC const *pDesc, gfx::ID3D11ShaderResourceView **ppSRV) { HRESULT hr = 0; D3D11_RESOURCE_DIMENSION Type{}; pResource->GetType(&Type); ID3D11ShaderResourceView *pView = nullptr; if (Type == D3D11_RESOURCE_DIMENSION_BUFFER) { hr = m_pFunction->CreateShaderResourceView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE1D) { hr = m_pFunction->CreateShaderResourceView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE2D) { hr = m_pFunction->CreateShaderResourceView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE3D) { hr = m_pFunction->CreateShaderResourceView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_UNKNOWN) { hr = m_pFunction->CreateShaderResourceView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } if (pView) { *ppSRV = new D3D11ShaderResourceView(pView); (*ppSRV)->m_pAllocationStart = pResource->m_pAllocationStart; if (Type == D3D11_RESOURCE_DIMENSION_BUFFER) { static_cast *>(*ppSRV)->m_pBuffer = static_cast *>(pResource); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE1D) { static_cast *>(*ppSRV)->m_pTexture1D = static_cast *>(pResource); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE2D) { static_cast *>(*ppSRV)->m_pTexture2D = static_cast *>(pResource); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE3D) { static_cast *>(*ppSRV)->m_pTexture3D = static_cast *>(pResource); } } return hr; } template HRESULT D3D11DeviceX::CreateUnorderedAccessView(gfx::ID3D11Resource *pResource, D3D11_UNORDERED_ACCESS_VIEW_DESC const *pDesc, gfx::ID3D11UnorderedAccessView **ppUAV) { HRESULT hr = 0; D3D11_RESOURCE_DIMENSION Type{}; pResource->GetType(&Type); ID3D11UnorderedAccessView *pView = nullptr; if (Type == D3D11_RESOURCE_DIMENSION_BUFFER) { hr = m_pFunction->CreateUnorderedAccessView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE1D) { hr = m_pFunction->CreateUnorderedAccessView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE2D) { hr = m_pFunction->CreateUnorderedAccessView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE3D) { hr = m_pFunction->CreateUnorderedAccessView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_UNKNOWN) { hr = m_pFunction->CreateUnorderedAccessView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } if (pView) { *ppUAV = new D3D11UnorderedAccessView(pView); (*ppUAV)->m_pAllocationStart = pResource->m_pAllocationStart; if (Type == D3D11_RESOURCE_DIMENSION_BUFFER) { static_cast *>(*ppUAV)->m_pBuffer = static_cast *>(pResource); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE1D) { static_cast *>(*ppUAV)->m_pTexture1D = static_cast *>(pResource); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE2D) { static_cast *>(*ppUAV)->m_pTexture2D = static_cast *>(pResource); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE3D) { static_cast *>(*ppUAV)->m_pTexture3D = static_cast *>(pResource); } } return hr; } template HRESULT D3D11DeviceX::CreateRenderTargetView(gfx::ID3D11Resource *pResource, D3D11_RENDER_TARGET_VIEW_DESC const *pDesc, gfx::ID3D11RenderTargetView **ppRTV) { HRESULT hr = 0; D3D11_RESOURCE_DIMENSION Type{}; pResource->GetType(&Type); ID3D11RenderTargetView *pView = nullptr; if (Type == D3D11_RESOURCE_DIMENSION_BUFFER) { hr = m_pFunction->CreateRenderTargetView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE1D) { hr = m_pFunction->CreateRenderTargetView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE2D) { hr = m_pFunction->CreateRenderTargetView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE3D) { hr = m_pFunction->CreateRenderTargetView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_UNKNOWN) { hr = m_pFunction->CreateRenderTargetView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } if (pView) { *ppRTV = new D3D11RenderTargetView(pView); } return hr; } template HRESULT D3D11DeviceX::CreateDepthStencilView(gfx::ID3D11Resource *pResource, D3D11_DEPTH_STENCIL_VIEW_DESC const *pDesc, gfx::ID3D11DepthStencilView **ppDSV) { HRESULT hr = 0; D3D11_RESOURCE_DIMENSION Type{}; pResource->GetType(&Type); ID3D11DepthStencilView *pView = nullptr; if (Type == D3D11_RESOURCE_DIMENSION_BUFFER) { hr = m_pFunction->CreateDepthStencilView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE1D) { hr = m_pFunction->CreateDepthStencilView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE2D) { hr = m_pFunction->CreateDepthStencilView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_TEXTURE3D) { hr = m_pFunction->CreateDepthStencilView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } else if (Type == D3D11_RESOURCE_DIMENSION_UNKNOWN) { hr = m_pFunction->CreateDepthStencilView(static_cast *>(pResource)->m_pFunction, pDesc, &pView); } if (pView) { *ppDSV = new D3D11DepthStencilView(pView); } return hr; } template HRESULT D3D11DeviceX::CreateInputLayout(const D3D11_INPUT_ELEMENT_DESC *pInputElementDescs, uint32_t NumElements, const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, ID3D11InputLayout **ppInputLayout) { return m_pFunction->CreateInputLayout(pInputElementDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, ppInputLayout); } template HRESULT D3D11DeviceX::CreateVertexShader(void const *pBytecode, uint64_t BytecodeLength, ID3D11ClassLinkage *pClassLinkage, gfx::ID3D11VertexShader **ppVS) { ID3D11VertexShader *Shader{}; HRESULT hr = m_pFunction->CreateVertexShader(pBytecode, BytecodeLength, pClassLinkage, &Shader); if (Shader) { *ppVS = new D3D11VertexShader(Shader); } return hr; } template HRESULT D3D11DeviceX::CreateGeometryShader(void const *pBytecode, uint64_t BytecodeLentgh, ID3D11ClassLinkage *pClassLinkage, gfx::ID3D11GeometryShader **ppGS) { ID3D11GeometryShader *Shader{}; HRESULT hr = m_pFunction->CreateGeometryShader(pBytecode, BytecodeLentgh, pClassLinkage, &Shader); if (Shader) { *ppGS = new D3D11GeometryShader(Shader); } return hr; } template HRESULT D3D11DeviceX::CreateGeometryShaderWithStreamOutput(void const *pBytecode, uint64_t BytecodeLentgh, D3D11_SO_DECLARATION_ENTRY const *pSODeclaration, uint32_t NumEntries, uint32_t const *pStrides, uint32_t NumStides, uint32_t RasterizedStream, ID3D11ClassLinkage *pClassLinkage, gfx::ID3D11GeometryShader **ppGS) { ID3D11GeometryShader *Shader{}; HRESULT hr = m_pFunction->CreateGeometryShaderWithStreamOutput(pBytecode, BytecodeLentgh, pSODeclaration, NumEntries, pStrides, NumStides, RasterizedStream, pClassLinkage, &Shader); if (Shader) { *ppGS = new D3D11GeometryShader(Shader); } return hr; } template HRESULT D3D11DeviceX::CreatePixelShader(void const *pBytecode, uint64_t BytecodeLentgh, ID3D11ClassLinkage *pClassLinkage, gfx::ID3D11PixelShader **ppPS) { ID3D11PixelShader *Shader{}; HRESULT hr = m_pFunction->CreatePixelShader(pBytecode, BytecodeLentgh, pClassLinkage, &Shader); if (Shader) { *ppPS = new D3D11PixelShader(Shader); } return hr; } template HRESULT D3D11DeviceX::CreateHullShader(void const *pBytecode, uint64_t BytecodeLentgh, ID3D11ClassLinkage *pClassLinkage, gfx::ID3D11HullShader **ppHS) { ID3D11HullShader *Shader{}; HRESULT hr = m_pFunction->CreateHullShader(pBytecode, BytecodeLentgh, pClassLinkage, &Shader); if (Shader) { *ppHS = new D3D11HullShader(Shader); } return hr; } template HRESULT D3D11DeviceX::CreateDomainShader(void const *pBytecode, uint64_t BytecodeLentgh, ID3D11ClassLinkage *pClassLinkage, gfx::ID3D11DomainShader **ppDS) { ID3D11DomainShader *Shader{}; HRESULT hr = m_pFunction->CreateDomainShader(pBytecode, BytecodeLentgh, pClassLinkage, &Shader); if (Shader) { *ppDS = new D3D11DomainShader(Shader); } return hr; } template HRESULT D3D11DeviceX::CreateComputeShader(void const *pBytecode, uint64_t BytecodeLentgh, ID3D11ClassLinkage *pClassLinkage, gfx::ID3D11ComputeShader **ppCS) { ID3D11ComputeShader *Shader{}; HRESULT hr = m_pFunction->CreateComputeShader(pBytecode, BytecodeLentgh, pClassLinkage, &Shader); if (Shader) { *ppCS = new D3D11ComputeShader(Shader); } return hr; } template HRESULT D3D11DeviceX::CreateClassLinkage(ID3D11ClassLinkage **ppClassLinkage) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateBlendState(D3D11_BLEND_DESC const *pDesc, gfx::ID3D11BlendState **ppBlendState) { ID3D11BlendState *State{}; HRESULT hr = m_pFunction->CreateBlendState(pDesc, &State); if (State) { *ppBlendState = new D3D11BlendState(State); } return hr; } template HRESULT D3D11DeviceX::CreateDepthStencilState(D3D11_DEPTH_STENCIL_DESC const *pDesc, gfx::ID3D11DepthStencilState **ppDepthStencilState) { ID3D11DepthStencilState *State{}; HRESULT hr = m_pFunction->CreateDepthStencilState(pDesc, &State); if (State) { *ppDepthStencilState = new D3D11DepthStencilState(State); } return hr; } template HRESULT D3D11DeviceX::CreateRasterizerState(D3D11_RASTERIZER_DESC const *pDesc, gfx::ID3D11RasterizerState **ppRasterizerState) { ID3D11RasterizerState *State{}; HRESULT hr = m_pFunction->CreateRasterizerState(pDesc, &State); if (State) { *ppRasterizerState = new D3D11RasterizerState(State); } return hr; } template HRESULT D3D11DeviceX::CreateSamplerState(D3D11_SAMPLER_DESC const *pDesc, gfx::ID3D11SamplerState **ppSamplerState) { ID3D11SamplerState *State{}; HRESULT hr = m_pFunction->CreateSamplerState(pDesc, &State); if (State) { *ppSamplerState = new D3D11SamplerState(State); } return hr; } template HRESULT D3D11DeviceX::CreateQuery(D3D11_QUERY_DESC const *pDesc, ID3D11Query **ppQuery) { return m_pFunction->CreateQuery(pDesc, ppQuery); } template HRESULT D3D11DeviceX::CreatePredicate(D3D11_QUERY_DESC const *pDesc, ID3D11Predicate **ppPrediticate) { return m_pFunction->CreatePredicate(pDesc, ppPrediticate); } template HRESULT D3D11DeviceX::CreateCounter(D3D11_COUNTER_DESC const *pDesc, ID3D11Counter **ppCounter) { return m_pFunction->CreateCounter(pDesc, ppCounter); } template HRESULT D3D11DeviceX::CreateDeferredContext(uint32_t Flags, gfx::ID3D11DeviceContext **ppDeferredContext) { ID3D11DeviceContext2 *pContext = nullptr; HRESULT hr = m_pFunction->CreateDeferredContext2(0, &pContext); *ppDeferredContext = new D3D11DeviceContextX(pContext); return hr; } template HRESULT D3D11DeviceX::OpenSharedResource(void *pResource, _GUID const &retInterface, void **ppResource) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CheckFormatSupport(DXGI_FORMAT Format, uint32_t *pFormatSupport) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CheckMultisampleQualityLevels(DXGI_FORMAT Format, uint32_t SampleCount, uint32_t *pNumQualityLevels) { IMPLEMENT_STUB(); return E_NOTIMPL; } template void D3D11DeviceX::CheckCounterInfo(D3D11_COUNTER_INFO *pCounterInfo) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::CheckCounter(D3D11_COUNTER_DESC const *pDesc, D3D11_COUNTER_TYPE *pCounterType, uint32_t *pActiveCounters, char *szName, uint32_t *pNameLength, char *szUnits, uint32_t *pUnitsLength, char *szDescription, uint32_t *pDescriptionLength) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CheckFeatureSupport(D3D11_FEATURE Feature, void *pFeatureSupportData, uint32_t FeatureSupportDataSize) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::GetPrivateData(_GUID const &guid, uint32_t *pDataSize, void *pData) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::SetPrivateData(_GUID const &guid, uint32_t DataSize, void const *pData) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::SetPrivateDataInterface(_GUID const &guid, IUnknown const *pData) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::SetPrivateDataInterfaceGraphics(_GUID const &guid, xbox::IGraphicsUnknown const *pData) { IMPLEMENT_STUB(); return E_NOTIMPL; } template D3D_FEATURE_LEVEL D3D11DeviceX::GetFeatureLevel() { IMPLEMENT_STUB(); return {}; } template uint32_t D3D11DeviceX::GetCreationFlags() { IMPLEMENT_STUB(); return {}; } template HRESULT D3D11DeviceX::GetDeviceRemovedReason() { IMPLEMENT_STUB(); return E_NOTIMPL; } template void D3D11DeviceX::GetImmediateContext(gfx::ID3D11DeviceContext **ppImmediateContext) { ID3D11DeviceContext *pContext = nullptr; ID3D11DeviceContext2 *pContext2 = nullptr; m_pFunction->GetImmediateContext(&pContext); if (pContext) pContext->QueryInterface(IID_PPV_ARGS(&pContext2)); *ppImmediateContext = new D3D11DeviceContextX(pContext2); } template HRESULT D3D11DeviceX::SetExceptionMode(uint32_t ExceptionMode) { IMPLEMENT_STUB(); return E_NOTIMPL; } template uint32_t D3D11DeviceX::GetExceptionMode() { IMPLEMENT_STUB(); return {}; } // // ID3D11Device1 // template void D3D11DeviceX::GetImmediateContext1(gfx::ID3D11DeviceContext1 **ppImmediateContext) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::CreateDeferredContext1(uint32_t Flags, gfx::ID3D11DeviceContext1 **ppDeferredContext1) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateBlendState1(D3D11_BLEND_DESC1 const *pDesc, ID3D11BlendState1 **ppBlendState) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateRasterizerState1(D3D11_RASTERIZER_DESC1 const *pDesc, ID3D11RasterizerState1 **ppRasterizerState) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateDeviceContextState(uint32_t Flags, D3D_FEATURE_LEVEL const *pFeatureLevels, uint32_t FeatureLevels, uint32_t SDKVersion, _GUID const &EmulatedInterface, D3D_FEATURE_LEVEL *pChosenFeatureLevel, ID3DDeviceContextState **ppContextState) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::OpenSharedResource1(void *pResource, _GUID const &retInterface, void **ppResource) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::OpenSharedResourceByName(wchar_t const *pName, uint32_t dwDesiredAccess, _GUID const &retInterface, void **ppResource) { IMPLEMENT_STUB(); return E_NOTIMPL; } // // ID3D11Device2 // template void D3D11DeviceX::GetImmediateContext2(gfx::ID3D11DeviceContext2 **ppImmediateContext) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::CreateDeferredContext2(uint32_t Flags, gfx::ID3D11DeviceContext2 **ppDeferredContext) { IMPLEMENT_STUB(); return E_NOTIMPL; } template void D3D11DeviceX::GetResourceTiling(gfx::ID3D11Resource *pTiledResource, uint32_t *pNumTilesForEntireResource, D3D11_PACKED_MIP_DESC *pPackedMipDesc, D3D11_TILE_SHAPE *pStandardTileShapeForNonPackedMips, uint32_t *pNumSubresourceTilings, uint32_t FirstSubresourceTilingToGet, D3D11_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::CheckMultisampleQualityLevels1(DXGI_FORMAT Format, uint32_t SampleCount, uint32_t Flags, uint32_t *pNumQualityLevels) { IMPLEMENT_STUB(); return E_NOTIMPL; } // // ID3D11DeviceX // template void D3D11DeviceX::GetImmediateContextX(gfx::ID3D11DeviceContextX **ppImmediateContextX) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::CreateCounterSet(gfx::D3D11X_COUNTER_SET_DESC const *pCounterSetDesc, gfx::ID3D11CounterSetX **ppCounterSet) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateCounterSample(gfx::ID3D11CounterSampleX **ppCounterSample) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::SetDriverHint(UINT Feature, UINT Value) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateDmaEngineContext(gfx::D3D11_DMA_ENGINE_CONTEXT_DESC const *pDmaEngineContextDesc, gfx::ID3D11DMAEngineContextX **ppDmaDeviceContext) { *ppDmaDeviceContext = new D3D11DMAEngineContextX(); return S_OK; } template BOOL D3D11DeviceX::IsFencePending(UINT64 Fence) { IMPLEMENT_STUB(); return {}; } template BOOL D3D11DeviceX::IsResourcePending(gfx::ID3D11Resource *pResource) { IMPLEMENT_STUB(); return {}; } template HRESULT D3D11DeviceX::CreatePlacementBuffer(D3D11_BUFFER_DESC const *pDesc, void *pVirtualAddress, gfx::ID3D11Buffer **ppBuffer) { 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) { 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) { 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 if (pVirtualAddress && pDesc2.SampleDesc.Count > 1) { 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) { 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) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::CreateComputeContextX(gfx::D3D11_COMPUTE_CONTEXT_DESC const *pComputeContextDesc, gfx::ID3D11ComputeContextX **ppComputeContext) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateSamplerStateX(gfx::D3D11X_SAMPLER_DESC const *pSamplerDesc, gfx::ID3D11SamplerState **ppSamplerState) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreateDeferredContextX(UINT Flags, gfx::ID3D11DeviceContextX **ppDeferredContext) { IMPLEMENT_STUB(); return E_NOTIMPL; } template void D3D11DeviceX::GarbageCollect(UINT Flags) { } template HRESULT D3D11DeviceX::CreateDepthStencilStateX(D3D11_DEPTH_STENCIL_DESC const *pDepthStencilStateDesc, gfx::ID3D11DepthStencilState **ppDepthStencilState) { IMPLEMENT_STUB(); return E_NOTIMPL; } template HRESULT D3D11DeviceX::CreatePlacementRenderableTexture2D(D3D11_TEXTURE2D_DESC const *pDesc, UINT TileModeIndex, UINT Pitch, gfx::D3D11X_RENDERABLE_TEXTURE_ADDRESSES const *pAddresses, gfx::ID3D11Texture2D **ppTexture2D) { IMPLEMENT_STUB(); return E_NOTIMPL; } template void D3D11DeviceX::GetDriverStatistics(UINT StructSize, gfx::D3D11X_DRIVER_STATISTICS *pStatistics) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::GetDescriptorSize(gfx::D3D11X_DESCRIPTOR_TYPE DescriptorType) { IMPLEMENT_STUB(); return E_NOTIMPL; } template void D3D11DeviceX::ComposeShaderResourceView(gfx::D3D11X_DESCRIPTOR_RESOURCE const *pDescriptorResource, gfx::D3D11X_RESOURCE_VIEW_DESC const *pViewDesc, gfx::D3D11X_DESCRIPTOR_SHADER_RESOURCE_VIEW *pDescriptorSrv) { IMPLEMENT_STUB(); } template void D3D11DeviceX::ComposeUnorderedAccessView(gfx::D3D11X_DESCRIPTOR_RESOURCE const *pDescriptorResource, gfx::D3D11X_RESOURCE_VIEW_DESC const *pViewDesc, gfx::D3D11X_DESCRIPTOR_UNORDERED_ACCESS_VIEW *pDescriptorUav) { IMPLEMENT_STUB(); } template void D3D11DeviceX::ComposeConstantBufferView(gfx::D3D11X_DESCRIPTOR_RESOURCE const *pDescriptorResource, gfx::D3D11X_RESOURCE_VIEW_DESC const *pViewDesc, gfx::D3D11X_DESCRIPTOR_CONSTANT_BUFFER_VIEW *pDescriptorCb) { IMPLEMENT_STUB(); } template void D3D11DeviceX::ComposeVertexBufferView(gfx::D3D11X_DESCRIPTOR_RESOURCE const *pDescriptorResource, gfx::D3D11X_RESOURCE_VIEW_DESC const *pViewDesc, gfx::D3D11X_DESCRIPTOR_VERTEX_BUFFER_VIEW *pDescriptorVb) { IMPLEMENT_STUB(); } template void D3D11DeviceX::ComposeSamplerState(gfx::D3D11X_SAMPLER_STATE_DESC const *pSamplerDesc, gfx::D3D11X_DESCRIPTOR_SAMPLER_STATE *pDescriptorSamplerState) { IMPLEMENT_STUB(); } template void D3D11DeviceX::PlaceSwapChainView(gfx::ID3D11Resource *pSwapChainBuffer, gfx::ID3D11View *pView) { IMPLEMENT_STUB(); } template void D3D11DeviceX::SetDebugFlags(UINT Flags) { IMPLEMENT_STUB(); } template uint32_t D3D11DeviceX::GetDebugFlags() { IMPLEMENT_STUB(); return {}; } template void D3D11DeviceX::SetHangCallbacks(gfx::D3D11XHANGBEGINCALLBACK pBeginCallback, gfx::D3D11XHANGPRINTCALLBACK pPrintCallback, gfx::D3D11XHANGDUMPCALLBACK pDumpCallback) { IMPLEMENT_STUB(); } template void D3D11DeviceX::ReportGpuHang(UINT Flags) { IMPLEMENT_STUB(); } template HRESULT D3D11DeviceX::SetGpuMemoryPriority(UINT Priority) { IMPLEMENT_STUB(); return E_NOTIMPL; } template void D3D11DeviceX::GetGpuHardwareConfiguration(gfx::D3D11X_GPU_HARDWARE_CONFIGURATION *pGpuHardwareConfiguration) { IMPLEMENT_STUB(); } #undef ABI_INTERFACE #define ABI_INTERFACE(ABI) D3D11DeviceX D3D11_DECLARE_ABI_TEMPLATES();