diff options
author | Jason Fielder <jason_apple> | 2022-03-30 20:47:59 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-03-30 20:53:22 +0300 |
commit | 49bc640b76c77a19e523cd1843585a0c6b21e82f (patch) | |
tree | c3446aaa594ac467a76a2e5af5dd86ba886b4aba /source/blender/gpu/shaders | |
parent | 7c9e128bbfb37d70799f8867d93992ee3f522242 (diff) |
Metal: GLSL Shader compatibility 5
MSL does not have an implicit global scope, this is emulated via macro's adding an indirection for uniforms, attributes, shader stage inputs and outputs such as:
#define roughness shaderinst->roughness.
Variables in GLSL which exist within uniform blocks can be directly referenced via the global scope, unlike standard C++. This means that variable name pollution occurs if subsequent local variables in the code use the same name, resulting in compilation errors.
A number of these conflicting names have been renamed to ensure unique naming and no further scope pollution.
Ref T96261
Reviewed By: fclem
Maniphest Tasks: T96261
Differential Revision: https://developer.blender.org/D14452
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl | 14 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl | 8 |
2 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl index cdc716db7a4..3edf0e31799 100644 --- a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl @@ -7,13 +7,13 @@ uniform vec4 WorldClipPlanes[6]; # define _world_clip_planes_calc_clip_distance(wpos, _clipplanes) \ { \ - vec4 pos = vec4(wpos, 1.0); \ - gl_ClipDistance[0] = dot(_clipplanes[0], pos); \ - gl_ClipDistance[1] = dot(_clipplanes[1], pos); \ - gl_ClipDistance[2] = dot(_clipplanes[2], pos); \ - gl_ClipDistance[3] = dot(_clipplanes[3], pos); \ - gl_ClipDistance[4] = dot(_clipplanes[4], pos); \ - gl_ClipDistance[5] = dot(_clipplanes[5], pos); \ + vec4 _pos = vec4(wpos, 1.0); \ + gl_ClipDistance[0] = dot(_clipplanes[0], _pos); \ + gl_ClipDistance[1] = dot(_clipplanes[1], _pos); \ + gl_ClipDistance[2] = dot(_clipplanes[2], _pos); \ + gl_ClipDistance[3] = dot(_clipplanes[3], _pos); \ + gl_ClipDistance[4] = dot(_clipplanes[4], _pos); \ + gl_ClipDistance[5] = dot(_clipplanes[5], _pos); \ } /* When all shaders are builtin shaders are migrated this could be applied directly. */ diff --git a/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl b/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl index 7d69cba5017..abd4592dc9d 100644 --- a/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl @@ -6,13 +6,13 @@ uniform bool srgbTarget = false; #endif -vec4 blender_srgb_to_framebuffer_space(vec4 col) +vec4 blender_srgb_to_framebuffer_space(vec4 in_color) { if (srgbTarget) { - vec3 c = max(col.rgb, vec3(0.0)); + vec3 c = max(in_color.rgb, vec3(0.0)); vec3 c1 = c * (1.0 / 12.92); vec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4)); - col.rgb = mix(c1, c2, step(vec3(0.04045), c)); + in_color.rgb = mix(c1, c2, step(vec3(0.04045), c)); } - return col; + return in_color; } |