Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

Commit 85c53b9

Browse files
committed
Small code refactoring - preparing for further parts of the tutorial.
1 parent c3741bf commit 85c53b9

11 files changed

+48
-114
lines changed

Project/Common/VulkanCommon.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ namespace ApiWithoutSecrets {
612612
// Set of images defined in a swap chain may not always be available for application to render to:
613613
// One may be displayed and one may wait in a queue to be presented
614614
// If application wants to use more images at the same time it must ask for more images
615-
uint32_t image_count = surface_capabilities.minImageCount + 1;
615+
uint32_t image_count = surface_capabilities.minImageCount + 2;
616616
if( (surface_capabilities.maxImageCount > 0) &&
617617
(image_count > surface_capabilities.maxImageCount) ) {
618618
image_count = surface_capabilities.maxImageCount;
@@ -699,13 +699,20 @@ namespace ApiWithoutSecrets {
699699
}
700700

701701
VkPresentModeKHR VulkanCommon::GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes ) {
702-
// FIFO present mode is always available
703702
// MAILBOX is the lowest latency V-Sync enabled mode (something like triple-buffering) so use it if available
704703
for( VkPresentModeKHR &present_mode : present_modes ) {
705704
if( present_mode == VK_PRESENT_MODE_MAILBOX_KHR ) {
706705
return present_mode;
707706
}
708707
}
708+
// IMMEDIATE mode allows us to display frames in a V-Sync independent manner so it can introduce screen tearing
709+
// But this mode is the best for benchmarking purposes if we want to check the real number of FPS
710+
for( VkPresentModeKHR &present_mode : present_modes ) {
711+
if( present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR ) {
712+
return present_mode;
713+
}
714+
}
715+
// FIFO present mode is always available
709716
for( VkPresentModeKHR &present_mode : present_modes ) {
710717
if( present_mode == VK_PRESENT_MODE_FIFO_KHR ) {
711718
return present_mode;

Project/Common/VulkanCommon.h

+34
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,40 @@ namespace ApiWithoutSecrets {
5757
}
5858
};
5959

60+
// ************************************************************ //
61+
// BufferParameters //
62+
// //
63+
// Vulkan Buffer's parameters container class //
64+
// ************************************************************ //
65+
struct BufferParameters {
66+
VkBuffer Handle;
67+
VkDeviceMemory Memory;
68+
uint32_t Size;
69+
70+
BufferParameters() :
71+
Handle( VK_NULL_HANDLE ),
72+
Memory( VK_NULL_HANDLE ),
73+
Size( 0 ) {
74+
}
75+
};
76+
77+
// ************************************************************ //
78+
// DescriptorParameters //
79+
// //
80+
// Container class for descriptor related resources //
81+
// ************************************************************ //
82+
struct DescriptorSetParameters {
83+
VkDescriptorPool Pool;
84+
VkDescriptorSetLayout Layout;
85+
VkDescriptorSet Handle;
86+
87+
DescriptorSetParameters() :
88+
Pool( VK_NULL_HANDLE ),
89+
Layout( VK_NULL_HANDLE ),
90+
Handle( VK_NULL_HANDLE ) {
91+
}
92+
};
93+
6094
// ************************************************************ //
6195
// SwapChainParameters //
6296
// //

Project/Tutorials/03/Tutorial03.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
namespace ApiWithoutSecrets {
2121

22-
Tutorial03::Tutorial03() :
23-
Vulkan() {
22+
Tutorial03::Tutorial03() {
2423
}
2524

2625
bool Tutorial03::CreateRenderPass() {

Project/Tutorials/04/Tutorial04.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
namespace ApiWithoutSecrets {
2222

23-
Tutorial04::Tutorial04() :
24-
Vulkan() {
23+
Tutorial04::Tutorial04() {
2524
}
2625

2726
bool Tutorial04::CreateRenderPass() {

Project/Tutorials/04/Tutorial04.h

-17
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,6 @@
2222

2323
namespace ApiWithoutSecrets {
2424

25-
// ************************************************************ //
26-
// BufferParameters //
27-
// //
28-
// Vulkan Buffer's parameters container class //
29-
// ************************************************************ //
30-
struct BufferParameters {
31-
VkBuffer Handle;
32-
VkDeviceMemory Memory;
33-
uint32_t Size;
34-
35-
BufferParameters() :
36-
Handle( VK_NULL_HANDLE ),
37-
Memory( VK_NULL_HANDLE ),
38-
Size( 0 ) {
39-
}
40-
};
41-
4225
// ************************************************************ //
4326
// VertexData //
4427
// //

Project/Tutorials/05/Tutorial05.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
namespace ApiWithoutSecrets {
2121

22-
Tutorial05::Tutorial05() :
23-
Vulkan() {
22+
Tutorial05::Tutorial05() {
2423
}
2524

2625
bool Tutorial05::CreateRenderingResources() {

Project/Tutorials/05/Tutorial05.h

-17
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,6 @@
2222

2323
namespace ApiWithoutSecrets {
2424

25-
// ************************************************************ //
26-
// BufferParameters //
27-
// //
28-
// Vulkan Buffer's parameters container class //
29-
// ************************************************************ //
30-
struct BufferParameters {
31-
VkBuffer Handle;
32-
VkDeviceMemory Memory;
33-
uint32_t Size;
34-
35-
BufferParameters() :
36-
Handle( VK_NULL_HANDLE ),
37-
Memory( VK_NULL_HANDLE ),
38-
Size( 0 ) {
39-
}
40-
};
41-
4225
// ************************************************************ //
4326
// VertexData //
4427
// //

Project/Tutorials/06/Tutorial06.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
namespace ApiWithoutSecrets {
2121

22-
Tutorial06::Tutorial06() :
23-
Vulkan() {
22+
Tutorial06::Tutorial06() {
2423
}
2524

2625
bool Tutorial06::CreateRenderingResources() {

Project/Tutorials/06/Tutorial06.h

-34
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,6 @@
2222

2323
namespace ApiWithoutSecrets {
2424

25-
// ************************************************************ //
26-
// BufferParameters //
27-
// //
28-
// Vulkan Buffer's parameters container class //
29-
// ************************************************************ //
30-
struct BufferParameters {
31-
VkBuffer Handle;
32-
VkDeviceMemory Memory;
33-
uint32_t Size;
34-
35-
BufferParameters() :
36-
Handle( VK_NULL_HANDLE ),
37-
Memory( VK_NULL_HANDLE ),
38-
Size( 0 ) {
39-
}
40-
};
41-
42-
// ************************************************************ //
43-
// DescriptorParameters //
44-
// //
45-
// Container class for descriptor related resources //
46-
// ************************************************************ //
47-
struct DescriptorSetParameters {
48-
VkDescriptorPool Pool;
49-
VkDescriptorSetLayout Layout;
50-
VkDescriptorSet Handle;
51-
52-
DescriptorSetParameters() :
53-
Pool( VK_NULL_HANDLE ),
54-
Layout( VK_NULL_HANDLE ),
55-
Handle( VK_NULL_HANDLE ) {
56-
}
57-
};
58-
5925
// ************************************************************ //
6026
// VertexData //
6127
// //

Project/Tutorials/07/Tutorial07.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
namespace ApiWithoutSecrets {
2121

22-
Tutorial07::Tutorial07() :
23-
Vulkan() {
22+
Tutorial07::Tutorial07() {
2423
}
2524

2625
bool Tutorial07::CreateRenderingResources() {

Project/Tutorials/07/Tutorial07.h

-34
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,6 @@
2222

2323
namespace ApiWithoutSecrets {
2424

25-
// ************************************************************ //
26-
// BufferParameters //
27-
// //
28-
// Vulkan Buffer's parameters container class //
29-
// ************************************************************ //
30-
struct BufferParameters {
31-
VkBuffer Handle;
32-
VkDeviceMemory Memory;
33-
uint32_t Size;
34-
35-
BufferParameters() :
36-
Handle( VK_NULL_HANDLE ),
37-
Memory( VK_NULL_HANDLE ),
38-
Size( 0 ) {
39-
}
40-
};
41-
42-
// ************************************************************ //
43-
// DescriptorParameters //
44-
// //
45-
// Container class for descriptor related resources //
46-
// ************************************************************ //
47-
struct DescriptorSetParameters {
48-
VkDescriptorPool Pool;
49-
VkDescriptorSetLayout Layout;
50-
VkDescriptorSet Handle;
51-
52-
DescriptorSetParameters() :
53-
Pool( VK_NULL_HANDLE ),
54-
Layout( VK_NULL_HANDLE ),
55-
Handle( VK_NULL_HANDLE ) {
56-
}
57-
};
58-
5925
// ************************************************************ //
6026
// VertexData //
6127
// //

0 commit comments

Comments
 (0)