HlslEmitter class
#include <Utilities/ShaderCompiler/Hlsl.h>
Transforms an already-lowered modern-GLSL stage source into HLSL (Shader Model 4/5).
Public types
Public static functions
-
static auto Transform(StringView modernSource,
bool vertexStage,
const StageReflection& reflection,
String& out,
Diagnostic& diag,
Dialect dialect = Dialect::Hlsl,
std::
int32_t maxBatchSize = 0) -> bool
Enum documentation
enum class ShaderCompiler:: HlslEmitter:: Dialect
Which member of the HLSL/Cg dialect family to emit.
Cg targets the PS Vita's sceGxm backend, whose shaders are compiled on the console by SceShaccCg. It is the same language family - floatN, mul(), lerp/frac/ddx and TEXCOORD<i> interpolant semantics are shared, which is why it lives here instead of in an emitter of its own - and differs only in the places listed below:
- Entry points are both named
main(VSMain/PSMainin HLSL) - System semantics:
POSITIONfor the clip position,WPOSfor the fragment position andCOLORfor the colour output, instead ofSV_Position/SV_Target - Uniforms are plain
uniformdeclarations (there is nocbuffer); the samplers are combinedsampler2D/sampler3Dobjects carrying the GXMTEXUNIT<n>semantic, sampled withtex2D()/tex2Dlod()instead ofTexture2D+SamplerState+.Sample() - There is no vertex-ID or instance-ID input at all - the GXM parameter semantics are the fixed-function-era Cg set - so a stage still referencing
gl_VertexID/gl_InstanceIDafter VertexIdRewrite has run is rejected with a diagnostic rather than mis-emitted
Function documentation
static bool ShaderCompiler:: HlslEmitter:: Transform(StringView modernSource,
bool vertexStage,
const StageReflection& reflection,
String& out,
Diagnostic& diag,
Dialect dialect = Dialect::Hlsl,
std:: int32_t maxBatchSize = 0)
Transforms modernSource (as produced by ShaderParser::BuildStageSource) into HLSL, writing the result to out. vertexStage selects the vertex-vs-fragment lowering; reflection supplies texture-unit register assignments and the batched instance-block stride (for the emitted array size). Returns false and fills diag when the source uses a construct the emitter does not handle.
maxBatchSize caps the BATCH_SIZE baked into a batched shader. Zero, the default, means the only bound is the 64 KB uniform block the desktop and Vita tiers have. The PlayStation 3 needs a far smaller one: its batched instance array reaches the vertex program through constant registers rather than a bindable buffer, so --emit-rsx passes the batch its backend supports.