diff --git a/Engine/Build/Commit.gitdeps.xml b/Engine/Build/Commit.gitdeps.xml index 693200a81c55..1dd29713db8b 100644 --- a/Engine/Build/Commit.gitdeps.xml +++ b/Engine/Build/Commit.gitdeps.xml @@ -96817,7 +96817,7 @@ - + @@ -117244,6 +117244,7 @@ + @@ -118324,7 +118325,6 @@ - @@ -178283,6 +178283,7 @@ + @@ -181329,7 +181330,6 @@ - diff --git a/Engine/Source/Runtime/D3D12RHI/Private/D3D12Adapter.cpp b/Engine/Source/Runtime/D3D12RHI/Private/D3D12Adapter.cpp index 55c0a747f557..f48a0c6772d7 100644 --- a/Engine/Source/Runtime/D3D12RHI/Private/D3D12Adapter.cpp +++ b/Engine/Source/Runtime/D3D12RHI/Private/D3D12Adapter.cpp @@ -571,6 +571,14 @@ void FD3D12Adapter::CreateRootDevice(bool bWithDebug) if (!bDeviceCreated) { +#if INTEL_EXTENSIONS + // Enable Intel App Discovery + if (IsRHIDeviceIntel() && bAllowVendorDevice) + { + EnableIntelAppDiscovery(GRHIDeviceId); + } +#endif + // Creating the Direct3D device. VERIFYD3D12RESULT(D3D12CreateDevice( GetAdapter(), diff --git a/Engine/Source/Runtime/D3D12RHI/Private/D3D12IntelExtensions.h b/Engine/Source/Runtime/D3D12RHI/Private/D3D12IntelExtensions.h index 8e7de8352ee8..692ac6116787 100644 --- a/Engine/Source/Runtime/D3D12RHI/Private/D3D12IntelExtensions.h +++ b/Engine/Source/Runtime/D3D12RHI/Private/D3D12IntelExtensions.h @@ -16,7 +16,10 @@ struct INTCExtensionContext; struct INTCExtensionInfo; - void DestroyIntelExtensionsContext(INTCExtensionContext* IntelExtensionContext); INTCExtensionContext* CreateIntelExtensionsContext(ID3D12Device* Device, INTCExtensionInfo& INTCExtensionInfo); + void DestroyIntelExtensionsContext(INTCExtensionContext* IntelExtensionContext); + bool EnableIntelAtomic64Support(INTCExtensionContext* IntelExtensionContext, INTCExtensionInfo& INTCExtensionInfo); + void EnableIntelAppDiscovery(uint32 DeviceId); + #endif //INTEL_EXTENSIONS diff --git a/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp b/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp index 5b9291b18392..9986537c1882 100644 --- a/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp +++ b/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp @@ -207,21 +207,25 @@ static D3D_SHADER_MODEL FindHighestShaderModel(ID3D12Device* Device) } #if INTEL_EXTENSIONS -void DestroyIntelExtensionsContext(INTCExtensionContext* IntelExtensionContext) +static INTCExtensionAppInfo1 GetIntelApplicationInfo() { - if (IntelExtensionContext) - { - const HRESULT hr = INTC_DestroyDeviceExtensionContext(&IntelExtensionContext); + // CVar set to disable workload registration + static TConsoleVariableData* CVarDisableEngineAndAppRegistration = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DisableEngineAndAppRegistration")); - if (hr == S_OK) - { - UE_LOG(LogD3D12RHI, Log, TEXT("Intel Extensions Framework unloaded")); - } - else if (hr == E_INVALIDARG) - { - UE_LOG(LogD3D12RHI, Log, TEXT("Intel Extensions Framework error when unloading")); - } + INTCExtensionAppInfo1 AppInfo{}; + + if (!(CVarDisableEngineAndAppRegistration && CVarDisableEngineAndAppRegistration->GetValueOnAnyThread() != 0)) + { + AppInfo.pApplicationName = FApp::HasProjectName() ? FApp::GetProjectName() : TEXT(""); + //AppInfo.ApplicationVersion = FApp::GetBuildVersion(); // Currently no support for version + + AppInfo.pEngineName = TEXT("Unreal Engine"); + AppInfo.EngineVersion.major = FEngineVersion::Current().GetMajor(); + AppInfo.EngineVersion.minor = FEngineVersion::Current().GetMinor(); + AppInfo.EngineVersion.patch = FEngineVersion::Current().GetPatch(); } + + return AppInfo; } INTCExtensionContext* CreateIntelExtensionsContext(ID3D12Device* Device, INTCExtensionInfo& INTCExtensionInfo) @@ -261,11 +265,8 @@ INTCExtensionContext* CreateIntelExtensionsContext(ID3D12Device* Device, INTCExt } INTCExtensionContext* IntelExtensionContext = nullptr; - INTCExtensionAppInfo1 AppInfo{}; - AppInfo.pEngineName = TEXT("Unreal Engine"); - AppInfo.EngineVersion.major = FEngineVersion::Current().GetMajor(); - AppInfo.EngineVersion.minor = FEngineVersion::Current().GetMinor(); - AppInfo.EngineVersion.patch = FEngineVersion::Current().GetPatch(); + // Fill in registration information for this workload (App name and Engine name) + INTCExtensionAppInfo1 AppInfo = GetIntelApplicationInfo(); const HRESULT hr = INTC_D3D12_CreateDeviceExtensionContext1(Device, &IntelExtensionContext, &INTCExtensionInfo, &AppInfo); @@ -303,6 +304,22 @@ INTCExtensionContext* CreateIntelExtensionsContext(ID3D12Device* Device, INTCExt return IntelExtensionContext; } +void DestroyIntelExtensionsContext(INTCExtensionContext* IntelExtensionContext) +{ + if (IntelExtensionContext) + { + const HRESULT hr = INTC_DestroyDeviceExtensionContext(&IntelExtensionContext); + if (SUCCEEDED(hr)) + { + UE_LOG(LogD3D12RHI, Log, TEXT("Intel Extensions Framework unloaded")); + } + else + { + UE_LOG(LogD3D12RHI, Log, TEXT("Intel Extensions Framework error when unloading: 0x%08x"), hr); + } + } +} + bool EnableIntelAtomic64Support(INTCExtensionContext* IntelExtensionContext, INTCExtensionInfo& INTCExtensionInfo) { if (IntelExtensionContext) @@ -341,7 +358,22 @@ bool EnableIntelAtomic64Support(INTCExtensionContext* IntelExtensionContext, INT return GDX12INTCAtomicUInt64Emulation; } -#endif + +void EnableIntelAppDiscovery(uint32 DeviceId) +{ + if (FAILED(INTC_LoadExtensionsLibrary(false, (uint32)EGpuVendorId::Intel, DeviceId))) + { + UE_LOG(LogD3D12RHI, Log, TEXT("Failed to load Intel Extensions Library (App Discovery)")); + return; + } + + // Fill in registration information for this workload (App name and Engine name) + INTCExtensionAppInfo1 AppInfo = GetIntelApplicationInfo(); + + // Intel Application Discovery - registering UE5 application info in the driver + INTC_D3D12_SetApplicationInfo(&AppInfo); +} +#endif // INTEL_EXTENSIONS static bool CheckDeviceForEmulatedAtomic64Support(IDXGIAdapter* Adapter, ID3D12Device* Device) { @@ -827,6 +859,7 @@ void FD3D12DynamicRHIModule::FindAdapter() } const EGpuVendorId PreferredVendor = RHIGetPreferredAdapterVendor(); + const bool bAllowVendorDevice = !FParse::Param(FCommandLine::Get(), TEXT("novendordevice")); // Enumerate the DXGIFactory's adapters. for (uint32 AdapterIndex = 0; FD3D12AdapterDesc::EnumAdapters(AdapterIndex, GpuPreference, DXGIFactory4, DXGIFactory6, TempAdapter.GetInitReference()) != DXGI_ERROR_NOT_FOUND; ++AdapterIndex) @@ -835,14 +868,24 @@ void FD3D12DynamicRHIModule::FindAdapter() if (TempAdapter) { FD3D12DeviceBasicInfo DeviceInfo; + // Log some information about the available D3D12 adapters. + DXGI_ADAPTER_DESC AdapterDesc{}; + VERIFYD3D12RESULT(TempAdapter->GetDesc(&AdapterDesc)); + +#if INTEL_EXTENSIONS + // Enable Intel App Discovery + if (AdapterDesc.VendorId == (uint32)EGpuVendorId::Intel && bAllowVendorDevice) + { + // Intel's App information needs to be registered *before* device creation, so we have to do it here at the last second. + // Even though it takes the device ID as an argument, we've been told by Intel that this isn't going to cause problems if multiple Intel devices are detected. + EnableIntelAppDiscovery(AdapterDesc.DeviceId); + } +#endif + if (SafeTestD3D12CreateDevice(TempAdapter, MinRequiredFeatureLevel, DeviceInfo)) { check(DeviceInfo.NumDeviceNodes > 0); - // Log some information about the available D3D12 adapters. - DXGI_ADAPTER_DESC AdapterDesc{}; - VERIFYD3D12RESULT(TempAdapter->GetDesc(&AdapterDesc)); - const uint32 OutputCount = CountAdapterOutputs(TempAdapter); UE_LOG(LogD3D12RHI, Log, diff --git a/Engine/Source/ThirdParty/Intel/ExtensionsFramework/IntelExtensionsFramework.Build.cs b/Engine/Source/ThirdParty/Intel/ExtensionsFramework/IntelExtensionsFramework.Build.cs index db3e9ff46c80..69ab04aaced2 100644 --- a/Engine/Source/ThirdParty/Intel/ExtensionsFramework/IntelExtensionsFramework.Build.cs +++ b/Engine/Source/ThirdParty/Intel/ExtensionsFramework/IntelExtensionsFramework.Build.cs @@ -20,10 +20,6 @@ public class IntelExtensionsFramework : ModuleRules PublicSystemIncludePaths.Add(IncludeDir); PublicAdditionalLibraries.Add(Path.Combine(LibrariesDir, "igdext64.lib")); - - PublicSystemLibraries.Add("shlwapi.lib"); - PublicSystemLibraries.Add("setupapi.lib"); - PublicSystemLibraries.Add("cfgmgr32.lib"); } else { diff --git a/Engine/Source/ThirdParty/Intel/ExtensionsFramework/igdext.h b/Engine/Source/ThirdParty/Intel/ExtensionsFramework/igdext.h index c7c79337488f..9ba283bc0265 100644 --- a/Engine/Source/ThirdParty/Intel/ExtensionsFramework/igdext.h +++ b/Engine/Source/ThirdParty/Intel/ExtensionsFramework/igdext.h @@ -151,6 +151,7 @@ extern "C" { HLSL = 5, // ?? CL_BIN = 6, // CL FE/BE generated Binary ESIMD_SPIRV = 7, // input is ESIMD SPIRV + ZEBIN_ELF = 8 // ZEBIN_ELF format shader binary }; ////////////////////////////////////////////////////////////////////////// @@ -265,7 +266,8 @@ extern "C" { // List of Intel D3D12 Features enum INTC_D3D12_FEATURES { - INTC_D3D12_FEATURE_D3D12_OPTIONS1 + INTC_D3D12_FEATURE_D3D12_OPTIONS1, + INTC_D3D12_FEATURE_D3D12_OPTIONS2 }; struct INTC_D3D12_FEATURE_DATA_D3D12_OPTIONS1 @@ -275,6 +277,13 @@ extern "C" { BOOL EmulatedTyped64bitAtomics; }; + struct INTC_D3D12_FEATURE_DATA_D3D12_OPTIONS2 + { + BOOL SIMD16Required; + BOOL LSCSupported; + BOOL LegacyTranslationRequired; + }; + #endif //INTC_IGDEXT_D3D12 ////////////////////////////////////////////////////////////////////////// @@ -710,6 +719,42 @@ extern "C" { void* pFeatureSupportData, UINT FeatureSupportDataSize ); + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// @brief Sets a custom shader cache file path + /// @param pExtensionContext A pointer to the extension context associated with the current Device. + /// @param filePath path to a pre-built shader cache file + /// @returns HRESULT S_OK if it was successful + HRESULT INTC_D3D12_AddShaderCachePath( + INTCExtensionContext* pExtensionContext, + const wchar_t* filePath ); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// @brief Removes a custom shader cache file path + /// @param pExtensionContext A pointer to the extension context associated with the current Device. + /// @param filePath path to a pre-built shader cache file + /// @returns HRESULT S_OK if it was successful + HRESULT INTC_D3D12_RemoveShaderCachePath( + INTCExtensionContext* pExtensionContext, + const wchar_t* filePath ); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// @brief Register Application Info in the graphics driver + /// @details + /// This function needs to be invoked before a D3D12 device has been created. + /// Prior to this function call, INTC_LoadExtensionsLibrary() has to be invoked with Vendor and Device ID information, to load the appropriate UMD dll. + /// @param pExtensionAppInfo Application Info to be passed to the driver + /// @returns HRESULT S_OK if it was successful + HRESULT INTC_D3D12_SetApplicationInfo( + INTCExtensionAppInfo1* pExtensionAppInfo ); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// @brief Internal use - Helps to retrieve previously set the Application Info + /// @param pExtensionAppInfo Application Info returned the extension DLL + /// @returns HRESULT S_OK if it was successful + HRESULT INTC_D3D12_GetApplicationInfo( + INTCExtensionAppInfo1* pExtensionAppInfo ); + + #endif //INTC_IGDEXT_D3D12 ////////////////////////////////////////////////////////////////////////// @@ -728,14 +773,18 @@ extern "C" { /// @param useCurrentProcessDir If true, this function attempts to load the Extensions Framework DLL /// from the current process directory. If false, this fnction attempts to load the Extensions /// Framework DLL from the installed graphics driver directory. + /// @param VendorID The Vendor ID of the graphics adapter + /// @param DeviceID The Device ID of the graphics adapter /// NOTE: This function determines the path to the installed Intel graphics driver directory using /// Intel's D3D11 or D3D12 user mode driver DLL, which is expected to already be loaded by the - /// current process. If this function is called before one of those DLLs is loaded (i.e. before - /// the application has called CreateDevice(...)), then it will fail and return E_FAIL. + /// current process. If this function is called before one of those DLLs is loaded, then the + /// Vendor and Device ID need to be supplied. /// @returns HRESULT Returns S_OK if it was successful. //////////////////////////////////////////////////////////////////////////////////////// HRESULT INTC_LoadExtensionsLibrary( - bool useCurrentProcessDir = false ); + bool useCurrentProcessDir = false, + size_t VendorID = 0, + size_t DeviceID = 0 ); //////////////////////////////////////////////////////////////////////////////////////// /// @brief Extension library loading helper function.