Repository navigation
bugfix(render2d): Flush batched 2D draws before they overflow the dynamic buffers - #3487
tintinhamans wants to merge 1 commit into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe Generals and GeneralsMD 2D renderers now check vertex and index counts against dynamic-buffer limits. W3DDisplay passes expected draw counts when it decides whether to reuse or flush a batch. Changes2D renderer capacity checks
Priority: ⬆️ High Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
[Medium impact] The PR appears safe to merge; no blocking issues were found.
|
1bdda9d to
1714002
Compare
| void Render2DClass::Render() | ||
| { | ||
| if ( !Indices.Count() || IsHidden) { | ||
| return; | ||
| } | ||
|
|
||
| const bool fits = Can_Add( 0, 0 ); | ||
| WWASSERT( fits ); | ||
| if ( !fits ) { |
There was a problem hiding this comment.
Is this meant to be an assert or runtime condition? This now implies that it cannot hit on runtime but also that it can hit on runtime. Which one is true?
There was a problem hiding this comment.
The assert flags a broken capacity assumption. The runtime guard prevents an unsafe buffer copy if it still happens.
1714002 to
fd459dd
Compare
fd459dd to
6b298b2
Compare
Render2DClass::RenderpassesIndices.Count()toDynamicIBAccessClass, which takes anunsigned short. 65538 indices become 2, the index buffer is locked for 2, and the copy loop writes all 65538.Before batching,
W3DDisplaycalledRenderafter every draw call. With batching,setup2DRenderStatepreviously only flushed when the texture, mode or grayscale changed, so identical draws could accumulate beyond the dynamic buffer limits.Drawable::drawAmmohits this: it draws one pip image per round in the clip, andClipSizeis a plainINI::parseInt. A weapon withShowsAmmoPipsand a clip of 10923 produces 65538 indices, and selecting or hovering the unit can write up to 128 KB past the buffer.DynamicVBAccessClassandDynamicIBAccessClassnow defineMAX_VERTEX_COUNTandMAX_INDEX_COUNT.Render2DClass::Can_Addchecks whether the batch has room for the requested vertices and indices.Each draw supplies its actual geometry counts to
setup2DRenderState, including rotated images and each clock branch. The batch flushes before the next draw would exceed either limit, rather than at half capacity.Renderkeeps an assertion to flag an oversized batch in diagnostic builds and a runtime guard to prevent an unsafe buffer copy.The similar narrowing in
drawRiverWateris handled separately.