Browse Source

Tying up some loose ends:

- Clean up lingering contexts on shutdown
- Set UAV state on output texture. Doesn't make any real difference but it seems to be the correct thing.
- Removed some TODOs
fsr2
Nico de Poel 11 months ago
parent
commit
7444ef9846
  1. 14
      FSR3UnityPlugin.cpp

14
FSR3UnityPlugin.cpp

@ -144,7 +144,16 @@ extern "C" bool UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_InitApi()
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_ShutdownApi() extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_ShutdownApi()
{ {
// TODO: destroy any remaining FSR3Features?
for (auto& feature : s_Features)
{
if (feature.upscalingContext != nullptr)
{
ffx::DestroyContext(feature.upscalingContext);
}
memset(&feature, 0, sizeof(FSR3Feature));
}
s_BackendDesc.device = nullptr; s_BackendDesc.device = nullptr;
} }
@ -242,7 +251,7 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data)
dispatchUpscale.exposure = ffxApiGetResourceDX12(feature.textureTable.exposureTexture, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); dispatchUpscale.exposure = ffxApiGetResourceDX12(feature.textureTable.exposureTexture, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ);
dispatchUpscale.reactive = ffxApiGetResourceDX12(feature.textureTable.reactiveMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); dispatchUpscale.reactive = ffxApiGetResourceDX12(feature.textureTable.reactiveMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ);
dispatchUpscale.transparencyAndComposition = ffxApiGetResourceDX12(feature.textureTable.transparencyMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); dispatchUpscale.transparencyAndComposition = ffxApiGetResourceDX12(feature.textureTable.transparencyMask, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ);
dispatchUpscale.output = ffxApiGetResourceDX12(feature.textureTable.colorOutput, FFX_API_RESOURCE_STATE_PIXEL_COMPUTE_READ); // TODO: shouldn't this be FFX_API_RESOURCE_STATE_UNORDERED_ACCESS?
dispatchUpscale.output = ffxApiGetResourceDX12(feature.textureTable.colorOutput, FFX_API_RESOURCE_STATE_UNORDERED_ACCESS);
dispatchUpscale.jitterOffset.x = params->jitterOffsetX; dispatchUpscale.jitterOffset.x = params->jitterOffsetX;
dispatchUpscale.jitterOffset.y = params->jitterOffsetY; dispatchUpscale.jitterOffset.y = params->jitterOffsetY;
@ -259,7 +268,6 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data)
dispatchUpscale.upscaleSize.height = feature.upscaleSizeHeight; dispatchUpscale.upscaleSize.height = feature.upscaleSizeHeight;
dispatchUpscale.cameraFovAngleVertical = params->cameraFovAngleVertical; dispatchUpscale.cameraFovAngleVertical = params->cameraFovAngleVertical;
// TODO: it's possible that Unity already does this flip, check!
if (feature.flags & FFX_UPSCALE_ENABLE_DEPTH_INVERTED) if (feature.flags & FFX_UPSCALE_ENABLE_DEPTH_INVERTED)
{ {
dispatchUpscale.cameraFar = params->cameraNear; dispatchUpscale.cameraFar = params->cameraNear;

Loading…
Cancel
Save