| 333 | // <- |
| 334 | |
| 335 | void RenderSystem::dispatchDrawCall(Dod::Ref p_DrawCall, |
| 336 | VkCommandBuffer p_CommandBuffer) |
| 337 | { |
| 338 | PipelineRef pipelineRef = DrawCallManager::_descPipeline(p_DrawCall); |
| 339 | PipelineLayoutRef pipelineLayoutRef = |
| 340 | PipelineManager::_descPipelineLayout(pipelineRef); |
| 341 | |
| 342 | VkPipeline newPipeline = PipelineManager::_vkPipeline(pipelineRef); |
| 343 | vkCmdBindPipeline(p_CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 344 | newPipeline); |
| 345 | |
| 346 | VkDescriptorSet descSets[2] = {DrawCallManager::_vkDescriptorSet(p_DrawCall), |
| 347 | ImageManager::_globalTextureDescriptorSet}; |
| 348 | |
| 349 | if (DrawCallManager::_vkDescriptorSet(p_DrawCall)) |
| 350 | { |
| 351 | vkCmdBindDescriptorSets( |
| 352 | p_CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 353 | PipelineLayoutManager::_vkPipelineLayout(pipelineLayoutRef), 0u, 2u, |
| 354 | descSets, (uint32_t)DrawCallManager::_dynamicOffsets(p_DrawCall).size(), |
| 355 | DrawCallManager::_dynamicOffsets(p_DrawCall).data()); |
| 356 | } |
| 357 | |
| 358 | // Bind vertex buffers |
| 359 | { |
| 360 | _INTR_ARRAY(VkBuffer)& vtxBuffers = |
| 361 | DrawCallManager::_vertexBuffers(p_DrawCall); |
| 362 | |
| 363 | if (!vtxBuffers.empty()) |
| 364 | { |
| 365 | vkCmdBindVertexBuffers( |
| 366 | p_CommandBuffer, 0u, (uint32_t)vtxBuffers.size(), vtxBuffers.data(), |
| 367 | DrawCallManager::_vertexBufferOffsets(p_DrawCall).data()); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | // Draw |
| 372 | { |
| 373 | BufferRef indexBufferRef = DrawCallManager::_descIndexBuffer(p_DrawCall); |
| 374 | if (indexBufferRef.isValid()) |
| 375 | { |
| 376 | const VkIndexType indexType = |
| 377 | BufferManager::_descBufferType(indexBufferRef) == BufferType::kIndex16 |
| 378 | ? VK_INDEX_TYPE_UINT16 |
| 379 | : VK_INDEX_TYPE_UINT32; |
| 380 | vkCmdBindIndexBuffer( |
| 381 | p_CommandBuffer, BufferManager::_vkBuffer(indexBufferRef), |
| 382 | DrawCallManager::_indexBufferOffset(p_DrawCall), indexType); |
| 383 | vkCmdDrawIndexed( |
| 384 | p_CommandBuffer, DrawCallManager::_descIndexCount(p_DrawCall), |
| 385 | DrawCallManager::_descInstanceCount(p_DrawCall), 0u, 0u, 0u); |
| 386 | } |
| 387 | else |
| 388 | { |
| 389 | vkCmdDraw(p_CommandBuffer, DrawCallManager::_descVertexCount(p_DrawCall), |
| 390 | DrawCallManager::_descInstanceCount(p_DrawCall), 0u, 0u); |
| 391 | } |
| 392 | } |