Metal: GLSL shader compatibility changes for global uniform and interface name collision.

For the Metal shader translation support for shader-global uniforms are remapped via macro's, and in such cases where a uniform name matches a vertex attribute name, compilation errors will occur due to this injected syntax being incompatible with the immediate code.

Also adding source-level function interface alternatives where sized arrays are passed in. These are not supported directly in Metal shading language and are instead handled as pointers. These pointers require explicit address-space qualifiers in some cases, if device/constant address space memory is passed into the function.

Ref T96261

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D15898
This commit is contained in:
Jason Fielder
2022-09-22 17:52:44 +02:00
committed by Clément Foucault
parent 1514e1a5b7
commit 18b45aabf9
25 changed files with 75 additions and 54 deletions

View File

@@ -7,7 +7,7 @@ void main()
discard;
}
#endif
fragColor = interp.color;
fragColor = interp.final_color;
if (lineSmooth) {
fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(interp.smoothline), 0.0, 1.0);
}

View File

@@ -18,14 +18,14 @@ vec4 clip_line_point_homogeneous_space(vec4 p, vec4 q)
void do_vertex(const int i, vec4 pos, vec2 ofs)
{
#if defined(UNIFORM)
interp_out.color = color;
interp_out.final_color = color;
#elif defined(FLAT)
/* WATCH: Assuming last provoking vertex. */
interp_out.color = interp_in[1].color;
interp_out.final_color = interp_in[1].final_color;
#elif defined(SMOOTH)
interp_out.color = interp_in[i].color;
interp_out.final_color = interp_in[i].final_color;
#endif
#ifdef CLIP

View File

@@ -3,7 +3,7 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifndef UNIFORM
interp.color = color;
interp.final_color = color;
#endif
#ifdef CLIP
interp.clip = dot(ModelMatrix * vec4(pos, 1.0), ClipPlane);

View File

@@ -9,7 +9,7 @@
#include "gpu_shader_create_info.hh"
GPU_SHADER_INTERFACE_INFO(gpu_shader_3D_polyline_iface, "interp")
.smooth(Type::VEC4, "color")
.smooth(Type::VEC4, "final_color")
.smooth(Type::FLOAT, "clip")
.no_perspective(Type::FLOAT, "smoothline");