diff --git a/renderdoc/driver/d3d11/d3d11_hooks.cpp b/renderdoc/driver/d3d11/d3d11_hooks.cpp index bd5ce5e74..82adff77d 100644 --- a/renderdoc/driver/d3d11/d3d11_hooks.cpp +++ b/renderdoc/driver/d3d11/d3d11_hooks.cpp @@ -24,6 +24,7 @@ ******************************************************************************/ #include "driver/d3d11/d3d11_device.h" +#include "driver/dx/official/amd/AmdDxExtApi.h" #include "driver/dxgi/dxgi_wrapped.h" #include "hooks/hooks.h" @@ -65,6 +66,14 @@ public: success &= CreateDeviceAndSwapChain.Initialize("D3D11CreateDeviceAndSwapChain", DLL_NAME, D3D11CreateDeviceAndSwapChain_hook); +// these are not required for success, but opportunistic to prevent AMD extensions from +// activating and causing later crashes when not replayed correctly +#if defined(RDC64BIT) + AmdCreate11.Initialize("AmdDxExtCreate11", "atidxx64.dll", AmdCreate11_hook); +#else + AmdCreate11.Initialize("AmdDxExtCreate11", "atidxx32.dll", AmdCreate11_hook); +#endif + if(!success) return false; @@ -98,6 +107,9 @@ private: Hook CreateDeviceAndSwapChain; Hook CreateDevice; + // optional extension hooks + Hook AmdCreate11; + // re-entrancy detection (can happen in rare cases with e.g. fraps) bool m_InsideCreate; @@ -290,6 +302,16 @@ private: return ret; } + + static HRESULT __cdecl AmdCreate11_hook(ID3D11Device *pDevice, IAmdDxExt **ppExt) + { + RDCLOG("Attempt to create AMD extension interface via AmdDxExtCreate11 was blocked."); + + if(ppExt) + *ppExt = NULL; + + return S_FALSE; + } }; D3D11Hook D3D11Hook::d3d11hooks; diff --git a/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj b/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj index aaa749adf..8d086948c 100644 --- a/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj +++ b/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj @@ -206,6 +206,9 @@ + + + @@ -214,7 +217,7 @@ - + @@ -236,4 +239,4 @@ - + \ No newline at end of file diff --git a/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj.filters b/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj.filters index 71f056e06..646b0c643 100644 --- a/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj.filters +++ b/renderdoc/driver/d3d11/renderdoc_d3d11.vcxproj.filters @@ -19,6 +19,9 @@ {069c5202-e850-427b-9353-250795a60436} + + {b92bf274-f255-4c2f-bc1f-dbd1807643a5} + @@ -131,5 +134,14 @@ official + + official\amd + + + official\amd + + + official\amd + - + \ No newline at end of file diff --git a/renderdoc/driver/dx/official/amd/AmdDxExt.h b/renderdoc/driver/dx/official/amd/AmdDxExt.h new file mode 100644 index 000000000..c4a8dc7fa --- /dev/null +++ b/renderdoc/driver/dx/official/amd/AmdDxExt.h @@ -0,0 +1,45 @@ +/* +*************************************************************************************************** +* +* Copyright (c) 2008-2016 Advanced Micro Devices, Inc. All rights reserved. +* +*************************************************************************************************** +*/ +/** +*************************************************************************************************** +* @file amddxext.h +* @brief AMD D3D Exension API include file. +*************************************************************************************************** +*/ +#ifndef _AMDDXEXT_H_ +#define _AMDDXEXT_H_ + + +/// Extended Primitive Topology enumeration +enum AmdDxExtPrimitiveTopology +{ + // D3D10_DDI_PRIMITIVE_TOPOLOGY_* values + AmdDxExtPrimitiveTopology_Undefined = 0, // D3D10 UNDEFINED + AmdDxExtPrimitiveTopology_PointList = 1, // D3D10 POINTLIST + AmdDxExtPrimitiveTopology_LineList = 2, // D3D10 LINELIST + AmdDxExtPrimitiveTopology_LineStrip = 3, // D3D10 LINESTRIP + AmdDxExtPrimitiveTopology_TriangleList = 4, // D3D10 TRIANGLELIST + AmdDxExtPrimitiveTopology_TriangleStrip = 5, // D3D10 TRIANGLESTRIP + // 6 is reserved for legacy triangle fans + AmdDxExtPrimitiveTopology_ExtQuadList = 7, // No D3D10 equivalent + AmdDxExtPrimitiveTopology_ExtPatch = 8, // No D3D10 equivalent + AmdDxExtPrimitiveTopology_ExtScreenRectList = 9, // No D3D10 equivalent + AmdDxExtPrimitiveTopology_LineListAdj = 10, // D3D10 LINELIST_ADJ + AmdDxExtPrimitiveTopology_LineStripAdj = 11, // D3D10 LINESTRIP_ADJ + AmdDxExtPrimitiveTopology_TriangleListAdj = 12, // D3D10 TRIANGLELIST_ADJ + AmdDxExtPrimitiveTopology_TriangleStripAdj = 13, // D3D10 TRIANGLESTRIP_ADJ + AmdDxExtPrimitiveTopology_Max = 14 +}; + + +enum AmdDxExtFeatureToken +{ + AmdDxExtFeature_ScreenRectSupport = 1, // Screen Rect supported - data is BOOL +}; + +#endif // _AMDDXEXT_H_ \ No newline at end of file diff --git a/renderdoc/driver/dx/official/amd/AmdDxExtApi.h b/renderdoc/driver/dx/official/amd/AmdDxExtApi.h new file mode 100644 index 000000000..d1ec9c55c --- /dev/null +++ b/renderdoc/driver/dx/official/amd/AmdDxExtApi.h @@ -0,0 +1,79 @@ +/* +*************************************************************************************************** +* +* Copyright (c) 2008-2016 Advanced Micro Devices, Inc. All rights reserved. +* +*************************************************************************************************** +*/ +/** +*************************************************************************************************** +* @file amddxextapi.h +* @brief AMD D3D Exension API include file. This is the main include file for apps using extensions. +*************************************************************************************************** +*/ +#ifndef _AMDDXEXTAPI_H_ +#define _AMDDXEXTAPI_H_ + +#include "AmdDxExt.h" +#include "AmdDxExtIface.h" + +// forward declaration of main extension interface defined lower in file +class IAmdDxExt; + +// forward declaration for d3d specific interfaces +interface ID3D10Device; +interface ID3D11Device; +interface ID3D10Resource; +interface ID3D11Resource; + +// App must use GetProcAddress, etc. to retrive this exported function +// The associated typedef provides a convenient way to define the function pointer +HRESULT __cdecl AmdDxExtCreate(ID3D10Device* pDevice, IAmdDxExt** ppExt); +typedef HRESULT(__cdecl* PFNAmdDxExtCreate)(ID3D10Device* pDevice, IAmdDxExt** ppExt); + +HRESULT __cdecl AmdDxExtCreate11(ID3D11Device* pDevice, IAmdDxExt** ppExt); +typedef HRESULT(__cdecl* PFNAmdDxExtCreate11)(ID3D11Device* pDevice, IAmdDxExt** ppExt); + +// Extension version information +struct AmdDxExtVersion +{ + unsigned int majorVersion; + unsigned int minorVersion; +}; + +// forward declaration of classes referenced by IAmdDxExt +class IAmdDxExtInterface; + +/** +*************************************************************************************************** +* @brief This class serves as the main extension interface. +* +* AmdDxExtCreate returns a pointer to an instantiation of this interface. +* This object is used to retrieve extension version information +* and to get specific extension interfaces desired. +*************************************************************************************************** +*/ +class IAmdDxExt : public IAmdDxExtInterface +{ +public: + virtual HRESULT GetVersion(AmdDxExtVersion* pExtVer) = 0; + virtual IAmdDxExtInterface* GetExtInterface(unsigned int iface) = 0; + + // General extensions + virtual HRESULT IaSetPrimitiveTopology(unsigned int topology) = 0; + virtual HRESULT IaGetPrimitiveTopology(AmdDxExtPrimitiveTopology* pExtTopology) = 0; + virtual HRESULT SetSingleSampleRead(ID3D10Resource* pResource, + BOOL singleSample) = 0; + virtual HRESULT SetSingleSampleRead11(ID3D11Resource* pResource, + BOOL singleSample) = 0; + + // Supported in version 9.0 and above. + virtual HRESULT QueryFeatureSupport(unsigned int featureToken, + void* pData, unsigned int dataSize) = 0; + +protected: + IAmdDxExt() {}; + virtual ~IAmdDxExt() = 0 {}; +}; + +#endif // _AMDDXEXTAPI_H_ diff --git a/renderdoc/driver/dx/official/amd/AmdDxExtIface.h b/renderdoc/driver/dx/official/amd/AmdDxExtIface.h new file mode 100644 index 000000000..11eb5a818 --- /dev/null +++ b/renderdoc/driver/dx/official/amd/AmdDxExtIface.h @@ -0,0 +1,40 @@ +/* +*************************************************************************************************** +* +* Copyright (c) 2008-2016 Advanced Micro Devices, Inc. All rights reserved. +* +*************************************************************************************************** +*/ +/** +*************************************************************************************************** +* @file amddxextiface.h +* @brief +* AMD D3D Exension API include file. This is a helper include file for extensions. It +* provides a common base class for all extension interfaces +*************************************************************************************************** +*/ +#ifndef _AMDDXEXTIFACE_H_ +#define _AMDDXEXTIFACE_H_ + +#include "AmdDxExt.h" + +/** +*************************************************************************************************** +* @brief Abstract extension interface class +* +* Each extension interface (e.g. tessellation) will derive from this class +*************************************************************************************************** +*/ +class IAmdDxExtInterface +{ +public: + virtual unsigned int AddRef(void) = 0; + virtual unsigned int Release(void) = 0; + +protected: + // Basic constructor + IAmdDxExtInterface() {}; + virtual ~IAmdDxExtInterface() = 0 {}; +}; + +#endif // _AMDDXEXTIFACE_H_ \ No newline at end of file