Harbor

Changelog 1277191a128d

document generated draw coverage

@sky · 1 month ago · parent c12bad10727f
0 added 2 modified 0 deleted
docs/gpu_intent_api.md +1 -1 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, supported borrowed imported mesh buffers, lit imported meshes, imported rect clips, and the bounded generated 2D rect/line/circle slice. 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, 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
227 unchanged lines hidden
tests/compiler_executor_test.odin +47 -0 modified
455 unchanged lines hidden
456 456 }
457 457
458 458 @(test)
459 + test_compiler_executes_planned_glyph_quad_stream_draw :: proc(t: ^testing.T) {
460 + rec := recording_backend_init()
461 + defer recording_backend_destroy(&rec)
462 + frame := ir.init_frame_ir()
463 + defer ir.destroy_frame_ir(&frame)
464 +
465 + buffer := ir.add_buffer(&frame, "glyphs", 512, {.Vertex}, {.Device_Local}, .Persistent)
466 + pass := ir.add_pass(&frame, {kind = .Render, name = "main"})
467 + vertex_shader := ir.add_shader(&frame, {stage = .Vertex, name = "vs"})
468 + fragment_shader := ir.add_shader(&frame, {stage = .Fragment, name = "fs"})
469 + pipeline_state := ir.default_graphics_pipeline_state()
470 + pipeline_state.vertex_shader = vertex_shader
471 + pipeline_state.fragment_shader = fragment_shader
472 + pipeline := ir.add_graphics_pipeline(&frame, "pipeline", pipeline_state)
473 +
474 + packet := ir.Draw_Packet {
475 + geometry = {kind = .Glyph_Quad_Stream, resource = buffer, vertex_count = 12},
476 + order = .Strict,
477 + }
478 + _ = ir.add_draw_packet(&frame, pass, pipeline, .Glyph_Quad_Stream, packet)
479 +
480 + backend := recording_backend_use(&rec)
481 + state := compiler.init_execution_state(&backend)
482 + defer compiler.destroy_execution_state_views(&state)
483 + append(&state.resources, compiler.Prepared_Resource {resource = buffer, kind = .Buffer, buffer = bk.Buffer_Handle(12)})
484 + append(
485 + &state.passes,
486 + compiler.Prepared_Pass {
487 + pass = pass,
488 + render_pass = bk.Render_Pass_Handle(21),
489 + framebuffer = bk.Framebuffer_Handle(22),
490 + begin_desc = {pass = bk.Render_Pass_Handle(21), framebuffer = bk.Framebuffer_Handle(22)},
491 + },
492 + )
493 + append(&state.shaders, compiler.Prepared_Shader {shader = vertex_shader, stage = .Vertex, module = bk.Shader_Handle(41)})
494 + append(&state.shaders, compiler.Prepared_Shader {shader = fragment_shader, stage = .Fragment, module = bk.Shader_Handle(42)})
495 +
496 + testing.expect(t, compiler.execute_prepared_planned_commands(&state, &frame, {}, {0, 0, 0, 1}))
497 + testing.expect_value(t, rec.begin_pass_count, 1)
498 + testing.expect_value(t, rec.end_pass_count, 1)
499 + testing.expect_value(t, rec.draw_count, 1)
500 + testing.expect_value(t, rec.vertex_count, u32(12))
501 + testing.expect_value(t, rec.bound_vertex_buffer, bk.Buffer_Handle(12))
502 + testing.expect_value(t, rec.bound_pipeline, bk.Pipeline_Handle(31))
503 + }
504 +
505 + @(test)
459 506 test_compiler_rejects_raw_planned_draw_with_diagnostic :: proc(t: ^testing.T) {
460 507 rec := recording_backend_init()
461 508 defer recording_backend_destroy(&rec)
158 unchanged lines hidden