Browse Source

Made context destruction more consistent and safe against duplicate slot freeing

fsr2
Nico de Poel 11 months ago
parent
commit
3db46ba447
  1. 11
      FSR3UnityPlugin.cpp

11
FSR3UnityPlugin.cpp

@ -144,14 +144,14 @@ extern "C" bool UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_InitApi()
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_ShutdownApi()
{
for (auto& feature : s_Features)
for (uint32_t slot = 0; slot < s_Features.size(); ++slot)
{
auto& feature = s_Features[slot];
if (feature.upscalingContext != nullptr)
{
ffx::DestroyContext(feature.upscalingContext);
FreeFeatureSlot(slot);
}
memset(&feature, 0, sizeof(FSR3Feature));
}
s_BackendDesc.device = nullptr;
@ -226,9 +226,11 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data)
return;
auto& feature = s_Features[featureSlot];
if (feature.upscalingContext != nullptr)
{
ffx::DestroyContext(feature.upscalingContext);
FreeFeatureSlot(featureSlot);
}
break;
}
case BaseEventId + FSR3PluginEvent::eExecute:
@ -316,6 +318,7 @@ static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data)
auto* params = (UnityRenderingExtTextureUpdateParamsV2*)data;
// userData = (featureId & (int) ushort.MaxValue) << 16 | (textureSlot & (int) short.MaxValue) << 1 | (clearTextureTable ? 1 : 0);
uint32_t featureSlot = (params->userData >> 16) & 0xFFFF;
uint32_t textureSlot = (params->userData >> 1) & 0x7FFF;
uint32_t clearTextureTable = params->userData & 0x1;

Loading…
Cancel
Save