From e0ea272c0d9cbb82510b8e7b7f36a24a331210f0 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 3 Aug 2022 21:14:49 +0200 Subject: [PATCH] [d3d11] Move misc methods to D3D11CommonContext --- src/d3d11/d3d11_context.cpp | 171 -------------------------- src/d3d11/d3d11_context.h | 72 ----------- src/d3d11/d3d11_context_common.cpp | 185 +++++++++++++++++++++++++++++ src/d3d11/d3d11_context_common.h | 72 +++++++++++ 4 files changed, 257 insertions(+), 243 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index f9ff67cc6..415516d73 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -30,177 +30,6 @@ namespace dxvk { } - void STDMETHODCALLTYPE D3D11DeviceContext::CopyTiles( - ID3D11Resource* pTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, - const D3D11_TILE_REGION_SIZE* pTileRegionSize, - ID3D11Buffer* pBuffer, - UINT64 BufferStartOffsetInBytes, - UINT Flags) { - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::CopyTiles: Not implemented"); - } - - - HRESULT STDMETHODCALLTYPE D3D11DeviceContext::CopyTileMappings( - ID3D11Resource* pDestTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, - ID3D11Resource* pSourceTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, - const D3D11_TILE_REGION_SIZE* pTileRegionSize, - UINT Flags) { - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::CopyTileMappings: Not implemented"); - - return DXGI_ERROR_INVALID_CALL; - } - - - HRESULT STDMETHODCALLTYPE D3D11DeviceContext::ResizeTilePool( - ID3D11Buffer* pTilePool, - UINT64 NewSizeInBytes) { - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::ResizeTilePool: Not implemented"); - - return DXGI_ERROR_INVALID_CALL; - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::TiledResourceBarrier( - ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, - ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) { - - } - - - HRESULT STDMETHODCALLTYPE D3D11DeviceContext::UpdateTileMappings( - ID3D11Resource* pTiledResource, - UINT NumTiledResourceRegions, - const D3D11_TILED_RESOURCE_COORDINATE* pTiledResourceRegionStartCoordinates, - const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes, - ID3D11Buffer* pTilePool, - UINT NumRanges, - const UINT* pRangeFlags, - const UINT* pTilePoolStartOffsets, - const UINT* pRangeTileCounts, - UINT Flags) { - bool s_errorShown = false; - - if (std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::UpdateTileMappings: Not implemented"); - - return DXGI_ERROR_INVALID_CALL; - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::UpdateTiles( - ID3D11Resource* pDestTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, - const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, - const void* pSourceTileData, - UINT Flags) { - bool s_errorShown = false; - - if (std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::UpdateTiles: Not implemented"); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::SetResourceMinLOD( - ID3D11Resource* pResource, - FLOAT MinLOD) { - bool s_errorShown = false; - - if (std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::SetResourceMinLOD: Not implemented"); - } - - - FLOAT STDMETHODCALLTYPE D3D11DeviceContext::GetResourceMinLOD(ID3D11Resource* pResource) { - bool s_errorShown = false; - - if (std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::GetResourceMinLOD: Not implemented"); - - return 0.0f; - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::SetMarkerInt( - LPCWSTR pLabel, - INT Data) { - // Not implemented in the backend, ignore - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::BeginEventInt( - LPCWSTR pLabel, - INT Data) { - // Not implemented in the backend, ignore - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::EndEvent() { - // Not implemented in the backend, ignore - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::GetHardwareProtectionState( - BOOL* pHwProtectionEnable) { - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::GetHardwareProtectionState: Not implemented"); - - if (pHwProtectionEnable) - *pHwProtectionEnable = FALSE; - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::SetHardwareProtectionState( - BOOL HwProtectionEnable) { - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::SetHardwareProtectionState: Not implemented"); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::TransitionSurfaceLayout( - IDXGIVkInteropSurface* pSurface, - const VkImageSubresourceRange* pSubresources, - VkImageLayout OldLayout, - VkImageLayout NewLayout) { - D3D10DeviceLock lock = LockContext(); - - // Get the underlying D3D11 resource - Com resource; - - pSurface->QueryInterface(__uuidof(ID3D11Resource), - reinterpret_cast(&resource)); - - // Get the texture from that resource - D3D11CommonTexture* texture = GetCommonTexture(resource.ptr()); - - EmitCs([ - cImage = texture->GetImage(), - cSubresources = *pSubresources, - cOldLayout = OldLayout, - cNewLayout = NewLayout - ] (DxvkContext* ctx) { - ctx->transformImage( - cImage, cSubresources, - cOldLayout, cNewLayout); - }); - } - - VkClearValue D3D11DeviceContext::ConvertColorValue( const FLOAT Color[4], const DxvkFormatInfo* pFormatInfo) { diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 34c613684..82597415b 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -34,78 +34,6 @@ namespace dxvk { DxvkCsChunkFlags CsFlags); ~D3D11DeviceContext(); - void STDMETHODCALLTYPE CopyTiles( - ID3D11Resource* pTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, - const D3D11_TILE_REGION_SIZE* pTileRegionSize, - ID3D11Buffer* pBuffer, - UINT64 BufferStartOffsetInBytes, - UINT Flags); - - HRESULT STDMETHODCALLTYPE CopyTileMappings( - ID3D11Resource* pDestTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, - ID3D11Resource* pSourceTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, - const D3D11_TILE_REGION_SIZE* pTileRegionSize, - UINT Flags); - - HRESULT STDMETHODCALLTYPE ResizeTilePool( - ID3D11Buffer* pTilePool, - UINT64 NewSizeInBytes); - - void STDMETHODCALLTYPE TiledResourceBarrier( - ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, - ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier); - - HRESULT STDMETHODCALLTYPE UpdateTileMappings( - ID3D11Resource* pTiledResource, - UINT NumTiledResourceRegions, - const D3D11_TILED_RESOURCE_COORDINATE* pTiledResourceRegionStartCoordinates, - const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes, - ID3D11Buffer* pTilePool, - UINT NumRanges, - const UINT* pRangeFlags, - const UINT* pTilePoolStartOffsets, - const UINT* pRangeTileCounts, - UINT Flags); - - void STDMETHODCALLTYPE UpdateTiles( - ID3D11Resource* pDestTiledResource, - const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, - const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, - const void* pSourceTileData, - UINT Flags); - - void STDMETHODCALLTYPE SetResourceMinLOD( - ID3D11Resource* pResource, - FLOAT MinLOD); - - FLOAT STDMETHODCALLTYPE GetResourceMinLOD( - ID3D11Resource* pResource); - - void STDMETHODCALLTYPE SetMarkerInt( - LPCWSTR pLabel, - INT Data); - - void STDMETHODCALLTYPE BeginEventInt( - LPCWSTR pLabel, - INT Data); - - void STDMETHODCALLTYPE EndEvent(); - - void STDMETHODCALLTYPE GetHardwareProtectionState( - BOOL* pHwProtectionEnable); - - void STDMETHODCALLTYPE SetHardwareProtectionState( - BOOL HwProtectionEnable); - - void STDMETHODCALLTYPE TransitionSurfaceLayout( - IDXGIVkInteropSurface* pSurface, - const VkImageSubresourceRange* pSubresources, - VkImageLayout OldLayout, - VkImageLayout NewLayout); - D3D10DeviceLock LockContext() { return m_multithread.AcquireLock(); } diff --git a/src/d3d11/d3d11_context_common.cpp b/src/d3d11/d3d11_context_common.cpp index 572731b8d..23859d19f 100644 --- a/src/d3d11/d3d11_context_common.cpp +++ b/src/d3d11/d3d11_context_common.cpp @@ -2788,12 +2788,197 @@ namespace dxvk { } + template + void STDMETHODCALLTYPE D3D11CommonContext::SetResourceMinLOD( + ID3D11Resource* pResource, + FLOAT MinLOD) { + bool s_errorShown = false; + + if (std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::SetResourceMinLOD: Not implemented"); + } + + + template + FLOAT STDMETHODCALLTYPE D3D11CommonContext::GetResourceMinLOD(ID3D11Resource* pResource) { + bool s_errorShown = false; + + if (std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::GetResourceMinLOD: Not implemented"); + + return 0.0f; + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::CopyTiles( + ID3D11Resource* pTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pTileRegionSize, + ID3D11Buffer* pBuffer, + UINT64 BufferStartOffsetInBytes, + UINT Flags) { + static bool s_errorShown = false; + + if (!std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::CopyTiles: Not implemented"); + } + + + template + HRESULT STDMETHODCALLTYPE D3D11CommonContext::CopyTileMappings( + ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, + ID3D11Resource* pSourceTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pTileRegionSize, + UINT Flags) { + static bool s_errorShown = false; + + if (!std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::CopyTileMappings: Not implemented"); + + return DXGI_ERROR_INVALID_CALL; + } + + + template + HRESULT STDMETHODCALLTYPE D3D11CommonContext::ResizeTilePool( + ID3D11Buffer* pTilePool, + UINT64 NewSizeInBytes) { + static bool s_errorShown = false; + + if (!std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::ResizeTilePool: Not implemented"); + + return DXGI_ERROR_INVALID_CALL; + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::TiledResourceBarrier( + ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, + ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) { + + } + + + template + HRESULT STDMETHODCALLTYPE D3D11CommonContext::UpdateTileMappings( + ID3D11Resource* pTiledResource, + UINT NumTiledResourceRegions, + const D3D11_TILED_RESOURCE_COORDINATE* pTiledResourceRegionStartCoordinates, + const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes, + ID3D11Buffer* pTilePool, + UINT NumRanges, + const UINT* pRangeFlags, + const UINT* pTilePoolStartOffsets, + const UINT* pRangeTileCounts, + UINT Flags) { + bool s_errorShown = false; + + if (std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::UpdateTileMappings: Not implemented"); + + return DXGI_ERROR_INVALID_CALL; + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::UpdateTiles( + ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, + const void* pSourceTileData, + UINT Flags) { + bool s_errorShown = false; + + if (std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::UpdateTiles: Not implemented"); + } + + template BOOL STDMETHODCALLTYPE D3D11CommonContext::IsAnnotationEnabled() { return m_annotation.GetStatus(); } + template + void STDMETHODCALLTYPE D3D11CommonContext::SetMarkerInt( + LPCWSTR pLabel, + INT Data) { + // Not implemented in the backend, ignore + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::BeginEventInt( + LPCWSTR pLabel, + INT Data) { + // Not implemented in the backend, ignore + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::EndEvent() { + // Not implemented in the backend, ignore + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::GetHardwareProtectionState( + BOOL* pHwProtectionEnable) { + static bool s_errorShown = false; + + if (!std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::GetHardwareProtectionState: Not implemented"); + + if (pHwProtectionEnable) + *pHwProtectionEnable = FALSE; + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::SetHardwareProtectionState( + BOOL HwProtectionEnable) { + static bool s_errorShown = false; + + if (!std::exchange(s_errorShown, true)) + Logger::err("D3D11DeviceContext::SetHardwareProtectionState: Not implemented"); + } + + + template + void STDMETHODCALLTYPE D3D11CommonContext::TransitionSurfaceLayout( + IDXGIVkInteropSurface* pSurface, + const VkImageSubresourceRange* pSubresources, + VkImageLayout OldLayout, + VkImageLayout NewLayout) { + D3D10DeviceLock lock = LockContext(); + + // Get the underlying D3D11 resource + Com resource; + + pSurface->QueryInterface(__uuidof(ID3D11Resource), + reinterpret_cast(&resource)); + + // Get the texture from that resource + D3D11CommonTexture* texture = GetCommonTexture(resource.ptr()); + + EmitCs([ + cImage = texture->GetImage(), + cSubresources = *pSubresources, + cOldLayout = OldLayout, + cNewLayout = NewLayout + ] (DxvkContext* ctx) { + ctx->transformImage( + cImage, cSubresources, + cOldLayout, cNewLayout); + }); + } + + template void D3D11CommonContext::ApplyInputLayout() { auto inputLayout = m_state.ia.inputLayout.prvRef(); diff --git a/src/d3d11/d3d11_context_common.h b/src/d3d11/d3d11_context_common.h index 12059a8c5..b3fc49bbe 100644 --- a/src/d3d11/d3d11_context_common.h +++ b/src/d3d11/d3d11_context_common.h @@ -664,8 +664,80 @@ namespace dxvk { ID3D11Predicate** ppPredicate, BOOL* pPredicateValue); + void STDMETHODCALLTYPE SetResourceMinLOD( + ID3D11Resource* pResource, + FLOAT MinLOD); + + FLOAT STDMETHODCALLTYPE GetResourceMinLOD( + ID3D11Resource* pResource); + + void STDMETHODCALLTYPE CopyTiles( + ID3D11Resource* pTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pTileRegionSize, + ID3D11Buffer* pBuffer, + UINT64 BufferStartOffsetInBytes, + UINT Flags); + + HRESULT STDMETHODCALLTYPE CopyTileMappings( + ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestRegionStartCoordinate, + ID3D11Resource* pSourceTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pSourceRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pTileRegionSize, + UINT Flags); + + HRESULT STDMETHODCALLTYPE ResizeTilePool( + ID3D11Buffer* pTilePool, + UINT64 NewSizeInBytes); + + void STDMETHODCALLTYPE TiledResourceBarrier( + ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, + ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier); + + HRESULT STDMETHODCALLTYPE UpdateTileMappings( + ID3D11Resource* pTiledResource, + UINT NumTiledResourceRegions, + const D3D11_TILED_RESOURCE_COORDINATE* pTiledResourceRegionStartCoordinates, + const D3D11_TILE_REGION_SIZE* pTiledResourceRegionSizes, + ID3D11Buffer* pTilePool, + UINT NumRanges, + const UINT* pRangeFlags, + const UINT* pTilePoolStartOffsets, + const UINT* pRangeTileCounts, + UINT Flags); + + void STDMETHODCALLTYPE UpdateTiles( + ID3D11Resource* pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE* pDestTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE* pDestTileRegionSize, + const void* pSourceTileData, + UINT Flags); + BOOL STDMETHODCALLTYPE IsAnnotationEnabled(); + void STDMETHODCALLTYPE SetMarkerInt( + LPCWSTR pLabel, + INT Data); + + void STDMETHODCALLTYPE BeginEventInt( + LPCWSTR pLabel, + INT Data); + + void STDMETHODCALLTYPE EndEvent(); + + void STDMETHODCALLTYPE GetHardwareProtectionState( + BOOL* pHwProtectionEnable); + + void STDMETHODCALLTYPE SetHardwareProtectionState( + BOOL HwProtectionEnable); + + void STDMETHODCALLTYPE TransitionSurfaceLayout( + IDXGIVkInteropSurface* pSurface, + const VkImageSubresourceRange* pSubresources, + VkImageLayout OldLayout, + VkImageLayout NewLayout); + protected: D3D11DeviceContextExt m_contextExt;