From 0a2b20bf59542db8e489ee54d701bb7cb571a290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 9 Nov 2017 17:40:32 +0100 Subject: [PATCH] More logging and tweaking --- Common/Vulkan/VulkanContext.cpp | 104 ++++++++++++++++++++++- Common/Vulkan/VulkanContext.h | 102 +--------------------- android/jni/app-android.cpp | 4 +- ext/native/gfx_es2/draw_text_android.cpp | 2 +- 4 files changed, 108 insertions(+), 104 deletions(-) diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index acc0cbff90..c31ee34647 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -585,14 +585,16 @@ void VulkanContext::InitSurfaceAndroid(ANativeWindow *wnd, int width, int height } void VulkanContext::ReinitSurfaceAndroid(int width, int height) { - ILOG("Destroying and reiniting Android Vulkan surface"); if (surface_ != VK_NULL_HANDLE) { + ILOG("Destroying Android Vulkan surface (%d, %d)", width_, height_); vkDestroySurfaceKHR(instance_, surface_, nullptr); surface_ = VK_NULL_HANDLE; } VkResult U_ASSERT_ONLY res; + ILOG("Creating Android Vulkan surface (%d, %d)", width, height); + VkAndroidSurfaceCreateInfoKHR android = { VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR }; android.flags = 0; android.window = native_window; @@ -970,3 +972,103 @@ const char *VulkanResultToString(VkResult res) { return "VK_ERROR_...(unknown)"; } } + +void VulkanDeleteList::Take(VulkanDeleteList &del) { + assert(cmdPools_.size() == 0); + assert(descPools_.size() == 0); + assert(modules_.size() == 0); + assert(buffers_.size() == 0); + assert(bufferViews_.size() == 0); + assert(images_.size() == 0); + assert(imageViews_.size() == 0); + assert(deviceMemory_.size() == 0); + assert(samplers_.size() == 0); + assert(pipelines_.size() == 0); + assert(pipelineCaches_.size() == 0); + assert(renderPasses_.size() == 0); + assert(framebuffers_.size() == 0); + assert(callbacks_.size() == 0); + cmdPools_ = std::move(del.cmdPools_); + descPools_ = std::move(del.descPools_); + modules_ = std::move(del.modules_); + buffers_ = std::move(del.buffers_); + bufferViews_ = std::move(del.bufferViews_); + images_ = std::move(del.images_); + imageViews_ = std::move(del.imageViews_); + deviceMemory_ = std::move(del.deviceMemory_); + samplers_ = std::move(del.samplers_); + pipelines_ = std::move(del.pipelines_); + pipelineCaches_ = std::move(del.pipelineCaches_); + renderPasses_ = std::move(del.renderPasses_); + framebuffers_ = std::move(del.framebuffers_); + pipelineLayouts_ = std::move(del.pipelineLayouts_); + descSetLayouts_ = std::move(del.descSetLayouts_); + callbacks_ = std::move(del.callbacks_); +} + +void VulkanDeleteList::PerformDeletes(VkDevice device) { + for (auto &cmdPool : cmdPools_) { + vkDestroyCommandPool(device, cmdPool, nullptr); + } + cmdPools_.clear(); + for (auto &descPool : descPools_) { + vkDestroyDescriptorPool(device, descPool, nullptr); + } + descPools_.clear(); + for (auto &module : modules_) { + vkDestroyShaderModule(device, module, nullptr); + } + modules_.clear(); + for (auto &buf : buffers_) { + vkDestroyBuffer(device, buf, nullptr); + } + buffers_.clear(); + for (auto &bufView : bufferViews_) { + vkDestroyBufferView(device, bufView, nullptr); + } + bufferViews_.clear(); + for (auto &image : images_) { + vkDestroyImage(device, image, nullptr); + } + images_.clear(); + for (auto &imageView : imageViews_) { + vkDestroyImageView(device, imageView, nullptr); + } + imageViews_.clear(); + for (auto &mem : deviceMemory_) { + vkFreeMemory(device, mem, nullptr); + } + deviceMemory_.clear(); + for (auto &sampler : samplers_) { + vkDestroySampler(device, sampler, nullptr); + } + samplers_.clear(); + for (auto &pipeline : pipelines_) { + vkDestroyPipeline(device, pipeline, nullptr); + } + pipelines_.clear(); + for (auto &pcache : pipelineCaches_) { + vkDestroyPipelineCache(device, pcache, nullptr); + } + pipelineCaches_.clear(); + for (auto &renderPass : renderPasses_) { + vkDestroyRenderPass(device, renderPass, nullptr); + } + renderPasses_.clear(); + for (auto &framebuffer : framebuffers_) { + vkDestroyFramebuffer(device, framebuffer, nullptr); + } + framebuffers_.clear(); + for (auto &pipeLayout : pipelineLayouts_) { + vkDestroyPipelineLayout(device, pipeLayout, nullptr); + } + pipelineLayouts_.clear(); + for (auto &descSetLayout : descSetLayouts_) { + vkDestroyDescriptorSetLayout(device, descSetLayout, nullptr); + } + descSetLayouts_.clear(); + for (auto &callback : callbacks_) { + callback.func(callback.userdata); + } + callbacks_.clear(); +} diff --git a/Common/Vulkan/VulkanContext.h b/Common/Vulkan/VulkanContext.h index 4b195ad1de..07f82ead75 100644 --- a/Common/Vulkan/VulkanContext.h +++ b/Common/Vulkan/VulkanContext.h @@ -89,106 +89,8 @@ public: void QueueDeleteDescriptorSetLayout(VkDescriptorSetLayout &descSetLayout) { descSetLayouts_.push_back(descSetLayout); descSetLayout = VK_NULL_HANDLE; } void QueueCallback(void(*func)(void *userdata), void *userdata) { callbacks_.push_back(Callback(func, userdata)); } - void Take(VulkanDeleteList &del) { - assert(cmdPools_.size() == 0); - assert(descPools_.size() == 0); - assert(modules_.size() == 0); - assert(buffers_.size() == 0); - assert(bufferViews_.size() == 0); - assert(images_.size() == 0); - assert(imageViews_.size() == 0); - assert(deviceMemory_.size() == 0); - assert(samplers_.size() == 0); - assert(pipelines_.size() == 0); - assert(pipelineCaches_.size() == 0); - assert(renderPasses_.size() == 0); - assert(framebuffers_.size() == 0); - assert(callbacks_.size() == 0); - cmdPools_ = std::move(del.cmdPools_); - descPools_ = std::move(del.descPools_); - modules_ = std::move(del.modules_); - buffers_ = std::move(del.buffers_); - bufferViews_ = std::move(del.bufferViews_); - images_ = std::move(del.images_); - imageViews_ = std::move(del.imageViews_); - deviceMemory_ = std::move(del.deviceMemory_); - samplers_ = std::move(del.samplers_); - pipelines_ = std::move(del.pipelines_); - pipelineCaches_ = std::move(del.pipelineCaches_); - renderPasses_ = std::move(del.renderPasses_); - framebuffers_ = std::move(del.framebuffers_); - pipelineLayouts_ = std::move(del.pipelineLayouts_); - descSetLayouts_ = std::move(del.descSetLayouts_); - callbacks_ = std::move(del.callbacks_); - } - - void PerformDeletes(VkDevice device) { - ILOG("PerformDeletes"); - for (auto &cmdPool : cmdPools_) { - vkDestroyCommandPool(device, cmdPool, nullptr); - } - cmdPools_.clear(); - for (auto &descPool : descPools_) { - vkDestroyDescriptorPool(device, descPool, nullptr); - } - descPools_.clear(); - for (auto &module : modules_) { - vkDestroyShaderModule(device, module, nullptr); - } - modules_.clear(); - for (auto &buf : buffers_) { - vkDestroyBuffer(device, buf, nullptr); - } - buffers_.clear(); - for (auto &bufView : bufferViews_) { - vkDestroyBufferView(device, bufView, nullptr); - } - bufferViews_.clear(); - for (auto &image : images_) { - vkDestroyImage(device, image, nullptr); - } - images_.clear(); - for (auto &imageView : imageViews_) { - vkDestroyImageView(device, imageView, nullptr); - } - imageViews_.clear(); - for (auto &mem : deviceMemory_) { - vkFreeMemory(device, mem, nullptr); - } - deviceMemory_.clear(); - for (auto &sampler : samplers_) { - vkDestroySampler(device, sampler, nullptr); - } - samplers_.clear(); - for (auto &pipeline : pipelines_) { - vkDestroyPipeline(device, pipeline, nullptr); - } - pipelines_.clear(); - for (auto &pcache : pipelineCaches_) { - vkDestroyPipelineCache(device, pcache, nullptr); - } - pipelineCaches_.clear(); - for (auto &renderPass : renderPasses_) { - vkDestroyRenderPass(device, renderPass, nullptr); - } - renderPasses_.clear(); - for (auto &framebuffer : framebuffers_) { - vkDestroyFramebuffer(device, framebuffer, nullptr); - } - framebuffers_.clear(); - for (auto &pipeLayout : pipelineLayouts_) { - vkDestroyPipelineLayout(device, pipeLayout, nullptr); - } - pipelineLayouts_.clear(); - for (auto &descSetLayout : descSetLayouts_) { - vkDestroyDescriptorSetLayout(device, descSetLayout, nullptr); - } - descSetLayouts_.clear(); - for (auto &callback : callbacks_) { - callback.func(callback.userdata); - } - callbacks_.clear(); - } + void Take(VulkanDeleteList &del); + void PerformDeletes(VkDevice device); private: std::vector cmdPools_; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 5e0f183d65..4ce9411e71 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -359,7 +359,7 @@ void AndroidVulkanContext::SwapBuffers() { } void AndroidVulkanContext::Resize() { - ILOG("AndroidVulkanContext::Resize begin"); + ILOG("AndroidVulkanContext::Resize begin (%d, %d)", g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight()); draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight()); g_Vulkan->DestroyObjects(); @@ -368,7 +368,7 @@ void AndroidVulkanContext::Resize() { g_Vulkan->ReinitSurfaceAndroid(pixel_xres, pixel_yres); g_Vulkan->InitObjects(); draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight()); - ILOG("AndroidVulkanContext::Resize end"); + ILOG("AndroidVulkanContext::Resize end (%d, %d)", g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight()); } void AndroidVulkanContext::SwapInterval(int interval) { diff --git a/ext/native/gfx_es2/draw_text_android.cpp b/ext/native/gfx_es2/draw_text_android.cpp index cb5ab910a2..b5628872cd 100644 --- a/ext/native/gfx_es2/draw_text_android.cpp +++ b/ext/native/gfx_es2/draw_text_android.cpp @@ -269,7 +269,7 @@ void TextDrawerAndroid::OncePerFrame() { // If DPI changed (small-mode, future proper monitor DPI support), drop everything. float newDpiScale = CalculateDPIScale(); if (newDpiScale != dpiScale_) { - ILOG("Scale changed - wiping cache"); + ILOG("DPI Scale changed (%f to %f) - wiping font cache", dpiScale_, newDpiScale); dpiScale_ = newDpiScale; ClearCache(); fontMap_.clear(); // size is precomputed using dpiScale_.