Add AMD D3D11 extensions headers, and force-disable AMD exts on create

* If the AMD extensions are active and captured, the driver will crash
  on replay in a hard to diagnose way (unless you know what's really
  wrong!)
* With this change, the target application should see the extensions
  failing to create and gracefully fallback to not using them.
This commit is contained in:
baldurk
2016-08-23 17:23:42 +02:00
parent 5826777dfe
commit e7cbc905e6
6 changed files with 204 additions and 3 deletions
+22
View File
@@ -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<PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN> CreateDeviceAndSwapChain;
Hook<PFN_D3D11_CREATE_DEVICE> CreateDevice;
// optional extension hooks
Hook<PFNAmdDxExtCreate11> 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;
@@ -206,6 +206,9 @@
<ClCompile Include="d3d9_hooks.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\dx\official\amd\AmdDxExt.h" />
<ClInclude Include="..\dx\official\amd\AmdDxExtApi.h" />
<ClInclude Include="..\dx\official\amd\AmdDxExtIface.h" />
<ClInclude Include="d3d11_common.h" />
<ClInclude Include="d3d11_context.h" />
<ClInclude Include="d3d11_debug.h" />
@@ -214,7 +217,7 @@
<ClInclude Include="d3d11_renderstate.h" />
<ClInclude Include="d3d11_replay.h" />
<ClInclude Include="d3d11_resources.h" />
<ClInclude Include="..\dx\official\d3d11.h" />
<ClInclude Include="..\dx\official\d3d11.h" />
<ClInclude Include="..\dx\official\d3d11_1.h" />
<ClInclude Include="..\dx\official\d3d11_2.h" />
<ClInclude Include="..\dx\official\d3d11_3.h" />
@@ -236,4 +239,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
@@ -19,6 +19,9 @@
<Filter Include="official">
<UniqueIdentifier>{069c5202-e850-427b-9353-250795a60436}</UniqueIdentifier>
</Filter>
<Filter Include="official\amd">
<UniqueIdentifier>{b92bf274-f255-4c2f-bc1f-dbd1807643a5}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="d3d11_context1_wrap.cpp">
@@ -131,5 +134,14 @@
<ClInclude Include="..\dx\official\d3dcompiler.h">
<Filter>official</Filter>
</ClInclude>
<ClInclude Include="..\dx\official\amd\AmdDxExtIface.h">
<Filter>official\amd</Filter>
</ClInclude>
<ClInclude Include="..\dx\official\amd\AmdDxExt.h">
<Filter>official\amd</Filter>
</ClInclude>
<ClInclude Include="..\dx\official\amd\AmdDxExtApi.h">
<Filter>official\amd</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
@@ -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_
@@ -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_
@@ -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_