| 2109 | } |
| 2110 | |
| 2111 | static void DeviceBufferUploadHelper(VulkanContext* context, const void* data, uint32_t size, uint32_t offset, DeviceBuffer* bufferOut) |
| 2112 | { |
| 2113 | VkResult res; |
| 2114 | |
| 2115 | if (bufferOut->m_Destroyed || bufferOut->m_Handle.m_Buffer == VK_NULL_HANDLE) |
| 2116 | { |
| 2117 | res = CreateDeviceBuffer(context->m_PhysicalDevice.m_Device, context->m_LogicalDevice.m_Device, |
| 2118 | size, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, bufferOut); |
| 2119 | CHECK_VK_ERROR(res); |
| 2120 | } |
| 2121 | |
| 2122 | VkCommandBuffer vk_command_buffer; |
| 2123 | if (context->m_FrameBegun) |
| 2124 | { |
| 2125 | vk_command_buffer = context->m_MainCommandBuffers[context->m_CurrentFrameInFlight]; |
| 2126 | } |
| 2127 | else |
| 2128 | { |
| 2129 | VkCommandBufferBeginInfo vk_command_buffer_begin_info; |
| 2130 | memset(&vk_command_buffer_begin_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 2131 | |
| 2132 | vk_command_buffer_begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2133 | vk_command_buffer_begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 2134 | vk_command_buffer = context->m_MainCommandBufferUploadHelper; |
| 2135 | res = vkBeginCommandBuffer(vk_command_buffer, &vk_command_buffer_begin_info); |
| 2136 | CHECK_VK_ERROR(res); |
| 2137 | } |
| 2138 | |
| 2139 | res = WriteToDeviceBuffer(context->m_LogicalDevice.m_Device, size, offset, data, bufferOut); |
| 2140 | CHECK_VK_ERROR(res); |
| 2141 | |
| 2142 | if (!context->m_FrameBegun) |
| 2143 | { |
| 2144 | vkEndCommandBuffer(vk_command_buffer); |
| 2145 | vkResetCommandBuffer(vk_command_buffer, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | static Pipeline* GetOrCreateComputePipeline(VkDevice vk_device, VkPipelineCache vk_pipeline_cache, PipelineCache& pipelineCache, VulkanProgram* program) |
| 2150 | { |
no test coverage detected