diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-12-05 04:15:06 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-12-05 04:51:48 +0300 |
commit | 354b1c162a03617a8d73d9954be4079ba0c31077 (patch) | |
tree | 8b5b4c66e4f9fb11f46717bfa6b1f5b17c5ec8a3 /source/blender/draw | |
parent | b5ebdb09af57af60ad1b19b1eeaef84a9e886a75 (diff) |
Fix T58733: Segmentation fault at start causes by shader compillation
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl index 7aa41e1a537..1b9b29b8ca2 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl @@ -53,17 +53,17 @@ WB_Normal workbench_normal_encode(vec3 n) #endif /* WORKBENCH_ENCODE_NORMALS */ /* Encoding into the alpha of a RGBA8 UNORM texture. */ -#define TARGET_BITCOUNT 8 -#define METALLIC_BITS 3 /* Metallic channel is less important. */ +#define TARGET_BITCOUNT 8u +#define METALLIC_BITS 3u /* Metallic channel is less important. */ #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) #define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS) /* Encode 2 float into 1 with the desired precision. */ float workbench_float_pair_encode(float v1, float v2) { - const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); - const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); - const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); + const uint total_mask = ~(0xFFFFFFFFu << TOTAL_BITS); + const uint v1_mask = ~(0xFFFFFFFFu << ROUGHNESS_BITS); + const uint v2_mask = ~(0xFFFFFFFFu << METALLIC_BITS); int iv1 = int(v1 * float(v1_mask)); int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS; return float(iv1 | iv2) * (1.0 / float(total_mask)); @@ -71,10 +71,10 @@ float workbench_float_pair_encode(float v1, float v2) void workbench_float_pair_decode(float data, out float v1, out float v2) { - const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); - const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); - const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); - int idata = int(data * float(total_mask)); + const uint total_mask = ~(0xFFFFFFFFu << TOTAL_BITS); + const uint v1_mask = ~(0xFFFFFFFFu << ROUGHNESS_BITS); + const uint v2_mask = ~(0xFFFFFFFFu << METALLIC_BITS); + uint idata = uint(data * float(total_mask)); v1 = float(idata & v1_mask) * (1.0 / float(v1_mask)); v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask)); } |