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
This commit is contained in:
Jason Fielder 2023-01-23 17:32:22 +01:00 committed by Clément Foucault
parent 8e56ded86d
commit 0ba5954bb2
Notes: blender-bot 2023-02-14 06:37:09 +01:00
Referenced by issue #103635, Metal backend shows everything in pink
Referenced by issue #96261, Metal Viewport
2 changed files with 6 additions and 39 deletions

View File

@ -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;
}

View File

@ -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));
}