|
MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
|
GLSL type and function spellings made valid as C++. More...
#include <glm/glm.hpp>#include <cstdint>
Include dependency graph for ShaderCompat.hpp:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Namespaces | |
| namespace | MayaFlux |
| Main namespace for the Maya Flux audio engine. | |
| namespace | MayaFlux::ShaderCompat |
Typedefs | |
| using | MayaFlux::ShaderCompat::ivec2 = glm::ivec2 |
| using | MayaFlux::ShaderCompat::ivec3 = glm::ivec3 |
| using | MayaFlux::ShaderCompat::mat3 = glm::mat3 |
| using | MayaFlux::ShaderCompat::mat4 = glm::mat4 |
| using | MayaFlux::ShaderCompat::uint = std::uint32_t |
| using | MayaFlux::ShaderCompat::uvec3 = glm::uvec3 |
| using | MayaFlux::ShaderCompat::vec2 = glm::vec2 |
| using | MayaFlux::ShaderCompat::vec3 = glm::vec3 |
| using | MayaFlux::ShaderCompat::vec4 = glm::vec4 |
GLSL type and function spellings made valid as C++.
A dual-source field body is authored once and compiled twice: by the host compiler into a callable, and by shaderc into SPIR-V. GLSL has no namespace qualification, so the body must be written unqualified, and this header makes unqualified lookup succeed on the host side.
Nothing is reimplemented. glm already mirrors the GLSL function set. Vector arguments would resolve through ADL without any declaration here, since a glm::vec3 argument brings namespace glm into the lookup set. Scalar arguments would not: a float has no associated namespace. The declarations below are therefore load-bearing for expressions such as clamp(d, 0.0f, 1.0f) and max(d * d, 0.1f), and the type aliases are load-bearing because vec3 and uint have no glm spelling that is also GLSL.
Authoring rules for any body that must survive both compilers:
Opening this namespace alongside using namespace std produces ambiguity on max, min and abs. Keep the directive scoped to the namespace where fields are authored.
Verified against glslangValidator -S comp and g++ -std=c++20 for radial attraction, cross-product swirl, sphere distance, smoothstep falloff, a four-iteration accumulation loop, and a ternary-guarded normalisation.
Definition in file ShaderCompat.hpp.