Browse Source

Initial update of dispatch parameters and enums for FSR 3.1

fsr3.1
Nico de Poel 2 years ago
parent
commit
b03217eebd
  1. 13
      Assets/Scripts/Core/Fsr3Upscaler.cs
  2. 12
      Assets/Scripts/Core/Fsr3UpscalerContext.cs
  3. 8
      Assets/Scripts/Core/Fsr3UpscalerResources.cs
  4. 2
      Assets/Scripts/Fsr3UpscalerImageEffect.cs

13
Assets/Scripts/Core/Fsr3Upscaler.cs

@ -49,7 +49,7 @@ namespace FidelityFX
var contextDescription = new ContextDescription
{
Flags = flags,
DisplaySize = displaySize,
MaxUpscaleSize = displaySize,
MaxRenderSize = maxRenderSize,
Shaders = shaders,
};
@ -158,6 +158,12 @@ namespace FidelityFX
EnableDebugChecking = 1 << 8,
}
[Flags]
public enum DispatchFlags
{
DrawDebugView = 1 << 0,
}
/// <summary>
/// A structure encapsulating the parameters required to initialize FidelityFX Super Resolution 3 upscaling.
/// </summary>
@ -165,7 +171,7 @@ namespace FidelityFX
{
public InitializationFlags Flags;
public Vector2Int MaxRenderSize;
public Vector2Int DisplaySize;
public Vector2Int MaxUpscaleSize;
public Fsr3UpscalerShaders Shaders;
}
@ -184,7 +190,7 @@ namespace FidelityFX
public Vector2 JitterOffset;
public Vector2 MotionVectorScale;
public Vector2Int RenderSize;
public Vector2Int InputResourceSize;
public Vector2Int UpscaleSize;
public bool EnableSharpening;
public float Sharpness;
public float FrameTimeDelta; // in seconds
@ -194,6 +200,7 @@ namespace FidelityFX
public float CameraFar;
public float CameraFovAngleVertical;
public float ViewSpaceToMetersFactor;
public DispatchFlags Flags;
// EXPERIMENTAL reactive mask generation parameters
public bool EnableAutoReactive;

12
Assets/Scripts/Core/Fsr3UpscalerContext.cs

@ -88,7 +88,7 @@ namespace FidelityFX
_firstExecution = true;
_resourceFrameIndex = 0;
UpscalerConsts.displaySize = _contextDescription.DisplaySize;
UpscalerConsts.displaySize = _contextDescription.MaxUpscaleSize;
_resources.Create(_contextDescription);
CreatePasses();
@ -192,8 +192,8 @@ namespace FidelityFX
const int threadGroupWorkRegionDim = 8;
int dispatchSrcX = (UpscalerConsts.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchSrcY = (UpscalerConsts.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchDstX = (_contextDescription.DisplaySize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchDstY = (_contextDescription.DisplaySize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchDstX = (_contextDescription.MaxUpscaleSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
int dispatchDstY = (_contextDescription.MaxUpscaleSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
// Clear reconstructed depth for max depth store
if (resetAccumulation)
@ -313,7 +313,7 @@ namespace FidelityFX
constants.jitterOffset = dispatchParams.JitterOffset;
constants.renderSize = dispatchParams.RenderSize;
constants.maxRenderSize = _contextDescription.MaxRenderSize;
constants.inputColorResourceDimensions = dispatchParams.InputResourceSize;
constants.inputColorResourceDimensions = dispatchParams.UpscaleSize;
// Compute the horizontal FOV for the shader from the vertical one
float aspectRatio = (float)dispatchParams.RenderSize.x / dispatchParams.RenderSize.y;
@ -325,7 +325,7 @@ namespace FidelityFX
constants.deviceToViewDepth = SetupDeviceDepthToViewSpaceDepthParams(dispatchParams);
// To be updated if resource is larger than the actual image size
constants.downscaleFactor = new Vector2((float)constants.renderSize.x / _contextDescription.DisplaySize.x, (float)constants.renderSize.y / _contextDescription.DisplaySize.y);
constants.downscaleFactor = new Vector2((float)constants.renderSize.x / _contextDescription.MaxUpscaleSize.x, (float)constants.renderSize.y / _contextDescription.MaxUpscaleSize.y);
constants.previousFramePreExposure = constants.preExposure;
constants.preExposure = (dispatchParams.PreExposure != 0) ? dispatchParams.PreExposure : 1.0f;
@ -340,7 +340,7 @@ namespace FidelityFX
_previousJitterOffset = constants.jitterOffset;
}
int jitterPhaseCount = Fsr3Upscaler.GetJitterPhaseCount(dispatchParams.RenderSize.x, _contextDescription.DisplaySize.x);
int jitterPhaseCount = Fsr3Upscaler.GetJitterPhaseCount(dispatchParams.RenderSize.x, _contextDescription.MaxUpscaleSize.x);
if (resetAccumulation || constants.jitterPhaseCount == 0)
{
constants.jitterPhaseCount = jitterPhaseCount;

8
Assets/Scripts/Core/Fsr3UpscalerResources.cs

@ -106,13 +106,13 @@ namespace FidelityFX
CreateDoubleBufferedResource(DilatedMotionVectors, "FSR3UPSCALER_InternalDilatedVelocity", contextDescription.MaxRenderSize, GraphicsFormat.R16G16_SFloat);
// Resources FSR3UPSCALER_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(LockStatus, "FSR3UPSCALER_LockStatus", contextDescription.DisplaySize, GraphicsFormat.R16G16_SFloat);
CreateDoubleBufferedResource(LockStatus, "FSR3UPSCALER_LockStatus", contextDescription.MaxUpscaleSize, GraphicsFormat.R16G16_SFloat);
// Resources FSR3UPSCALER_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(InternalUpscaled, "FSR3UPSCALER_InternalUpscaled", contextDescription.DisplaySize, GraphicsFormat.R16G16B16A16_SFloat);
CreateDoubleBufferedResource(InternalUpscaled, "FSR3UPSCALER_InternalUpscaled", contextDescription.MaxUpscaleSize, GraphicsFormat.R16G16B16A16_SFloat);
// Resources FSR3UPSCALER_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource(LumaHistory, "FSR3UPSCALER_LumaHistory", contextDescription.DisplaySize, GraphicsFormat.R8G8B8A8_UNorm);
CreateDoubleBufferedResource(LumaHistory, "FSR3UPSCALER_LumaHistory", contextDescription.MaxUpscaleSize, GraphicsFormat.R8G8B8A8_UNorm);
}
public void CreateTcrAutogenResources(Fsr3Upscaler.ContextDescription contextDescription)
@ -136,7 +136,7 @@ namespace FidelityFX
// These do not need to persist between frames, but they do need to be available between passes
public static void CreateAliasableResources(CommandBuffer commandBuffer, Fsr3Upscaler.ContextDescription contextDescription, Fsr3Upscaler.DispatchDescription dispatchParams)
{
Vector2Int displaySize = contextDescription.DisplaySize;
Vector2Int displaySize = contextDescription.MaxUpscaleSize;
Vector2Int maxRenderSize = contextDescription.MaxRenderSize;
// FSR3UPSCALER_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE

2
Assets/Scripts/Fsr3UpscalerImageEffect.cs

@ -391,7 +391,7 @@ namespace FidelityFX
_renderCamera.ResetProjectionMatrix();
// Update the input resource descriptions
_dispatchDescription.InputResourceSize = new Vector2Int(src.width, src.height);
_dispatchDescription.UpscaleSize = new Vector2Int(src.width, src.height);
_dispatchCommandBuffer.Clear();

Loading…
Cancel
Save