Browse Source

Modified inpainting pyramid passes to use a maximum of 7 mip levels. This allows the shaders to stay within the limit of 8 UAV bindings required by DX11.0, and gets rid of Unity's warnings and errors about breaking this limit.

fsr3framegen
Nico de Poel 2 years ago
parent
commit
4b675d285e
  1. 2
      Runtime/FrameInterpolation/FrameInterpolationContext.cs
  2. 12
      Runtime/FrameInterpolation/FrameInterpolationPass.cs
  3. 6
      Shaders/shaders/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass.hlsl
  4. 6
      Shaders/shaders/ffx_frameinterpolation_compute_inpainting_pyramid_pass.hlsl
  5. 27
      Shaders/shaders/frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.h
  6. 4
      Shaders/shaders/frameinterpolation/ffx_frameinterpolation_inpainting.h

2
Runtime/FrameInterpolation/FrameInterpolationContext.cs

@ -286,7 +286,7 @@ namespace FidelityFX.FrameGen
ref FrameInterpolation.InpaintingPyramidConstants spdConstants = ref SpdConstants; ref FrameInterpolation.InpaintingPyramidConstants spdConstants = ref SpdConstants;
spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x; spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x;
spdConstants.mips = (uint)numWorkGroupsAndMips.y;
spdConstants.mips = (uint)Math.Min(numWorkGroupsAndMips.y, 7);
spdConstants.workGroupOffsetX = (uint)workGroupOffset.x; spdConstants.workGroupOffsetX = (uint)workGroupOffset.x;
spdConstants.workGroupOffsetY = (uint)workGroupOffset.y; spdConstants.workGroupOffsetY = (uint)workGroupOffset.y;
} }

12
Runtime/FrameInterpolation/FrameInterpolationPass.cs

@ -293,12 +293,6 @@ namespace FidelityFX.FrameGen
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4); BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5); BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6); BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap7, Resources.InpaintingPyramid, 7);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap8, Resources.InpaintingPyramid, 8);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap9, Resources.InpaintingPyramid, 9);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap10, Resources.InpaintingPyramid, 10);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap11, Resources.InpaintingPyramid, 11);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap12, Resources.InpaintingPyramid, 12);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants, 0, Marshal.SizeOf<FrameInterpolation.InpaintingPyramidConstants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants, 0, Marshal.SizeOf<FrameInterpolation.InpaintingPyramidConstants>());
@ -359,12 +353,6 @@ namespace FidelityFX.FrameGen
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4); BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap4, Resources.InpaintingPyramid, 4);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5); BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap5, Resources.InpaintingPyramid, 5);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6); BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap6, Resources.InpaintingPyramid, 6);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap7, Resources.InpaintingPyramid, 7);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap8, Resources.InpaintingPyramid, 8);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap9, Resources.InpaintingPyramid, 9);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap10, Resources.InpaintingPyramid, 10);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap11, Resources.InpaintingPyramid, 11);
BindMipmap(commandBuffer, FrameInterpolationShaderIDs.UavInpaintingPyramidMipmap12, Resources.InpaintingPyramid, 12);
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbFrameInterpolation, Constants, 0, Marshal.SizeOf<FrameInterpolation.Constants>());
commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants, 0, Marshal.SizeOf<FrameInterpolation.InpaintingPyramidConstants>()); commandBuffer.SetComputeConstantBufferParam(ComputeShader, FrameInterpolationShaderIDs.CbInpaintingPyramid, _spdConstants, 0, Marshal.SizeOf<FrameInterpolation.InpaintingPyramidConstants>());

6
Shaders/shaders/ffx_frameinterpolation_compute_game_vector_field_inpainting_pyramid_pass.hlsl

@ -31,12 +31,6 @@
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 5 #define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 5
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 6 #define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 6
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 7 #define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 7
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7 8
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8 9
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9 10
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10 11
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11 12
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12 13
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 #define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0

6
Shaders/shaders/ffx_frameinterpolation_compute_inpainting_pyramid_pass.hlsl

