From 458c149c71491f4c9f51a637e4d33b44f5d3ff93 Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Mon, 20 Apr 2020 20:29:15 +0200 Subject: [PATCH] Code cleanup --- base/vulkanexamplebase.cpp | 12 ------------ base/vulkanexamplebase.h | 9 ++------- examples/computecloth/computecloth.cpp | 7 ------- examples/computenbody/computenbody.cpp | 7 ------- examples/computeraytracing/computeraytracing.cpp | 7 ------- examples/computeshader/computeshader.cpp | 7 ------- examples/deferred/deferred.cpp | 10 ---------- examples/deferredshadows/deferredshadows.cpp | 10 ---------- examples/distancefieldfonts/distancefieldfonts.cpp | 10 ---------- examples/geometryshader/geometryshader.cpp | 10 ---------- examples/gltfscene/gltfscene.cpp | 2 +- examples/pushconstants/pushconstants.cpp | 12 +----------- examples/terraintessellation/terraintessellation.cpp | 10 ---------- 13 files changed, 4 insertions(+), 109 deletions(-) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index da4aae53..5ab27685 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -110,18 +110,6 @@ std::string VulkanExampleBase::getWindowTitle() return windowTitle; } -bool VulkanExampleBase::checkCommandBuffers() -{ - for (auto& cmdBuffer : drawCmdBuffers) - { - if (cmdBuffer == VK_NULL_HANDLE) - { - return false; - } - } - return true; -} - void VulkanExampleBase::createCommandBuffers() { // Create one command buffer for each swap chain image and reuse for rendering diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 8d6ba2b6..c3c498b9 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -71,6 +71,8 @@ private: void createSynchronizationPrimitives(); void initSwapchain(); void setupSwapChain(); + void createCommandBuffers(); + void destroyCommandBuffers(); protected: // Frame counter to display fps uint32_t frameCounter = 0; @@ -332,13 +334,6 @@ public: /** @brief (Virtual) Called after the physical device features have been read, can be used to set features to enable on the device */ virtual void getEnabledFeatures(); - /** @brief Checks if command buffers are valid (!= VK_NULL_HANDLE) */ - bool checkCommandBuffers(); - /** @brief Creates the per-frame command buffers */ - void createCommandBuffers(); - /** @brief Destroy all command buffers and set their handles to VK_NULL_HANDLE */ - void destroyCommandBuffers(); - /** @brief Creates and returns a new command buffer */ VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin); /** @brief End the command buffer, submit it to the queue and free (if requested) */ diff --git a/examples/computecloth/computecloth.cpp b/examples/computecloth/computecloth.cpp index 34ed35f1..0eea27e9 100644 --- a/examples/computecloth/computecloth.cpp +++ b/examples/computecloth/computecloth.cpp @@ -231,13 +231,6 @@ public: void buildCommandBuffers() { - // Destroy command buffers if already present - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkClearValue clearValues[2]; diff --git a/examples/computenbody/computenbody.cpp b/examples/computenbody/computenbody.cpp index 5dd81add..99d2d656 100644 --- a/examples/computenbody/computenbody.cpp +++ b/examples/computenbody/computenbody.cpp @@ -135,13 +135,6 @@ public: void buildCommandBuffers() { - // Destroy command buffers if already present - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkClearValue clearValues[2]; diff --git a/examples/computeraytracing/computeraytracing.cpp b/examples/computeraytracing/computeraytracing.cpp index 9a34f737..4712b72f 100644 --- a/examples/computeraytracing/computeraytracing.cpp +++ b/examples/computeraytracing/computeraytracing.cpp @@ -208,13 +208,6 @@ public: void buildCommandBuffers() { - // Destroy command buffers if already present - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkClearValue clearValues[2]; diff --git a/examples/computeshader/computeshader.cpp b/examples/computeshader/computeshader.cpp index 37d13447..f2f84f32 100644 --- a/examples/computeshader/computeshader.cpp +++ b/examples/computeshader/computeshader.cpp @@ -203,13 +203,6 @@ public: void buildCommandBuffers() { - // Destroy command buffers if already present - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkClearValue clearValues[2]; diff --git a/examples/deferred/deferred.cpp b/examples/deferred/deferred.cpp index 10d407e3..fee8c412 100644 --- a/examples/deferred/deferred.cpp +++ b/examples/deferred/deferred.cpp @@ -529,16 +529,6 @@ public: textures.floor.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor01_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue); } - void reBuildCommandBuffers() - { - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - buildCommandBuffers(); - } - void buildCommandBuffers() { VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); diff --git a/examples/deferredshadows/deferredshadows.cpp b/examples/deferredshadows/deferredshadows.cpp index 9bc27c25..1ad80c59 100644 --- a/examples/deferredshadows/deferredshadows.cpp +++ b/examples/deferredshadows/deferredshadows.cpp @@ -467,16 +467,6 @@ public: textures.background.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor02_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue); } - void reBuildCommandBuffers() - { - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - buildCommandBuffers(); - } - void buildCommandBuffers() { VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); diff --git a/examples/distancefieldfonts/distancefieldfonts.cpp b/examples/distancefieldfonts/distancefieldfonts.cpp index 9ded1f7c..8269b5ab 100644 --- a/examples/distancefieldfonts/distancefieldfonts.cpp +++ b/examples/distancefieldfonts/distancefieldfonts.cpp @@ -201,16 +201,6 @@ public: textures.fontBitmap.loadFromFile(getAssetPath() + "textures/font_bitmap_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue); } - void reBuildCommandBuffers() - { - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - buildCommandBuffers(); - } - void buildCommandBuffers() { VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); diff --git a/examples/geometryshader/geometryshader.cpp b/examples/geometryshader/geometryshader.cpp index e19651be..6569f1e0 100644 --- a/examples/geometryshader/geometryshader.cpp +++ b/examples/geometryshader/geometryshader.cpp @@ -107,16 +107,6 @@ public: } } - void reBuildCommandBuffers() - { - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - buildCommandBuffers(); - } - void buildCommandBuffers() { VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); diff --git a/examples/gltfscene/gltfscene.cpp b/examples/gltfscene/gltfscene.cpp index eae17dfb..f567bbeb 100644 --- a/examples/gltfscene/gltfscene.cpp +++ b/examples/gltfscene/gltfscene.cpp @@ -520,7 +520,7 @@ public: } } else { - vks::tools::exitFatal("Could not open the glTF file\n\nThe file is part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1); + vks::tools::exitFatal("Could not open the glTF file.\n\nThe file is part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1); return; } diff --git a/examples/pushconstants/pushconstants.cpp b/examples/pushconstants/pushconstants.cpp index d2330230..c56e371a 100644 --- a/examples/pushconstants/pushconstants.cpp +++ b/examples/pushconstants/pushconstants.cpp @@ -91,16 +91,6 @@ public: uniformBuffer.destroy(); } - void reBuildCommandBuffers() - { - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - buildCommandBuffers(); - } - void buildCommandBuffers() { VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); @@ -457,7 +447,7 @@ public: draw(); if (!paused) { - reBuildCommandBuffers(); + buildCommandBuffers(); } } diff --git a/examples/terraintessellation/terraintessellation.cpp b/examples/terraintessellation/terraintessellation.cpp index 284431d5..0966d45e 100644 --- a/examples/terraintessellation/terraintessellation.cpp +++ b/examples/terraintessellation/terraintessellation.cpp @@ -305,16 +305,6 @@ public: textures.terrainArray.descriptor.sampler = textures.terrainArray.sampler; } - void reBuildCommandBuffers() - { - if (!checkCommandBuffers()) - { - destroyCommandBuffers(); - createCommandBuffers(); - } - buildCommandBuffers(); - } - void buildCommandBuffers() { VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();