Skip to content

perf: single render pass with per-group scissor rect#200

Merged
kolkov merged 2 commits intomainfrom
perf/scissor-single-render-pass
Mar 13, 2026
Merged

perf: single render pass with per-group scissor rect#200
kolkov merged 2 commits intomainfrom
perf/scissor-single-render-pass

Conversation

@kolkov
Copy link
Contributor

@kolkov kolkov commented Mar 13, 2026

Summary

  • Fix GPU scissor rect performance regression from v0.36.1 — scissor clipping
    created multiple render passes per frame (one per scissor change), causing GPU
    utilization to spike from ~3% to ~45% during ListView scrolling
  • Replaced batch-breaking flushOnScissorChange with ScissorGroup timeline
    tracking — all draws accumulate within a single render pass, scissor rect changed
    per group via SetScissorRect() (WebGPU dynamic state, zero cost)
  • GPU utilization back to ~3% during scrolling (validated in gogpu/ui Widget Demo)

Changes

  • internal/gpu/render_session.goScissorGroup type, RenderFrameGrouped,
    encodeSubmitReadbackGrouped/encodeSubmitSurfaceGrouped, recordGroupDraws
    helper for DRY 5-tier draw recording
  • internal/gpu/sdf_gpu.goscissorSegment timeline tracking,
    buildScissorGroups replaces flushOnScissorChange
  • CHANGELOG.md — v0.36.2 entry

Test plan

  • GOWORK=off go build ./... passes
  • golangci-lint run — 0 issues
  • Manual validation: gogpu/ui Widget Demo, ListView 1000 items scrolling, GPU ~3%

kolkov added 2 commits March 13, 2026 03:52
Replace flush-on-scissor-change (3 render passes per frame) with
scissor timeline grouping (1 render pass, multiple SetScissorRect
calls). SetScissorRect is dynamic render pass state — nearly free.

- Add scissorSegment tracking in SDFAccelerator
- Add ScissorGroup type for per-group draw dispatch
- Add RenderFrameGrouped + encodeSubmit*Grouped in GPURenderSession
- Add recordGroupDraws helper (DRY across readback/surface paths)
- Remove flushOnScissorChange (caused 3x render pass overhead)

Reduces GPU utilization from ~45% to ~5% on Intel Iris Xe during
ScrollView scrolling (1000-item ListView).
@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kolkov kolkov merged commit d2ecf93 into main Mar 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant