|
|
|
@ -299,21 +299,35 @@ FfxUInt32x2 SPD_RenderSize() |
|
|
|
} |
|
|
|
#endif // #if defined(FSR2_BIND_CB_SPD) |
|
|
|
|
|
|
|
// Declare and sample camera buffers as regular textures, unless overridden |
|
|
|
#if !defined(UNITY_FSR_TEX2D) |
|
|
|
#define UNITY_FSR_TEX2D(type) Texture2D<type> |
|
|
|
#endif |
|
|
|
#if !defined(UNITY_FSR_RWTEX2D) |
|
|
|
#define UNITY_FSR_RWTEX2D(type) RWTexture2D<type> |
|
|
|
#endif |
|
|
|
#if !defined(UNITY_FSR_POS) |
|
|
|
#define UNITY_FSR_POS(pxPos) (pxPos) |
|
|
|
#endif |
|
|
|
#if !defined(UNITY_FSR_UV) |
|
|
|
#define UNITY_FSR_UV(uv) (uv) |
|
|
|
#endif |
|
|
|
|
|
|
|
SamplerState s_PointClamp : register(s0); |
|
|
|
SamplerState s_LinearClamp : register(s1); |
|
|
|
|
|
|
|
// SRVs |
|
|
|
#if defined FSR2_BIND_SRV_INPUT_COLOR |
|
|
|
Texture2D<FfxFloat32x4> r_input_color_jittered : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_COLOR); |
|
|
|
UNITY_FSR_TEX2D(FfxFloat32x4) r_input_color_jittered : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_COLOR); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_SRV_INPUT_OPAQUE_ONLY |
|
|
|
Texture2D<FfxFloat32x4> r_input_opaque_only : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY); |
|
|
|
UNITY_FSR_TEX2D(FfxFloat32x4) r_input_opaque_only : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_SRV_INPUT_MOTION_VECTORS |
|
|
|
Texture2D<FfxFloat32x4> r_input_motion_vectors : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_MOTION_VECTORS); |
|
|
|
UNITY_FSR_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_MOTION_VECTORS); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_SRV_INPUT_DEPTH |
|
|
|
Texture2D<FfxFloat32> r_input_depth : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_DEPTH); |
|
|
|
UNITY_FSR_TEX2D(FfxFloat32) r_input_depth : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_DEPTH); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_SRV_INPUT_EXPOSURE |
|
|
|
Texture2D<FfxFloat32x2> r_input_exposure : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_EXPOSURE); |
|
|
|
@ -322,10 +336,10 @@ SamplerState s_LinearClamp : register(s1); |
|
|
|
Texture2D<FfxFloat32x2> r_auto_exposure : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_SRV_REACTIVE_MASK |
|
|
|
Texture2D<FfxFloat32> r_reactive_mask : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); |
|
|
|
UNITY_FSR_TEX2D(FfxFloat32) r_reactive_mask : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK |
|
|
|
Texture2D<FfxFloat32> r_transparency_and_composition_mask : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); |
|
|
|
UNITY_FSR_TEX2D(FfxFloat32) r_transparency_and_composition_mask : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH |
|
|
|
Texture2D<FfxUInt32> r_reconstructed_previous_nearest_depth : FFXM_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); |
|
|
|
@ -414,7 +428,7 @@ SamplerState s_LinearClamp : register(s1); |
|
|
|
RWTexture2D<FfxFloat32x4> rw_luma_history : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_UAV_UPSCALED_OUTPUT |
|
|
|
RWTexture2D<FfxFloat32x4> rw_upscaled_output : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_UPSCALED_OUTPUT); |
|
|
|
UNITY_FSR_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_UPSCALED_OUTPUT); |
|
|
|
#endif |
|
|
|
#if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE |
|
|
|
globallycoherent RWTexture2D<FfxFloat32> rw_img_mip_shading_change : FFXM_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); |
|
|
|
@ -456,7 +470,7 @@ FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel) |
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_DEPTH) |
|
|
|
FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) |
|
|
|
{ |
|
|
|
return r_input_depth[iPxPos]; |
|
|
|
return r_input_depth[UNITY_FSR_POS(iPxPos)]; |
|
|
|
} |
|
|
|
/* |
|
|
|
dd00 (-1,1) *------* dd10 (0,-1) |
|
|
|
@ -470,7 +484,7 @@ void GatherInputDepthRQuad(FfxFloat32x2 fUV, |
|
|
|
FFXM_PARAMETER_INOUT FfxFloat32 dd01, |
|
|
|
FFXM_PARAMETER_INOUT FfxFloat32 dd11) |
|
|
|
{ |
|
|
|
FfxFloat32x4 rrrr = r_input_depth.GatherRed(s_PointClamp, fUV); |
|
|
|
FfxFloat32x4 rrrr = r_input_depth.GatherRed(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
dd01 = FfxFloat32(rrrr.x); |
|
|
|
dd11 = FfxFloat32(rrrr.y); |
|
|
|
dd10 = FfxFloat32(rrrr.z); |
|
|
|
@ -481,14 +495,14 @@ void GatherInputDepthRQuad(FfxFloat32x2 fUV, |
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_DEPTH) |
|
|
|
FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) |
|
|
|
{ |
|
|
|
return r_input_depth.SampleLevel(s_LinearClamp, fUV, 0).x; |
|
|
|
return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(FSR2_BIND_SRV_REACTIVE_MASK) |
|
|
|
FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) |
|
|
|
{ |
|
|
|
return r_reactive_mask[iPxPos]; |
|
|
|
return r_reactive_mask[UNITY_FSR_POS(iPxPos)]; |
|
|
|
} |
|
|
|
/* |
|
|
|
col00 (-1,1) *------* col10 (0,-1) |
|
|
|
@ -502,7 +516,7 @@ void GatherReactiveRQuad(FfxFloat32x2 fUV, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F col01, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F col11) |
|
|
|
{ |
|
|
|
FFXM_MIN16_F4 rrrr = r_reactive_mask.GatherRed(s_PointClamp, fUV); |
|
|
|
FFXM_MIN16_F4 rrrr = r_reactive_mask.GatherRed(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
col01 = FFXM_MIN16_F(rrrr.x); |
|
|
|
col11 = FFXM_MIN16_F(rrrr.y); |
|
|
|
col10 = FFXM_MIN16_F(rrrr.z); |
|
|
|
@ -513,7 +527,7 @@ void GatherReactiveRQuad(FfxFloat32x2 fUV, |
|
|
|
#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) |
|
|
|
FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) |
|
|
|
{ |
|
|
|
return r_transparency_and_composition_mask[iPxPos]; |
|
|
|
return r_transparency_and_composition_mask[UNITY_FSR_POS(iPxPos)]; |
|
|
|
} |
|
|
|
/* |
|
|
|
col00 (-1,1) *------* col10 (0,-1) |
|
|
|
@ -527,7 +541,7 @@ void GatherTransparencyAndCompositionMaskRQuad(FfxFloat32x2 fUV, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F col01, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F col11) |
|
|
|
{ |
|
|
|
FFXM_MIN16_F4 rrrr = r_transparency_and_composition_mask.GatherRed(s_PointClamp, fUV); |
|
|
|
FFXM_MIN16_F4 rrrr = r_transparency_and_composition_mask.GatherRed(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
col01 = FFXM_MIN16_F(rrrr.x); |
|
|
|
col11 = FFXM_MIN16_F(rrrr.y); |
|
|
|
col10 = FFXM_MIN16_F(rrrr.z); |
|
|
|
@ -538,7 +552,7 @@ void GatherTransparencyAndCompositionMaskRQuad(FfxFloat32x2 fUV, |
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_COLOR) |
|
|
|
FFXM_MIN16_F3 LoadInputColor(FfxUInt32x2 iPxPos) |
|
|
|
{ |
|
|
|
return r_input_color_jittered[iPxPos].rgb; |
|
|
|
return r_input_color_jittered[UNITY_FSR_POS(iPxPos)].rgb; |
|
|
|
} |
|
|
|
/* |
|
|
|
col00 (-1,1) *------* col10 (0,-1) |
|
|
|
@ -552,9 +566,9 @@ void GatherInputColorRGBQuad(FfxFloat32x2 fUV, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F3 col01, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F3 col11) |
|
|
|
{ |
|
|
|
FFXM_MIN16_F4 rrrr = r_input_color_jittered.GatherRed(s_PointClamp, fUV); |
|
|
|
FFXM_MIN16_F4 gggg = r_input_color_jittered.GatherGreen(s_PointClamp, fUV); |
|
|
|
FFXM_MIN16_F4 bbbb = r_input_color_jittered.GatherBlue(s_PointClamp, fUV); |
|
|
|
FFXM_MIN16_F4 rrrr = r_input_color_jittered.GatherRed(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
FFXM_MIN16_F4 gggg = r_input_color_jittered.GatherGreen(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
FFXM_MIN16_F4 bbbb = r_input_color_jittered.GatherBlue(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
col01 = FFXM_MIN16_F3(rrrr.x, gggg.x, bbbb.x); |
|
|
|
col11 = FFXM_MIN16_F3(rrrr.y, gggg.y, bbbb.y); |
|
|
|
col10 = FFXM_MIN16_F3(rrrr.z, gggg.z, bbbb.z); |
|
|
|
@ -565,7 +579,7 @@ void GatherInputColorRGBQuad(FfxFloat32x2 fUV, |
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_COLOR) |
|
|
|
FFXM_MIN16_F3 SampleInputColor(FfxFloat32x2 fUV) |
|
|
|
{ |
|
|
|
return r_input_color_jittered.SampleLevel(s_LinearClamp, fUV, 0).rgb; |
|
|
|
return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).rgb; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
@ -603,7 +617,7 @@ void GatherPreparedInputColorRGBQuad(FfxFloat32x2 fUV, |
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) |
|
|
|
FFXM_MIN16_F2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) |
|
|
|
{ |
|
|
|
FFXM_MIN16_F2 fSrcMotionVector = r_input_motion_vectors[iPxDilatedMotionVectorPos].xy; |
|
|
|
FFXM_MIN16_F2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR_POS(iPxDilatedMotionVectorPos)].xy; |
|
|
|
|
|
|
|
FFXM_MIN16_F2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); |
|
|
|
|
|
|
|
@ -625,8 +639,8 @@ void GatherInputMotionVectorRGQuad(FfxFloat32x2 fUV, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F2 col01, |
|
|
|
FFXM_PARAMETER_INOUT FFXM_MIN16_F2 col11) |
|
|
|
{ |
|
|
|
FFXM_MIN16_F4 rrrr = r_input_motion_vectors.GatherRed(s_PointClamp, fUV); |
|
|
|
FFXM_MIN16_F4 gggg = r_input_motion_vectors.GatherGreen(s_PointClamp, fUV); |
|
|
|
FFXM_MIN16_F4 rrrr = r_input_motion_vectors.GatherRed(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
FFXM_MIN16_F4 gggg = r_input_motion_vectors.GatherGreen(s_PointClamp, UNITY_FSR_UV(fUV)); |
|
|
|
col01 = FFXM_MIN16_F2(rrrr.x, gggg.x) * MotionVectorScale(); |
|
|
|
col11 = FFXM_MIN16_F2(rrrr.y, gggg.y) * MotionVectorScale(); |
|
|
|
col10 = FFXM_MIN16_F2(rrrr.z, gggg.z) * MotionVectorScale(); |
|
|
|
@ -711,7 +725,7 @@ void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeigh |
|
|
|
#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) |
|
|
|
void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) |
|
|
|
{ |
|
|
|
rw_upscaled_output[iPxPos] = FfxFloat32x4(fColor, 1.f); |
|
|
|
rw_upscaled_output[UNITY_FSR_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
@ -948,7 +962,7 @@ FFXM_MIN16_F2 LoadDilatedReactiveMasks(FFXM_PARAMETER_IN FfxUInt32x2 iPxPos) |
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) |
|
|
|
FfxFloat32x3 LoadOpaqueOnly(FFXM_PARAMETER_IN FFXM_MIN16_I2 iPxPos) |
|
|
|
{ |
|
|
|
return r_input_opaque_only[iPxPos].xyz; |
|
|
|
return r_input_opaque_only[UNITY_FSR_POS(iPxPos)].xyz; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|