Browse Source

Added some extra safety checks

master
Nico de Poel 11 months ago
parent
commit
bfc905ff75
  1. 19
      FSR3UnityPlugin.cpp

19
FSR3UnityPlugin.cpp

@ -173,16 +173,15 @@ static uint32_t AllocateFeatureSlot()
static void FreeFeatureSlot(uint32_t featureSlot)
{
// Prevent duplicate free slots
auto& slots = s_FeatureSlots._Get_container();
if (std::find(slots.begin(), slots.end(), featureSlot) != slots.end())
return;
s_FeatureSlots.push(featureSlot);
memset(&s_Features[featureSlot], 0, sizeof(FSR3Feature));
}
static PFN_vkVoidFunction GetVulkanDeviceProcAddr(VkDevice device, const char* pName)
{
UnityVulkanInstance instance = s_GraphicsVulkan->Instance();
return instance.getInstanceProcAddr(instance.instance, pName);
}
static bool LoadFidelityFXLibrary(_In_ LPCWSTR lpLibFileName)
{
s_ffxModule = LoadLibrary(lpLibFileName);
@ -229,6 +228,12 @@ static bool LoadFidelityFXLibrary(_In_ LPCWSTR lpLibFileName)
return true;
}
static PFN_vkVoidFunction GetVulkanDeviceProcAddr(VkDevice device, const char* pName)
{
UnityVulkanInstance instance = s_GraphicsVulkan->Instance();
return instance.getInstanceProcAddr(instance.instance, pName);
}
extern "C" bool UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_InitApi()
{
std::lock_guard<std::mutex> lock(s_FeatureMutex);
@ -276,6 +281,8 @@ extern "C" bool UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_InitApi()
static void DestroyFeature(uint32_t featureSlot)
{
auto& feature = s_Features[featureSlot];
if (feature.upscalingContext == nullptr && !feature.isValid)
return;
if (s_GraphicsD3D12 != nullptr)
{

Loading…
Cancel
Save