Class MonoGameGlslRewriter
- Namespace
- ShadowDusk.GLSL
- Assembly
- ShadowDusk.GLSL.dll
Rewrites the modern GLSL that SPIRV-Cross emits (#version 140,
in/out, in_var_TEXCOORD0, texture(), a named UBO)
into the legacy MojoShader dialect that MonoGame's OpenGL runtime expects
(legacy varying names, gl_FragColor, texture2D(),
ps_uniforms_vec4[]). This is a pure string transform with no external
dependencies.
public static class MonoGameGlslRewriter
- Inheritance
-
MonoGameGlslRewriter
- Inherited Members
Methods
Rewrite(string, ShaderStage, IReadOnlyList<int>?)
Rewrites SPIRV-Cross GLSL into the MonoGame/MojoShader dialect for the given stage.
public static MonoGameGlslResult Rewrite(string glsl, ShaderStage stage, IReadOnlyList<int>? samplerSlots = null)
Parameters
glslstringThe modern GLSL emitted by SPIRV-Cross.
stageShaderStageThe shader stage being rewritten (vertex or pixel).
samplerSlotsIReadOnlyList<int>The GL texture unit each sampler declaration must be numbered with, indexed by the order SPIRV-Cross declares the combined samplers. Supplying it is what makes the emitted
ps_s{N}follow the shader'sregister(sN)/ declaration order the way fxc (and therefore mgfxc) allocates, rather than SPIRV-Cross's first-use numbering (GitHub issue #189). When null — or shorter than the number of samplers found — the positional fallback applies, which is correct precisely when the two orders coincide.
Returns
- MonoGameGlslResult
The rewritten GLSL together with the discovered samplers, uniform register count, and (for the vertex stage) vertex attributes.
Exceptions
- MonoGameGlslRewriteException
Thrown when the input GLSL cannot be rewritten faithfully into the dialect.