Safety, comments

This commit is contained in:
Henrik Rydgård 2020-11-01 23:37:32 +01:00
parent 32eb882bc6
commit 291742535b
3 changed files with 9 additions and 4 deletions

View File

@ -213,7 +213,11 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan
}
}
void VulkanRenderManager::CreateBackbuffers() {
bool VulkanRenderManager::CreateBackbuffers() {
if (!vulkan_->GetSwapchain()) {
ERROR_LOG(G3D, "No swapchain - can't create backbuffers");
return false;
}
VkResult res = vkGetSwapchainImagesKHR(vulkan_->GetDevice(), vulkan_->GetSwapchain(), &swapchainImageCount_, nullptr);
_dbg_assert_(res == VK_SUCCESS);
@ -222,7 +226,7 @@ void VulkanRenderManager::CreateBackbuffers() {
if (res != VK_SUCCESS) {
ERROR_LOG(G3D, "vkGetSwapchainImagesKHR failed");
delete[] swapchainImages;
return;
return false;
}
VkCommandBuffer cmdInit = GetInitCmd();
@ -283,6 +287,7 @@ void VulkanRenderManager::CreateBackbuffers() {
INFO_LOG(G3D, "Starting Vulkan submission thread (threadInitFrame_ = %d)", vulkan_->GetCurFrame());
thread_ = std::thread(&VulkanRenderManager::ThreadFunc, this);
}
return true;
}
void VulkanRenderManager::StopThread() {

View File

@ -289,7 +289,7 @@ public:
return renderStepOffset_ + (int)steps_.size();
}
void CreateBackbuffers();
bool CreateBackbuffers();
void DestroyBackbuffers();
bool HasBackbuffers() {

View File

@ -411,7 +411,7 @@ void PresentationCommon::CreateDeviceObjects() {
vdata_ = draw_->CreateBuffer(sizeof(Vertex) * 8, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
// TODO: Use 4 and a strip?
// TODO: Use a triangle strip? Makes the UV rotation slightly more complex.
idata_ = draw_->CreateBuffer(sizeof(uint16_t) * 6, BufferUsageFlag::DYNAMIC | BufferUsageFlag::INDEXDATA);
uint16_t indexes[] = { 0, 1, 2, 0, 2, 3 };
draw_->UpdateBuffer(idata_, (const uint8_t *)indexes, 0, sizeof(indexes), Draw::UPDATE_DISCARD);