Q100409: How to migrate older Custom Shaders into Mari 4.1v1 or newer by using MARI_VERSION

Follow

SYMPTOMS

In 3.4v1/4.1v1 versions of Mari and later, some user-created Custom Shaders may encounter the following compile error:

0(2754) : error C7011: implicit cast from "uvec4" to "uvec2"

This article explains why you may be seeing the error and how you, as a developer, can adjust your Custom Shaders to work around this issue and ensure your Shader files can be used across Mari versions.

 

 

CAUSE

Starting in 3.4v1/4.1v1, we have extended the texture token system in Mari to use uvec4. 

Previous version of Mari used uvec2 which means that some Custom GLSL Shaders written for uvec2, may be failing due to the texture token changes from uvec2 to uvec4.

Unfortunately, we did not have a way of defining the texture token version change between Mari 3.3v1/3.4v1 and Mari 4.0x/4.1x (and later versions), and the above error will be displayed when such shaders fail to be interpreted in the newer Mari versions. 

 

 

RESOLUTION

In Mari 3.4v1/4.1v1, we have introduced a new MARI_VERSION define option within the GLSL code, in order to workaround the issue. This update allows the user to maintain a single code base for their Custom Shaders, without the need to duplicate their shader code between versions of Mari.

This can be implemented in the user's Shader, as below, where:

  • M - representative of a major version number
  • mm - minor version number filled with 0
  • RR - release number filled with 0


For example:

#if (MARI_VERSION >= MmmRR) 
// This code is compiled only on Mari M.mmvRR or newer.
...
#endif
To apply this practically in Mari 3.4v1, the code would need to be defined within the Shader file as the following:
#if (MARI_VERSION >= 30401)
// This code is compiled only on Mari 3.4v1 or newer.
#endif


To apply this practically in Mari 4.1v1, the code would need to be defined within the Shader file as the following: 

#if (MARI_VERSION >= 40101)
// This code is compiled only on Mari 4.1v1 or newer.
#endif

 

 

FURTHER HELP

If you are experiencing difficulties please create a support ticket and provide us with the information requested in this article:
Q100090: Information to send Support when reporting a Mari issue

For more information on how to open a Support ticket, please refer to this article:
Q100064: How to raise a support ticket

    We're sorry to hear that

    Please tell us why