|
|
|
@ -1,4 +1,4 @@ |
|
|
|
// Copyright (c) 2023 Nico de Poel
|
|
|
|
// Copyright (c) 2024 Nico de Poel
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
@ -93,17 +93,45 @@ namespace FidelityFX |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal class Fsr3UpscalerPrepareInputsPass : Fsr3UpscalerPass |
|
|
|
{ |
|
|
|
public Fsr3UpscalerPrepareInputsPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
: base(contextDescription, resources, constants) |
|
|
|
{ |
|
|
|
InitComputeShader("prepare_inputs_pass", contextDescription.Shaders.prepareInputsPass); |
|
|
|
} |
|
|
|
|
|
|
|
internal class Fsr3UpscalerComputeLuminancePyramidPass : Fsr3UpscalerPass |
|
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
{ |
|
|
|
ref var color = ref dispatchParams.Color; |
|
|
|
ref var depth = ref dispatchParams.Depth; |
|
|
|
ref var motionVectors = ref dispatchParams.MotionVectors; |
|
|
|
ref var exposure = ref dispatchParams.Exposure; |
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); |
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); |
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal class Fsr3UpscalerLumaPyramidPass : Fsr3UpscalerPass |
|
|
|
{ |
|
|
|
private readonly ComputeBuffer _spdConstants; |
|
|
|
|
|
|
|
public Fsr3UpscalerComputeLuminancePyramidPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) |
|
|
|
public Fsr3UpscalerLumaPyramidPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) |
|
|
|
: base(contextDescription, resources, constants) |
|
|
|
{ |
|
|
|
_spdConstants = spdConstants; |
|
|
|
|
|
|
|
InitComputeShader("compute_luminance_pyramid_pass", contextDescription.Shaders.lumaPyramidPass); |
|
|
|
InitComputeShader("luma_pyramid_pass", contextDescription.Shaders.lumaPyramidPass); |
|
|
|
} |
|
|
|
|
|
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
@ -123,40 +151,44 @@ namespace FidelityFX |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal class Fsr3UpscalerReconstructPreviousDepthPass : Fsr3UpscalerPass |
|
|
|
internal class Fsr3UpscalerShadingChangePyramidPass : Fsr3UpscalerPass |
|
|
|
{ |
|
|
|
public Fsr3UpscalerReconstructPreviousDepthPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
private readonly ComputeBuffer _spdConstants; |
|
|
|
|
|
|
|
public Fsr3UpscalerShadingChangePyramidPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants, ComputeBuffer spdConstants) |
|
|
|
: base(contextDescription, resources, constants) |
|
|
|
{ |
|
|
|
InitComputeShader("reconstruct_previous_depth_pass", contextDescription.Shaders.prepareInputsPass); |
|
|
|
_spdConstants = spdConstants; |
|
|
|
|
|
|
|
InitComputeShader("shading_change_pyramid_pass", contextDescription.Shaders.shadingChangePyramidPass); |
|
|
|
} |
|
|
|
|
|
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
{ |
|
|
|
ref var color = ref dispatchParams.Color; |
|
|
|
ref var depth = ref dispatchParams.Depth; |
|
|
|
ref var motionVectors = ref dispatchParams.MotionVectors; |
|
|
|
ref var exposure = ref dispatchParams.Exposure; |
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputColor, color.RenderTarget, color.MipLevel, color.SubElement); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputDepth, depth.RenderTarget, depth.MipLevel, depth.SubElement); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputMotionVectors, motionVectors.RenderTarget, motionVectors.MipLevel, motionVectors.SubElement); |
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); |
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr3ShaderIDs.CbFsr3Upscaler, Constants, 0, Marshal.SizeOf<Fsr3Upscaler.UpscalerConstants>()); |
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal class Fsr3UpscalerDepthClipPass : Fsr3UpscalerPass |
|
|
|
internal class Fsr3UpscalerShadingChangePass : Fsr3UpscalerPass |
|
|
|
{ |
|
|
|
public Fsr3UpscalerShadingChangePass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
: base(contextDescription, resources, constants) |
|
|
|
{ |
|
|
|
InitComputeShader("shading_change_pass", contextDescription.Shaders.shadingChangePass); |
|
|
|
} |
|
|
|
|
|
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal class Fsr3UpscalerPrepareReactivityPass : Fsr3UpscalerPass |
|
|
|
{ |
|
|
|
public Fsr3UpscalerDepthClipPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
public Fsr3UpscalerPrepareReactivityPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
: base(contextDescription, resources, constants) |
|
|
|
{ |
|
|
|
InitComputeShader("depth_clip_pass", contextDescription.Shaders.prepareReactivityPass); |
|
|
|
InitComputeShader("prepare_reactivity_pass", contextDescription.Shaders.prepareReactivityPass); |
|
|
|
} |
|
|
|
|
|
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
@ -186,12 +218,12 @@ namespace FidelityFX |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal class Fsr3UpscalerLockPass : Fsr3UpscalerPass |
|
|
|
internal class Fsr3UpscalerLumaInstabilityPass : Fsr3UpscalerPass |
|
|
|
{ |
|
|
|
public Fsr3UpscalerLockPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
public Fsr3UpscalerLumaInstabilityPass(Fsr3Upscaler.ContextDescription contextDescription, Fsr3UpscalerResources resources, ComputeBuffer constants) |
|
|
|
: base(contextDescription, resources, constants) |
|
|
|
{ |
|
|
|
InitComputeShader("lock_pass", contextDescription.Shaders.lumaInstabilityPass); |
|
|
|
InitComputeShader("luma_instability_pass", contextDescription.Shaders.lumaInstabilityPass); |
|
|
|
} |
|
|
|
|
|
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr3Upscaler.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
|
|