Fixed two critical bugs preventing multiple textured sprites from rendering correctly:
1. **setState consumed by submit**: Render state was set once at the beginning,
but bgfx consumes state at each submit(). Batches 2+ had no state → invisible.
FIX: Call setState() before EACH batch, not once globally.
2. **Buffer overwrite race condition**: updateBuffer() is immediate but submit()
is deferred. When batch 2 called updateBuffer(), it overwrote batch 1's data
BEFORE bgfx executed the draw calls. All batches used the last batch's data
→ all sprites rendered at the same position (superimposed).
FIX: Use transient buffers (one per batch, frame-local) instead of reusing
the same dynamic buffer. Each batch gets its own isolated memory.
Changes:
- SpritePass: setState before each batch + transient buffer allocation per batch
- UIRenderer: Retained mode rendering (render:sprite:add/update/remove)
- test_ui_showcase: Added 3 textured buttons demo section
- test_3buttons_minimal: Minimal test case for multi-texture debugging
Tested: 3 textured buttons now render at correct positions with correct textures.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>