|
|
@ -22,54 +22,6 @@ namespace FidelityFX |
|
|
protected ComputeShader ComputeShader; |
|
|
protected ComputeShader ComputeShader; |
|
|
protected int KernelIndex; |
|
|
protected int KernelIndex; |
|
|
|
|
|
|
|
|
// Shader resource views, i.e. read-only bindings
|
|
|
|
|
|
internal static readonly int SrvInputColor = Shader.PropertyToID("r_input_color_jittered"); |
|
|
|
|
|
internal static readonly int SrvOpaqueOnly = Shader.PropertyToID("r_input_opaque_only"); |
|
|
|
|
|
internal static readonly int SrvInputMotionVectors = Shader.PropertyToID("r_input_motion_vectors"); |
|
|
|
|
|
internal static readonly int SrvInputDepth = Shader.PropertyToID("r_input_depth"); |
|
|
|
|
|
internal static readonly int SrvInputExposure = Shader.PropertyToID("r_input_exposure"); |
|
|
|
|
|
internal static readonly int SrvAutoExposure = Shader.PropertyToID("r_auto_exposure"); |
|
|
|
|
|
internal static readonly int SrvReactiveMask = Shader.PropertyToID("r_reactive_mask"); |
|
|
|
|
|
internal static readonly int SrvTransparencyAndCompositionMask = Shader.PropertyToID("r_transparency_and_composition_mask"); |
|
|
|
|
|
internal static readonly int SrvReconstructedPrevNearestDepth = Shader.PropertyToID("r_reconstructed_previous_nearest_depth"); |
|
|
|
|
|
internal static readonly int SrvDilatedMotionVectors = Shader.PropertyToID("r_dilated_motion_vectors"); |
|
|
|
|
|
internal static readonly int SrvPrevDilatedMotionVectors = Shader.PropertyToID("r_previous_dilated_motion_vectors"); |
|
|
|
|
|
internal static readonly int SrvDilatedDepth = Shader.PropertyToID("r_dilatedDepth"); |
|
|
|
|
|
internal static readonly int SrvInternalUpscaled = Shader.PropertyToID("r_internal_upscaled_color"); |
|
|
|
|
|
internal static readonly int SrvLockStatus = Shader.PropertyToID("r_lock_status"); |
|
|
|
|
|
internal static readonly int SrvLockInputLuma = Shader.PropertyToID("r_lock_input_luma"); |
|
|
|
|
|
internal static readonly int SrvPreparedInputColor = Shader.PropertyToID("r_prepared_input_color"); |
|
|
|
|
|
internal static readonly int SrvLumaHistory = Shader.PropertyToID("r_luma_history"); |
|
|
|
|
|
internal static readonly int SrvRcasInput = Shader.PropertyToID("r_rcas_input"); |
|
|
|
|
|
internal static readonly int SrvLanczosLut = Shader.PropertyToID("r_lanczos_lut"); |
|
|
|
|
|
internal static readonly int SrvSceneLuminanceMips = Shader.PropertyToID("r_imgMips"); |
|
|
|
|
|
internal static readonly int SrvUpscaleMaximumBiasLut = Shader.PropertyToID("r_upsample_maximum_bias_lut"); |
|
|
|
|
|
internal static readonly int SrvDilatedReactiveMasks = Shader.PropertyToID("r_dilated_reactive_masks"); |
|
|
|
|
|
|
|
|
|
|
|
// Unordered access views, i.e. random read/write bindings
|
|
|
|
|
|
internal static readonly int UavReconstructedPrevNearestDepth = Shader.PropertyToID("rw_reconstructed_previous_nearest_depth"); |
|
|
|
|
|
internal static readonly int UavDilatedMotionVectors = Shader.PropertyToID("rw_dilated_motion_vectors"); |
|
|
|
|
|
internal static readonly int UavDilatedDepth = Shader.PropertyToID("rw_dilatedDepth"); |
|
|
|
|
|
internal static readonly int UavInternalUpscaled = Shader.PropertyToID("rw_internal_upscaled_color"); |
|
|
|
|
|
internal static readonly int UavLockStatus = Shader.PropertyToID("rw_lock_status"); |
|
|
|
|
|
internal static readonly int UavLockInputLuma = Shader.PropertyToID("rw_lock_input_luma"); |
|
|
|
|
|
internal static readonly int UavNewLocks = Shader.PropertyToID("rw_new_locks"); |
|
|
|
|
|
internal static readonly int UavPreparedInputColor = Shader.PropertyToID("rw_prepared_input_color"); |
|
|
|
|
|
internal static readonly int UavLumaHistory = Shader.PropertyToID("rw_luma_history"); |
|
|
|
|
|
internal static readonly int UavUpscaledOutput = Shader.PropertyToID("rw_upscaled_output"); |
|
|
|
|
|
internal static readonly int UavExposureMipLumaChange = Shader.PropertyToID("rw_img_mip_shading_change"); |
|
|
|
|
|
internal static readonly int UavExposureMip5 = Shader.PropertyToID("rw_img_mip_5"); |
|
|
|
|
|
internal static readonly int UavDilatedReactiveMasks = Shader.PropertyToID("rw_dilated_reactive_masks"); |
|
|
|
|
|
internal static readonly int UavAutoExposure = Shader.PropertyToID("rw_auto_exposure"); |
|
|
|
|
|
internal static readonly int UavSpdAtomicCount = Shader.PropertyToID("rw_spd_global_atomic"); |
|
|
|
|
|
internal static readonly int UavAutoReactive = Shader.PropertyToID("rw_output_autoreactive"); |
|
|
|
|
|
|
|
|
|
|
|
// Constant buffer bindings
|
|
|
|
|
|
protected static readonly int CbFsr2 = Shader.PropertyToID("cbFSR2"); |
|
|
|
|
|
protected static readonly int CbSpd = Shader.PropertyToID("cbSPD"); |
|
|
|
|
|
protected static readonly int CbRcas = Shader.PropertyToID("cbRCAS"); |
|
|
|
|
|
protected static readonly int CbGenReactive = Shader.PropertyToID("cbGenerateReactive"); |
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool AllowFP16 => true; |
|
|
protected virtual bool AllowFP16 => true; |
|
|
|
|
|
|
|
|
protected Fsr2Pipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
protected Fsr2Pipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) |
|
|
@ -94,40 +46,38 @@ namespace FidelityFX |
|
|
// Set up shared aliasable resources, i.e. temporary render textures
|
|
|
// Set up shared aliasable resources, i.e. temporary render textures
|
|
|
// These do not need to persist between frames, but they do need to be available between passes
|
|
|
// These do not need to persist between frames, but they do need to be available between passes
|
|
|
|
|
|
|
|
|
// TODO: we could potentially gather *all* resource binding here, by using CommandBuffer.SetGlobalTexture for everything
|
|
|
|
|
|
|
|
|
|
|
|
// Resource FSR2_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
// Resource FSR2_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
commandBuffer.GetTemporaryRT(UavSpdAtomicCount, 1, 1, 0, default, GraphicsFormat.R32_UInt, 1, true); |
|
|
|
|
|
|
|
|
commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavSpdAtomicCount, 1, 1, 0, default, GraphicsFormat.R32_UInt, 1, true); |
|
|
|
|
|
|
|
|
// FSR2_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
// FSR2_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
commandBuffer.GetTemporaryRT(UavReconstructedPrevNearestDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_UInt, 1, true); |
|
|
|
|
|
|
|
|
commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_UInt, 1, true); |
|
|
|
|
|
|
|
|
// FSR2_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
// FSR2_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
commandBuffer.GetTemporaryRT(UavDilatedDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_SFloat, 1, true); |
|
|
|
|
|
|
|
|
commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavDilatedDepth, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R32_SFloat, 1, true); |
|
|
|
|
|
|
|
|
// FSR2_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
// FSR2_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
commandBuffer.GetTemporaryRT(UavLockInputLuma, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16_SFloat, 1, true); |
|
|
|
|
|
|
|
|
commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavLockInputLuma, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16_SFloat, 1, true); |
|
|
|
|
|
|
|
|
// FSR2_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
// FSR2_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
commandBuffer.GetTemporaryRT(UavDilatedReactiveMasks, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R8G8_UNorm, 1, true); |
|
|
|
|
|
|
|
|
commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavDilatedReactiveMasks, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R8G8_UNorm, 1, true); |
|
|
|
|
|
|
|
|
// FSR2_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
// FSR2_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
commandBuffer.GetTemporaryRT(UavPreparedInputColor, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16G16B16A16_SFloat, 1, true); |
|
|
|
|
|
|
|
|
commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavPreparedInputColor, maxRenderSize.x, maxRenderSize.y, 0, default, GraphicsFormat.R16G16B16A16_SFloat, 1, true); |
|
|
|
|
|
|
|
|
// FSR2_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
// FSR2_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
|
|
|
commandBuffer.GetTemporaryRT(UavNewLocks, displaySize.x, displaySize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); |
|
|
|
|
|
|
|
|
commandBuffer.GetTemporaryRT(Fsr2ShaderIDs.UavNewLocks, displaySize.x, displaySize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void UnregisterResources(CommandBuffer commandBuffer) |
|
|
public static void UnregisterResources(CommandBuffer commandBuffer) |
|
|
{ |
|
|
{ |
|
|
// Release all of the aliasable resources used this frame
|
|
|
// Release all of the aliasable resources used this frame
|
|
|
commandBuffer.ReleaseTemporaryRT(UavSpdAtomicCount); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(UavReconstructedPrevNearestDepth); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(UavDilatedDepth); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(UavLockInputLuma); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(UavDilatedReactiveMasks); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(UavPreparedInputColor); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(UavNewLocks); |
|
|
|
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavSpdAtomicCount); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavDilatedDepth); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavLockInputLuma); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavDilatedReactiveMasks); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavPreparedInputColor); |
|
|
|
|
|
commandBuffer.ReleaseTemporaryRT(Fsr2ShaderIDs.UavNewLocks); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected void LoadComputeShader(string name) |
|
|
protected void LoadComputeShader(string name) |
|
|
@ -192,14 +142,14 @@ namespace FidelityFX |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
if (dispatchParams.Color.HasValue) |
|
|
if (dispatchParams.Color.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputColor, dispatchParams.Color.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavExposureMipLumaChange, Resources.SceneLuminance, ShadingChangeMipLevel); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavExposureMip5, Resources.SceneLuminance, 5); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavAutoExposure, Resources.AutoExposure); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavExposureMipLumaChange, Resources.SceneLuminance, ShadingChangeMipLevel); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavExposureMip5, Resources.SceneLuminance, 5); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoExposure, Resources.AutoExposure); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbSpd, _spdConstants, 0, Marshal.SizeOf<Fsr2.SpdConstants>()); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbSpd, _spdConstants, 0, Marshal.SizeOf<Fsr2.SpdConstants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
} |
|
|
} |
|
|
@ -216,20 +166,20 @@ namespace FidelityFX |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
if (dispatchParams.Color.HasValue) |
|
|
if (dispatchParams.Color.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputColor, dispatchParams.Color.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
if (dispatchParams.Depth.HasValue) |
|
|
if (dispatchParams.Depth.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputDepth, dispatchParams.Depth.Value, 0, RenderTextureSubElement.Depth); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth.Value, 0, RenderTextureSubElement.Depth); |
|
|
|
|
|
|
|
|
if (dispatchParams.MotionVectors.HasValue) |
|
|
if (dispatchParams.MotionVectors.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputMotionVectors, dispatchParams.MotionVectors.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, dispatchParams.MotionVectors.Value); |
|
|
|
|
|
|
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
} |
|
|
} |
|
|
@ -246,29 +196,29 @@ namespace FidelityFX |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
if (dispatchParams.Color.HasValue) |
|
|
if (dispatchParams.Color.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputColor, dispatchParams.Color.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.Color.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
if (dispatchParams.Depth.HasValue) |
|
|
if (dispatchParams.Depth.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputDepth, dispatchParams.Depth.Value, 0, RenderTextureSubElement.Depth); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputDepth, dispatchParams.Depth.Value, 0, RenderTextureSubElement.Depth); |
|
|
|
|
|
|
|
|
if (dispatchParams.MotionVectors.HasValue) |
|
|
if (dispatchParams.MotionVectors.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputMotionVectors, dispatchParams.MotionVectors.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, dispatchParams.MotionVectors.Value); |
|
|
|
|
|
|
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
if (dispatchParams.Reactive.HasValue) |
|
|
if (dispatchParams.Reactive.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvReactiveMask, dispatchParams.Reactive.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReactiveMask, dispatchParams.Reactive.Value); |
|
|
|
|
|
|
|
|
if (dispatchParams.TransparencyAndComposition.HasValue) |
|
|
if (dispatchParams.TransparencyAndComposition.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvTransparencyAndCompositionMask, dispatchParams.TransparencyAndComposition.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvTransparencyAndCompositionMask, dispatchParams.TransparencyAndComposition.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvReconstructedPrevNearestDepth, UavReconstructedPrevNearestDepth); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvDilatedDepth, UavDilatedDepth); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvReconstructedPrevNearestDepth, Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedDepth, Fsr2ShaderIDs.UavDilatedDepth); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPrevDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex ^ 1]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
} |
|
|
} |
|
|
@ -284,8 +234,8 @@ namespace FidelityFX |
|
|
|
|
|
|
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvLockInputLuma, UavLockInputLuma); |
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockInputLuma, Fsr2ShaderIDs.UavLockInputLuma); |
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
} |
|
|
} |
|
|
@ -305,31 +255,31 @@ namespace FidelityFX |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
if ((ContextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) |
|
|
if ((ContextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) == 0) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedMotionVectors[frameIndex]); |
|
|
else if (dispatchParams.MotionVectors.HasValue) |
|
|
else if (dispatchParams.MotionVectors.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputMotionVectors, dispatchParams.MotionVectors.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputMotionVectors, dispatchParams.MotionVectors.Value); |
|
|
|
|
|
|
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvDilatedReactiveMasks, UavDilatedReactiveMasks); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInternalUpscaled, Resources.InternalUpscaled[frameIndex ^ 1]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvLockStatus, Resources.LockStatus[frameIndex ^ 1]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvPreparedInputColor, UavPreparedInputColor); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvLanczosLut, Resources.LanczosLut); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvUpscaleMaximumBiasLut, Resources.MaximumBiasLut); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvSceneLuminanceMips, Resources.SceneLuminance); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvAutoExposure, Resources.AutoExposure); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavLockStatus, Resources.LockStatus[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavLumaHistory, Resources.LumaHistory[frameIndex]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvDilatedReactiveMasks, Fsr2ShaderIDs.UavDilatedReactiveMasks); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInternalUpscaled, Resources.InternalUpscaled[frameIndex ^ 1]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLockStatus, Resources.LockStatus[frameIndex ^ 1]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvPreparedInputColor, Fsr2ShaderIDs.UavPreparedInputColor); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLanczosLut, Resources.LanczosLut); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvUpscaleMaximumBiasLut, Resources.MaximumBiasLut); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvSceneLuminanceMips, Resources.SceneLuminance); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvAutoExposure, Resources.AutoExposure); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); |
|
|
|
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavInternalUpscaled, Resources.InternalUpscaled[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavLockStatus, Resources.LockStatus[frameIndex]); |
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavLumaHistory, Resources.LumaHistory[frameIndex]); |
|
|
|
|
|
|
|
|
if (dispatchParams.Output.HasValue) |
|
|
if (dispatchParams.Output.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavUpscaledOutput, dispatchParams.Output.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavUpscaledOutput, dispatchParams.Output.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
} |
|
|
} |
|
|
@ -384,15 +334,15 @@ namespace FidelityFX |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
public override void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.DispatchDescription dispatchParams, int frameIndex, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
if (dispatchParams.Exposure.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputExposure, dispatchParams.Exposure.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvRcasInput, Resources.InternalUpscaled[frameIndex]); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvRcasInput, Resources.InternalUpscaled[frameIndex]); |
|
|
|
|
|
|
|
|
if (dispatchParams.Output.HasValue) |
|
|
if (dispatchParams.Output.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavUpscaledOutput, dispatchParams.Output.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavUpscaledOutput, dispatchParams.Output.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbRcas, _rcasConstants, 0, Marshal.SizeOf<Fsr2.RcasConstants>()); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbFsr2, Constants, 0, Marshal.SizeOf<Fsr2.Fsr2Constants>()); |
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbRcas, _rcasConstants, 0, Marshal.SizeOf<Fsr2.RcasConstants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
} |
|
|
} |
|
|
@ -417,15 +367,15 @@ namespace FidelityFX |
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) |
|
|
public void ScheduleDispatch(CommandBuffer commandBuffer, Fsr2.GenerateReactiveDescription dispatchParams, int dispatchX, int dispatchY) |
|
|
{ |
|
|
{ |
|
|
if (dispatchParams.ColorOpaqueOnly.HasValue) |
|
|
if (dispatchParams.ColorOpaqueOnly.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvOpaqueOnly, dispatchParams.ColorOpaqueOnly.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
if (dispatchParams.ColorPreUpscale.HasValue) |
|
|
if (dispatchParams.ColorPreUpscale.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, SrvInputColor, dispatchParams.ColorPreUpscale.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.SrvInputColor, dispatchParams.ColorPreUpscale.Value, 0, RenderTextureSubElement.Color); |
|
|
|
|
|
|
|
|
if (dispatchParams.OutReactive.HasValue) |
|
|
if (dispatchParams.OutReactive.HasValue) |
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, UavAutoReactive, dispatchParams.OutReactive.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr2ShaderIDs.UavAutoReactive, dispatchParams.OutReactive.Value); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf<Fsr2.GenerateReactiveConstants>()); |
|
|
|
|
|
|
|
|
commandBuffer.SetComputeConstantBufferParam(ComputeShader, Fsr2ShaderIDs.CbGenReactive, _generateReactiveConstants, 0, Marshal.SizeOf<Fsr2.GenerateReactiveConstants>()); |
|
|
|
|
|
|
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
commandBuffer.DispatchCompute(ComputeShader, KernelIndex, dispatchX, dispatchY, 1); |
|
|
} |
|
|
} |
|
|
|