|
|
|
@ -12,6 +12,8 @@ namespace ArmASR |
|
|
|
private static readonly string OptionInvertedDepth = "FFXM_FSR2_OPTION_INVERTED_DEPTH"; |
|
|
|
private static readonly string OptionReprojectUseLut = "FFXM_FSR2_OPTION_REPROJECT_USE_LANCZOS_TYPE"; |
|
|
|
private static readonly string OptionApplySharpening = "FFXM_FSR2_OPTION_APPLY_SHARPENING"; |
|
|
|
private static readonly string OptionBalancedPreset = "FFXM_FSR2_OPTION_SHADER_OPT_BALANCED"; |
|
|
|
private static readonly string OptionPerformancePreset = "FFXM_FSR2_OPTION_SHADER_OPT_PERFORMANCE"; |
|
|
|
|
|
|
|
#if UNITY_2021_2_OR_NEWER
|
|
|
|
private readonly GlobalKeyword _halfPrecisionKeyword; |
|
|
|
@ -21,6 +23,8 @@ namespace ArmASR |
|
|
|
private readonly GlobalKeyword _invertedDepthKeyword; |
|
|
|
private readonly GlobalKeyword _reprojectUseLutKeyword; |
|
|
|
private readonly GlobalKeyword _applySharpeningKeyword; |
|
|
|
private readonly GlobalKeyword _balancedPresetKeyword; |
|
|
|
private readonly GlobalKeyword _performancePresetKeyword; |
|
|
|
#endif
|
|
|
|
|
|
|
|
public AsrKeywords() |
|
|
|
@ -33,10 +37,12 @@ namespace ArmASR |
|
|
|
_invertedDepthKeyword = GlobalKeyword.Create(OptionInvertedDepth); |
|
|
|
_reprojectUseLutKeyword = GlobalKeyword.Create(OptionReprojectUseLut); |
|
|
|
_applySharpeningKeyword = GlobalKeyword.Create(OptionApplySharpening); |
|
|
|
_balancedPresetKeyword = GlobalKeyword.Create(OptionBalancedPreset); |
|
|
|
_performancePresetKeyword = GlobalKeyword.Create(OptionPerformancePreset); |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
public void ApplyKeywords(CommandBuffer commandBuffer, Asr.InitializationFlags initFlags, in Asr.DispatchDescription dispatchParams) |
|
|
|
public void ApplyKeywords(CommandBuffer commandBuffer, Asr.Variant variant, Asr.InitializationFlags initFlags, in Asr.DispatchDescription dispatchParams) |
|
|
|
{ |
|
|
|
bool useLut = false; |
|
|
|
#if UNITY_2022_1_OR_NEWER // This will also work in 2020.3.43+ and 2021.3.14+
|
|
|
|
@ -82,6 +88,22 @@ namespace ArmASR |
|
|
|
commandBuffer.EnableKeyword(_applySharpeningKeyword); |
|
|
|
else |
|
|
|
commandBuffer.DisableKeyword(_applySharpeningKeyword); |
|
|
|
|
|
|
|
switch (variant) |
|
|
|
{ |
|
|
|
case Asr.Variant.Quality: |
|
|
|
commandBuffer.DisableKeyword(_balancedPresetKeyword); |
|
|
|
commandBuffer.DisableKeyword(_performancePresetKeyword); |
|
|
|
break; |
|
|
|
case Asr.Variant.Balanced: |
|
|
|
commandBuffer.EnableKeyword(_balancedPresetKeyword); |
|
|
|
commandBuffer.DisableKeyword(_performancePresetKeyword); |
|
|
|
break; |
|
|
|
case Asr.Variant.Performance: |
|
|
|
commandBuffer.EnableKeyword(_balancedPresetKeyword); |
|
|
|
commandBuffer.EnableKeyword(_performancePresetKeyword); |
|
|
|
break; |
|
|
|
} |
|
|
|
#else
|
|
|
|
if ((initFlags & Asr.InitializationFlags.EnableFP16Usage) != 0) |
|
|
|
commandBuffer.EnableShaderKeyword(OptionHalfPrecision); |
|
|
|
@ -117,6 +139,22 @@ namespace ArmASR |
|
|
|
commandBuffer.EnableShaderKeyword(OptionApplySharpening); |
|
|
|
else |
|
|
|
commandBuffer.DisableShaderKeyword(OptionApplySharpening); |
|
|
|
|
|
|
|
switch (variant) |
|
|
|
{ |
|
|
|
case Asr.Variant.Quality: |
|
|
|
commandBuffer.DisableShaderKeyword(OptionBalancedPreset); |
|
|
|
commandBuffer.DisableShaderKeyword(OptionPerformancePreset); |
|
|
|
break; |
|
|
|
case Asr.Variant.Balanced: |
|
|
|
commandBuffer.EnableShaderKeyword(OptionBalancedPreset); |
|
|
|
commandBuffer.DisableShaderKeyword(OptionPerformancePreset); |
|
|
|
break; |
|
|
|
case Asr.Variant.Performance: |
|
|
|
commandBuffer.EnableShaderKeyword(OptionBalancedPreset); |
|
|
|
commandBuffer.EnableShaderKeyword(OptionPerformancePreset); |
|
|
|
break; |
|
|
|
} |
|
|
|
#endif
|
|
|
|
|
|
|
|
} |
|
|
|
|