Allocate a buffer (from the array) with room for 'entries' entries. NOTE: Pointer might go invalid after a consecutive call to RenderListAlloc if reallocation of backing buffer happens.
| 261 | // NOTE: Pointer might go invalid after a consecutive call to RenderListAlloc if reallocation |
| 262 | // of backing buffer happens. |
| 263 | RenderListEntry* RenderListAlloc(HRenderContext render_context, uint32_t entries) |
| 264 | { |
| 265 | dmArray<RenderListEntry> & render_list = render_context->m_RenderList; |
| 266 | |
| 267 | if (render_list.Remaining() < entries) |
| 268 | { |
| 269 | const uint32_t needed = entries - render_list.Remaining(); |
| 270 | render_list.OffsetCapacity(dmMath::Max<uint32_t>(256, needed)); |
| 271 | render_context->m_RenderListSortIndices.SetCapacity(render_list.Capacity()); |
| 272 | } |
| 273 | |
| 274 | uint32_t size = render_list.Size(); |
| 275 | render_list.SetSize(size + entries); |
| 276 | |
| 277 | // If we push new items after the last frustum culling, we need to reevaluate them. |
| 278 | RenderListEntry* start = render_list.Begin() + size; |
| 279 | memset(start, 0, entries * sizeof(RenderListEntry)); |
| 280 | |
| 281 | return start; |
| 282 | } |
| 283 | |
| 284 | // Submit a range of entries (pointers must be from a range allocated by RenderListAlloc, and not between two alloc calls). |
| 285 | void RenderListSubmit(HRenderContext render_context, RenderListEntry *begin, RenderListEntry *end) |