Summary
Enable g3d 3D rendering inside gogpu/ui applications. Three changes:
desktop.WithPreRender hook — allows g3d to render to surface before ui compositor (Scenario A: fullscreen 3D + UI overlay)
widget.Canvas.DrawGPUTexture interface method — add to Canvas interface directly (pre-1.0, not type assertion)
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
Summary
Enable g3d 3D rendering inside gogpu/ui applications. Three changes:
desktop.WithPreRenderhook — allows g3d to render to surface before ui compositor (Scenario A: fullscreen 3D + UI overlay)widget.Canvas.DrawGPUTextureinterface method — add to Canvas interface directly (pre-1.0, not type assertion)Viewport3Dwidget — 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.RunwithWithPreRender(fn). g3d renders first (LoadOp::Clear), ui compositor on top (LoadOp::Load). ~40 LOC.Scenario B (embedded):
Viewport3Dwidget owns offscreen color+depth textures. User callback renders 3D. Compositor blits viaDrawGPUTexture. ~200 LOC.Canvas interface: Add
DrawGPUTexture(view gpucontext.TextureView, x, y float64, width, height int)towidget.Canvas. Pre-1.0 = right architecture now, not type assertion workaround.Enterprise References
Phased Implementation
desktop.WithPreRender+ force LoadOp::Loadwidget.Canvas.DrawGPUTextureinterface methodViewport3Dwidget (texture lifecycle, events, options)ADR:
ADR-048-G3D-UI-COMPOSITING.md