Shader Compilation Pipeline, API Comparison, and Minimal Compiler Design
Context
Assume you are targeting modern discrete GPUs and common programmable stages (vertex, fragment/pixel, compute). Explain how shader source (HLSL/GLSL) becomes GPU-executable code and how different graphics APIs influence compilation artifacts and runtime usage.
Tasks
-
End-to-end shader compilation pipeline
-
From HLSL/GLSL source to GPU-executable code, cover:
-
Front-end: preprocessing, parsing, semantic analysis
-
Intermediate representations (IR): kinds, why they’re used
-
Optimization passes: typical and GPU-specific
-
Reflection metadata: what is captured and how it’s used
-
Back-end code generation: SPIR-V/DXIL/GLSL and driver JIT to GPU ISA
-
API comparison: DirectX-like vs Vulkan/OpenGL
-
Compare resource binding models
-
Compare command submission and synchronization
-
Compare pipeline state management and compilation artifacts
-
Minimal shader compiler design
-
Outline a minimal front end (language support, AST/IR, validation)
-
Outline a minimal back end (targets, code emission, validation, reflection)
-
Mention key trade-offs and pitfalls