mirror of
https://github.com/opus-tango/IntroductionToVulkan.git
synced 2026-03-20 12:05:20 +00:00
Small code refactoring - preparing for further parts of the tutorial.
This commit is contained in:
@@ -612,7 +612,7 @@ namespace ApiWithoutSecrets {
|
|||||||
// Set of images defined in a swap chain may not always be available for application to render to:
|
// Set of images defined in a swap chain may not always be available for application to render to:
|
||||||
// One may be displayed and one may wait in a queue to be presented
|
// One may be displayed and one may wait in a queue to be presented
|
||||||
// If application wants to use more images at the same time it must ask for more images
|
// If application wants to use more images at the same time it must ask for more images
|
||||||
uint32_t image_count = surface_capabilities.minImageCount + 1;
|
uint32_t image_count = surface_capabilities.minImageCount + 2;
|
||||||
if( (surface_capabilities.maxImageCount > 0) &&
|
if( (surface_capabilities.maxImageCount > 0) &&
|
||||||
(image_count > surface_capabilities.maxImageCount) ) {
|
(image_count > surface_capabilities.maxImageCount) ) {
|
||||||
image_count = surface_capabilities.maxImageCount;
|
image_count = surface_capabilities.maxImageCount;
|
||||||
@@ -699,13 +699,20 @@ namespace ApiWithoutSecrets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkPresentModeKHR VulkanCommon::GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes ) {
|
VkPresentModeKHR VulkanCommon::GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes ) {
|
||||||
// FIFO present mode is always available
|
|
||||||
// MAILBOX is the lowest latency V-Sync enabled mode (something like triple-buffering) so use it if available
|
// MAILBOX is the lowest latency V-Sync enabled mode (something like triple-buffering) so use it if available
|
||||||
for( VkPresentModeKHR &present_mode : present_modes ) {
|
for( VkPresentModeKHR &present_mode : present_modes ) {
|
||||||
if( present_mode == VK_PRESENT_MODE_MAILBOX_KHR ) {
|
if( present_mode == VK_PRESENT_MODE_MAILBOX_KHR ) {
|
||||||
return present_mode;
|
return present_mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// IMMEDIATE mode allows us to display frames in a V-Sync independent manner so it can introduce screen tearing
|
||||||
|
// But this mode is the best for benchmarking purposes if we want to check the real number of FPS
|
||||||
|
for( VkPresentModeKHR &present_mode : present_modes ) {
|
||||||
|
if( present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR ) {
|
||||||
|
return present_mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// FIFO present mode is always available
|
||||||
for( VkPresentModeKHR &present_mode : present_modes ) {
|
for( VkPresentModeKHR &present_mode : present_modes ) {
|
||||||
if( present_mode == VK_PRESENT_MODE_FIFO_KHR ) {
|
if( present_mode == VK_PRESENT_MODE_FIFO_KHR ) {
|
||||||
return present_mode;
|
return present_mode;
|
||||||
|
|||||||
@@ -57,6 +57,40 @@ namespace ApiWithoutSecrets {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ************************************************************ //
|
||||||
|
// BufferParameters //
|
||||||
|
// //
|
||||||
|
// Vulkan Buffer's parameters container class //
|
||||||
|
// ************************************************************ //
|
||||||
|
struct BufferParameters {
|
||||||
|
VkBuffer Handle;
|
||||||
|
VkDeviceMemory Memory;
|
||||||
|
uint32_t Size;
|
||||||
|
|
||||||
|
BufferParameters() :
|
||||||
|
Handle( VK_NULL_HANDLE ),
|
||||||
|
Memory( VK_NULL_HANDLE ),
|
||||||
|
Size( 0 ) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ************************************************************ //
|
||||||
|
// DescriptorParameters //
|
||||||
|
// //
|
||||||
|
// Container class for descriptor related resources //
|
||||||
|
// ************************************************************ //
|
||||||
|
struct DescriptorSetParameters {
|
||||||
|
VkDescriptorPool Pool;
|
||||||
|
VkDescriptorSetLayout Layout;
|
||||||
|
VkDescriptorSet Handle;
|
||||||
|
|
||||||
|
DescriptorSetParameters() :
|
||||||
|
Pool( VK_NULL_HANDLE ),
|
||||||
|
Layout( VK_NULL_HANDLE ),
|
||||||
|
Handle( VK_NULL_HANDLE ) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ************************************************************ //
|
// ************************************************************ //
|
||||||
// SwapChainParameters //
|
// SwapChainParameters //
|
||||||
// //
|
// //
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
Tutorial03::Tutorial03() :
|
Tutorial03::Tutorial03() {
|
||||||
Vulkan() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tutorial03::CreateRenderPass() {
|
bool Tutorial03::CreateRenderPass() {
|
||||||
|
|||||||
@@ -20,8 +20,7 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
Tutorial04::Tutorial04() :
|
Tutorial04::Tutorial04() {
|
||||||
Vulkan() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tutorial04::CreateRenderPass() {
|
bool Tutorial04::CreateRenderPass() {
|
||||||
|
|||||||
@@ -22,23 +22,6 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
// ************************************************************ //
|
|
||||||
// BufferParameters //
|
|
||||||
// //
|
|
||||||
// Vulkan Buffer's parameters container class //
|
|
||||||
// ************************************************************ //
|
|
||||||
struct BufferParameters {
|
|
||||||
VkBuffer Handle;
|
|
||||||
VkDeviceMemory Memory;
|
|
||||||
uint32_t Size;
|
|
||||||
|
|
||||||
BufferParameters() :
|
|
||||||
Handle( VK_NULL_HANDLE ),
|
|
||||||
Memory( VK_NULL_HANDLE ),
|
|
||||||
Size( 0 ) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ************************************************************ //
|
// ************************************************************ //
|
||||||
// VertexData //
|
// VertexData //
|
||||||
// //
|
// //
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
Tutorial05::Tutorial05() :
|
Tutorial05::Tutorial05() {
|
||||||
Vulkan() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tutorial05::CreateRenderingResources() {
|
bool Tutorial05::CreateRenderingResources() {
|
||||||
|
|||||||
@@ -22,23 +22,6 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
// ************************************************************ //
|
|
||||||
// BufferParameters //
|
|
||||||
// //
|
|
||||||
// Vulkan Buffer's parameters container class //
|
|
||||||
// ************************************************************ //
|
|
||||||
struct BufferParameters {
|
|
||||||
VkBuffer Handle;
|
|
||||||
VkDeviceMemory Memory;
|
|
||||||
uint32_t Size;
|
|
||||||
|
|
||||||
BufferParameters() :
|
|
||||||
Handle( VK_NULL_HANDLE ),
|
|
||||||
Memory( VK_NULL_HANDLE ),
|
|
||||||
Size( 0 ) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ************************************************************ //
|
// ************************************************************ //
|
||||||
// VertexData //
|
// VertexData //
|
||||||
// //
|
// //
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
Tutorial06::Tutorial06() :
|
Tutorial06::Tutorial06() {
|
||||||
Vulkan() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tutorial06::CreateRenderingResources() {
|
bool Tutorial06::CreateRenderingResources() {
|
||||||
|
|||||||
@@ -22,40 +22,6 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
// ************************************************************ //
|
|
||||||
// BufferParameters //
|
|
||||||
// //
|
|
||||||
// Vulkan Buffer's parameters container class //
|
|
||||||
// ************************************************************ //
|
|
||||||
struct BufferParameters {
|
|
||||||
VkBuffer Handle;
|
|
||||||
VkDeviceMemory Memory;
|
|
||||||
uint32_t Size;
|
|
||||||
|
|
||||||
BufferParameters() :
|
|
||||||
Handle( VK_NULL_HANDLE ),
|
|
||||||
Memory( VK_NULL_HANDLE ),
|
|
||||||
Size( 0 ) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ************************************************************ //
|
|
||||||
// DescriptorParameters //
|
|
||||||
// //
|
|
||||||
// Container class for descriptor related resources //
|
|
||||||
// ************************************************************ //
|
|
||||||
struct DescriptorSetParameters {
|
|
||||||
VkDescriptorPool Pool;
|
|
||||||
VkDescriptorSetLayout Layout;
|
|
||||||
VkDescriptorSet Handle;
|
|
||||||
|
|
||||||
DescriptorSetParameters() :
|
|
||||||
Pool( VK_NULL_HANDLE ),
|
|
||||||
Layout( VK_NULL_HANDLE ),
|
|
||||||
Handle( VK_NULL_HANDLE ) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ************************************************************ //
|
// ************************************************************ //
|
||||||
// VertexData //
|
// VertexData //
|
||||||
// //
|
// //
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
Tutorial07::Tutorial07() :
|
Tutorial07::Tutorial07() {
|
||||||
Vulkan() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tutorial07::CreateRenderingResources() {
|
bool Tutorial07::CreateRenderingResources() {
|
||||||
|
|||||||
@@ -22,40 +22,6 @@
|
|||||||
|
|
||||||
namespace ApiWithoutSecrets {
|
namespace ApiWithoutSecrets {
|
||||||
|
|
||||||
// ************************************************************ //
|
|
||||||
// BufferParameters //
|
|
||||||
// //
|
|
||||||
// Vulkan Buffer's parameters container class //
|
|
||||||
// ************************************************************ //
|
|
||||||
struct BufferParameters {
|
|
||||||
VkBuffer Handle;
|
|
||||||
VkDeviceMemory Memory;
|
|
||||||
uint32_t Size;
|
|
||||||
|
|
||||||
BufferParameters() :
|
|
||||||
Handle( VK_NULL_HANDLE ),
|
|
||||||
Memory( VK_NULL_HANDLE ),
|
|
||||||
Size( 0 ) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ************************************************************ //
|
|
||||||
// DescriptorParameters //
|
|
||||||
// //
|
|
||||||
// Container class for descriptor related resources //
|
|
||||||
// ************************************************************ //
|
|
||||||
struct DescriptorSetParameters {
|
|
||||||
VkDescriptorPool Pool;
|
|
||||||
VkDescriptorSetLayout Layout;
|
|
||||||
VkDescriptorSet Handle;
|
|
||||||
|
|
||||||
DescriptorSetParameters() :
|
|
||||||
Pool( VK_NULL_HANDLE ),
|
|
||||||
Layout( VK_NULL_HANDLE ),
|
|
||||||
Handle( VK_NULL_HANDLE ) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// ************************************************************ //
|
// ************************************************************ //
|
||||||
// VertexData //
|
// VertexData //
|
||||||
// //
|
// //
|
||||||
|
|||||||
Reference in New Issue
Block a user