From f859aa75bae8adc3950102bd05ac07830cbbd43c Mon Sep 17 00:00:00 2001 From: Julien Ignace Date: Fri, 26 Mar 2021 10:48:59 +0100 Subject: [PATCH] Added mobile preprocessor guards around half conversion warning pragmas --- com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl | 4 ++++ com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl | 4 ++++ com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl | 4 ++++ com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl | 4 ++++ .../ShaderLibrary/CommonLighting.hlsl | 4 ++++ .../ShaderLibrary/CommonMaterial.hlsl | 4 ++++ .../ShaderLibrary/EntityLighting.hlsl | 4 ++++ .../ShaderLibrary/ImageBasedLighting.hlsl | 4 ++++ com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl | 4 ++++ .../ShaderLibrary/Sampling/Fibonacci.hlsl | 4 ++++ .../ShaderLibrary/Sampling/Hammersley.hlsl | 4 ++++ .../ShaderLibrary/Sampling/Sampling.hlsl | 4 ++++ .../ShaderLibrary/SpaceTransforms.hlsl | 4 ++++ 13 files changed, 52 insertions(+) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl index 8329de1697e..c8923bb6f7b 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl @@ -1,7 +1,9 @@ #ifndef __ACES__ #define __ACES__ +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif /** * https://github.com/ampas/aces-dev @@ -1318,6 +1320,8 @@ half3 ODT_P3DCI_48nits(half3 oces) return outputCV; } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // __ACES__ diff --git a/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl index a059dbc82d0..72b831d61cd 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/BSDF.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_BSDF_INCLUDED #define UNITY_BSDF_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" @@ -640,6 +642,8 @@ real3 D_KajiyaKay(real3 T, real3 H, real specularExponent) return dirAttn * norm * PositivePow(sinTHSq, 0.5 * n); } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_BSDF_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl index 5d6f4556fc6..015d9893270 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_COLOR_INCLUDED #define UNITY_COLOR_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl" @@ -734,6 +736,8 @@ half3 DecodeRGBM(half4 rgbm) return rgbm.xyz * rgbm.w * kRGBMRange; } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_COLOR_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl index 970185ce0b2..ebd7569ef6e 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_COMMON_INCLUDED #define UNITY_COMMON_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif // Convention: @@ -1353,6 +1355,8 @@ float SharpenAlpha(float alpha, float alphaClipTreshold) // These clamping function to max of floating point 16 bit are use to prevent INF in code in case of extreme value TEMPLATE_1_REAL(ClampToFloat16Max, value, return min(value, HALF_MAX)) +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_COMMON_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl index eed1b01f74c..dfc73c49963 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_COMMON_LIGHTING_INCLUDED #define UNITY_COMMON_LIGHTING_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif // Ligthing convention // Light direction is oriented backward (-Z). i.e in shader code, light direction is -lightData.forward @@ -457,6 +459,8 @@ bool IsMatchingLightLayer(uint lightLayers, uint renderingLayers) return (lightLayers & renderingLayers) != 0; } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_COMMON_LIGHTING_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl index d341f789185..397e2ff537b 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_COMMON_MATERIAL_INCLUDED #define UNITY_COMMON_MATERIAL_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif //----------------------------------------------------------------------------- // Define constants @@ -332,6 +334,8 @@ real3 LerpWhiteTo(real3 b, real t) return real3(oneMinusT, oneMinusT, oneMinusT) + b * t; } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_COMMON_MATERIAL_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl index f78c1f48b7a..3510068309b 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_ENTITY_LIGHTING_INCLUDED #define UNITY_ENTITY_LIGHTING_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" @@ -367,6 +369,8 @@ real3 SampleDirectionalLightmap(TEXTURE2D_LIGHTMAP_PARAM(lightmapTex, lightmapSa return bakeDiffuseLighting; } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_ENTITY_LIGHTING_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl index bcacb705d20..48fe074f506 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/ImageBasedLighting.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_IMAGE_BASED_LIGHTING_INCLUDED #define UNITY_IMAGE_BASED_LIGHTING_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" @@ -740,6 +742,8 @@ float InfluenceFadeNormalWeight(float3 normal, float3 centerToPos) return saturate((-1.0f / 0.4f) * dot(normal, centerToPos) + (0.6f / 0.4f)); } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_IMAGE_BASED_LIGHTING_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl index a2f40bf2afe..bd297c3d7b4 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_PACKING_INCLUDED #define UNITY_PACKING_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif //----------------------------------------------------------------------------- // Normal packing @@ -583,6 +585,8 @@ float2 Unpack8ToFloat2(float f) return float2(x, y); } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_PACKING_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Fibonacci.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Fibonacci.hlsl index f07ea67c9a1..0fa2682f2af 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Fibonacci.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Fibonacci.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_FIBONACCI_INCLUDED #define UNITY_FIBONACCI_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif // Computes a point using the Fibonacci sequence of length N. // Input: Fib[N - 1], Fib[N - 2], and the index 'i' of the point. @@ -297,6 +299,8 @@ real2 SampleSphereFibonacci(uint i, uint sampleCount) return real2(1 - 2 * f.x, TWO_PI * f.y); } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_FIBONACCI_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Hammersley.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Hammersley.hlsl index 30b6274233a..56a60a4bc7f 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Hammersley.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Hammersley.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_HAMMERSLEY_INCLUDED #define UNITY_HAMMERSLEY_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif // Ref: http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html uint ReverseBits32(uint bits) @@ -422,6 +424,8 @@ real2 Hammersley2d(uint i, uint sampleCount) } } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_HAMMERSLEY_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Sampling.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Sampling.hlsl index 05c7f38a2e6..009e2b432ce 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Sampling.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Sampling.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_SAMPLING_INCLUDED #define UNITY_SAMPLING_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif //----------------------------------------------------------------------------- // Sample generator @@ -307,6 +309,8 @@ void SampleCone(real2 u, real cosHalfAngle, rcpPdf = TWO_PI * (1 - cosHalfAngle); } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif // UNITY_SAMPLING_INCLUDED diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index c695ead283e..52903b13e55 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -1,7 +1,9 @@ #ifndef UNITY_SPACE_TRANSFORMS_INCLUDED #define UNITY_SPACE_TRANSFORMS_INCLUDED +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (disable : 3205) // conversion of larger type to smaller +#endif // Caution: For HDRP, adding a function in this file requires adding the appropriate #define in PickingSpaceTransforms.hlsl @@ -238,6 +240,8 @@ real3 TransformObjectToTangent(real3 dirOS, real3x3 tangentToWorld) return TransformWorldToTangent(normalWS, tangentToWorld); } +#if SHADER_API_MOBILE || SHADER_API_GLES || SHADER_API_GLES3 #pragma warning (enable : 3205) // conversion of larger type to smaller +#endif #endif