@ -30,12 +30,6 @@
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 5 #define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4 5
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 6 #define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5 6
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 7 #define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6 7
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7 8
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8 9
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9 10
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10 11
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11 12
#define FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12 13
#define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0 #define FFX_FRAMEINTERPOLATION_BIND_CB_FRAMEINTERPOLATION 0

27
Shaders/shaders/frameinterpolation/ffx_frameinterpolation_callbacks_hlsl.h

@ -701,13 +701,7 @@ FfxFloat32x2 LoadInputMotionVector(FfxInt32x2 iPxDilatedMotionVectorPos)
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3) && \ defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_3) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4) && \ defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5) && \ defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11) && \
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12)
defined(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6)
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid0 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0); RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid0 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_0);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid1 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1); RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid1 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_1);
@ -716,13 +710,6 @@ FfxFloat32x2 LoadInputMotionVector(FfxInt32x2 iPxDilatedMotionVectorPos)
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid4 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4); RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid4 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_4);
globallycoherent RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid5 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5); globallycoherent RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid5 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_5);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid6 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6); RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid6 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_6);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid7 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_7);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid8 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_8);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid9 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_9);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid10 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_10);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid11 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_11);
RWTexture2D<FfxFloat32x4> rw_inpainting_pyramid12 : FFX_DECLARE_UAV(FFX_FRAMEINTERPOLATION_BIND_UAV_INPAINTING_PYRAMID_MIPMAP_12);
FfxFloat32x4 RWLoadInpaintingPyramid(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 index) FfxFloat32x4 RWLoadInpaintingPyramid(FFX_PARAMETER_IN FfxInt32x2 iPxPos, FFX_PARAMETER_IN FfxUInt32 index)
{ {
@ -738,12 +725,6 @@ FfxFloat32x2 LoadInputMotionVector(FfxInt32x2 iPxDilatedMotionVectorPos)
LOAD(4); LOAD(4);
LOAD(5); LOAD(5);
LOAD(6); LOAD(6);
LOAD(7);
LOAD(8);
LOAD(9);
LOAD(10);
LOAD(11);
LOAD(12);
return 0; return 0;
#undef LOAD #undef LOAD
@ -764,12 +745,6 @@ FfxFloat32x2 LoadInputMotionVector(FfxInt32x2 iPxDilatedMotionVectorPos)
STORE(4); STORE(4);
STORE(5); STORE(5);
STORE(6); STORE(6);
STORE(7);
STORE(8);
STORE(9);
STORE(10);
STORE(11);
STORE(12);
#undef STORE #undef STORE
} }

4
Shaders/shaders/frameinterpolation/ffx_frameinterpolation_inpainting.h

@ -55,7 +55,7 @@ FfxFloat32x3 ComputeInpainting(FfxInt32x2 iPxPos)
FfxFloat32 fWeightSum = 0.0f; FfxFloat32 fWeightSum = 0.0f;
FfxInt32x2 iTexSize = DisplaySize(); FfxInt32x2 iTexSize = DisplaySize();
for (FfxInt32 iMipLevel = 0; iMipLevel < 10; iMipLevel++) {
for (FfxInt32 iMipLevel = 0; iMipLevel < 7; iMipLevel++) {
iTexSize /= 2; iTexSize /= 2;
@ -63,7 +63,7 @@ FfxFloat32x3 ComputeInpainting(FfxInt32x2 iPxPos)
if (fMipColor.w > 0.0f) { if (fMipColor.w > 0.0f) {
const FfxFloat32x3 fNormalizedMipColor = fMipColor.rgb / fMipColor.w; const FfxFloat32x3 fNormalizedMipColor = fMipColor.rgb / fMipColor.w;
const FfxFloat32 fMipWeight = ffxPow(1.0f - iMipLevel / 10.0f, 3.0f) * fMipColor.w;
const FfxFloat32 fMipWeight = ffxPow(1.0f - iMipLevel / 7.0f, 3.0f) * fMipColor.w;
fColor += FfxFloat32x4(fNormalizedMipColor, 1.0f) * fMipWeight; fColor += FfxFloat32x4(fNormalizedMipColor, 1.0f) * fMipWeight;
} }

Loading…
Cancel
Save