Add AGS lib to D3D11 for efficient UAV writes overlaps on AMD GPUs
This commit is contained in:
@@ -18,6 +18,10 @@
|
|||||||
#include <ThirdParty/nvapi/nvapi.h>
|
#include <ThirdParty/nvapi/nvapi.h>
|
||||||
extern bool EnableNvapi;
|
extern bool EnableNvapi;
|
||||||
#endif
|
#endif
|
||||||
|
#if COMPILE_WITH_AGS
|
||||||
|
#include <ThirdParty/AGS/amd_ags.h>
|
||||||
|
extern AGSContext* AgsContext;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DX11_CLEAR_SR_ON_STAGE_DISABLE 0
|
#define DX11_CLEAR_SR_ON_STAGE_DISABLE 0
|
||||||
|
|
||||||
@@ -920,7 +924,16 @@ void GPUContextDX11::OverlapUA(bool end)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// TODO: add support for AMD extensions to overlap UAV writes (agsDriverExtensionsDX11_BeginUAVOverlap/agsDriverExtensionsDX11_EndUAVOverlap)
|
#if COMPILE_WITH_AGS
|
||||||
|
if (AgsContext)
|
||||||
|
{
|
||||||
|
if (end)
|
||||||
|
agsDriverExtensionsDX11_EndUAVOverlap(AgsContext, _context);
|
||||||
|
else
|
||||||
|
agsDriverExtensionsDX11_BeginUAVOverlap(AgsContext, _context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// TODO: add support for Intel extensions to overlap UAV writes (INTC_D3D11_BeginUAVOverlap/INTC_D3D11_EndUAVOverlap)
|
// TODO: add support for Intel extensions to overlap UAV writes (INTC_D3D11_BeginUAVOverlap/INTC_D3D11_EndUAVOverlap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
#include <ThirdParty/nvapi/nvapi.h>
|
#include <ThirdParty/nvapi/nvapi.h>
|
||||||
bool EnableNvapi = false;
|
bool EnableNvapi = false;
|
||||||
#endif
|
#endif
|
||||||
|
#if COMPILE_WITH_AGS
|
||||||
|
#include <ThirdParty/AGS/amd_ags.h>
|
||||||
|
AGSContext* AgsContext = nullptr;
|
||||||
|
#endif
|
||||||
#if !USE_EDITOR && PLATFORM_WINDOWS
|
#if !USE_EDITOR && PLATFORM_WINDOWS
|
||||||
#include "Engine/Core/Config/PlatformSettings.h"
|
#include "Engine/Core/Config/PlatformSettings.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -436,7 +440,7 @@ bool GPUDeviceDX11::Init()
|
|||||||
NvAPI_ShortString buildBranch("");
|
NvAPI_ShortString buildBranch("");
|
||||||
if (NvAPI_SYS_GetDriverAndBranchVersion(&driverVersion, buildBranch) == NVAPI_OK)
|
if (NvAPI_SYS_GetDriverAndBranchVersion(&driverVersion, buildBranch) == NVAPI_OK)
|
||||||
{
|
{
|
||||||
LOG(Info, "NvApi driver version: {}, {}", driverVersion, StringAsUTF16<>(buildBranch).Get());
|
LOG(Info, "NvApi driver version: {}, {}", driverVersion, TO_UTF16(buildBranch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -447,6 +451,44 @@ bool GPUDeviceDX11::Init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if COMPILE_WITH_AGS
|
||||||
|
if (_adapter->IsAMD())
|
||||||
|
{
|
||||||
|
AGSGPUInfo gpuInfo = {};
|
||||||
|
AGSConfiguration config = {};
|
||||||
|
AGSReturnCode returnCode = agsInitialize(AGS_CURRENT_VERSION, &config, &AgsContext, &gpuInfo);
|
||||||
|
if (returnCode == AGS_SUCCESS)
|
||||||
|
{
|
||||||
|
LOG(Info, "AMD driver version: {}, Radeon Software Version {}", TO_UTF16(gpuInfo.driverVersion), TO_UTF16(gpuInfo.radeonSoftwareVersion));
|
||||||
|
for (int32 i = 0; i < gpuInfo.numDevices; i++)
|
||||||
|
{
|
||||||
|
AGSDeviceInfo& deviceInfo = gpuInfo.devices[i];
|
||||||
|
const Char* asicFamily[] =
|
||||||
|
{
|
||||||
|
TEXT("Unknown"),
|
||||||
|
TEXT("Pre GCN"),
|
||||||
|
TEXT("GCN Gen1"),
|
||||||
|
TEXT("GCN Gen2"),
|
||||||
|
TEXT("GCN Gen3"),
|
||||||
|
TEXT("GCN Gen4"),
|
||||||
|
TEXT("Vega"),
|
||||||
|
TEXT("RDNA"),
|
||||||
|
TEXT("RDNA2"),
|
||||||
|
TEXT("RDNA3"),
|
||||||
|
TEXT("RDNA4"),
|
||||||
|
};
|
||||||
|
LOG(Info, " > GPU {}: {} ({})", i, TO_UTF16(deviceInfo.adapterString), asicFamily[deviceInfo.asicFamily <= AGSAsicFamily_RDNA4 ? deviceInfo.asicFamily : 0]);
|
||||||
|
LOG(Info, " CUs: {}, WGPs: {}, ROPs: {}", deviceInfo.numCUs, deviceInfo.numWGPs, deviceInfo.numROPs);
|
||||||
|
LOG(Info, " Core clock: {} MHz, Memory clock: {} MHz, {:.2f} Tflops", deviceInfo.coreClock, deviceInfo.memoryClock, deviceInfo.teraFlops);
|
||||||
|
LOG(Info, " Local memory: {} MB ({:.2f} GB/s), Shared memory: {} MB", (int32)(deviceInfo.localMemoryInBytes / (1024ull * 1024ull)), (float)deviceInfo.memoryBandwidth / 1024.0f, (int32)(deviceInfo.sharedMemoryInBytes / (1024ull * 1024ull)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(Warning, "agsInitialize failed with result {} ({})", (int32)returnCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get DXGI adapter
|
// Get DXGI adapter
|
||||||
ComPtr<IDXGIAdapter> adapter;
|
ComPtr<IDXGIAdapter> adapter;
|
||||||
|
|||||||
@@ -16,5 +16,7 @@ public class GraphicsDeviceDX11 : GraphicsDeviceBaseModule
|
|||||||
options.OutputFiles.Add("d3d11.lib");
|
options.OutputFiles.Add("d3d11.lib");
|
||||||
if (nvapi.Use(options))
|
if (nvapi.Use(options))
|
||||||
options.PrivateDependencies.Add("nvapi");
|
options.PrivateDependencies.Add("nvapi");
|
||||||
|
if (AGS.Use(options))
|
||||||
|
options.PrivateDependencies.Add("AGS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TO_UTF16(str) StringAsUTF16<>(str).Get()
|
||||||
|
|
||||||
template<typename CharType = Char>
|
template<typename CharType = Char>
|
||||||
class StringAsTerminated
|
class StringAsTerminated
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user