Current API#
YotsubaShaderCross exposes Parser, CompilerGLSL, CompilerHLSL, CompilerMSL, and reflection APIs. There is no YotsubaShader.Transpile namespace or Transpile.FromSpirVTo* wrapper in this checkout.
using System;
using System.IO;
using YotsubaShaderCross;
byte[] bytes = File.ReadAllBytes("shader.spv");
if (bytes.Length % sizeof(uint) != 0)
throw new InvalidDataException("SPIR-V must contain complete 32-bit words.");
uint[] words = new uint[bytes.Length / sizeof(uint)];
Buffer.BlockCopy(bytes, 0, words, 0, bytes.Length);
var parser = new Parser(new CppVector<uint>(words));
parser.parse();
var glsl = new CompilerGLSL(parser.get_parsed_ir());
CompilerGLSL.Options options = glsl.get_common_options();
options.version = 450;
options.es = false;
glsl.set_common_options(options);
string source = glsl.compile().str();
For GLSL ES, set options.es = true and choose an appropriate version, such as 300. For HLSL or MSL, use their compiler classes and backend-specific options. The result is source text; the target graphics toolchain still compiles that text.
WGSL emission is planned for 2027 and has no implemented compiler class. CompilerCSHARP exists as a stub whose constructors throw NotImplementedException. Neither is a usable conversion path today.
The translated library targets .NET 8. Managed code alone does not establish compatibility with every console, browser, AOT environment, or GPU driver; validate your intended platform separately.
