diff options
author | Jason Fielder <jason_apple> | 2022-09-22 18:52:44 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-09-22 18:53:56 +0300 |
commit | 18b45aabf91ad0a407e8c7cd16c5503e7a99d6fa (patch) | |
tree | c4b5a1db3ec5bab9f1d9f1038d131f398046506a /source/blender/draw/intern | |
parent | 1514e1a5b7e15ec0c11cd40c2b9389982bd5d00e (diff) |
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
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/shaders/common_smaa_lib.glsl | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/source/blender/draw/intern/shaders/common_smaa_lib.glsl b/source/blender/draw/intern/shaders/common_smaa_lib.glsl index dbc4c998b34..0c040c9acfe 100644 --- a/source/blender/draw/intern/shaders/common_smaa_lib.glsl +++ b/source/blender/draw/intern/shaders/common_smaa_lib.glsl @@ -588,15 +588,18 @@ SamplerState PointSampler # else # define mad(a, b, c) (a * b + c) # endif -# define float2 vec2 -# define float3 vec3 -# define float4 vec4 -# define int2 ivec2 -# define int3 ivec3 -# define int4 ivec4 -# define bool2 bvec2 -# define bool3 bvec3 -# define bool4 bvec4 +/* NOTE(Metal): Types already natively declared in MSL. */ +# ifndef GPU_METAL +# define float2 vec2 +# define float3 vec3 +# define float4 vec4 +# define int2 ivec2 +# define int3 ivec3 +# define int4 ivec4 +# define bool2 bvec2 +# define bool3 bvec3 +# define bool4 bvec4 +# endif #endif /* clang-format off */ @@ -658,7 +661,14 @@ void SMAAMovc(bool4 cond, inout float4 variable, float4 value) /** * Edge Detection Vertex Shader */ +# ifdef GPU_METAL +/* NOTE: Metal API requires explicit address space qualifiers for pointer types. + * Arrays in functions are passed as pointers, and thus require explicit address + * space. */ +void SMAAEdgeDetectionVS(float2 texcoord, thread float4 *offset) +# else void SMAAEdgeDetectionVS(float2 texcoord, out float4 offset[3]) +# endif { offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-1.0, 0.0, 0.0, -1.0), texcoord.xyxy); offset[1] = mad(SMAA_RT_METRICS.xyxy, float4(1.0, 0.0, 0.0, 1.0), texcoord.xyxy); @@ -668,7 +678,16 @@ void SMAAEdgeDetectionVS(float2 texcoord, out float4 offset[3]) /** * Blend Weight Calculation Vertex Shader */ +# ifdef GPU_METAL +/* NOTE: Metal API requires explicit address space qualifiers for pointer types. + * Arrays in functions are passed as pointers, and thus require explicit address + * space. */ +void SMAABlendingWeightCalculationVS(float2 texcoord, + thread float2 &pixcoord, + thread float4 *offset) +# else void SMAABlendingWeightCalculationVS(float2 texcoord, out float2 pixcoord, out float4 offset[3]) +# endif { pixcoord = texcoord * SMAA_RT_METRICS.zw; |