Browse Source

Improved XeSS implementation by properly including motion vector scale and jitter scale parameters.

master
Nico de Poel 1 year ago
parent
commit
364469f4b3
  1. BIN
      com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/Plugins/Win64/XeSSUnityPlugin.dll
  2. 25
      com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/XeSSUpscalerPlugin.cs

BIN
com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/Plugins/Win64/XeSSUnityPlugin.dll

25
com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/XeSSUpscalerPlugin.cs

@ -76,6 +76,8 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.XeSS
if (initSettings.GetFlag(FfxFsr2InitializationFlags.EnableAutoExposure)) initFlags |= XeSSLibrary.InitFlags.EnableAutoExposure; if (initSettings.GetFlag(FfxFsr2InitializationFlags.EnableAutoExposure)) initFlags |= XeSSLibrary.InitFlags.EnableAutoExposure;
// TODO: use NDC velocity? I think motion vectors might be in normalized device coordinates... // TODO: use NDC velocity? I think motion vectors might be in normalized device coordinates...
Debug.Log($"Setting up XeSS with input size: {initSettings.maxRenderSizeWidth}x{initSettings.maxRenderSizeHeight}, output size: {initSettings.displaySizeWidth}x{initSettings.displaySizeHeight}, flags: {initFlags}");
_contextHandle = XeSSLibrary.CreateContext(outputResolution, XeSSLibrary.QualitySetting.Quality, initFlags); _contextHandle = XeSSLibrary.CreateContext(outputResolution, XeSSLibrary.QualitySetting.Quality, initFlags);
_paramsBuffer = Marshal.AllocHGlobal(Marshal.SizeOf<XeSSLibrary.ExecuteParams>()); _paramsBuffer = Marshal.AllocHGlobal(Marshal.SizeOf<XeSSLibrary.ExecuteParams>());
} }
@ -111,6 +113,10 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.XeSS
_executeParams.pResponsivePixelMaskTexture = textures.biasColorMask.ToNativePtr(); _executeParams.pResponsivePixelMaskTexture = textures.biasColorMask.ToNativePtr();
_executeParams.pOutputTexture = textures.colorOutput.ToNativePtr(); _executeParams.pOutputTexture = textures.colorOutput.ToNativePtr();
_executeParams.velocityScaleX = executeData.MVScaleX;
_executeParams.velocityScaleY = executeData.MVScaleY;
_executeParams.jitterScaleX = 1f;
_executeParams.jitterScaleY = -1f;
_executeParams.jitterOffsetX = executeData.jitterOffsetX; _executeParams.jitterOffsetX = executeData.jitterOffsetX;
_executeParams.jitterOffsetY = executeData.jitterOffsetY; _executeParams.jitterOffsetY = executeData.jitterOffsetY;
_executeParams.exposureScale = executeData.preExposure; _executeParams.exposureScale = executeData.preExposure;
@ -200,32 +206,51 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.XeSS
/** Input color texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/ /** Input color texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/
public IntPtr pColorTexture; public IntPtr pColorTexture;
/** Input motion vector texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/ /** Input motion vector texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/
public IntPtr pVelocityTexture; public IntPtr pVelocityTexture;
/** Optional depth texture. Required if XESS_INIT_FLAG_HIGH_RES_MV has not been specified. /** Optional depth texture. Required if XESS_INIT_FLAG_HIGH_RES_MV has not been specified.
* Must be in NON_PIXEL_SHADER_RESOURCE state.*/ * Must be in NON_PIXEL_SHADER_RESOURCE state.*/
public IntPtr pDepthTexture; public IntPtr pDepthTexture;
/** Optional 1x1 exposure scale texture. Required if XESS_INIT_FLAG_EXPOSURE_TEXTURE has been /** Optional 1x1 exposure scale texture. Required if XESS_INIT_FLAG_EXPOSURE_TEXTURE has been
* specified. Must be in NON_PIXEL_SHADER_RESOURCE state */ * specified. Must be in NON_PIXEL_SHADER_RESOURCE state */
public IntPtr pExposureScaleTexture; public IntPtr pExposureScaleTexture;
/** Optional responsive pixel mask texture. Required if XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK /** Optional responsive pixel mask texture. Required if XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK
* has been specified. Must be in NON_PIXEL_SHADER_RESOURCE state */ * has been specified. Must be in NON_PIXEL_SHADER_RESOURCE state */
public IntPtr pResponsivePixelMaskTexture; public IntPtr pResponsivePixelMaskTexture;
/** Output texture in target resolution. Must be in UNORDERED_ACCESS state.*/ /** Output texture in target resolution. Must be in UNORDERED_ACCESS state.*/
public IntPtr pOutputTexture; public IntPtr pOutputTexture;
public float jitterScaleX;
public float jitterScaleY;
public float velocityScaleX;
public float velocityScaleY;
/** Jitter X coordinate in the range [-0.5, 0.5]. */ /** Jitter X coordinate in the range [-0.5, 0.5]. */
public float jitterOffsetX; public float jitterOffsetX;
/** Jitter Y coordinate in the range [-0.5, 0.5]. */ /** Jitter Y coordinate in the range [-0.5, 0.5]. */
public float jitterOffsetY; public float jitterOffsetY;
/** Optional input color scaling. Default is 1. */ /** Optional input color scaling. Default is 1. */
public float exposureScale; public float exposureScale;
public float dummy0;
/** Resets the history accumulation in this frame. */ /** Resets the history accumulation in this frame. */
public uint resetHistory; public uint resetHistory;
/** Input color width. */ /** Input color width. */
public uint inputWidth; public uint inputWidth;
/** Input color height. */ /** Input color height. */
public uint inputHeight; public uint inputHeight;
public uint dummy1;
} }
public static QualitySetting ConvertQuality(FSR2Quality quality) public static QualitySetting ConvertQuality(FSR2Quality quality)

Loading…
Cancel
Save