diff options
author | Jason Fielder <jason_apple> | 2022-03-22 14:44:26 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-03-22 14:54:44 +0300 |
commit | 19c793af35ea8e694c16995d115d7c9247fee81a (patch) | |
tree | c24ad1eead6cb91cbc6260a10e8cf13dc13db903 /source/blender/gpu/opengl/gl_shader.cc | |
parent | 309ea314858a9b7892ea2c8a6fe55ab2a1028697 (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/opengl/gl_shader.cc')
-rw-r--r-- | source/blender/gpu/opengl/gl_shader.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index c0182306047..c76e21f9f71 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -24,6 +24,8 @@ using namespace blender; using namespace blender::gpu; using namespace blender::gpu::shader; +extern char datatoc_glsl_shader_defines_glsl[]; + /* -------------------------------------------------------------------- */ /** \name Creation / Destruction * \{ */ @@ -760,7 +762,7 @@ bool GLShader::do_geometry_shader_injection(const shader::ShaderCreateInfo *info static char *glsl_patch_default_get() { /** Used for shader patching. Init once. */ - static char patch[1024] = "\0"; + static char patch[2048] = "\0"; if (patch[0] != '\0') { return patch; } @@ -827,6 +829,9 @@ static char *glsl_patch_default_get() STR_CONCATF(patch, slen, "#define DFDX_SIGN %1.1f\n", GLContext::derivative_signs[0]); STR_CONCATF(patch, slen, "#define DFDY_SIGN %1.1f\n", GLContext::derivative_signs[1]); + /* GLSL Backend Lib. */ + STR_CONCAT(patch, slen, datatoc_glsl_shader_defines_glsl); + BLI_assert(slen < sizeof(patch)); return patch; } |