Code cleanup
This commit is contained in:
parent
9fc8b0032c
commit
458c149c71
13 changed files with 4 additions and 109 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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) */
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue