Minor code cleanup

This commit is contained in:
Sascha Willems 2024-01-01 16:41:38 +01:00
parent 9b52fb76d8
commit c23027d687
2 changed files with 13 additions and 13 deletions

View file

@ -144,7 +144,7 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
} }
VkResult result = vkCreateInstance(&instanceCreateInfo, nullptr, &instance); VkResult result = vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
// If the debug utils extension is present we set up debug functions, so samples an label objects for debugging // If the debug utils extension is present we set up debug functions, so samples can label objects for debugging
if (std::find(supportedInstanceExtensions.begin(), supportedInstanceExtensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME) != supportedInstanceExtensions.end()) { if (std::find(supportedInstanceExtensions.begin(), supportedInstanceExtensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME) != supportedInstanceExtensions.end()) {
vks::debugutils::setup(instance); vks::debugutils::setup(instance);
} }
@ -1076,7 +1076,7 @@ bool VulkanExampleBase::initVulkan()
// Find a suitable depth and/or stencil format // Find a suitable depth and/or stencil format
VkBool32 validFormat{ false }; VkBool32 validFormat{ false };
// Sample that make use of stencil will require a depth + stencil format, so we select from a different list // Samples that make use of stencil will require a depth + stencil format, so we select from a different list
if (requiresStencil) { if (requiresStencil) {
validFormat = vks::tools::getSupportedDepthStencilFormat(physicalDevice, &depthFormat); validFormat = vks::tools::getSupportedDepthStencilFormat(physicalDevice, &depthFormat);
} else { } else {

View file

@ -100,16 +100,16 @@ protected:
uint32_t lastFPS = 0; uint32_t lastFPS = 0;
std::chrono::time_point<std::chrono::high_resolution_clock> lastTimestamp, tPrevEnd; std::chrono::time_point<std::chrono::high_resolution_clock> lastTimestamp, tPrevEnd;
// Vulkan instance, stores all per-application states // Vulkan instance, stores all per-application states
VkInstance instance; VkInstance instance{ VK_NULL_HANDLE };
std::vector<std::string> supportedInstanceExtensions; std::vector<std::string> supportedInstanceExtensions;
// Physical device (GPU) that Vulkan will use // Physical device (GPU) that Vulkan will use
VkPhysicalDevice physicalDevice; VkPhysicalDevice physicalDevice{ VK_NULL_HANDLE };
// Stores physical device properties (for e.g. checking device limits) // Stores physical device properties (for e.g. checking device limits)
VkPhysicalDeviceProperties deviceProperties; VkPhysicalDeviceProperties deviceProperties{};
// Stores the features available on the selected physical device (for e.g. checking if a feature is available) // Stores the features available on the selected physical device (for e.g. checking if a feature is available)
VkPhysicalDeviceFeatures deviceFeatures; VkPhysicalDeviceFeatures deviceFeatures{};
// Stores all available memory (type) properties for the physical device // Stores all available memory (type) properties for the physical device
VkPhysicalDeviceMemoryProperties deviceMemoryProperties; VkPhysicalDeviceMemoryProperties deviceMemoryProperties{};
/** @brief Set of physical device features to be enabled for this example (must be set in the derived constructor) */ /** @brief Set of physical device features to be enabled for this example (must be set in the derived constructor) */
VkPhysicalDeviceFeatures enabledFeatures{}; VkPhysicalDeviceFeatures enabledFeatures{};
/** @brief Set of device extensions to be enabled for this example (must be set in the derived constructor) */ /** @brief Set of device extensions to be enabled for this example (must be set in the derived constructor) */
@ -118,13 +118,13 @@ protected:
/** @brief Optional pNext structure for passing extension structures to device creation */ /** @brief Optional pNext structure for passing extension structures to device creation */
void* deviceCreatepNextChain = nullptr; void* deviceCreatepNextChain = nullptr;
/** @brief Logical device, application's view of the physical device (GPU) */ /** @brief Logical device, application's view of the physical device (GPU) */
VkDevice device; VkDevice device{ VK_NULL_HANDLE };
// Handle to the device graphics queue that command buffers are submitted to // Handle to the device graphics queue that command buffers are submitted to
VkQueue queue; VkQueue queue{ VK_NULL_HANDLE };
// Depth buffer format (selected during Vulkan initialization) // Depth buffer format (selected during Vulkan initialization)
VkFormat depthFormat; VkFormat depthFormat;
// Command buffer pool // Command buffer pool
VkCommandPool cmdPool; VkCommandPool cmdPool{ VK_NULL_HANDLE };
/** @brief Pipeline stages used to wait at for graphics queue submissions */ /** @brief Pipeline stages used to wait at for graphics queue submissions */
VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
// Contains command buffers and semaphores to be presented to the queue // Contains command buffers and semaphores to be presented to the queue
@ -132,17 +132,17 @@ protected:
// Command buffers used for rendering // Command buffers used for rendering
std::vector<VkCommandBuffer> drawCmdBuffers; std::vector<VkCommandBuffer> drawCmdBuffers;
// Global render pass for frame buffer writes // Global render pass for frame buffer writes
VkRenderPass renderPass = VK_NULL_HANDLE; VkRenderPass renderPass{ VK_NULL_HANDLE };
// List of available frame buffers (same as number of swap chain images) // List of available frame buffers (same as number of swap chain images)
std::vector<VkFramebuffer>frameBuffers; std::vector<VkFramebuffer>frameBuffers;
// Active frame buffer index // Active frame buffer index
uint32_t currentBuffer = 0; uint32_t currentBuffer = 0;
// Descriptor set pool // Descriptor set pool
VkDescriptorPool descriptorPool = VK_NULL_HANDLE; VkDescriptorPool descriptorPool{ VK_NULL_HANDLE };
// List of shader modules created (stored for cleanup) // List of shader modules created (stored for cleanup)
std::vector<VkShaderModule> shaderModules; std::vector<VkShaderModule> shaderModules;
// Pipeline cache object // Pipeline cache object
VkPipelineCache pipelineCache; VkPipelineCache pipelineCache{ VK_NULL_HANDLE };
// Wraps the swap chain to present images (framebuffers) to the windowing system // Wraps the swap chain to present images (framebuffers) to the windowing system
VulkanSwapChain swapChain; VulkanSwapChain swapChain;
// Synchronization semaphores // Synchronization semaphores