Files
Cielonos/Assets/OtherPlugins/GraphicsCat/Modules/LitPlus/Shaders/Includes/Common/Precision.hlsl
SoulliesOfficial d15957c719 更新
2025-12-17 04:19:38 -05:00

45 lines
1.4 KiB
HLSL

#pragma once
// Include Unity's Common.hlsl first
// # It also contains some precision definitions, otherwise ours will overwrite them
// # Also, if we include our Precision before Common, it will cause SafePositivePow_half to be defined twice
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
// Xiaomi 3, CPU 1036, GPU 330
// Scene sample GPU side consumption: float 46ms, half 31ms, more than 30% improvement
// First define aliases for float
// Then replace float with half
// The order cannot be changed
typedef float full;
typedef float2 full2;
typedef float3 full3;
typedef float4 full4;
typedef float2x2 full2x2;
typedef float3x3 full3x3;
typedef float4x4 full4x4;
// URP has two sets of functions (half + float)
// Introducing our definitions will cause function redefinition errors
// Disable them for now
// #define HALF_MODE 1
// #define FULL_MODE 1
#if HALF_MODE // Global half precision
#define float half
#define float2 half2
#define float3 half3
#define float4 half4
#define float2x2 half2x2
#define float3x3 half3x3
#define float4x4 half4x4
#elif FULL_MODE // Global single precision
#define half float
#define half2 float2
#define half3 float3
#define half4 float4
#define half2x2 float2x2
#define half3x3 float3x3
#define half4x4 float4x4
#endif // Mixed precision, precision is determined by float or half