Code cleanup

This commit is contained in:
Sascha Willems 2020-04-20 20:29:15 +02:00
parent 9fc8b0032c
commit 458c149c71
13 changed files with 4 additions and 109 deletions

View file

@ -110,18 +110,6 @@ std::string VulkanExampleBase::getWindowTitle()
return windowTitle; return windowTitle;
} }
bool VulkanExampleBase::checkCommandBuffers()
{
for (auto& cmdBuffer : drawCmdBuffers)
{
if (cmdBuffer == VK_NULL_HANDLE)
{
return false;
}
}
return true;
}
void VulkanExampleBase::createCommandBuffers() void VulkanExampleBase::createCommandBuffers()
{ {
// Create one command buffer for each swap chain image and reuse for rendering // Create one command buffer for each swap chain image and reuse for rendering

View file

@ -71,6 +71,8 @@ private:
void createSynchronizationPrimitives(); void createSynchronizationPrimitives();
void initSwapchain(); void initSwapchain();
void setupSwapChain(); void setupSwapChain();
void createCommandBuffers();
void destroyCommandBuffers();
protected: protected:
// Frame counter to display fps // Frame counter to display fps
uint32_t frameCounter = 0; 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 */ /** @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(); 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 */ /** @brief Creates and returns a new command buffer */
VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin); VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin);
/** @brief End the command buffer, submit it to the queue and free (if requested) */ /** @brief End the command buffer, submit it to the queue and free (if requested) */

View file

@ -231,13 +231,6 @@ public:
void buildCommandBuffers() void buildCommandBuffers()
{ {
// Destroy command buffers if already present
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
VkClearValue clearValues[2]; VkClearValue clearValues[2];

View file

@ -135,13 +135,6 @@ public:
void buildCommandBuffers() void buildCommandBuffers()
{ {
// Destroy command buffers if already present
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
VkClearValue clearValues[2]; VkClearValue clearValues[2];

View file

@ -208,13 +208,6 @@ public:
void buildCommandBuffers() void buildCommandBuffers()
{ {
// Destroy command buffers if already present
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
VkClearValue clearValues[2]; VkClearValue clearValues[2];

View file

@ -203,13 +203,6 @@ public:
void buildCommandBuffers() void buildCommandBuffers()
{ {
// Destroy command buffers if already present
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
VkClearValue clearValues[2]; VkClearValue clearValues[2];

View file

@ -529,16 +529,6 @@ public:
textures.floor.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor01_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue); textures.floor.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor01_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
} }
void reBuildCommandBuffers()
{
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
buildCommandBuffers();
}
void buildCommandBuffers() void buildCommandBuffers()
{ {
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();

View file

@ -467,16 +467,6 @@ public:
textures.background.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor02_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue); textures.background.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor02_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
} }
void reBuildCommandBuffers()
{
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
buildCommandBuffers();
}
void buildCommandBuffers() void buildCommandBuffers()
{ {
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();

View file

@ -201,16 +201,6 @@ public:
textures.fontBitmap.loadFromFile(getAssetPath() + "textures/font_bitmap_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue); textures.fontBitmap.loadFromFile(getAssetPath() + "textures/font_bitmap_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
} }
void reBuildCommandBuffers()
{
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
buildCommandBuffers();
}
void buildCommandBuffers() void buildCommandBuffers()
{ {
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();

View file

@ -107,16 +107,6 @@ public:
} }
} }
void reBuildCommandBuffers()
{
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
buildCommandBuffers();
}
void buildCommandBuffers() void buildCommandBuffers()
{ {
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();

View file

@ -520,7 +520,7 @@ public:
} }
} }
else { 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; return;
} }

View file

@ -91,16 +91,6 @@ public:
uniformBuffer.destroy(); uniformBuffer.destroy();
} }
void reBuildCommandBuffers()
{
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
buildCommandBuffers();
}
void buildCommandBuffers() void buildCommandBuffers()
{ {
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
@ -457,7 +447,7 @@ public:
draw(); draw();
if (!paused) if (!paused)
{ {
reBuildCommandBuffers(); buildCommandBuffers();
} }
} }

View file

@ -305,16 +305,6 @@ public:
textures.terrainArray.descriptor.sampler = textures.terrainArray.sampler; textures.terrainArray.descriptor.sampler = textures.terrainArray.sampler;
} }
void reBuildCommandBuffers()
{
if (!checkCommandBuffers())
{
destroyCommandBuffers();
createCommandBuffers();
}
buildCommandBuffers();
}
void buildCommandBuffers() void buildCommandBuffers()
{ {
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo(); VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();