|
|
@ -339,35 +339,21 @@ FfxUInt32x2 SPD_RenderSize() |
|
|
} |
|
|
} |
|
|
#endif // #if defined(FSR2_BIND_CB_SPD) |
|
|
#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_PointClamp : register(s0); |
|
|
SamplerState s_LinearClamp : register(s1); |
|
|
SamplerState s_LinearClamp : register(s1); |
|
|
|
|
|
|
|
|
// SRVs |
|
|
// SRVs |
|
|
#if defined FSR2_BIND_SRV_INPUT_COLOR |
|
|
#if defined FSR2_BIND_SRV_INPUT_COLOR |
|
|
UNITY_FSR_TEX2D(FfxFloat32x4) r_input_color_jittered : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_COLOR); |
|
|
|
|
|
|
|
|
TYPED_TEXTURE2D_X(FfxFloat32x4, r_input_color_jittered) : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_COLOR); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_SRV_INPUT_OPAQUE_ONLY |
|
|
#if defined FSR2_BIND_SRV_INPUT_OPAQUE_ONLY |
|
|
UNITY_FSR_TEX2D(FfxFloat32x4) r_input_opaque_only : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY); |
|
|
|
|
|
|
|
|
TYPED_TEXTURE2D_X(FfxFloat32x4, r_input_opaque_only) : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_SRV_INPUT_MOTION_VECTORS |
|
|
#if defined FSR2_BIND_SRV_INPUT_MOTION_VECTORS |
|
|
UNITY_FSR_TEX2D(FfxFloat32x4) r_input_motion_vectors : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_MOTION_VECTORS); |
|
|
|
|
|
|
|
|
TYPED_TEXTURE2D_X(FfxFloat32x4, r_input_motion_vectors) : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_MOTION_VECTORS); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_SRV_INPUT_DEPTH |
|
|
#if defined FSR2_BIND_SRV_INPUT_DEPTH |
|
|
UNITY_FSR_TEX2D(FfxFloat32) r_input_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_DEPTH); |
|
|
|
|
|
|
|
|
TYPED_TEXTURE2D_X(FfxFloat32, r_input_depth) : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_DEPTH); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_SRV_INPUT_EXPOSURE |
|
|
#if defined FSR2_BIND_SRV_INPUT_EXPOSURE |
|
|
Texture2D<FfxFloat32x2> r_input_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_EXPOSURE); |
|
|
Texture2D<FfxFloat32x2> r_input_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_INPUT_EXPOSURE); |
|
|
@ -376,10 +362,10 @@ SamplerState s_LinearClamp : register(s1); |
|
|
Texture2D<FfxFloat32x2> r_auto_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE); |
|
|
Texture2D<FfxFloat32x2> r_auto_exposure : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_AUTO_EXPOSURE); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_SRV_REACTIVE_MASK |
|
|
#if defined FSR2_BIND_SRV_REACTIVE_MASK |
|
|
UNITY_FSR_TEX2D(FfxFloat32) r_reactive_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); |
|
|
|
|
|
|
|
|
TYPED_TEXTURE2D_X(FfxFloat32, r_reactive_mask) : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_REACTIVE_MASK); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK |
|
|
#if defined FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK |
|
|
UNITY_FSR_TEX2D(FfxFloat32) r_transparency_and_composition_mask : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); |
|
|
|
|
|
|
|
|
TYPED_TEXTURE2D_X(FfxFloat32, r_transparency_and_composition_mask) : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH |
|
|
#if defined FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH |
|
|
Texture2D<FfxUInt32> r_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); |
|
|
Texture2D<FfxUInt32> r_reconstructed_previous_nearest_depth : FFX_FSR2_DECLARE_SRV(FSR2_BIND_SRV_RECONSTRUCTED_PREV_NEAREST_DEPTH); |
|
|
@ -463,7 +449,7 @@ SamplerState s_LinearClamp : register(s1); |
|
|
RWTexture2D<FfxFloat32x4> rw_luma_history : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY); |
|
|
RWTexture2D<FfxFloat32x4> rw_luma_history : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_LUMA_HISTORY); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_UAV_UPSCALED_OUTPUT |
|
|
#if defined FSR2_BIND_UAV_UPSCALED_OUTPUT |
|
|
UNITY_FSR_RWTEX2D(FfxFloat32x4) rw_upscaled_output : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_UPSCALED_OUTPUT); |
|
|
|
|
|
|
|
|
RW_TEXTURE2D_X(FfxFloat32x4, rw_upscaled_output) : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_UPSCALED_OUTPUT); |
|
|
#endif |
|
|
#endif |
|
|
#if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE |
|
|
#if defined FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE |
|
|
globallycoherent RWTexture2D<FfxFloat32> rw_img_mip_shading_change : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); |
|
|
globallycoherent RWTexture2D<FfxFloat32> rw_img_mip_shading_change : FFX_FSR2_DECLARE_UAV(FSR2_BIND_UAV_EXPOSURE_MIP_LUMA_CHANGE); |
|
|
@ -514,42 +500,42 @@ FfxFloat32 SampleMipLuma(FfxFloat32x2 fUV, FfxUInt32 mipLevel) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_DEPTH) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_DEPTH) |
|
|
FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) |
|
|
FfxFloat32 LoadInputDepth(FfxUInt32x2 iPxPos) |
|
|
{ |
|
|
{ |
|
|
return r_input_depth[UNITY_FSR_POS(iPxPos)]; |
|
|
|
|
|
|
|
|
return r_input_depth[COORD_TEXTURE2D_X(iPxPos)]; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_DEPTH) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_DEPTH) |
|
|
FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) |
|
|
FfxFloat32 SampleInputDepth(FfxFloat32x2 fUV) |
|
|
{ |
|
|
{ |
|
|
return r_input_depth.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).x; |
|
|
|
|
|
|
|
|
return SAMPLE_TEXTURE2D_X_LOD(r_input_depth, s_LinearClamp, fUV, 0).x; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if defined(FSR2_BIND_SRV_REACTIVE_MASK) |
|
|
#if defined(FSR2_BIND_SRV_REACTIVE_MASK) |
|
|
FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) |
|
|
FfxFloat32 LoadReactiveMask(FfxUInt32x2 iPxPos) |
|
|
{ |
|
|
{ |
|
|
return r_reactive_mask[UNITY_FSR_POS(iPxPos)]; |
|
|
|
|
|
|
|
|
return r_reactive_mask[COORD_TEXTURE2D_X(iPxPos)]; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) |
|
|
#if defined(FSR2_BIND_SRV_TRANSPARENCY_AND_COMPOSITION_MASK) |
|
|
FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) |
|
|
FfxFloat32 LoadTransparencyAndCompositionMask(FfxUInt32x2 iPxPos) |
|
|
{ |
|
|
{ |
|
|
return r_transparency_and_composition_mask[UNITY_FSR_POS(iPxPos)]; |
|
|
|
|
|
|
|
|
return r_transparency_and_composition_mask[COORD_TEXTURE2D_X(iPxPos)]; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_COLOR) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_COLOR) |
|
|
FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) |
|
|
FfxFloat32x3 LoadInputColor(FfxUInt32x2 iPxPos) |
|
|
{ |
|
|
{ |
|
|
return r_input_color_jittered[UNITY_FSR_POS(iPxPos)].rgb; |
|
|
|
|
|
|
|
|
return r_input_color_jittered[COORD_TEXTURE2D_X(iPxPos)].rgb; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if defined(FSR2_BIND_SRV_INPUT_COLOR) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_COLOR) |
|
|
FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) |
|
|
FfxFloat32x3 SampleInputColor(FfxFloat32x2 fUV) |
|
|
{ |
|
|
{ |
|
|
return r_input_color_jittered.SampleLevel(s_LinearClamp, UNITY_FSR_UV(fUV), 0).rgb; |
|
|
|
|
|
|
|
|
return SAMPLE_TEXTURE2D_X_LOD(r_input_color_jittered, s_LinearClamp, fUV, 0).rgb; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
@ -571,7 +557,7 @@ FFX_MIN16_F3 LoadPreparedInputColorHalf(FfxUInt32x2 iPxPos) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_MOTION_VECTORS) |
|
|
FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) |
|
|
FfxFloat32x2 LoadInputMotionVector(FfxUInt32x2 iPxDilatedMotionVectorPos) |
|
|
{ |
|
|
{ |
|
|
FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[UNITY_FSR_POS(iPxDilatedMotionVectorPos)].xy; |
|
|
|
|
|
|
|
|
FfxFloat32x2 fSrcMotionVector = r_input_motion_vectors[COORD_TEXTURE2D_X(iPxDilatedMotionVectorPos)].xy; |
|
|
|
|
|
|
|
|
FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); |
|
|
FfxFloat32x2 fUvMotionVector = fSrcMotionVector * MotionVectorScale(); |
|
|
|
|
|
|
|
|
@ -630,7 +616,7 @@ void StoreInternalColorAndWeight(FfxUInt32x2 iPxPos, FfxFloat32x4 fColorAndWeigh |
|
|
#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) |
|
|
#if defined(FSR2_BIND_UAV_UPSCALED_OUTPUT) |
|
|
void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) |
|
|
void StoreUpscaledOutput(FfxUInt32x2 iPxPos, FfxFloat32x3 fColor) |
|
|
{ |
|
|
{ |
|
|
rw_upscaled_output[UNITY_FSR_POS(iPxPos)] = FfxFloat32x4(fColor, 1.f); |
|
|
|
|
|
|
|
|
rw_upscaled_output[COORD_TEXTURE2D_X(iPxPos)] = FfxFloat32x4(fColor, 1.f); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
@ -862,7 +848,7 @@ void StoreDilatedReactiveMasks(FFX_PARAMETER_IN FfxUInt32x2 iPxPos, FFX_PARAMETE |
|
|
#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) |
|
|
#if defined(FSR2_BIND_SRV_INPUT_OPAQUE_ONLY) |
|
|
FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) |
|
|
FfxFloat32x3 LoadOpaqueOnly(FFX_PARAMETER_IN FFX_MIN16_I2 iPxPos) |
|
|
{ |
|
|
{ |
|
|
return r_input_opaque_only[UNITY_FSR_POS(iPxPos)].xyz; |
|
|
|
|
|
|
|
|
return r_input_opaque_only[COORD_TEXTURE2D_X(iPxPos)].xyz; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|