From e4684baf209d02795941fa3594647e501cfc6267 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 12 Nov 2014 23:28:19 +0000 Subject: [PATCH] Handle fetching DX11.2 interfaces, but just as passthru. Closes #106 * Until I have a sample that uses it, I'm not going to attempt to serialise the tiled resource API. It has a lot of other potential knock-ons too (e.g. to initial contents). --- renderdoc/driver/d3d11/d3d11_common.h | 4 +- renderdoc/driver/d3d11/d3d11_context.cpp | 36 ++--- renderdoc/driver/d3d11/d3d11_context.h | 70 ++++++++- .../driver/d3d11/d3d11_context2_wrap.cpp | 137 ++++++++++++++++++ renderdoc/driver/d3d11/d3d11_context_wrap.cpp | 20 +-- renderdoc/driver/d3d11/d3d11_device.cpp | 21 ++- renderdoc/driver/d3d11/d3d11_device.h | 39 ++++- renderdoc/driver/d3d11/d3d11_device1_wrap.cpp | 65 +++++++++ renderdoc/renderdoc.vcxproj | 1 + renderdoc/renderdoc.vcxproj.filters | 3 + 10 files changed, 345 insertions(+), 51 deletions(-) create mode 100644 renderdoc/driver/d3d11/d3d11_context2_wrap.cpp diff --git a/renderdoc/driver/d3d11/d3d11_common.h b/renderdoc/driver/d3d11/d3d11_common.h index ec6d7776a..ab2c81748 100644 --- a/renderdoc/driver/d3d11/d3d11_common.h +++ b/renderdoc/driver/d3d11/d3d11_common.h @@ -294,9 +294,9 @@ enum D3D11ChunkType SET_PS_CBUFFERS1, SET_CS_CBUFFERS1, - BEGIN_EVENT, + PUSH_EVENT, SET_MARKER, - END_EVENT, + POP_EVENT, DEBUG_MESSAGES, diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index adc46eaea..8f9e40192 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -41,7 +41,7 @@ WRAPPED_POOL_INST(WrappedID3D11CommandList); INT STDMETHODCALLTYPE WrappedID3DUserDefinedAnnotation::BeginEvent(LPCWSTR Name) { if(m_Context) - return m_Context->BeginEvent(0, Name); + return m_Context->PushEvent(0, Name); return -1; } @@ -49,7 +49,7 @@ INT STDMETHODCALLTYPE WrappedID3DUserDefinedAnnotation::BeginEvent(LPCWSTR Name) INT STDMETHODCALLTYPE WrappedID3DUserDefinedAnnotation::EndEvent() { if(m_Context) - return m_Context->EndEvent(); + return m_Context->PopEvent(); return -1; } @@ -103,6 +103,9 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device* real m_pRealContext1 = NULL; m_pRealContext->QueryInterface(__uuidof(ID3D11DeviceContext1), (void **)&m_pRealContext1); + + m_pRealContext2 = NULL; + m_pRealContext->QueryInterface(__uuidof(ID3D11DeviceContext2), (void **)&m_pRealContext2); #endif #if defined(RELEASE) @@ -191,6 +194,7 @@ WrappedID3D11DeviceContext::~WrappedID3D11DeviceContext() #if defined(INCLUDE_D3D_11_1) SAFE_RELEASE(m_pRealContext1); + SAFE_RELEASE(m_pRealContext2); #endif SAFE_DELETE(m_CurrentPipelineState); @@ -874,14 +878,14 @@ void WrappedID3D11DeviceContext::ProcessChunk(uint64_t offset, D3D11ChunkType ch break; #endif - case BEGIN_EVENT: - context->Serialise_BeginEvent(0, L""); + case PUSH_EVENT: + context->Serialise_PushEvent(0, L""); break; case SET_MARKER: context->Serialise_SetMarker(0, L""); break; - case END_EVENT: - context->Serialise_EndEvent(); + case POP_EVENT: + context->Serialise_PopEvent(); break; case CONTEXT_CAPTURE_FOOTER: @@ -924,12 +928,12 @@ void WrappedID3D11DeviceContext::ProcessChunk(uint64_t offset, D3D11ChunkType ch { // no push/pop necessary } - else if(context->m_State == READING && chunk == BEGIN_EVENT) + else if(context->m_State == READING && chunk == PUSH_EVENT) { // push down the drawcallstack to the latest drawcall context->m_DrawcallStack.push_back(&context->m_DrawcallStack.back()->children.back()); } - else if(context->m_State == READING && chunk == END_EVENT) + else if(context->m_State == READING && chunk == POP_EVENT) { // refuse to pop off further than the root drawcall (mismatched begin/end events e.g.) RDCASSERT(context->m_DrawcallStack.size() > 1); @@ -1311,9 +1315,6 @@ void WrappedID3D11DeviceContext::ClearMaps() HRESULT STDMETHODCALLTYPE WrappedID3D11DeviceContext::QueryInterface( REFIID riid, void **ppvObject ) { - //DEFINE_GUID(IID_ID3D11DeviceContext2,0x420d5b32,0xb90c,0x4da4,0xbe,0xf0,0x35,0x9f,0x6a,0x24,0xa8,0x3a); - static const GUID ID3D11DeviceContext2_uuid = { 0x420d5b32, 0xb90c, 0x4da4, { 0xbe, 0xf0, 0x35, 0x9f, 0x6a, 0x24, 0xa8, 0x3a } }; - if(riid == __uuidof(ID3D11DeviceContext)) { *ppvObject = (ID3D11DeviceContext *)this; @@ -1333,6 +1334,13 @@ HRESULT STDMETHODCALLTYPE WrappedID3D11DeviceContext::QueryInterface( REFIID rii AddRef(); return S_OK; } + else if(riid == __uuidof(ID3D11DeviceContext2)) + { + *ppvObject = (ID3D11DeviceContext2 *)this; + AddRef(); + RDCWARN("Trying to get ID3D11Device2. DX11.2 tiled resources are not supported at this time."); + return S_OK; + } else if(riid == __uuidof(ID3DUserDefinedAnnotation)) { *ppvObject = (ID3DUserDefinedAnnotation *)&m_UserAnnotation; @@ -1340,12 +1348,6 @@ HRESULT STDMETHODCALLTYPE WrappedID3D11DeviceContext::QueryInterface( REFIID rii return S_OK; } #endif - else if(riid == ID3D11DeviceContext2_uuid) - { - RDCWARN("Trying to get ID3D11DeviceContext2. DX11.2 not supported at this time."); - *ppvObject = NULL; - return E_NOINTERFACE; - } else { string guid = ToStr::Get(riid); diff --git a/renderdoc/driver/d3d11/d3d11_context.h b/renderdoc/driver/d3d11/d3d11_context.h index 49a6418a4..4bb2d0da8 100644 --- a/renderdoc/driver/d3d11/d3d11_context.h +++ b/renderdoc/driver/d3d11/d3d11_context.h @@ -28,8 +28,11 @@ #include "core/core.h" #include "api/replay/renderdoc_replay.h" +#include "d3d11_common.h" + #if defined(INCLUDE_D3D_11_1) #include +#include #endif #include "d3d11_manager.h" @@ -127,12 +130,13 @@ struct DrawcallTreeNode } }; -class WrappedID3D11DeviceContext : public RefCounter, #if defined(INCLUDE_D3D_11_1) - public ID3D11DeviceContext1 +#define D3DCONTEXTPARENT ID3D11DeviceContext2 #else - public ID3D11DeviceContext +#define D3DCONTEXTPARENT ID3D11DeviceContext #endif + +class WrappedID3D11DeviceContext : public RefCounter, public D3DCONTEXTPARENT { private: friend class WrappedID3D11DeviceContext; @@ -174,6 +178,8 @@ private: #if defined(INCLUDE_D3D_11_1) ID3D11DeviceContext1* m_pRealContext1; bool m_SetCBuffer1; + + ID3D11DeviceContext2* m_pRealContext2; #endif set m_DeferredRecords; @@ -236,8 +242,8 @@ private: //////////////////////////////////////////////////////////////// // implement InterceptorSystem privately, since it is not thread safe (like all other context functions) IMPLEMENT_FUNCTION_SERIALISED(void, SetMarker(uint32_t col, const wchar_t *name)); - IMPLEMENT_FUNCTION_SERIALISED(int, BeginEvent(uint32_t col, const wchar_t *name)); - IMPLEMENT_FUNCTION_SERIALISED(int, EndEvent()); + IMPLEMENT_FUNCTION_SERIALISED(int, PushEvent(uint32_t col, const wchar_t *name)); + IMPLEMENT_FUNCTION_SERIALISED(int, PopEvent()); public: static const int AllocPoolCount = 2048; static const int AllocPoolMaxByteSize = 3*1024*1024; @@ -963,5 +969,59 @@ public: ID3D11View *pResourceView, const D3D11_RECT *pRects, UINT NumRects)); + + ////////////////////////////// + // implement ID3D11DeviceContext2 + + IMPLEMENT_FUNCTION_SERIALISED(virtual 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)); + + IMPLEMENT_FUNCTION_SERIALISED(virtual 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)); + + IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, CopyTiles( + ID3D11Resource *pTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE *pTileRegionSize, + ID3D11Buffer *pBuffer, + UINT64 BufferStartOffsetInBytes, + UINT Flags)); + + IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, UpdateTiles( + ID3D11Resource *pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE *pDestTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE *pDestTileRegionSize, + const void *pSourceTileData, + UINT Flags)); + + IMPLEMENT_FUNCTION_SERIALISED(virtual HRESULT STDMETHODCALLTYPE, ResizeTilePool( + ID3D11Buffer *pTilePool, + UINT64 NewSizeInBytes)); + + IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, TiledResourceBarrier( + ID3D11DeviceChild *pTiledResourceOrViewAccessBeforeBarrier, + ID3D11DeviceChild *pTiledResourceOrViewAccessAfterBarrier)); + + virtual BOOL STDMETHODCALLTYPE IsAnnotationEnabled(); + + virtual void STDMETHODCALLTYPE SetMarkerInt(LPCWSTR pLabel, INT Data); + + virtual void STDMETHODCALLTYPE BeginEventInt(LPCWSTR pLabel, INT Data); + + virtual void STDMETHODCALLTYPE EndEvent(); #endif }; diff --git a/renderdoc/driver/d3d11/d3d11_context2_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context2_wrap.cpp new file mode 100644 index 000000000..d008fd084 --- /dev/null +++ b/renderdoc/driver/d3d11/d3d11_context2_wrap.cpp @@ -0,0 +1,137 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2014 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + + +#include "d3d11_context.h" + +#if defined(INCLUDE_D3D_11_1) + +HRESULT WrappedID3D11DeviceContext::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) +{ + RDCUNIMPLEMENTED("Tiled resources are not yet supported. Please contact me if you have a working example!"); + + if(m_pRealContext2 == NULL) return E_NOINTERFACE; + + return m_pRealContext2->UpdateTileMappings(pTiledResource, NumTiledResourceRegions, pTiledResourceRegionStartCoordinates, pTiledResourceRegionSizes, + pTilePool, NumRanges, pRangeFlags, pTilePoolStartOffsets, pRangeTileCounts, Flags); +} + +HRESULT WrappedID3D11DeviceContext::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) +{ + RDCUNIMPLEMENTED("Tiled resources are not yet supported. Please contact me if you have a working example!"); + + if(m_pRealContext2 == NULL) return E_NOINTERFACE; + + return m_pRealContext2->CopyTileMappings(pDestTiledResource, pDestRegionStartCoordinate, pSourceTiledResource, + pSourceRegionStartCoordinate, pTileRegionSize, Flags); +} + +void WrappedID3D11DeviceContext::CopyTiles( + ID3D11Resource *pTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE *pTileRegionSize, + ID3D11Buffer *pBuffer, + UINT64 BufferStartOffsetInBytes, + UINT Flags) +{ + RDCUNIMPLEMENTED("Tiled resources are not yet supported. Please contact me if you have a working example!"); + + if(m_pRealContext2 == NULL) return; + + return m_pRealContext2->CopyTiles(pTiledResource, pTileRegionStartCoordinate, pTileRegionSize, pBuffer, BufferStartOffsetInBytes, Flags); +} + +void WrappedID3D11DeviceContext::UpdateTiles( + ID3D11Resource *pDestTiledResource, + const D3D11_TILED_RESOURCE_COORDINATE *pDestTileRegionStartCoordinate, + const D3D11_TILE_REGION_SIZE *pDestTileRegionSize, + const void *pSourceTileData, + UINT Flags) +{ + RDCUNIMPLEMENTED("Tiled resources are not yet supported. Please contact me if you have a working example!"); + + if(m_pRealContext2 == NULL) return; + + return m_pRealContext2->UpdateTiles(pDestTiledResource, pDestTileRegionStartCoordinate, pDestTileRegionSize, pSourceTileData, Flags); +} + +HRESULT WrappedID3D11DeviceContext::ResizeTilePool( + ID3D11Buffer *pTilePool, + UINT64 NewSizeInBytes) +{ + RDCUNIMPLEMENTED("Tiled resources are not yet supported. Please contact me if you have a working example!"); + + if(m_pRealContext2 == NULL) return E_NOINTERFACE; + + return m_pRealContext2->ResizeTilePool(pTilePool, NewSizeInBytes); +} + +void WrappedID3D11DeviceContext::TiledResourceBarrier( + ID3D11DeviceChild *pTiledResourceOrViewAccessBeforeBarrier, + ID3D11DeviceChild *pTiledResourceOrViewAccessAfterBarrier) +{ + RDCUNIMPLEMENTED("Tiled resources are not yet supported. Please contact me if you have a working example!"); + + if(m_pRealContext2 == NULL) return; + + return m_pRealContext2->TiledResourceBarrier(pTiledResourceOrViewAccessBeforeBarrier, pTiledResourceOrViewAccessAfterBarrier); +} + +BOOL WrappedID3D11DeviceContext::IsAnnotationEnabled() +{ + return TRUE; +} + +void WrappedID3D11DeviceContext::SetMarkerInt(LPCWSTR pLabel, INT Data) +{ + SetMarker(0, pLabel); +} + +void WrappedID3D11DeviceContext::BeginEventInt(LPCWSTR pLabel, INT Data) +{ + PushEvent(0, pLabel); +} + +void WrappedID3D11DeviceContext::EndEvent() +{ + PopEvent(); +} + +#endif \ No newline at end of file diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index fa8acedc4..c068e704a 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -54,7 +54,7 @@ bool WrappedID3D11DeviceContext::Serialise_SetMarker(uint32_t col, const wchar_t return true; } -bool WrappedID3D11DeviceContext::Serialise_BeginEvent(uint32_t col, const wchar_t *name_) +bool WrappedID3D11DeviceContext::Serialise_PushEvent(uint32_t col, const wchar_t *name_) { SERIALISE_ELEMENT(uint32_t, colour, col); @@ -74,7 +74,7 @@ bool WrappedID3D11DeviceContext::Serialise_BeginEvent(uint32_t col, const wchar_ return true; } -bool WrappedID3D11DeviceContext::Serialise_EndEvent() +bool WrappedID3D11DeviceContext::Serialise_PopEvent() { if(m_State == READING && !m_CurEvents.empty()) { @@ -100,13 +100,13 @@ void WrappedID3D11DeviceContext::SetMarker(uint32_t col, const wchar_t *name) } } -int WrappedID3D11DeviceContext::BeginEvent(uint32_t col, const wchar_t *name) +int WrappedID3D11DeviceContext::PushEvent(uint32_t col, const wchar_t *name) { if(m_State == WRITING_CAPFRAME) { - SCOPED_SERIALISE_CONTEXT(BEGIN_EVENT); + SCOPED_SERIALISE_CONTEXT(PUSH_EVENT); m_pSerialiser->Serialise("context", m_ResourceID); - Serialise_BeginEvent(col, name); + Serialise_PushEvent(col, name); m_ContextRecord->AddChunk(scope.Get()); } @@ -114,13 +114,13 @@ int WrappedID3D11DeviceContext::BeginEvent(uint32_t col, const wchar_t *name) return m_MarkerIndentLevel++; } -int WrappedID3D11DeviceContext::EndEvent() +int WrappedID3D11DeviceContext::PopEvent() { if(m_State == WRITING_CAPFRAME) { - SCOPED_SERIALISE_CONTEXT(END_EVENT); + SCOPED_SERIALISE_CONTEXT(POP_EVENT); m_pSerialiser->Serialise("context", m_ResourceID); - Serialise_EndEvent(); + Serialise_PopEvent(); m_ContextRecord->AddChunk(scope.Get()); } @@ -202,10 +202,10 @@ void WrappedID3D11DeviceContext::DrainAnnotationQueue() SetMarker(a.m_Col, a.m_Name.c_str()); break; case Annotation::ANNOT_BEGINEVENT: - BeginEvent(a.m_Col, a.m_Name.c_str()); + PushEvent(a.m_Col, a.m_Name.c_str()); break; case Annotation::ANNOT_ENDEVENT: - EndEvent(); + PopEvent(); break; } } diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index f6ec122b9..0becc753f 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -264,6 +264,9 @@ WrappedID3D11Device::WrappedID3D11Device(ID3D11Device* realDevice, D3D11InitPara #if defined(INCLUDE_D3D_11_1) m_pDevice1 = NULL; m_pDevice->QueryInterface(__uuidof(ID3D11Device1), (void **)&m_pDevice1); + + m_pDevice2 = NULL; + m_pDevice->QueryInterface(__uuidof(ID3D11Device2), (void **)&m_pDevice2); #endif m_Replay.SetDevice(this); @@ -417,6 +420,7 @@ WrappedID3D11Device::~WrappedID3D11Device() #if defined(INCLUDE_D3D_11_1) SAFE_RELEASE(m_pDevice1); + SAFE_RELEASE(m_pDevice2); #endif SAFE_RELEASE(m_pImmediateContext); @@ -484,12 +488,6 @@ HRESULT WrappedID3D11Device::QueryInterface(REFIID riid, void **ppvObject) // DEFINE_GUID(IID_IDirect3DDevice9, 0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb); static const GUID IDirect3DDevice9_uuid = { 0xd0223b96, 0xbf7a, 0x43fd, { 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb } }; - //DEFINE_GUID(IID_ID3D11Device2,0x9d06dffa,0xd1e5,0x4d07,0x83,0xa8,0x1b,0xb1,0x23,0xf2,0xf8,0x41); - static const GUID ID3D11Device2_uuid = { 0x9d06dffa, 0xd1e5, 0x4d07, { 0x83, 0xa8, 0x1b, 0xb1, 0x23, 0xf2, 0xf8, 0x41 } }; - - //1fbad429-66ab-41cc-9617-667ac10e4459 - static const GUID ID3D11ShaderTraceFactory_uuid = { 0x1fbad429, 0x66ab, 0x41cc, { 0x96, 0x17, 0x66, 0x7a, 0xc1, 0x0e, 0x44, 0x59 } }; - if(riid == __uuidof(IDXGIDevice)) { m_pDevice->QueryInterface(riid, ppvObject); @@ -549,14 +547,13 @@ HRESULT WrappedID3D11Device::QueryInterface(REFIID riid, void **ppvObject) *ppvObject = (ID3D11Device1 *)this; return S_OK; } -#endif - else if(riid == ID3D11Device2_uuid) + else if(riid == __uuidof(ID3D11Device2)) { - RDCWARN("Trying to get ID3D11Device2. DX11.2 not supported at this time."); - *ppvObject = NULL; - return E_NOINTERFACE; + AddRef(); + *ppvObject = (ID3D11Device2 *)this; + RDCWARN("Trying to get ID3D11Device2. DX11.2 tiled resources are not supported at this time."); + return S_OK; } -#if defined(INCLUDE_D3D_11_1) else if(riid == __uuidof(ID3D11ShaderTraceFactory)) { RDCWARN("Trying to get ID3D11ShaderTraceFactory. Not supported at this time."); diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 2c98a00e0..a35a92949 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -33,8 +33,11 @@ #include "core/core.h" #include "api/replay/renderdoc_replay.h" +#include "d3d11_common.h" + #if defined(INCLUDE_D3D_11_1) #include +#include #endif #include "d3d11_manager.h" @@ -132,13 +135,13 @@ struct DummyID3D11InfoQueue : public ID3D11InfoQueue class WrappedID3D11ClassLinkage; enum CaptureFailReason; -class WrappedID3D11Device : - public IFrameCapturer, #if defined(INCLUDE_D3D_11_1) - public ID3D11Device1 +#define D3DDEVICEPARENT ID3D11Device2 #else - public ID3D11Device +#define D3DDEVICEPARENT ID3D11Device #endif + +class WrappedID3D11Device : public IFrameCapturer, public D3DDEVICEPARENT { private: // since enumeration creates a lot of devices, save @@ -168,6 +171,7 @@ private: ID3D11Device* m_pDevice; #if defined(INCLUDE_D3D_11_1) ID3D11Device1* m_pDevice1; + ID3D11Device2* m_pDevice2; #endif ID3D11InfoQueue *m_pInfoQueue; WrappedID3D11DeviceContext* m_pImmediateContext; @@ -509,10 +513,10 @@ public: IMPLEMENT_FUNCTION_SERIALISED(virtual UINT STDMETHODCALLTYPE, GetExceptionMode( void)); +#if defined(INCLUDE_D3D_11_1) ////////////////////////////// // implement ID3D11Device1 -#if defined(INCLUDE_D3D_11_1) IMPLEMENT_FUNCTION_SERIALISED(virtual void STDMETHODCALLTYPE, GetImmediateContext1(ID3D11DeviceContext1 **ppImmediateContext)); IMPLEMENT_FUNCTION_SERIALISED(virtual HRESULT STDMETHODCALLTYPE, CreateDeferredContext1( @@ -546,5 +550,30 @@ public: DWORD dwDesiredAccess, REFIID returnedInterface, void **ppResource)); + + ////////////////////////////// + // implement ID3D11Device2 + + virtual void STDMETHODCALLTYPE GetImmediateContext2( + ID3D11DeviceContext2 **ppImmediateContext); + + virtual HRESULT STDMETHODCALLTYPE CreateDeferredContext2( + UINT ContextFlags, + ID3D11DeviceContext2 **ppDeferredContext); + + virtual void STDMETHODCALLTYPE GetResourceTiling( + ID3D11Resource *pTiledResource, + UINT *pNumTilesForEntireResource, + D3D11_PACKED_MIP_DESC *pPackedMipDesc, + D3D11_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + UINT *pNumSubresourceTilings, + UINT FirstSubresourceTilingToGet, + D3D11_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + virtual HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels1( + DXGI_FORMAT Format, + UINT SampleCount, + UINT Flags, + UINT *pNumQualityLevels); #endif }; diff --git a/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp index 2934a8273..b9d208ea5 100644 --- a/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device1_wrap.cpp @@ -28,6 +28,9 @@ #include "d3d11_context.h" #if defined(INCLUDE_D3D_11_1) +/////////////////////////////////////////////////////////////////////////////////////////////////////// +// ID3D11Device1 interface + void WrappedID3D11Device::GetImmediateContext1(ID3D11DeviceContext1 **ppImmediateContext) { if(m_pDevice1 == NULL) return; @@ -229,4 +232,66 @@ HRESULT WrappedID3D11Device::OpenSharedResourceByName(LPCWSTR lpName, DWORD dwDe RDCUNIMPLEMENTED("Not wrapping OpenSharedResourceByName"); return m_pDevice1->OpenSharedResourceByName(lpName, dwDesiredAccess, returnedInterface, ppResource); } + +/////////////////////////////////////////////////////////////////////////////////////////////////////// +// ID3D11Device2 interface + +void WrappedID3D11Device::GetImmediateContext2(ID3D11DeviceContext2 **ppImmediateContext) +{ + if(m_pDevice2 == NULL) return; + + if(ppImmediateContext) + { + m_pImmediateContext->AddRef(); + *ppImmediateContext = (ID3D11DeviceContext2 *)m_pImmediateContext; + } +} + +HRESULT WrappedID3D11Device::CreateDeferredContext2(UINT ContextFlags, ID3D11DeviceContext2 **ppDeferredContext) +{ + if(m_pDevice2 == NULL) return E_NOINTERFACE; + if(ppDeferredContext == NULL) return m_pDevice2->CreateDeferredContext2(ContextFlags, NULL); + + ID3D11DeviceContext *defCtx = NULL; + HRESULT ret = CreateDeferredContext(ContextFlags, &defCtx); + + if(SUCCEEDED(ret)) + { + WrappedID3D11DeviceContext *wrapped = (WrappedID3D11DeviceContext *)defCtx; + *ppDeferredContext = (ID3D11DeviceContext2 *)wrapped; + } + else + { + SAFE_RELEASE(defCtx); + } + + return ret; +} + +void WrappedID3D11Device::GetResourceTiling( + ID3D11Resource *pTiledResource, + UINT *pNumTilesForEntireResource, + D3D11_PACKED_MIP_DESC *pPackedMipDesc, + D3D11_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + UINT *pNumSubresourceTilings, + UINT FirstSubresourceTilingToGet, + D3D11_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips) +{ + if(m_pDevice2 == NULL) return; + + m_pDevice2->GetResourceTiling(pTiledResource, pNumTilesForEntireResource, pPackedMipDesc, pStandardTileShapeForNonPackedMips, + pNumSubresourceTilings, FirstSubresourceTilingToGet, pSubresourceTilingsForNonPackedMips); +} + +HRESULT WrappedID3D11Device::CheckMultisampleQualityLevels1( + DXGI_FORMAT Format, + UINT SampleCount, + UINT Flags, + UINT *pNumQualityLevels) +{ + if(m_pDevice2 == NULL) return E_NOINTERFACE; + + return m_pDevice2->CheckMultisampleQualityLevels1(Format, SampleCount, Flags, pNumQualityLevels); +} + #endif \ No newline at end of file diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj index a567b6812..93f5ccabc 100644 --- a/renderdoc/renderdoc.vcxproj +++ b/renderdoc/renderdoc.vcxproj @@ -312,6 +312,7 @@ + diff --git a/renderdoc/renderdoc.vcxproj.filters b/renderdoc/renderdoc.vcxproj.filters index 680065c02..e3f943759 100644 --- a/renderdoc/renderdoc.vcxproj.filters +++ b/renderdoc/renderdoc.vcxproj.filters @@ -521,6 +521,9 @@ Core + + Drivers\D3D11 +