Browse Source

Made shading change mip level into a reusable const value, and fixed mip sizes for exposure RTs.

Actually tested the output of the luminance pyramid shader now and it seems to be working.
mac-autoexp
Nico de Poel 3 years ago
parent
commit
16f529bce8
  1. 6
      Assets/Scripts/Fsr2Context.cs
  2. 6
      Assets/Scripts/Fsr2Pipeline.cs

6
Assets/Scripts/Fsr2Context.cs

@ -160,7 +160,7 @@ namespace FidelityFX
bool resetAccumulation = dispatchParams.Reset || _firstExecution;
_firstExecution = false;
// TODO Register resources: ...
Fsr2Pipeline.RegisterResources(_commandBuffer, dispatchParams);
SetupConstants(dispatchParams, resetAccumulation);
@ -184,8 +184,6 @@ namespace FidelityFX
_fsr2ConstantsBuffer.SetData(_fsr2ConstantsArray);
_spdConstantsBuffer.SetData(_spdConstantsArray);
Fsr2Pipeline.RegisterResources(_commandBuffer, dispatchParams);
// Compute luminance pyramid
_computeLuminancePyramidPipeline.ScheduleDispatch(_commandBuffer, dispatchParams, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y);
@ -288,7 +286,7 @@ namespace FidelityFX
constants.frameIndex++;
// Shading change usage of the SPD mip levels
constants.lumaMipLevelToUse = 4; // NOTE: this is derived from a bunch of auto-generated constant values in the FSR2 code
constants.lumaMipLevelToUse = Fsr2Pipeline.ShadingChangeMipLevel;
float mipDiv = 2 << constants.lumaMipLevelToUse;
constants.lumaMipDimensions.x = (int)(constants.maxRenderSize.x / mipDiv);

6
Assets/Scripts/Fsr2Pipeline.cs

@ -8,6 +8,8 @@ namespace FidelityFX
{
internal abstract class Fsr2Pipeline: IDisposable
{
internal const int ShadingChangeMipLevel = 4; // Corresponds to FFX_FSR2_SHADING_CHANGE_MIP_LEVEL define
private readonly Fsr2Callbacks _callbacks;
protected readonly ComputeBuffer Constants;
@ -57,8 +59,8 @@ namespace FidelityFX
commandBuffer.GetTemporaryRT(UavSpdAtomicCount, 1, 1, 0, FilterMode.Point, GraphicsFormat.R32_UInt, 1, true);
// Resource FSR2_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE, has mipmap chain
commandBuffer.GetTemporaryRT(UavExposureMipLumaChange, dispatchParams.RenderSize.x >> 4, dispatchParams.RenderSize.y >> 4, 0, FilterMode.Point, GraphicsFormat.R16_SFloat, 1, true);
commandBuffer.GetTemporaryRT(UavExposureMip5, dispatchParams.RenderSize.x >> 5, dispatchParams.RenderSize.y >> 5, 0, FilterMode.Point, GraphicsFormat.R16_SFloat, 1, true);
commandBuffer.GetTemporaryRT(UavExposureMipLumaChange, dispatchParams.RenderSize.x >> (ShadingChangeMipLevel + 1), dispatchParams.RenderSize.y >> (ShadingChangeMipLevel + 1), 0, FilterMode.Point, GraphicsFormat.R16_SFloat, 1, true);
commandBuffer.GetTemporaryRT(UavExposureMip5, dispatchParams.RenderSize.x >> 6, dispatchParams.RenderSize.y >> 6, 0, FilterMode.Point, GraphicsFormat.R16_SFloat, 1, true);
}
public static void UnregisterResources(CommandBuffer commandBuffer)

Loading…
Cancel
Save