Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Fielder <jason_apple>2022-03-22 14:44:26 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-03-22 14:54:44 +0300
commit19c793af35ea8e694c16995d115d7c9247fee81a (patch)
treec24ad1eead6cb91cbc6260a10e8cf13dc13db903 /source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
parent309ea314858a9b7892ea2c8a6fe55ab2a1028697 (diff)
Metal: Make GLSL shader source MSL compliant also
Metal shading language follows the C++ 14 standard and in some cases requires a greater level of explicitness than GLSL. There are also some small language differences: - Explicit type-casts (C++ requirements) - Explicit constant values (C++ requirements, e.g. floating point values using 0.0 instead of 0). - Metal/OpenGL compatibility paths - GLSL Function prototypes - Explicit accessors for vector types when sampling textures. Authored by Apple: Michael Parkin-White Ref T96261 Reviewed By: fclem Maniphest Tasks: T96261 Differential Revision: https://developer.blender.org/D14378
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
index d9a5aeeef46..903c602c5d6 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl
@@ -15,6 +15,32 @@ void main()
{
vec2 uv;
vec2 co;
+
+#ifdef GPU_METAL
+/* Metal API does not support Triangle fan primitive topology.
+ * When this shader is called using Triangle-Strip, vertex ID's
+ * are in a different order. */
+# define GPU_PRIM_TRI_STRIP
+#endif
+
+#ifdef GPU_PRIM_TRI_STRIP
+ if (gl_VertexID == 0) {
+ co = rect_geom.xw;
+ uv = rect_icon.xw;
+ }
+ else if (gl_VertexID == 1) {
+ co = rect_geom.xy;
+ uv = rect_icon.xy;
+ }
+ else if (gl_VertexID == 2) {
+ co = rect_geom.zw;
+ uv = rect_icon.zw;
+ }
+ else {
+ co = rect_geom.zy;
+ uv = rect_icon.zy;
+ }
+#else
if (gl_VertexID == 0) {
co = rect_geom.xy;
uv = rect_icon.xy;
@@ -31,6 +57,7 @@ void main()
co = rect_geom.zy;
uv = rect_icon.zy;
}
+#endif
gl_Position = ModelViewProjectionMatrix * vec4(co, 0.0f, 1.0f);
texCoord_interp = uv;