| 1293 | /////////////////////////////////////////// |
| 1294 | |
| 1295 | void render_list_execute_material(render_list_t list_id, render_layer_ filter, uint32_t view_count, int32_t queue_start, int32_t queue_end, material_t override_material) { |
| 1296 | _render_list_t *list = &local.lists[list_id]; |
| 1297 | list->state = render_list_state_rendering; |
| 1298 | |
| 1299 | if (list->queue.count == 0) { |
| 1300 | list->state = render_list_state_rendered; |
| 1301 | return; |
| 1302 | } |
| 1303 | // TODO: this isn't entirely optimal here, this would be best if sorted |
| 1304 | // solely by the mesh id since we only have one single material. |
| 1305 | render_list_prep(list_id); |
| 1306 | material_check_dirty(override_material); |
| 1307 | uint64_t sort_id_start = render_sort_id_from_queue(queue_start); |
| 1308 | uint64_t sort_id_end = render_sort_id_from_queue(queue_end); |
| 1309 | |
| 1310 | render_item_t *run_start = nullptr; |
| 1311 | for (int32_t i = 0; i < list->queue.count; i++) { |
| 1312 | render_item_t *item = &list->queue[i]; |
| 1313 | |
| 1314 | // Skip this item if it's filtered out |
| 1315 | if ((item->layer & filter) == 0 || item->sort_id < sort_id_start) continue; |
| 1316 | // End early if we're past the end of the desired queue range |
| 1317 | if (item->sort_id >= sort_id_end) break; |
| 1318 | |
| 1319 | // If it's the first in the run, record the material/mesh |
| 1320 | if (run_start == nullptr) { |
| 1321 | run_start = item; |
| 1322 | } |
| 1323 | // If the mesh changed |
| 1324 | else if (run_start->mesh != item->mesh) { |
| 1325 | // Render the run that just ended |
| 1326 | render_list_execute_run(list, override_material, &run_start->mesh->gpu_mesh, run_start->mesh_inds, view_count); |
| 1327 | local.instance_list.clear(); |
| 1328 | // Start the next run |
| 1329 | run_start = item; |
| 1330 | } |
| 1331 | |
| 1332 | // Add the current item to the run of instances |
| 1333 | XMMATRIX transpose = XMMatrixTranspose(item->transform); |
| 1334 | local.instance_list.add(render_transform_buffer_t{ transpose, item->color }); |
| 1335 | } |
| 1336 | // Render the last remaining run, which won't be triggered by the loop's |
| 1337 | // conditions |
| 1338 | if (local.instance_list.count > 0) { |
| 1339 | render_list_execute_run(list, override_material, &run_start->mesh->gpu_mesh, run_start->mesh_inds, view_count); |
| 1340 | local.instance_list.clear(); |
| 1341 | } |
| 1342 | |
| 1343 | list->state = render_list_state_rendered; |
| 1344 | } |
| 1345 | |
| 1346 | /////////////////////////////////////////// |
| 1347 |
nothing calls this directly
no test coverage detected