Appendices
Syntax cheat sheet, keywords, intrinsic & method quick reference, version history, learning resources and suggested study plan (12 weeks).
Appendices
45.1 Syntax cheat sheet AppendStructuredBuffer asm bool break Buffer ByteAddressBuffer case cbuffer centroid class column_major compile const ConstantBuffer ConsumeStructuredBuffer continue default discard do double else export extern false float for groupshared half if in inline inout InputPatch int interface line lineadj linear LineStream matrix min16float min10float min16int min12int min16uint namespace nointerpolation noperspective NULL out OutputPatch packoffset pass point PointStream precise RasterizerOrderedBuffer RasterizerOrderedTexture2D register return row_major RWBuffer RWByteAddressBuffer RWStructuredBuffer RWTexture1D RWTexture2D RWTexture3D sample sampler SamplerState SamplerComparisonState shared snorm static StructuredBuffer struct switch technique technique10 technique11 template Texture1D Texture2D Texture2DMS Texture3D TextureCube TextureCubeArray triangle triangleadj TriangleStream true typedef uint uniform unorm unsigned vector void volatile while
Mesh/RT/work-graph additions: vertices indices primitives payload RayDesc RayQuery RaytracingAccelerationStructure BuiltInTriangleIntersectionAttributes NodeOutput DispatchNodeInputRecord ThreadNodeInputRecord GroupNodeInputRecords. Common attributes: [numthreads] [unroll] [loop] [branch] [flatten] [earlydepthstencil] [maxvertexcount] [instance] [domain] [partitioning] [outputtopology] [outputcontrolpoints] [patchconstantfunc] [maxtessfactor] [shader("...")] [RootSignature] [WaveSize] [NodeLaunch] [[vk::binding]] [[vk::push_constant]].
45.3 Intrinsic & method quick reference sin cos tan asin acos atan atan2 sinh cosh tanh sincos radians degrees
pow exp exp2 log log2 log10 sqrt rsqrt rcp abs sign floor ceil round trunc frac fmod modf min max clamp saturate lerp step smoothstep mad fma isnan isinf isfinite frexp ldexp
dot cross length distance normalize reflect refract faceforward
mul transpose determinant (no inverse) Logical (2021) all any and or select
countbits firstbithigh firstbitlow reversebits asfloat asint asuint asdouble f16tof32 f32tof16 pack_u8 pack_s8 pack_clamp_u8 unpack_u8u32 dot4add_u8packed dot4add_i8packed dot2add
Sample SampleLevel SampleBias SampleGrad SampleCmp SampleCmpLevelZero SampleCmpLevel Load Gather GatherRed/Green/Blue/Alpha GatherCmp GetDimensions CalculateLevelOfDetail operator[]
Load Load2 Load3 Load4 Load<T> Store Store2 Store3 Store4 GetDimensions Append Consume IncrementCounter DecrementCounter
ddx ddy ddx_coarse ddy_coarse ddx_fine ddy_fine fwidth clip discard EvaluateAttributeAtSample EvaluateAttributeAtCentroid EvaluateAttributeSnapped GetAttributeAtVertex IsHelperLane GetRenderTargetSampleCount
GroupMemoryBarrier GroupMemoryBarrierWithGroupSync DeviceMemoryBarrier DeviceMemoryBarrierWithGroupSync AllMemoryBarrier AllMemoryBarrierWithGroupSync
InterlockedAdd InterlockedMin InterlockedMax InterlockedAnd InterlockedOr InterlockedXor InterlockedExchange InterlockedCompareExchange InterlockedCompareStore (+ 64-bit and float-bitwise variants)
WaveGetLaneCount WaveGetLaneIndex WaveIsFirstLane WaveActiveAnyTrue WaveActiveAllTrue WaveActiveBallot WaveReadLaneFirst WaveReadLaneAt WaveActiveSum/Product/Min/Max/BitAnd/BitOr/BitXor WaveActiveCountBits WaveActiveAllEqual WavePrefixSum/Product/CountBits WaveMatch WaveMultiPrefix* QuadReadAcrossX/Y/Diagonal QuadReadLaneAt QuadAny QuadAll
Append RestartStrip SetMeshOutputCounts DispatchMesh TraceRay ReportHit IgnoreHit AcceptHitAndEndSearch CallShader DispatchRaysIndex DispatchRaysDimensions WorldRayOrigin WorldRayDirection ObjectRayOrigin ObjectRayDirection RayTMin RayTCurrent RayFlags InstanceIndex InstanceID GeometryIndex PrimitiveIndex HitKind ObjectToWorld3x4 WorldToObject3x4
TraceRayInline Proceed Abort CandidateType CommitNonOpaqueTriangleHit CommitProceduralPrimitiveHit CommittedStatus CommittedRayT CommittedTriangleBarycentrics CommittedPrimitiveIndex CommittedInstanceIndex
Get Count GetThreadNodeOutputRecords GetGroupNodeOutputRecords OutputComplete IsValid 45.4 Version history HLSL introduced; vs/ps 2.0 SM 3.0 (DX9.0c) dynamic branching, vertex texture fetch geometry shaders, cbuffers, resource objects, integers, SV_ semantics SM 4.1 (DX10.1) cube arrays, Gather tessellation, compute, UAVs, structured buffers, atomics register spaces, descriptor arrays, HLSL root signatures
DXIL, wave intrinsics, 64-bit ints, open-source compiler SV_ViewID, SV_Barycentrics 16-bit types, denorm control DXR 1.0 libraries packed dot products, VRS mesh/amplification shaders, DXR 1.1 RayQuery, sampler feedback, WaveMatch
ResourceDescriptorHeap, 64-bit atomics, WaveSize, compute derivatives templates, operator overloading, bitfields; default in DXC 1.7 advanced texture ops, writable MSAA, quad any/all work graphs, start vertex/instance location, comparison bias/grad, WaveSize ranges long vectors, Shader Execution Reordering, opacity micromaps 45.5 Learning resources Official documentation:
Microsoft Learn: *HLSL reference* and *Programming guide for HLSL* (learn.microsoft.com, Direct3D section)
DirectX-Specs (microsoft.github.io/DirectX-Specs) — shader model, DXR, mesh shader, work graph specs
DirectXShaderCompiler wiki & SPIR-V docs (github.com/microsoft/DirectXShaderCompiler)
DirectX Developer Blog (devblogs.microsoft.com/directx) — feature announcements, Agility SDK releases
*DirectX-Graphics-Samples* (D3D12 samples incl. HelloTriangle, mesh shaders, DXR, work graphs) Online (free):
*GPU Gems* 1–3 (free on NVIDIA Developer); *Ray Tracing Gems* I & II (free PDFs)
*LearnOpenGL* (concepts transfer directly to HLSL), Inigo Quilez's articles, Shadertoy
*Catlike Coding* (Unity shader tutorials), Ben Golus's articles, Cyanilux's URP guides
*A trip through the Graphics Pipeline* — Fabian Giesen; Jendrik Illner's *Graphics Programming Weekly*
AMD GPUOpen and NVIDIA developer blogs (wave intrinsics, mesh shaders, occupancy)
*Introduction to 3D Game Programming with DirectX 12* — Frank D. Luna (HLSL throughout)
*Introduction to 3D Game Programming with DirectX 11* — Frank D. Luna
*Practical Rendering and Computation with Direct3D 11* — Zink, Pettineo, Hoxley
*Real-Time Rendering* (4th ed.) — Akenine-Möller, Haines, Hoffman et al.
*Physically Based Rendering* (4th ed., free online) — Pharr, Jakob, Humphreys
*Practical Shader Development* — Kyle Halladay (HLSL & GLSL, Unity)
*Unity Shaders and Effects Cookbook* / *The Unity Shaders Bible* — Jos Dickinson / Fabrizio Espíndola *GPU Pro / GPU Zen* series
Community: DirectX Discord, Graphics Programming Discord, r/GraphicsProgramming, r/directx, Unity and Unreal forums, SIGGRAPH courses (*Advances in Real-Time Rendering*, *Physically Based Shading*).
45.6 Suggested study plan (12 weeks) HLSL overview, shader models, pipeline, tools, first D3D11 triangle
DXC/FXC, data types, vectors/matrices, semantics Operators, control flow & attributes, intrinsics — Part I exercises, Project 1 cbuffers & packing, resources, registers/spaces, root signatures
Transformations, pixel output & blending, texture sampling Lighting, normal/environment mapping, color & HDR — Project 2
Post-processing, shadows, instancing & skinning — Part II exercises, Project 3
Geometry, tessellation, compute, UAVs & atomics — Project 6 PBR & IBL, wave intrinsics, mesh shaders — Project 4
DXR & RayQuery, bindless, work graphs — Project 5 or 8 HLSL 2021, Vulkan/SPIR-V, cross-compilation & reflection, debugging — Project 7
Performance, permutations, Unity/Unreal, best practices — Part III exercises, finish a capstone 🎓 Final Words
You've gone from a single colored triangle to physically based shading, compute-driven simulations, mesh shaders, bindless rendering, work graphs, and hardware ray tracing — in a language that runs on Direct3D, Vulkan, Xbox, Unity, and Unreal alike. Keep your matrix conventions, coordinate spaces, color spaces, and cbuffer layouts straight; debug visually and with PIX or RenderDoc; read the DirectX-Specs when a new shader model ships; and measure before you optimize. Build the capstone projects, study the official samples, share your shaders, and keep pushing pixels. Happy shading! 🎨
// ---- Resources & constants ----
cbuffer PerFrame : register(b0) { float4x4 gViewProj; float3 gCamPos; float gTime; };
ConstantBuffer<DrawData> gDraw : register(b1, space1);
Texture2D<float4> gTex : register(t0); SamplerState gSamp : register(s0);
StructuredBuffer<Light> gLights : register(t1); ByteAddressBuffer gRaw : register(t2);
RWTexture2D<float4> gOut : register(u0); RWStructuredBuffer<uint> gCount : register(u1);
// ---- Vertex shader ----
struct VSIn { float3 pos : POSITION; float3 n : NORMAL; float2 uv : TEXCOORD0; };
struct VSOut { float4 pos : SV_Position; float3 n : NORMAL; float2 uv : TEXCOORD0; };
VSOut VSMain(VSIn i, uint iid : SV_InstanceID)
{
VSOut o; o.pos = mul(gViewProj, float4(i.pos, 1)); o.n = i.n; o.uv = i.uv; return o;
}
// ---- Pixel shader ----
float4 PSMain(VSOut i) : SV_Target
{
float3 N = normalize(i.n), L = normalize(float3(1, 1, -1));
return gTex.Sample(gSamp, i.uv) * (0.1 + saturate(dot(N, L)));
}
// ---- Compute shader ----
groupshared float sTmp[64];
[numthreads(64, 1, 1)]
void CSMain(uint3 dtid : SV_DispatchThreadID, uint gi : SV_GroupIndex)
{
sTmp[gi] = gi; GroupMemoryBarrierWithGroupSync();
uint or
…