Skip to content

feat: 3D compositing — PreRender hook, Canvas.DrawGPUTexture, Viewport3D widget (ADR-048) #150

Description

@kolkov

Summary

Enable g3d 3D rendering inside gogpu/ui applications. Three changes:

  1. desktop.WithPreRender hook — allows g3d to render to surface before ui compositor (Scenario A: fullscreen 3D + UI overlay)
  2. widget.Canvas.DrawGPUTexture interface method — add to Canvas interface directly (pre-1.0, not type assertion)
  3. Viewport3D widget — embedded 3D viewport following Qt6 QRhiWidget pattern (Scenario B: CAD, IDE)

Related: g3d#5 (@striter-no), gogpu tracking issue (TBD)

Architecture (ADR-048)

Scenario A (overlay): desktop.Run with WithPreRender(fn). g3d renders first (LoadOp::Clear), ui compositor on top (LoadOp::Load). ~40 LOC.

Scenario B (embedded): Viewport3D widget owns offscreen color+depth textures. User callback renders 3D. Compositor blits via DrawGPUTexture. ~200 LOC.

Canvas interface: Add DrawGPUTexture(view gpucontext.TextureView, x, y float64, width, height int) to widget.Canvas. Pre-1.0 = right architecture now, not type assertion workaround.

Enterprise References

  • Qt6 QRhiWidget (framework manages texture, user overrides render)
  • Unity RenderTexture + RawImage
  • Godot SubViewport + SubViewportContainer
  • Bevy+egui (LoadOp::Load, render graph dependencies)

Phased Implementation

Phase Scope LOC
1 desktop.WithPreRender + force LoadOp::Load ~40
2 widget.Canvas.DrawGPUTexture interface method ~10
3 Viewport3D widget (texture lifecycle, events, options) ~200

ADR: ADR-048-G3D-UI-COMPOSITING.md

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions