Changeset 8b823e7 in opengl-game for vulkan-game.cpp
- Timestamp:
- Jan 24, 2021, 11:38:43 PM (5 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- d8cf709
- Parents:
- ce9dc9f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
rce9dc9f r8b823e7 38 38 */ 39 39 40 // Put in here to use for IMGUI, but I might use something similar in other places as well 41 static void check_vk_result(VkResult result) { 42 if (result == VK_SUCCESS) 40 static void check_imgui_vk_result(VkResult res) { 41 if (res == VK_SUCCESS) { 43 42 return; 44 fprintf(stderr, "[vulkan] Error: VkResult = %d\n", result); 45 if (result < 0) 46 abort(); 43 } 44 45 ostringstream oss; 46 oss << "[imgui] Vulkan error! VkResult is \"" << VulkanUtils::resultString(res) << "\"" << __LINE__; 47 if (res < 0) { 48 throw runtime_error("Fatal: " + oss.str()); 49 } else { 50 cerr << oss.str(); 51 } 47 52 } 48 53 … … 251 256 init_info.MinImageCount = this->swapChainMinImageCount; 252 257 init_info.ImageCount = this->swapChainImageCount; 253 init_info.CheckVkResultFn = check_ vk_result;258 init_info.CheckVkResultFn = check_imgui_vk_result; 254 259 ImGui_ImplVulkan_Init(&init_info, this->renderPass); 255 260 … … 261 266 // Upload Fonts 262 267 { 263 VkResult err;264 265 268 VkCommandBuffer command_buffer; 266 269 … … 271 274 info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; 272 275 info.commandBufferCount = 1; 273 err = vkAllocateCommandBuffers(this->device, &info, &command_buffer); 274 check_vk_result(err); 276 277 VKUTIL_CHECK_RESULT(vkAllocateCommandBuffers(this->device, &info, &command_buffer), 278 "failed to allocate command buffers!"); 275 279 276 280 //err = vkResetCommandPool(this->device, command_pool, 0); // Probably not really needed here since the command pool is never used before this … … 279 283 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; 280 284 begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; 281 err = vkBeginCommandBuffer(command_buffer, &begin_info);282 check_vk_result(err);285 VKUTIL_CHECK_RESULT(vkBeginCommandBuffer(command_buffer, &begin_info), 286 "failed to begin recording command buffer!"); 283 287 284 288 ImGui_ImplVulkan_CreateFontsTexture(command_buffer); … … 288 292 end_info.commandBufferCount = 1; 289 293 end_info.pCommandBuffers = &command_buffer; 290 err = vkEndCommandBuffer(command_buffer); 291 check_vk_result(err); 292 err = vkQueueSubmit(this->graphicsQueue, 1, &end_info, VK_NULL_HANDLE); 293 check_vk_result(err); 294 295 VKUTIL_CHECK_RESULT(vkEndCommandBuffer(command_buffer), 296 "failed to record command buffer!"); 297 298 VKUTIL_CHECK_RESULT(vkQueueSubmit(this->graphicsQueue, 1, &end_info, VK_NULL_HANDLE), 299 "failed to submit draw command buffer!"); 294 300 295 301 if (vkDeviceWaitIdle(this->device) != VK_SUCCESS) { … … 300 306 301 307 // This should make the command pool reusable for later 302 err = vkResetCommandPool(this->device, resourceCommandPool, 0);303 check_vk_result(err);308 VKUTIL_CHECK_RESULT(vkResetCommandPool(this->device, resourceCommandPool, 0), 309 "failed to reset command pool!"); 304 310 } 305 311
Note:
See TracChangeset
for help on using the changeset viewer.