mirror of
https://github.com/opus-tango/IntroductionToVulkan.git
synced 2026-03-20 03:55:26 +00:00
Changed all printf() functions to std::cout. Added information about available swap chain image usages. Cleaned included header files.
This commit is contained in:
@@ -18,18 +18,17 @@
|
|||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace OS {
|
namespace OS {
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||||
// nor any responsibility to update it.
|
// nor any responsibility to update it.
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include "Tools.h"
|
#include "Tools.h"
|
||||||
|
|
||||||
namespace Tools {
|
namespace Tools {
|
||||||
@@ -16,7 +18,7 @@ namespace Tools {
|
|||||||
|
|
||||||
std::ifstream file( filename, std::ios::binary );
|
std::ifstream file( filename, std::ios::binary );
|
||||||
if( file.fail() ) {
|
if( file.fail() ) {
|
||||||
printf( "Could not open \"%s\" file!\n", filename.c_str() );
|
std::cout << "Could not open \"" << filename << "\" file!" << std::endl;
|
||||||
return std::vector<char>();
|
return std::vector<char>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fstream>
|
|
||||||
#include "vulkan.h"
|
#include "vulkan.h"
|
||||||
|
|
||||||
namespace Tools {
|
namespace Tools {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||||
// nor any responsibility to update it.
|
// nor any responsibility to update it.
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include "VulkanCommon.h"
|
#include "VulkanCommon.h"
|
||||||
#include "VulkanFunctions.h"
|
#include "VulkanFunctions.h"
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ namespace Tutorial {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( VulkanLibrary == nullptr ) {
|
if( VulkanLibrary == nullptr ) {
|
||||||
printf( "Could not load Vulkan library!\n" );
|
std::cout << "Could not load Vulkan library!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -119,7 +118,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
#define VK_EXPORTED_FUNCTION( fun ) \
|
#define VK_EXPORTED_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
||||||
printf( "Could not load exported function: " #fun "!\n" ); \
|
std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +130,7 @@ namespace Tutorial {
|
|||||||
bool VulkanCommon::LoadGlobalLevelEntryPoints() {
|
bool VulkanCommon::LoadGlobalLevelEntryPoints() {
|
||||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
||||||
printf( "Could not load global level function: " #fun "!\n" ); \
|
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,13 +143,13 @@ namespace Tutorial {
|
|||||||
uint32_t extensions_count = 0;
|
uint32_t extensions_count = 0;
|
||||||
if( (vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(extensions_count == 0) ) {
|
(extensions_count == 0) ) {
|
||||||
printf( "Error occurred during instance extensions enumeration!\n" );
|
std::cout << "Error occurred during instance extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
||||||
if( vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
if( vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during instance extensions enumeration!\n" );
|
std::cout << "Error occurred during instance extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
for( size_t i = 0; i < extensions.size(); ++i ) {
|
for( size_t i = 0; i < extensions.size(); ++i ) {
|
||||||
if( !CheckExtensionAvailability( extensions[i], available_extensions ) ) {
|
if( !CheckExtensionAvailability( extensions[i], available_extensions ) ) {
|
||||||
printf( "Could not find instance extension named \"%s\"!\n", extensions[i] );
|
std::cout << "Could not find instance extension named \"" << extensions[i] << "\"!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +193,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create Vulkan instance!\n" );
|
std::cout << "Could not create Vulkan instance!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -203,7 +202,7 @@ namespace Tutorial {
|
|||||||
bool VulkanCommon::LoadInstanceLevelEntryPoints() {
|
bool VulkanCommon::LoadInstanceLevelEntryPoints() {
|
||||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
||||||
printf( "Could not load instance level function: " #fun "\n" ); \
|
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +252,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf( "Could not create presentation surface!\n" );
|
std::cout << "Could not create presentation surface!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,13 +260,13 @@ namespace Tutorial {
|
|||||||
uint32_t num_devices = 0;
|
uint32_t num_devices = 0;
|
||||||
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
||||||
(num_devices == 0) ) {
|
(num_devices == 0) ) {
|
||||||
printf( "Error occurred during physical devices enumeration!\n" );
|
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
||||||
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during physical devices enumeration!\n" );
|
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +279,7 @@ namespace Tutorial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( Vulkan.PhysicalDevice == VK_NULL_HANDLE ) {
|
if( Vulkan.PhysicalDevice == VK_NULL_HANDLE ) {
|
||||||
printf( "Could not select physical device based on the chosen properties!\n" );
|
std::cout << "Could not select physical device based on the chosen properties!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +324,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateDevice( Vulkan.PhysicalDevice, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
if( vkCreateDevice( Vulkan.PhysicalDevice, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create Vulkan device!\n" );
|
std::cout << "Could not create Vulkan device!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,13 +337,13 @@ namespace Tutorial {
|
|||||||
uint32_t extensions_count = 0;
|
uint32_t extensions_count = 0;
|
||||||
if( (vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(extensions_count == 0) ) {
|
(extensions_count == 0) ) {
|
||||||
printf( "Error occurred during physical device %p extensions enumeration!\n", physical_device );
|
std::cout << "Error occurred during physical device " << physical_device << " extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
||||||
if( vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
if( vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during physical device %p extensions enumeration!\n", physical_device );
|
std::cout << "Error occurred during physical device " << physical_device << " extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +353,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
for( size_t i = 0; i < device_extensions.size(); ++i ) {
|
for( size_t i = 0; i < device_extensions.size(); ++i ) {
|
||||||
if( !CheckExtensionAvailability( device_extensions[i], available_extensions ) ) {
|
if( !CheckExtensionAvailability( device_extensions[i], available_extensions ) ) {
|
||||||
printf( "Physical device %p doesn't support extension named \"%s\"!\n", physical_device, device_extensions[i] );
|
std::cout << "Physical device " << physical_device << " doesn't support extension named \"" << device_extensions[i] << "\"!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,14 +368,14 @@ namespace Tutorial {
|
|||||||
|
|
||||||
if( (major_version < 1) &&
|
if( (major_version < 1) &&
|
||||||
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
||||||
printf( "Physical device %p doesn't support required parameters!\n", physical_device );
|
std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t queue_families_count = 0;
|
uint32_t queue_families_count = 0;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
||||||
if( queue_families_count == 0 ) {
|
if( queue_families_count == 0 ) {
|
||||||
printf( "Physical device %p doesn't have any queue families!\n", physical_device );
|
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +417,7 @@ namespace Tutorial {
|
|||||||
// If this device doesn't support queues with graphics and present capabilities don't use it
|
// If this device doesn't support queues with graphics and present capabilities don't use it
|
||||||
if( (graphics_queue_family_index == UINT32_MAX) ||
|
if( (graphics_queue_family_index == UINT32_MAX) ||
|
||||||
(present_queue_family_index == UINT32_MAX) ) {
|
(present_queue_family_index == UINT32_MAX) ) {
|
||||||
printf( "Could not find queue families with required properties on physical device %p!\n", physical_device );
|
std::cout << "Could not find queue families with required properties on physical device " << physical_device << "!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +429,7 @@ namespace Tutorial {
|
|||||||
bool VulkanCommon::LoadDeviceLevelEntryPoints() {
|
bool VulkanCommon::LoadDeviceLevelEntryPoints() {
|
||||||
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
||||||
printf( "Could not load device level function: " #fun "!\n" ); \
|
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,33 +451,33 @@ namespace Tutorial {
|
|||||||
|
|
||||||
VkSurfaceCapabilitiesKHR surface_capabilities;
|
VkSurfaceCapabilitiesKHR surface_capabilities;
|
||||||
if( vkGetPhysicalDeviceSurfaceCapabilitiesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &surface_capabilities ) != VK_SUCCESS ) {
|
if( vkGetPhysicalDeviceSurfaceCapabilitiesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &surface_capabilities ) != VK_SUCCESS ) {
|
||||||
printf( "Could not check presentation surface capabilities!\n" );
|
std::cout << "Could not check presentation surface capabilities!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t formats_count;
|
uint32_t formats_count;
|
||||||
if( (vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(formats_count == 0) ) {
|
(formats_count == 0) ) {
|
||||||
printf( "Error occurred during presentation surface formats enumeration!\n" );
|
std::cout << "Error occurred during presentation surface formats enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkSurfaceFormatKHR> surface_formats( formats_count );
|
std::vector<VkSurfaceFormatKHR> surface_formats( formats_count );
|
||||||
if( vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, &surface_formats[0] ) != VK_SUCCESS ) {
|
if( vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, &surface_formats[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during presentation surface formats enumeration!\n" );
|
std::cout << "Error occurred during presentation surface formats enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t present_modes_count;
|
uint32_t present_modes_count;
|
||||||
if( (vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(present_modes_count == 0) ) {
|
(present_modes_count == 0) ) {
|
||||||
printf( "Error occurred during presentation surface present modes enumeration!\n" );
|
std::cout << "Error occurred during presentation surface present modes enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkPresentModeKHR> present_modes( present_modes_count );
|
std::vector<VkPresentModeKHR> present_modes( present_modes_count );
|
||||||
if( vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, &present_modes[0] ) != VK_SUCCESS ) {
|
if( vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, &present_modes[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during presentation surface present modes enumeration!\n" );
|
std::cout << "Error occurred during presentation surface present modes enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,8 +489,10 @@ namespace Tutorial {
|
|||||||
VkPresentModeKHR desired_present_mode = GetSwapChainPresentMode( present_modes );
|
VkPresentModeKHR desired_present_mode = GetSwapChainPresentMode( present_modes );
|
||||||
VkSwapchainKHR old_swap_chain = Vulkan.SwapChain.Handle;
|
VkSwapchainKHR old_swap_chain = Vulkan.SwapChain.Handle;
|
||||||
|
|
||||||
if( static_cast<int>(desired_usage) == 0 ) {
|
if( static_cast<int>(desired_usage) == -1 ) {
|
||||||
printf( "TRANSFER_DST image usage is not supported by the swap chain!" );
|
return false;
|
||||||
|
}
|
||||||
|
if( static_cast<int>(desired_present_mode) == -1 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,7 +518,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateSwapchainKHR( Vulkan.Device, &swap_chain_create_info, nullptr, &Vulkan.SwapChain.Handle ) != VK_SUCCESS ) {
|
if( vkCreateSwapchainKHR( Vulkan.Device, &swap_chain_create_info, nullptr, &Vulkan.SwapChain.Handle ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create swap chain!\n" );
|
std::cout << "Could not create swap chain!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( old_swap_chain != VK_NULL_HANDLE ) {
|
if( old_swap_chain != VK_NULL_HANDLE ) {
|
||||||
@@ -529,12 +530,12 @@ namespace Tutorial {
|
|||||||
uint32_t image_count = 0;
|
uint32_t image_count = 0;
|
||||||
if( (vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain.Handle, &image_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain.Handle, &image_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(image_count == 0) ) {
|
(image_count == 0) ) {
|
||||||
printf( "Could not get swap chain images!\n" );
|
std::cout << "Could not get swap chain images!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Vulkan.SwapChain.Images.resize( image_count );
|
Vulkan.SwapChain.Images.resize( image_count );
|
||||||
if( vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain.Handle, &image_count, &Vulkan.SwapChain.Images[0] ) != VK_SUCCESS ) {
|
if( vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain.Handle, &image_count, &Vulkan.SwapChain.Images[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Could not get swap chain images!\n" );
|
std::cout << "Could not get swap chain images!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,7 +551,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
if( (vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.ImageAvailableSemaphore ) != VK_SUCCESS) ||
|
if( (vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.ImageAvailableSemaphore ) != VK_SUCCESS) ||
|
||||||
(vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.RenderingFinishedSemaphore ) != VK_SUCCESS) ) {
|
(vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.RenderingFinishedSemaphore ) != VK_SUCCESS) ) {
|
||||||
printf( "Could not create semaphores!\n" );
|
std::cout << "Could not create semaphores!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,7 +629,18 @@ namespace Tutorial {
|
|||||||
if( surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT ) {
|
if( surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT ) {
|
||||||
return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
}
|
}
|
||||||
return 0;
|
std::cout << "VK_IMAGE_USAGE_TRANSFER_DST image usage is not supported by the swap chain!" << std::endl
|
||||||
|
<< "Supported swap chain's image usages include:" << std::endl
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT ? " VK_IMAGE_USAGE_TRANSFER_SRC\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT ? " VK_IMAGE_USAGE_TRANSFER_DST\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT ? " VK_IMAGE_USAGE_SAMPLED\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_STORAGE_BIT ? " VK_IMAGE_USAGE_STORAGE\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_COLOR_ATTACHMENT\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_INPUT_ATTACHMENT" : "")
|
||||||
|
<< std::endl;
|
||||||
|
return static_cast<VkImageUsageFlags>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSurfaceTransformFlagBitsKHR VulkanCommon::GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities ) {
|
VkSurfaceTransformFlagBitsKHR VulkanCommon::GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities ) {
|
||||||
@@ -636,7 +648,7 @@ namespace Tutorial {
|
|||||||
// being other than default orientation)
|
// being other than default orientation)
|
||||||
// If the specified transform is other than current transform, presentation engine will transform image
|
// If the specified transform is other than current transform, presentation engine will transform image
|
||||||
// during presentation operation; this operation may hit performance on some platforms
|
// during presentation operation; this operation may hit performance on some platforms
|
||||||
// Here we don't want any transformations to occur so if no transform is supported use it
|
// Here we don't want any transformations to occur so if the identity transform is supported use it
|
||||||
// otherwise just use the same transform as current transform
|
// otherwise just use the same transform as current transform
|
||||||
if( surface_capabilities.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR ) {
|
if( surface_capabilities.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR ) {
|
||||||
return VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
return VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||||
@@ -653,7 +665,13 @@ namespace Tutorial {
|
|||||||
return present_mode;
|
return present_mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return VK_PRESENT_MODE_FIFO_KHR;
|
for( VkPresentModeKHR &present_mode : present_modes ) {
|
||||||
|
if( present_mode == VK_PRESENT_MODE_FIFO_KHR ) {
|
||||||
|
return present_mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "FIFO present mode is not supported by the swap chain!" << std::endl;
|
||||||
|
return static_cast<VkPresentModeKHR>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VulkanCommon::~VulkanCommon() {
|
VulkanCommon::~VulkanCommon() {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace Tutorial {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( VulkanLibrary == nullptr ) {
|
if( VulkanLibrary == nullptr ) {
|
||||||
printf( "Could not load Vulkan library!\n" );
|
std::cout << "Could not load Vulkan library!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -78,7 +78,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
#define VK_EXPORTED_FUNCTION( fun ) \
|
#define VK_EXPORTED_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
||||||
printf( "Could not load exported function: " #fun "!\n" ); \
|
std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ namespace Tutorial {
|
|||||||
bool Tutorial01::LoadGlobalLevelEntryPoints() {
|
bool Tutorial01::LoadGlobalLevelEntryPoints() {
|
||||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
||||||
printf( "Could not load global level function: " #fun "!\n" ); \
|
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create Vulkan instance!\n" );
|
std::cout << "Could not create Vulkan instance!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -131,7 +131,7 @@ namespace Tutorial {
|
|||||||
bool Tutorial01::LoadInstanceLevelEntryPoints() {
|
bool Tutorial01::LoadInstanceLevelEntryPoints() {
|
||||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
||||||
printf( "Could not load instance level function: " #fun "\n" ); \
|
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,13 +144,13 @@ namespace Tutorial {
|
|||||||
uint32_t num_devices = 0;
|
uint32_t num_devices = 0;
|
||||||
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
||||||
(num_devices == 0) ) {
|
(num_devices == 0) ) {
|
||||||
printf( "Error occurred during physical devices enumeration!\n" );
|
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
||||||
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during physical devices enumeration!\n" );
|
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ namespace Tutorial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( selected_physical_device == VK_NULL_HANDLE ) {
|
if( selected_physical_device == VK_NULL_HANDLE ) {
|
||||||
printf( "Could not select physical device based on the chosen properties!\n" );
|
std::cout << "Could not select physical device based on the chosen properties!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create Vulkan device!\n" );
|
std::cout << "Could not create Vulkan device!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,14 +212,14 @@ namespace Tutorial {
|
|||||||
|
|
||||||
if( (major_version < 1) &&
|
if( (major_version < 1) &&
|
||||||
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
||||||
printf( "Physical device %p doesn't support required parameters!\n", physical_device );
|
std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t queue_families_count = 0;
|
uint32_t queue_families_count = 0;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
||||||
if( queue_families_count == 0 ) {
|
if( queue_families_count == 0 ) {
|
||||||
printf( "Physical device %p doesn't have any queue families!\n", physical_device );
|
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,14 +233,14 @@ namespace Tutorial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "Could not find queue family with required properties on physical device %p!\n", physical_device );
|
std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tutorial01::LoadDeviceLevelEntryPoints() {
|
bool Tutorial01::LoadDeviceLevelEntryPoints() {
|
||||||
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
||||||
printf( "Could not load device level function: " #fun "!\n" ); \
|
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||||
// nor any responsibility to update it.
|
// nor any responsibility to update it.
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include "Tutorial02.h"
|
#include "Tutorial02.h"
|
||||||
#include "VulkanFunctions.h"
|
#include "VulkanFunctions.h"
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ namespace Tutorial {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( VulkanLibrary == nullptr ) {
|
if( VulkanLibrary == nullptr ) {
|
||||||
printf( "Could not load Vulkan library!\n" );
|
std::cout << "Could not load Vulkan library!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -79,7 +78,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
#define VK_EXPORTED_FUNCTION( fun ) \
|
#define VK_EXPORTED_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
||||||
printf( "Could not load exported function: " #fun "!\n" ); \
|
std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +90,7 @@ namespace Tutorial {
|
|||||||
bool Tutorial02::LoadGlobalLevelEntryPoints() {
|
bool Tutorial02::LoadGlobalLevelEntryPoints() {
|
||||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
||||||
printf( "Could not load global level function: " #fun "!\n" ); \
|
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,13 +103,13 @@ namespace Tutorial {
|
|||||||
uint32_t extensions_count = 0;
|
uint32_t extensions_count = 0;
|
||||||
if( (vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(extensions_count == 0) ) {
|
(extensions_count == 0) ) {
|
||||||
printf( "Error occurred during instance extensions enumeration!\n" );
|
std::cout << "Error occurred during instance extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
||||||
if( vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
if( vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during instance extensions enumeration!\n" );
|
std::cout << "Error occurred during instance extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +126,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
for( size_t i = 0; i < extensions.size(); ++i ) {
|
for( size_t i = 0; i < extensions.size(); ++i ) {
|
||||||
if( !CheckExtensionAvailability( extensions[i], available_extensions ) ) {
|
if( !CheckExtensionAvailability( extensions[i], available_extensions ) ) {
|
||||||
printf( "Could not find instance extension named \"%s\"!\n", extensions[i] );
|
std::cout << "Could not find instance extension named \"" << extensions[i] << "\"!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +153,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create Vulkan instance!\n" );
|
std::cout << "Could not create Vulkan instance!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -172,7 +171,7 @@ namespace Tutorial {
|
|||||||
bool Tutorial02::LoadInstanceLevelEntryPoints() {
|
bool Tutorial02::LoadInstanceLevelEntryPoints() {
|
||||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
||||||
printf( "Could not load instance level function: " #fun "\n" ); \
|
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +221,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf( "Could not create presentation surface!\n" );
|
std::cout << "Could not create presentation surface!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,13 +229,13 @@ namespace Tutorial {
|
|||||||
uint32_t num_devices = 0;
|
uint32_t num_devices = 0;
|
||||||
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
||||||
(num_devices == 0) ) {
|
(num_devices == 0) ) {
|
||||||
printf( "Error occurred during physical devices enumeration!\n" );
|
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
||||||
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during physical devices enumeration!\n" );
|
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +248,7 @@ namespace Tutorial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( Vulkan.PhysicalDevice == VK_NULL_HANDLE ) {
|
if( Vulkan.PhysicalDevice == VK_NULL_HANDLE ) {
|
||||||
printf( "Could not select physical device based on the chosen properties!\n" );
|
std::cout << "Could not select physical device based on the chosen properties!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +293,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateDevice( Vulkan.PhysicalDevice, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
if( vkCreateDevice( Vulkan.PhysicalDevice, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create Vulkan device!\n" );
|
std::cout << "Could not create Vulkan device!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,13 +306,13 @@ namespace Tutorial {
|
|||||||
uint32_t extensions_count = 0;
|
uint32_t extensions_count = 0;
|
||||||
if( (vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(extensions_count == 0) ) {
|
(extensions_count == 0) ) {
|
||||||
printf( "Error occurred during physical device %p extensions enumeration!\n", physical_device );
|
std::cout << "Error occurred during physical device " << physical_device << " extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
std::vector<VkExtensionProperties> available_extensions( extensions_count );
|
||||||
if( vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
if( vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, &available_extensions[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during physical device %p extensions enumeration!\n", physical_device );
|
std::cout << "Error occurred during physical device " << physical_device << " extensions enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +322,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
for( size_t i = 0; i < device_extensions.size(); ++i ) {
|
for( size_t i = 0; i < device_extensions.size(); ++i ) {
|
||||||
if( !CheckExtensionAvailability( device_extensions[i], available_extensions ) ) {
|
if( !CheckExtensionAvailability( device_extensions[i], available_extensions ) ) {
|
||||||
printf( "Physical device %p doesn't support extension named \"%s\"!\n", physical_device, device_extensions[i] );
|
std::cout << "Physical device " << physical_device << " doesn't support extension named \"" << device_extensions[i] << "\"!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,14 +337,14 @@ namespace Tutorial {
|
|||||||
|
|
||||||
if( (major_version < 1) &&
|
if( (major_version < 1) &&
|
||||||
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
||||||
printf( "Physical device %p doesn't support required parameters!\n", physical_device );
|
std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t queue_families_count = 0;
|
uint32_t queue_families_count = 0;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
||||||
if( queue_families_count == 0 ) {
|
if( queue_families_count == 0 ) {
|
||||||
printf( "Physical device %p doesn't have any queue families!\n", physical_device );
|
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +386,7 @@ namespace Tutorial {
|
|||||||
// If this device doesn't support queues with graphics and present capabilities don't use it
|
// If this device doesn't support queues with graphics and present capabilities don't use it
|
||||||
if( (graphics_queue_family_index == UINT32_MAX) ||
|
if( (graphics_queue_family_index == UINT32_MAX) ||
|
||||||
(present_queue_family_index == UINT32_MAX) ) {
|
(present_queue_family_index == UINT32_MAX) ) {
|
||||||
printf( "Could not find queue families with required properties on physical device %p!\n", physical_device );
|
std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +398,7 @@ namespace Tutorial {
|
|||||||
bool Tutorial02::LoadDeviceLevelEntryPoints() {
|
bool Tutorial02::LoadDeviceLevelEntryPoints() {
|
||||||
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
||||||
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
||||||
printf( "Could not load device level function: " #fun "!\n" ); \
|
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +422,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
if( (vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.ImageAvailableSemaphore ) != VK_SUCCESS) ||
|
if( (vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.ImageAvailableSemaphore ) != VK_SUCCESS) ||
|
||||||
(vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.RenderingFinishedSemaphore ) != VK_SUCCESS) ) {
|
(vkCreateSemaphore( Vulkan.Device, &semaphore_create_info, nullptr, &Vulkan.RenderingFinishedSemaphore ) != VK_SUCCESS) ) {
|
||||||
printf( "Could not create semaphores!\n" );
|
std::cout << "Could not create semaphores!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,33 +436,33 @@ namespace Tutorial {
|
|||||||
|
|
||||||
VkSurfaceCapabilitiesKHR surface_capabilities;
|
VkSurfaceCapabilitiesKHR surface_capabilities;
|
||||||
if( vkGetPhysicalDeviceSurfaceCapabilitiesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &surface_capabilities ) != VK_SUCCESS ) {
|
if( vkGetPhysicalDeviceSurfaceCapabilitiesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &surface_capabilities ) != VK_SUCCESS ) {
|
||||||
printf( "Could not check presentation surface capabilities!\n" );
|
std::cout << "Could not check presentation surface capabilities!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t formats_count;
|
uint32_t formats_count;
|
||||||
if( (vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(formats_count == 0) ) {
|
(formats_count == 0) ) {
|
||||||
printf( "Error occurred during presentation surface formats enumeration!\n" );
|
std::cout << "Error occurred during presentation surface formats enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkSurfaceFormatKHR> surface_formats( formats_count );
|
std::vector<VkSurfaceFormatKHR> surface_formats( formats_count );
|
||||||
if( vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, &surface_formats[0] ) != VK_SUCCESS ) {
|
if( vkGetPhysicalDeviceSurfaceFormatsKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &formats_count, &surface_formats[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during presentation surface formats enumeration!\n" );
|
std::cout << "Error occurred during presentation surface formats enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t present_modes_count;
|
uint32_t present_modes_count;
|
||||||
if( (vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(present_modes_count == 0) ) {
|
(present_modes_count == 0) ) {
|
||||||
printf( "Error occurred during presentation surface present modes enumeration!\n" );
|
std::cout << "Error occurred during presentation surface present modes enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<VkPresentModeKHR> present_modes( present_modes_count );
|
std::vector<VkPresentModeKHR> present_modes( present_modes_count );
|
||||||
if( vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, &present_modes[0] ) != VK_SUCCESS ) {
|
if( vkGetPhysicalDeviceSurfacePresentModesKHR( Vulkan.PhysicalDevice, Vulkan.PresentationSurface, &present_modes_count, &present_modes[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during presentation surface present modes enumeration!\n" );
|
std::cout << "Error occurred during presentation surface present modes enumeration!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,8 +474,10 @@ namespace Tutorial {
|
|||||||
VkPresentModeKHR desired_present_mode = GetSwapChainPresentMode( present_modes );
|
VkPresentModeKHR desired_present_mode = GetSwapChainPresentMode( present_modes );
|
||||||
VkSwapchainKHR old_swap_chain = Vulkan.SwapChain;
|
VkSwapchainKHR old_swap_chain = Vulkan.SwapChain;
|
||||||
|
|
||||||
if( static_cast<int>(desired_usage) == 0 ) {
|
if( static_cast<int>(desired_usage) == -1 ) {
|
||||||
printf( "TRANSFER_DST image usage is not supported by the swap chain!" );
|
return false;
|
||||||
|
}
|
||||||
|
if( static_cast<int>(desired_present_mode) == -1 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +503,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateSwapchainKHR( Vulkan.Device, &swap_chain_create_info, nullptr, &Vulkan.SwapChain ) != VK_SUCCESS ) {
|
if( vkCreateSwapchainKHR( Vulkan.Device, &swap_chain_create_info, nullptr, &Vulkan.SwapChain ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create swap chain!\n" );
|
std::cout << "Could not create swap chain!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( old_swap_chain != VK_NULL_HANDLE ) {
|
if( old_swap_chain != VK_NULL_HANDLE ) {
|
||||||
@@ -574,7 +575,18 @@ namespace Tutorial {
|
|||||||
if( surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT ) {
|
if( surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT ) {
|
||||||
return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
}
|
}
|
||||||
return 0;
|
std::cout << "VK_IMAGE_USAGE_TRANSFER_DST image usage is not supported by the swap chain!" << std::endl
|
||||||
|
<< "Supported swap chain's image usages include:" << std::endl
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT ? " VK_IMAGE_USAGE_TRANSFER_SRC\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT ? " VK_IMAGE_USAGE_TRANSFER_DST\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_SAMPLED_BIT ? " VK_IMAGE_USAGE_SAMPLED\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_STORAGE_BIT ? " VK_IMAGE_USAGE_STORAGE\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_COLOR_ATTACHMENT\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT\n" : "")
|
||||||
|
<< (surface_capabilities.supportedUsageFlags & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT ? " VK_IMAGE_USAGE_INPUT_ATTACHMENT" : "")
|
||||||
|
<< std::endl;
|
||||||
|
return static_cast<VkImageUsageFlags>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSurfaceTransformFlagBitsKHR Tutorial02::GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities ) {
|
VkSurfaceTransformFlagBitsKHR Tutorial02::GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities ) {
|
||||||
@@ -599,7 +611,13 @@ namespace Tutorial {
|
|||||||
return present_mode;
|
return present_mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return VK_PRESENT_MODE_FIFO_KHR;
|
for( VkPresentModeKHR &present_mode : present_modes ) {
|
||||||
|
if( present_mode == VK_PRESENT_MODE_FIFO_KHR ) {
|
||||||
|
return present_mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "FIFO present mode is not supported by the swap chain!" << std::endl;
|
||||||
|
return static_cast<VkPresentModeKHR>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tutorial02::OnWindowSizeChanged() {
|
bool Tutorial02::OnWindowSizeChanged() {
|
||||||
@@ -623,14 +641,14 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateCommandPool( Vulkan.Device, &cmd_pool_create_info, nullptr, &Vulkan.PresentQueueCmdPool ) != VK_SUCCESS ) {
|
if( vkCreateCommandPool( Vulkan.Device, &cmd_pool_create_info, nullptr, &Vulkan.PresentQueueCmdPool ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create a command pool!\n" );
|
std::cout << "Could not create a command pool!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t image_count = 0;
|
uint32_t image_count = 0;
|
||||||
if( (vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain, &image_count, nullptr ) != VK_SUCCESS) ||
|
if( (vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain, &image_count, nullptr ) != VK_SUCCESS) ||
|
||||||
(image_count == 0) ) {
|
(image_count == 0) ) {
|
||||||
printf( "Could not get the number of swap chain images!\n" );
|
std::cout << "Could not get the number of swap chain images!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,12 +662,12 @@ namespace Tutorial {
|
|||||||
image_count // uint32_t bufferCount
|
image_count // uint32_t bufferCount
|
||||||
};
|
};
|
||||||
if( vkAllocateCommandBuffers( Vulkan.Device, &cmd_buffer_allocate_info, &Vulkan.PresentQueueCmdBuffers[0] ) != VK_SUCCESS ) {
|
if( vkAllocateCommandBuffers( Vulkan.Device, &cmd_buffer_allocate_info, &Vulkan.PresentQueueCmdBuffers[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Could not allocate command buffers!\n" );
|
std::cout << "Could not allocate command buffers!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !RecordCommandBuffers() ) {
|
if( !RecordCommandBuffers() ) {
|
||||||
printf( "Could not record command buffers!\n" );
|
std::cout << "Could not record command buffers!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -660,7 +678,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
std::vector<VkImage> swap_chain_images( image_count );
|
std::vector<VkImage> swap_chain_images( image_count );
|
||||||
if( vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain, &image_count, &swap_chain_images[0] ) != VK_SUCCESS ) {
|
if( vkGetSwapchainImagesKHR( Vulkan.Device, Vulkan.SwapChain, &image_count, &swap_chain_images[0] ) != VK_SUCCESS ) {
|
||||||
printf( "Could not get swap chain images!\n" );
|
std::cout << "Could not get swap chain images!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,7 +735,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
vkCmdPipelineBarrier( Vulkan.PresentQueueCmdBuffers[i], VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier_from_clear_to_present );
|
vkCmdPipelineBarrier( Vulkan.PresentQueueCmdBuffers[i], VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier_from_clear_to_present );
|
||||||
if( vkEndCommandBuffer( Vulkan.PresentQueueCmdBuffers[i] ) != VK_SUCCESS ) {
|
if( vkEndCommandBuffer( Vulkan.PresentQueueCmdBuffers[i] ) != VK_SUCCESS ) {
|
||||||
printf( "Could not record command buffers!\n" );
|
std::cout << "Could not record command buffers!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -751,7 +769,7 @@ namespace Tutorial {
|
|||||||
case VK_ERROR_OUT_OF_DATE_KHR:
|
case VK_ERROR_OUT_OF_DATE_KHR:
|
||||||
return OnWindowSizeChanged();
|
return OnWindowSizeChanged();
|
||||||
default:
|
default:
|
||||||
printf( "Problem occurred during swap chain image acquisition!\n" );
|
std::cout << "Problem occurred during swap chain image acquisition!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,7 +809,7 @@ namespace Tutorial {
|
|||||||
case VK_SUBOPTIMAL_KHR:
|
case VK_SUBOPTIMAL_KHR:
|
||||||
return OnWindowSizeChanged();
|
return OnWindowSizeChanged();
|
||||||
default:
|
default:
|
||||||
printf( "Problem occurred during image presentation!\n" );
|
std::cout << "Problem occurred during image presentation!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateRenderPass( GetDevice(), &render_pass_create_info, nullptr, &Vulkan.RenderPass ) != VK_SUCCESS ) {
|
if( vkCreateRenderPass( GetDevice(), &render_pass_create_info, nullptr, &Vulkan.RenderPass ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create render pass!\n" );
|
std::cout << "Could not create render pass!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateImageView( GetDevice(), &image_view_create_info, nullptr, &Vulkan.FramebufferObjects[i].ImageView ) != VK_SUCCESS ) {
|
if( vkCreateImageView( GetDevice(), &image_view_create_info, nullptr, &Vulkan.FramebufferObjects[i].ImageView ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create image view for framebuffer!\n" );
|
std::cout << "Could not create image view for framebuffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateFramebuffer( GetDevice(), &framebuffer_create_info, nullptr, &Vulkan.FramebufferObjects[i].Handle ) != VK_SUCCESS ) {
|
if( vkCreateFramebuffer( GetDevice(), &framebuffer_create_info, nullptr, &Vulkan.FramebufferObjects[i].Handle ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create a framebuffer!\n" );
|
std::cout << "Could not create a framebuffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
VkShaderModule shader_module;
|
VkShaderModule shader_module;
|
||||||
if( vkCreateShaderModule( GetDevice(), &shader_module_create_info, nullptr, &shader_module ) != VK_SUCCESS ) {
|
if( vkCreateShaderModule( GetDevice(), &shader_module_create_info, nullptr, &shader_module ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create shader module from a %s file!\n", filename );
|
std::cout << "Could not create shader module from a \"" << filename << "\" file!" << std::endl;
|
||||||
return Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule>();
|
return Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
if( vkCreatePipelineLayout( GetDevice(), &layout_create_info, nullptr, &pipeline_layout ) != VK_SUCCESS ) {
|
if( vkCreatePipelineLayout( GetDevice(), &layout_create_info, nullptr, &pipeline_layout ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create pipeline layout!\n" );
|
std::cout << "Could not create pipeline layout!" << std::endl;
|
||||||
return Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout>();
|
return Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateGraphicsPipelines( GetDevice(), VK_NULL_HANDLE, 1, &pipeline_create_info, nullptr, &Vulkan.GraphicsPipeline ) != VK_SUCCESS ) {
|
if( vkCreateGraphicsPipelines( GetDevice(), VK_NULL_HANDLE, 1, &pipeline_create_info, nullptr, &Vulkan.GraphicsPipeline ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create graphics pipeline!\n" );
|
std::cout << "Could not create graphics pipeline!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -335,7 +335,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
bool Tutorial03::CreateCommandBuffers() {
|
bool Tutorial03::CreateCommandBuffers() {
|
||||||
if( !CreateCommandPool( GetGraphicsQueue().FamilyIndex, &Vulkan.GraphicsCommandPool ) ) {
|
if( !CreateCommandPool( GetGraphicsQueue().FamilyIndex, &Vulkan.GraphicsCommandPool ) ) {
|
||||||
printf( "Could not create command pool!\n" );
|
std::cout << "Could not create command pool!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ namespace Tutorial {
|
|||||||
Vulkan.GraphicsCommandBuffers.resize( image_count, VK_NULL_HANDLE );
|
Vulkan.GraphicsCommandBuffers.resize( image_count, VK_NULL_HANDLE );
|
||||||
|
|
||||||
if( !AllocateCommandBuffers( Vulkan.GraphicsCommandPool, image_count, &Vulkan.GraphicsCommandBuffers[0] ) ) {
|
if( !AllocateCommandBuffers( Vulkan.GraphicsCommandPool, image_count, &Vulkan.GraphicsCommandBuffers[0] ) ) {
|
||||||
printf( "Could not allocate command buffers!\n" );
|
std::cout << "Could not allocate command buffers!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -462,7 +462,7 @@ namespace Tutorial {
|
|||||||
vkCmdPipelineBarrier( Vulkan.GraphicsCommandBuffers[i], VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier_from_draw_to_present );
|
vkCmdPipelineBarrier( Vulkan.GraphicsCommandBuffers[i], VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier_from_draw_to_present );
|
||||||
}
|
}
|
||||||
if( vkEndCommandBuffer( Vulkan.GraphicsCommandBuffers[i] ) != VK_SUCCESS ) {
|
if( vkEndCommandBuffer( Vulkan.GraphicsCommandBuffers[i] ) != VK_SUCCESS ) {
|
||||||
printf( "Could not record command buffer!\n" );
|
std::cout << "Could not record command buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -503,7 +503,7 @@ namespace Tutorial {
|
|||||||
case VK_ERROR_OUT_OF_DATE_KHR:
|
case VK_ERROR_OUT_OF_DATE_KHR:
|
||||||
return OnWindowSizeChanged();
|
return OnWindowSizeChanged();
|
||||||
default:
|
default:
|
||||||
printf( "Problem occurred during swap chain image acquisition!\n" );
|
std::cout << "Problem occurred during swap chain image acquisition!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +543,7 @@ namespace Tutorial {
|
|||||||
case VK_SUBOPTIMAL_KHR:
|
case VK_SUBOPTIMAL_KHR:
|
||||||
return OnWindowSizeChanged();
|
return OnWindowSizeChanged();
|
||||||
default:
|
default:
|
||||||
printf( "Problem occurred during image presentation!\n" );
|
std::cout << "Problem occurred during image presentation!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateRenderPass( GetDevice(), &render_pass_create_info, nullptr, &Vulkan.RenderPass ) != VK_SUCCESS ) {
|
if( vkCreateRenderPass( GetDevice(), &render_pass_create_info, nullptr, &Vulkan.RenderPass ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create render pass!\n" );
|
std::cout << "Could not create render pass!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,17 +99,17 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateImage( GetDevice(), &image_create_info, nullptr, &Vulkan.Image.Handle ) != VK_SUCCESS ) {
|
if( vkCreateImage( GetDevice(), &image_create_info, nullptr, &Vulkan.Image.Handle ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create an image!\n" );
|
std::cout << "Could not create an image!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !AllocateImageMemory( Vulkan.Image.Handle, &Vulkan.Image.Memory ) ) {
|
if( !AllocateImageMemory( Vulkan.Image.Handle, &Vulkan.Image.Memory ) ) {
|
||||||
printf( "Could not allocate memory for an image!\n" );
|
std::cout << "Could not allocate memory for an image!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( vkBindImageMemory( GetDevice(), Vulkan.Image.Handle, Vulkan.Image.Memory, 0 ) != VK_SUCCESS ) {
|
if( vkBindImageMemory( GetDevice(), Vulkan.Image.Handle, Vulkan.Image.Memory, 0 ) != VK_SUCCESS ) {
|
||||||
printf( "Could not bind memory for an image!\n" );
|
std::cout << "Could not bind memory for an image!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateImageView( GetDevice(), &image_view_create_info, nullptr, &Vulkan.Image.View ) != VK_SUCCESS ) {
|
if( vkCreateImageView( GetDevice(), &image_view_create_info, nullptr, &Vulkan.Image.View ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create an image view!\n" );
|
std::cout << "Could not create an image view!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateFramebuffer( GetDevice(), &framebuffer_create_info, nullptr, &Vulkan.Framebuffer ) != VK_SUCCESS ) {
|
if( vkCreateFramebuffer( GetDevice(), &framebuffer_create_info, nullptr, &Vulkan.Framebuffer ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create a framebuffer!\n" );
|
std::cout << "Could not create a framebuffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -204,7 +204,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
VkShaderModule shader_module;
|
VkShaderModule shader_module;
|
||||||
if( vkCreateShaderModule( GetDevice(), &shader_module_create_info, nullptr, &shader_module ) != VK_SUCCESS ) {
|
if( vkCreateShaderModule( GetDevice(), &shader_module_create_info, nullptr, &shader_module ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create shader module from a %s file!\n", filename );
|
std::cout << "Could not create shader module from a \"" << filename << "\" file!" << std::endl;
|
||||||
return Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule>();
|
return Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
if( vkCreatePipelineLayout( GetDevice(), &layout_create_info, nullptr, &pipeline_layout ) != VK_SUCCESS ) {
|
if( vkCreatePipelineLayout( GetDevice(), &layout_create_info, nullptr, &pipeline_layout ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create pipeline layout!\n" );
|
std::cout << "Could not create pipeline layout!" << std::endl;
|
||||||
return Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout>();
|
return Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +410,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateGraphicsPipelines( GetDevice(), VK_NULL_HANDLE, 1, &pipeline_create_info, nullptr, &Vulkan.GraphicsPipeline ) != VK_SUCCESS ) {
|
if( vkCreateGraphicsPipelines( GetDevice(), VK_NULL_HANDLE, 1, &pipeline_create_info, nullptr, &Vulkan.GraphicsPipeline ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create graphics pipeline!\n" );
|
std::cout << "Could not create graphics pipeline!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -450,23 +450,23 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkCreateBuffer( GetDevice(), &buffer_create_info, nullptr, &Vulkan.VertexBuffer.Handle ) != VK_SUCCESS ) {
|
if( vkCreateBuffer( GetDevice(), &buffer_create_info, nullptr, &Vulkan.VertexBuffer.Handle ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create a vertex buffer!\n" );
|
std::cout << "Could not create a vertex buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !AllocateBufferMemory( Vulkan.VertexBuffer.Handle, &Vulkan.VertexBuffer.Memory ) ) {
|
if( !AllocateBufferMemory( Vulkan.VertexBuffer.Handle, &Vulkan.VertexBuffer.Memory ) ) {
|
||||||
printf( "Could not allocate memory for a vertex buffer!\n" );
|
std::cout << "Could not allocate memory for a vertex buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( vkBindBufferMemory( GetDevice(), Vulkan.VertexBuffer.Handle, Vulkan.VertexBuffer.Memory, 0 ) != VK_SUCCESS ) {
|
if( vkBindBufferMemory( GetDevice(), Vulkan.VertexBuffer.Handle, Vulkan.VertexBuffer.Memory, 0 ) != VK_SUCCESS ) {
|
||||||
printf( "Could not bind memory for a vertex buffer!\n" );
|
std::cout << "Could not bind memory for a vertex buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *vertex_buffer_memory_pointer;
|
void *vertex_buffer_memory_pointer;
|
||||||
if( vkMapMemory( GetDevice(), Vulkan.VertexBuffer.Memory, 0, Vulkan.VertexBuffer.Size, 0, &vertex_buffer_memory_pointer ) != VK_SUCCESS ) {
|
if( vkMapMemory( GetDevice(), Vulkan.VertexBuffer.Memory, 0, Vulkan.VertexBuffer.Size, 0, &vertex_buffer_memory_pointer ) != VK_SUCCESS ) {
|
||||||
printf( "Could not map memory and upload data to a vertex buffer!\n" );
|
std::cout << "Could not map memory and upload data to a vertex buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +475,7 @@ namespace Tutorial {
|
|||||||
vkUnmapMemory( GetDevice(), Vulkan.VertexBuffer.Memory );
|
vkUnmapMemory( GetDevice(), Vulkan.VertexBuffer.Memory );
|
||||||
|
|
||||||
if( !CommitMemoryChanges( Vulkan.VertexBuffer.Handle, Vulkan.VertexBuffer.Size ) ) {
|
if( !CommitMemoryChanges( Vulkan.VertexBuffer.Handle, Vulkan.VertexBuffer.Size ) ) {
|
||||||
printf( "Could not setup a barrier for a vertex buffer!\n" );
|
std::cout << "Could not setup a barrier for a vertex buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ namespace Tutorial {
|
|||||||
vkCmdPipelineBarrier( Vulkan.CopyingCommandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, &barrier_from_host_write_to_attribute_read, 0, nullptr );
|
vkCmdPipelineBarrier( Vulkan.CopyingCommandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, &barrier_from_host_write_to_attribute_read, 0, nullptr );
|
||||||
|
|
||||||
if( vkEndCommandBuffer( Vulkan.CopyingCommandBuffer ) != VK_SUCCESS ) {
|
if( vkEndCommandBuffer( Vulkan.CopyingCommandBuffer ) != VK_SUCCESS ) {
|
||||||
printf( "Could not record command with buffer barrier!\n" );
|
std::cout << "Could not record command with buffer barrier!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,7 +550,7 @@ namespace Tutorial {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if( vkQueueSubmit( GetGraphicsQueue().Handle, 1, &submit_rendering_info, VK_NULL_HANDLE ) != VK_SUCCESS ) {
|
if( vkQueueSubmit( GetGraphicsQueue().Handle, 1, &submit_rendering_info, VK_NULL_HANDLE ) != VK_SUCCESS ) {
|
||||||
printf( "Error occurred during submission of command buffer with vertex buffer barrier!!\n" );
|
std::cout << "Error occurred during submission of command buffer with vertex buffer barrier!!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,7 +566,7 @@ namespace Tutorial {
|
|||||||
VK_FENCE_CREATE_SIGNALED_BIT // VkFenceCreateFlags flags
|
VK_FENCE_CREATE_SIGNALED_BIT // VkFenceCreateFlags flags
|
||||||
};
|
};
|
||||||
if( vkCreateFence( GetDevice(), &fence_create_info, nullptr, &Vulkan.Fence ) != VK_SUCCESS ) {
|
if( vkCreateFence( GetDevice(), &fence_create_info, nullptr, &Vulkan.Fence ) != VK_SUCCESS ) {
|
||||||
printf( "Could not create a fence!\n" );
|
std::cout << "Could not create a fence!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -574,15 +574,15 @@ namespace Tutorial {
|
|||||||
|
|
||||||
bool Tutorial04::CreateCommandBuffers() {
|
bool Tutorial04::CreateCommandBuffers() {
|
||||||
if( !CreateCommandPool( GetGraphicsQueue().FamilyIndex, &Vulkan.GraphicsCommandPool ) ) {
|
if( !CreateCommandPool( GetGraphicsQueue().FamilyIndex, &Vulkan.GraphicsCommandPool ) ) {
|
||||||
printf( "Could not create command pool!\n" );
|
std::cout << "Could not create command pool!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( !AllocateCommandBuffers( Vulkan.GraphicsCommandPool, 1, &Vulkan.RenderingCommandBuffer ) ) {
|
if( !AllocateCommandBuffers( Vulkan.GraphicsCommandPool, 1, &Vulkan.RenderingCommandBuffer ) ) {
|
||||||
printf( "Could not allocate rendering command buffer!\n" );
|
std::cout << "Could not allocate rendering command buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( !AllocateCommandBuffers( Vulkan.GraphicsCommandPool, 1, &Vulkan.CopyingCommandBuffer ) ) {
|
if( !AllocateCommandBuffers( Vulkan.GraphicsCommandPool, 1, &Vulkan.CopyingCommandBuffer ) ) {
|
||||||
printf( "Could not allocate copying command buffer!\n" );
|
std::cout << "Could not allocate copying command buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -662,7 +662,7 @@ namespace Tutorial {
|
|||||||
vkCmdEndRenderPass( Vulkan.RenderingCommandBuffer );
|
vkCmdEndRenderPass( Vulkan.RenderingCommandBuffer );
|
||||||
|
|
||||||
if( vkEndCommandBuffer( Vulkan.RenderingCommandBuffer ) != VK_SUCCESS ) {
|
if( vkEndCommandBuffer( Vulkan.RenderingCommandBuffer ) != VK_SUCCESS ) {
|
||||||
printf( "Could not record drawing command buffer!\n" );
|
std::cout << "Could not record drawing command buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -670,7 +670,7 @@ namespace Tutorial {
|
|||||||
|
|
||||||
bool Tutorial04::RecordCopyingCommandBuffer( VkImage swap_chain_image ) {
|
bool Tutorial04::RecordCopyingCommandBuffer( VkImage swap_chain_image ) {
|
||||||
if( vkWaitForFences( GetDevice(), 1, &Vulkan.Fence, VK_FALSE, 1000000000 ) != VK_SUCCESS ) {
|
if( vkWaitForFences( GetDevice(), 1, &Vulkan.Fence, VK_FALSE, 1000000000 ) != VK_SUCCESS ) {
|
||||||
printf( "Waiting for fence takes too long!\n" );
|
std::cout << "Waiting for fence takes too long!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vkResetFences( GetDevice(), 1, &Vulkan.Fence );
|
vkResetFences( GetDevice(), 1, &Vulkan.Fence );
|
||||||
@@ -755,7 +755,7 @@ namespace Tutorial {
|
|||||||
vkCmdPipelineBarrier( Vulkan.CopyingCommandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier_from_transfer_dst_to_present );
|
vkCmdPipelineBarrier( Vulkan.CopyingCommandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &barrier_from_transfer_dst_to_present );
|
||||||
|
|
||||||
if( vkEndCommandBuffer( Vulkan.CopyingCommandBuffer ) != VK_SUCCESS ) {
|
if( vkEndCommandBuffer( Vulkan.CopyingCommandBuffer ) != VK_SUCCESS ) {
|
||||||
printf( "Could not record copying command buffer!\n" );
|
std::cout << "Could not record copying command buffer!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -779,7 +779,7 @@ namespace Tutorial {
|
|||||||
case VK_ERROR_OUT_OF_DATE_KHR:
|
case VK_ERROR_OUT_OF_DATE_KHR:
|
||||||
return OnWindowSizeChanged();
|
return OnWindowSizeChanged();
|
||||||
default:
|
default:
|
||||||
printf( "Problem occurred during swap chain image acquisition!\n" );
|
std::cout << "Problem occurred during swap chain image acquisition!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,7 +839,7 @@ namespace Tutorial {
|
|||||||
case VK_SUBOPTIMAL_KHR:
|
case VK_SUBOPTIMAL_KHR:
|
||||||
return OnWindowSizeChanged();
|
return OnWindowSizeChanged();
|
||||||
default:
|
default:
|
||||||
printf( "Problem occurred during image presentation!\n" );
|
std::cout << "Problem occurred during image presentation!" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user