| 3235 | } |
| 3236 | |
| 3237 | static void VulkanDrawElements(HContext _context, PrimitiveType prim_type, uint32_t first, uint32_t count, Type type, HIndexBuffer index_buffer, uint32_t instance_count) |
| 3238 | { |
| 3239 | DM_PROFILE(__FUNCTION__); |
| 3240 | DM_PROPERTY_ADD_U32(rmtp_DrawCalls, 1); |
| 3241 | |
| 3242 | VulkanContext* context = (VulkanContext*) _context; |
| 3243 | |
| 3244 | assert(context->m_FrameBegun); |
| 3245 | const uint8_t ix = context->m_CurrentFrameInFlight; |
| 3246 | |
| 3247 | VkCommandBuffer vk_command_buffer = context->m_MainCommandBuffers[ix]; |
| 3248 | context->m_PipelineState.m_PrimtiveType = prim_type; |
| 3249 | if (!DrawSetup(context, vk_command_buffer, &context->m_MainScratchBuffers[ix], (DeviceBuffer*) index_buffer, type)) |
| 3250 | { |
| 3251 | dmLogError("Failed setup draw state"); |
| 3252 | return; |
| 3253 | } |
| 3254 | |
| 3255 | // The 'first' value that comes in is intended to be a byte offset, |
| 3256 | // but vkCmdDrawIndexed only operates with actual offset values into the index buffer |
| 3257 | uint32_t index_offset = first / (type == TYPE_UNSIGNED_SHORT ? 2 : 4); |
| 3258 | vkCmdDrawIndexed(vk_command_buffer, count, dmMath::Max((uint32_t) 1, instance_count), index_offset, 0, 0); |
| 3259 | } |
| 3260 | |
| 3261 | static void VulkanDraw(HContext _context, PrimitiveType prim_type, uint32_t first, uint32_t count, uint32_t instance_count) |
| 3262 | { |