SwShaderRuntime.h file
C++ runtime library the GLSL-to-C++ transpiler (ShaderCompiler/GlslToCpp) targets.
The offline transpiler lowers a shader's fragment GLSL into a plain C++ function that the CPU software renderer calls once per pixel, so an effect runs in software exactly as its GLSL specifies instead of being hand-ported. That generated code is written against the small value types and free functions defined here: GLSL-shaped vec2/vec3/vec4 (plus minimal integer and boolean vectors), the arithmetic operators and the built-in functions the shader corpus uses, a swTexture() sampler shim over SwTexture and a packColor() writer to the rasterizer's RGBA8 output pixel.
Swizzle-access convention (chosen so the emitter never needs C++ lvalue swizzles):
- A single component is a plain field:
.x/.y/.z/.w, aliased through a union to.r/.g/.b/.aand.s/.t/.p/.q. Because it is a real member it works as both a read and a write target, so the emitter mapsv.xand an assignmentv.x = ...straight through. - A multi-component read swizzle (
v.rgb,v.xy) is a const method the emitter calls:v.rgb(),v.xy(). The base is evaluated once and a fresh vector is returned. Only the common/contiguous swizzles are provided here (see the file tail) — the full permutation set is a mechanical later completion. - A multi-component write swizzle (
v.xy = ...) is NOT supported; the emitter would have to decompose it into per-component field writes. No corpus shader needs it yet.