[Bf-blender-cvs] [0ba5954bb27] master: Fix T103635: Fix failing EEVEE and OCIO shader compilations in Metal.

Jason Fielder noreply at git.blender.org
Mon Jan 23 17:40:25 CET 2023


Commit: 0ba5954bb27b4fee5d0ed1a14feb91118b6f3fad
Author: Jason Fielder
Date:   Mon Jan 23 17:32:22 2023 +0100
Branches: master
https://developer.blender.org/rB0ba5954bb27b4fee5d0ed1a14feb91118b6f3fad

Fix T103635: Fix failing EEVEE and OCIO shader compilations in Metal.

Affecting render output preview when tone mapping is used, and EEVEE scenes such as Mr Elephant rendering in pink due to missing shaders.

Authored by Apple: Michael Parkin-White

Ref T103635
Ref T96261

Reviewed By: fclem

Maniphest Tasks: T103635, T96261

Differential Revision: https://developer.blender.org/D16923

===================================================================

M	source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl
M	source/blender/gpu/shaders/metal/mtl_shader_defines.msl

===================================================================

diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl
index 33108d3a989..9e8a40fa41a 100644
--- a/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl
+++ b/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl
@@ -146,7 +146,7 @@ void ycca_to_rgba_itu_601(vec4 ycca, out vec4 color)
 {
   ycca.xyz *= 255.0;
   ycca.xyz -= vec3(16.0, 128.0, 128.0);
-  color.rgb = mat3(vec3(1.164), 0.0, -0.392, 2.017, 1.596, -0.813, 0.0) * ycca.xyz;
+  color.rgb = mat3(1.164, 1.164, 1.164, 0.0, -0.392, 2.017, 1.596, -0.813, 0.0) * ycca.xyz;
   color.rgb /= 255.0;
   color.a = ycca.a;
 }
@@ -155,7 +155,7 @@ void ycca_to_rgba_itu_709(vec4 ycca, out vec4 color)
 {
   ycca.xyz *= 255.0;
   ycca.xyz -= vec3(16.0, 128.0, 128.0);
-  color.rgb = mat3(vec3(1.164), 0.0, -0.213, 2.115, 1.793, -0.534, 0.0) * ycca.xyz;
+  color.rgb = mat3(1.164, 1.164, 1.164, 0.0, -0.213, 2.115, 1.793, -0.534, 0.0) * ycca.xyz;
   color.rgb /= 255.0;
   color.a = ycca.a;
 }
@@ -163,7 +163,7 @@ void ycca_to_rgba_itu_709(vec4 ycca, out vec4 color)
 void ycca_to_rgba_jpeg(vec4 ycca, out vec4 color)
 {
   ycca.xyz *= 255.0;
-  color.rgb = mat3(vec3(1.0), 0.0, -0.34414, 1.772, 1.402, -0.71414, 0.0) * ycca.xyz;
+  color.rgb = mat3(1.0, 1.0, 1.0, 0.0, -0.34414, 1.772, 1.402, -0.71414, 0.0) * ycca.xyz;
   color.rgb += vec3(-179.456, 135.45984, -226.816);
   color.rgb /= 255.0;
   color.a = ycca.a;
@@ -203,7 +203,7 @@ void rgba_to_ycca_jpeg(vec4 rgba, out vec4 ycca)
 
 void yuva_to_rgba_itu_709(vec4 yuva, out vec4 color)
 {
-  color.rgb = mat3(vec3(1.0), 0.0, -0.21482, 2.12798, 1.28033, -0.38059, 0.0) * yuva.xyz;
+  color.rgb = mat3(1.0, 1.0, 1.0, 0.0, -0.21482, 2.12798, 1.28033, -0.38059, 0.0) * yuva.xyz;
   color.a = yuva.a;
 }
 
diff --git a/source/blender/gpu/shaders/metal/mtl_shader_defines.msl b/source/blender/gpu/shaders/metal/mtl_shader_defines.msl
index f1a8af63d72..69202a7a70e 100644
--- a/source/blender/gpu/shaders/metal/mtl_shader_defines.msl
+++ b/source/blender/gpu/shaders/metal/mtl_shader_defines.msl
@@ -210,7 +210,7 @@ template<typename S, typename T, access A>
 inline vec<S, 4> _texelFetch_internal(thread _mtl_combined_image_sampler_1d<S, A> tex,
                                       T texel,
                                       uint lod,
-                                      T offset = 0)
+                                      T offset)
 {
   float w = tex.texture->get_width();
   if ((texel + offset) >= 0 && (texel + offset) < w) {
@@ -222,38 +222,6 @@ inline vec<S, 4> _texelFetch_internal(thread _mtl_combined_image_sampler_1d<S, A
   }
 }
 
-template<typename S, typename T, access A>
-inline vec<S, 4> _texelFetch_internal(thread _mtl_combined_image_sampler_1d<S, A> tex,
-                                      vec<T, 1> texel,
-                                      uint lod,
-                                      vec<T, 1> offset = 0)
-{
-  float w = tex.texture->get_width();
-  if ((texel + offset) >= 0 && (texel + offset) < w) {
-    /* LODs not supported for 1d textures. This must be zero. */
-    return tex.texture->read(uint(texel + offset), 0);
-  }
-  else {
-    return vec<S, 4>(0);
-  }
-}
-
-template<typename S, typename T, int n, access A>
-inline vec<S, 4> _texelFetch_internal(thread _mtl_combined_image_sampler_1d<S, A> tex,
-                                      vec<T, n> texel,
-                                      uint lod,
-                                      vec<T, n> offset = vec<T, n>(0))
-{
-  float w = tex.texture->get_width();
-  if ((texel.x + offset.x) >= 0 && (texel.x + offset.x) < w) {
-    /* LODs not supported for 1d textures. This must be zero. */
-    return tex.texture->read(uint(texel.x + offset.x), 0);
-  }
-  else {
-    return vec<S, 4>(0);
-  }
-}
-
 template<typename S, typename T, access A>
 inline vec<S, 4> _texelFetch_internal(thread _mtl_combined_image_sampler_1d_array<S, A> tex,
                                       vec<T, 2> texel,
@@ -1236,8 +1204,7 @@ mat3 MAT3x3(
 {
   return mat3(vec3(a1, a2, a3), vec3(b1, b2, b3), vec3(c1, c2, c3));
 }
-mat3 MAT3x3(
-    vec3 a, float b1, float b2, float b3, float c1, float c2, float c3)
+mat3 MAT3x3(vec3 a, float b1, float b2, float b3, float c1, float c2, float c3)
 {
   return mat3(a, vec3(b1, b2, b3), vec3(c1, c2, c3));
 }



More information about the Bf-blender-cvs mailing list