Harbor

Changelog 586c223831d7

document instance input parity

@sky · 1 month ago · parent 8a393f4c65a8
0 added 3 modified 0 deleted
docs/gpu_intent_api.md +4 -2 modified
18 unchanged lines hidden
19 19
20 20 ## Execution model
21 21
22 - The authoritative runtime direction is a planned-IR executor: validation produces diagnostics, planning orders commands, and backend lowering walks the planned IR to issue backend operations. A gated backend-native planned draw path now handles materialized IR buffers, render passes, shaders, graphics pipelines, descriptor sets, direct indexed draws, direct non-indexed draws, single-command indirect indexed/non-indexed draws, supported borrowed imported mesh buffers, lit imported meshes, imported rect clips, the generated 2D rect/line/circle slice, generated textured quads with concrete texture IDs, and generated glyph quads with texture-backed materials. The current runtime translator that maps remaining generated/imported producer forms into legacy 2D/3D renderer calls is migration-only. New backend parity work must not add feature-specific translator branches unless the branch is a temporary, tracked bridge with a removal path.
22 + The authoritative runtime direction is a planned-IR executor: validation produces diagnostics, planning orders commands, and backend lowering walks the planned IR to issue backend operations. A gated backend-native planned draw path now handles materialized IR buffers, render passes, shaders, graphics pipelines, descriptor sets, direct indexed draws, direct non-indexed draws, true per-instance vertex buffers for pipelines that declare an instance layout, single-command indirect indexed/non-indexed draws, supported borrowed imported mesh buffers, lit imported meshes, imported rect clips, the generated 2D rect/line/circle slice, generated textured quads with concrete texture IDs, and generated glyph quads with texture-backed materials. The current runtime translator that maps remaining generated/imported producer forms into legacy 2D/3D renderer calls is migration-only. New backend parity work must not add feature-specific translator branches unless the branch is a temporary, tracked bridge with a removal path.
23 23
24 24 Runtime lowering must not fail silently. If a command cannot be lowered, `gpu` records a structured diagnostic with the command handle and reason, then fails submission or mode classification explicitly.
25 25
26 unchanged lines hidden
52 52
53 53 `compute_barrier(ctx)` is a conservative/global **in-frame** barrier for compute-written storage/UAV data consumed by later backend work in the same frame. Its consumer scope is later compute shader reads/writes, vertex/fragment shader reads, vertex/index fetch, and indirect command reads. It is intentionally over-synchronized for correctness; it is not a render-target transition substitute, CPU readback fence, cross-frame lifetime rule, or feedback-loop validator. Backends that lack a complete storage descriptor path must report that separately through capabilities or diagnostics instead of pretending the barrier enables unsupported binding.
54 54
55 - Indirect draw argument buffers use the backend-neutral `Indirect_Draw_Args` and `Indirect_Draw_Indexed_Args` ABI. The layouts are intentionally byte-identical to Vulkan, D3D11, D3D12, and OpenGL single-command indirect arguments: 16 bytes for non-indexed draws and 20 bytes for indexed draws. In IR, `packet.instances.indirect` is the argument-buffer resource, `packet.instances.offset` is the byte offset, `packet.instances.stride` is zero-or-ABI-size for Phase 7a, and `packet.instances.count` is limited to one command. True per-instance vertex streams remain separate unsupported vertex-input work.
55 + Indirect draw argument buffers use the backend-neutral `Indirect_Draw_Args` and `Indirect_Draw_Indexed_Args` ABI. The layouts are intentionally byte-identical to Vulkan, D3D11, D3D12, and OpenGL single-command indirect arguments: 16 bytes for non-indexed draws and 20 bytes for indexed draws. In IR, `packet.instances.indirect` is the argument-buffer resource, `packet.instances.offset` is the byte offset, `packet.instances.stride` is zero-or-ABI-size for indirect arguments, and `packet.instances.count` is limited to one command in the current executor.
56 56
57 + Per-instance vertex streams use the normal `packet.instances.resource` field, not the indirect argument field. A planned instance-buffer draw requires a graphics pipeline with `has_instance_layout = true`, a nonzero `packet.instances.stride`, and a prepared instance buffer. Slot 0 is the per-vertex stream; slot 1 is the per-instance stream bound with `packet.instances.offset` and `packet.instances.stride`. Vulkan, D3D11, D3D12, and OpenGL all lower the same backend-neutral `Vertex_Binding.input_rate` and `Vertex_Attribute.binding` metadata; OpenGL uses the DSA vertex-attrib-binding/divisor path internally. Indirect draws may also bind an instance stream: the indirect buffer controls counts/firsts, while the instance buffer controls per-instance attributes.
58 +
57 59 D3D12 runtime fence behavior cannot be executed by Linux CI. D3D12 lifetime and transition work is accepted by static backend checks, pure fence-order tests where available, and explicit Windows runtime verification debt.
58 60
59 61 Current backend sync matrix:
195 unchanged lines hidden
tests/render_ir/dump_test.odin +1 -1 modified
95 unchanged lines hidden
96 96 " #1 name=\"material\" layout=1 bindings=1\n" +
97 97 " binding=0 type=Combined_Image_Sampler resource=2 sampler=3 size=0\n" +
98 98 "pipelines 2\n" +
99 - " #1 Graphics name=\"rect\" key=\"gfx:vs=1;fs=2;layouts=1;layout=PNU;topology=Triangle_List;cull=Back;front=Counter_Clockwise;blend=true/Alpha;depth=false/false;color=B8G8R8A8_SRGB;depth_format=Undefined;pc=0;pc_stages=None\"\n" +
99 + " #1 Graphics name=\"rect\" key=\"gfx:vs=1;fs=2;layouts=1;layout=PNU;instance_layout=false/PNU;topology=Triangle_List;cull=Back;front=Counter_Clockwise;blend=true/Alpha;depth=false/false;color=B8G8R8A8_SRGB;depth_format=Undefined;pc=0;pc_stages=None\"\n" +
100 100 " #2 Compute name=\"particles\" key=\"compute:shader=0;layouts=None;pc=0;pc_stages=None\"\n" +
101 101 "commands 2\n" +
102 102 " #1 Draw pass=1 pipeline=1 vertex_count=6 instance_count=1\n" +
3 unchanged lines hidden
tests/render_ir/pipeline_desc_test.odin +2 -2 modified
83 unchanged lines hidden
84 84 testing.expect_value(
85 85 t,
86 86 gfx_key,
87 - "gfx:vs=1;fs=2;layouts=None;layout=PNU;topology=Triangle_List;cull=Back;front=Counter_Clockwise;blend=true/Alpha;depth=true/true;color=B8G8R8A8_SRGB;depth_format=D32_SFLOAT;pc=64;pc_stages=Vertex|Fragment",
87 + "gfx:vs=1;fs=2;layouts=None;layout=PNU;instance_layout=false/PNU;topology=Triangle_List;cull=Back;front=Counter_Clockwise;blend=true/Alpha;depth=true/true;color=B8G8R8A8_SRGB;depth_format=D32_SFLOAT;pc=64;pc_stages=Vertex|Fragment",
88 88 )
89 89
90 90 compute_key := ir.format_pipeline_cache_key(
23 unchanged lines hidden
114 114 testing.expect_value(
115 115 t,
116 116 key,
117 - "gfx:vs=0;fs=0;layouts=1|2;layout=PNU;topology=Triangle_List;cull=Back;front=Counter_Clockwise;blend=true/Alpha;depth=false/false;color=B8G8R8A8_SRGB;depth_format=Undefined;pc=0;pc_stages=None",
117 + "gfx:vs=0;fs=0;layouts=1|2;layout=PNU;instance_layout=false/PNU;topology=Triangle_List;cull=Back;front=Counter_Clockwise;blend=true/Alpha;depth=false/false;color=B8G8R8A8_SRGB;depth_format=Undefined;pc=0;pc_stages=None",
118 118 )
119 119 }