Lesson 0001 — Object Graph & First WGSL Triangle

← index

1 · The object graph

navigator.gpu.requestAdapter()   →  IDXGIAdapter
    .requestDevice()             →  ID3D12Device + Direct queue (merged!)
device.createCommandEncoder()    →  Command allocator + list
encoder.beginRenderPass(...)     →  OMSetRenderTargets scope (explicit pass)
device.createRenderPipeline()    →  ID3D12PipelineState (immutable, one-shot)
pipeline.getBindGroupLayout()    →  root parameter reflection
device.createBindGroup(...)      →  descriptor heap slice → root params
queue.submit([cmdBuffer])        →  ExecuteCommandLists + implicit present

2 · Live triangle

No vertex buffer at all — positions generated from @builtin(vertex_index). No viewport/scissor — the render pass defaults to the attachment size. No fences — queue.submit is ordered.

3 · WGSL first contact — vs HLSL

float4 / float3x3        vec4f / mat3x3f
[SV_Position]            @builtin(position)
semantics on params      attributes declared per-field
cbuffer                  var<uniform> (address space!)

4 · The exercise (running above)

The canvas is the triangle from §2 plus the lesson exercise already wired: time as a 16-byte uniform written via device.queue.writeBuffer each frame, bind group created from pipeline.getBindGroupLayout(0), and the three vertices rotating around origin in the VS. Read the source of this page — the WGSL for the rotation is commented.

5 · Checkpoint questions

Answer these in chat before lesson 0002:

  1. Why must fragment.targets[0].format equal the configured canvas format?
  2. What replaces ResourceBarrier(RENDER_TARGET → PIXEL_SHADER_RESOURCE)?
  3. Why must the bind group layout come from getBindGroupLayout(0) rather than being invented?