adding define option to disable all KHR functions
This commit is contained in:
22
kvf.h
22
kvf.h
@@ -43,6 +43,8 @@
|
|||||||
* or VK_NO_PROTOTYPES before including this file to avoid conflicts with Vulkan prototypes.
|
* or VK_NO_PROTOTYPES before including this file to avoid conflicts with Vulkan prototypes.
|
||||||
*
|
*
|
||||||
* You can also #define KVF_ENABLE_VALIDATION_LAYERS to enable validation layers.
|
* You can also #define KVF_ENABLE_VALIDATION_LAYERS to enable validation layers.
|
||||||
|
*
|
||||||
|
* Use #define KVF_NO_KHR to remove all functions that use KHR calls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef KBZ_8_VULKAN_FRAMEWORK_H
|
#ifndef KBZ_8_VULKAN_FRAMEWORK_H
|
||||||
@@ -99,11 +101,15 @@ VkPhysicalDevice kvfPickGoodPhysicalDevice(VkInstance instance, VkSurfaceKHR sur
|
|||||||
|
|
||||||
VkQueue kvfGetDeviceQueue(VkDevice device, KvfQueueType queue);
|
VkQueue kvfGetDeviceQueue(VkDevice device, KvfQueueType queue);
|
||||||
uint32_t kvfGetDeviceQueueFamily(VkDevice device, KvfQueueType queue);
|
uint32_t kvfGetDeviceQueueFamily(VkDevice device, KvfQueueType queue);
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
bool kvfQueuePresentKHR(VkDevice device, VkSemaphore wait, VkSwapchainKHR swapchain, uint32_t image_index); // return false when the swapchain must be recreated
|
bool kvfQueuePresentKHR(VkDevice device, VkSemaphore wait, VkSwapchainKHR swapchain, uint32_t image_index); // return false when the swapchain must be recreated
|
||||||
|
#endif
|
||||||
|
|
||||||
// Meant to be used when creating a VkDevice with a custom VkPhysicalDevice
|
// Meant to be used when creating a VkDevice with a custom VkPhysicalDevice
|
||||||
int32_t kvfFindDeviceQueueFamily(VkPhysicalDevice physical, KvfQueueType type); // This function cannot find present queue
|
int32_t kvfFindDeviceQueueFamily(VkPhysicalDevice physical, KvfQueueType type); // This function cannot find present queue
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
int32_t kvfFindDeviceQueueFamilyKHR(VkPhysicalDevice physical, VkSurfaceKHR surface, KvfQueueType type); // This one can find present queue
|
int32_t kvfFindDeviceQueueFamilyKHR(VkPhysicalDevice physical, VkSurfaceKHR surface, KvfQueueType type); // This one can find present queue
|
||||||
|
#endif
|
||||||
|
|
||||||
VkDevice kvfCreateDefaultDevice(VkPhysicalDevice physical);
|
VkDevice kvfCreateDefaultDevice(VkPhysicalDevice physical);
|
||||||
VkDevice kvfCreateDevice(VkPhysicalDevice physical, const char** extensions, uint32_t extensions_count, VkPhysicalDeviceFeatures* features);
|
VkDevice kvfCreateDevice(VkPhysicalDevice physical, const char** extensions, uint32_t extensions_count, VkPhysicalDeviceFeatures* features);
|
||||||
@@ -118,12 +124,14 @@ void kvfDestroyFence(VkDevice device, VkFence fence);
|
|||||||
VkSemaphore kvfCreateSemaphore(VkDevice device);
|
VkSemaphore kvfCreateSemaphore(VkDevice device);
|
||||||
void kvfDestroySemaphore(VkDevice device, VkSemaphore semaphore);
|
void kvfDestroySemaphore(VkDevice device, VkSemaphore semaphore);
|
||||||
|
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
VkSwapchainKHR kvfCreateSwapchainKHR(VkDevice device, VkPhysicalDevice physical, VkSurfaceKHR surface, VkExtent2D extent, bool try_vsync);
|
VkSwapchainKHR kvfCreateSwapchainKHR(VkDevice device, VkPhysicalDevice physical, VkSurfaceKHR surface, VkExtent2D extent, bool try_vsync);
|
||||||
VkFormat kvfGetSwapchainImagesFormat(VkSwapchainKHR swapchain);
|
VkFormat kvfGetSwapchainImagesFormat(VkSwapchainKHR swapchain);
|
||||||
uint32_t kvfGetSwapchainImagesCount(VkSwapchainKHR swapchain);
|
uint32_t kvfGetSwapchainImagesCount(VkSwapchainKHR swapchain);
|
||||||
uint32_t kvfGetSwapchainMinImagesCount(VkSwapchainKHR swapchain);
|
uint32_t kvfGetSwapchainMinImagesCount(VkSwapchainKHR swapchain);
|
||||||
VkExtent2D kvfGetSwapchainImagesSize(VkSwapchainKHR swapchain);
|
VkExtent2D kvfGetSwapchainImagesSize(VkSwapchainKHR swapchain);
|
||||||
void kvfDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain);
|
void kvfDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain);
|
||||||
|
#endif
|
||||||
|
|
||||||
VkImage kvfCreateImage(VkDevice device, uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, KvfImageType type);
|
VkImage kvfCreateImage(VkDevice device, uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, KvfImageType type);
|
||||||
void kvfImageToBuffer(VkCommandBuffer cmd, VkBuffer dst, VkImage src, size_t buffer_offset, VkImageAspectFlagBits aspect, VkExtent3D extent);
|
void kvfImageToBuffer(VkCommandBuffer cmd, VkBuffer dst, VkImage src, size_t buffer_offset, VkImageAspectFlagBits aspect, VkExtent3D extent);
|
||||||
@@ -151,7 +159,9 @@ void kvfSubmitCommandBuffer(VkDevice device, VkCommandBuffer buffer, KvfQueueTyp
|
|||||||
void kvfSubmitSingleTimeCommandBuffer(VkDevice device, VkCommandBuffer buffer, KvfQueueType queue, VkFence fence);
|
void kvfSubmitSingleTimeCommandBuffer(VkDevice device, VkCommandBuffer buffer, KvfQueueType queue, VkFence fence);
|
||||||
|
|
||||||
VkAttachmentDescription kvfBuildAttachmentDescription(KvfImageType type, VkFormat format, VkImageLayout initial, VkImageLayout final, bool clear, VkSampleCountFlagBits samples);
|
VkAttachmentDescription kvfBuildAttachmentDescription(KvfImageType type, VkFormat format, VkImageLayout initial, VkImageLayout final, bool clear, VkSampleCountFlagBits samples);
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
VkAttachmentDescription kvfBuildSwapchainAttachmentDescription(VkSwapchainKHR swapchain, bool clear);
|
VkAttachmentDescription kvfBuildSwapchainAttachmentDescription(VkSwapchainKHR swapchain, bool clear);
|
||||||
|
#endif
|
||||||
|
|
||||||
VkRenderPass kvfCreateRenderPass(VkDevice device, VkAttachmentDescription* attachments, size_t attachments_count, VkPipelineBindPoint bind_point);
|
VkRenderPass kvfCreateRenderPass(VkDevice device, VkAttachmentDescription* attachments, size_t attachments_count, VkPipelineBindPoint bind_point);
|
||||||
VkRenderPass kvfCreateRenderPassWithSubpassDependencies(VkDevice device, VkAttachmentDescription* attachments, size_t attachments_count, VkPipelineBindPoint bind_point, VkSubpassDependency* dependencies, size_t dependencies_count);
|
VkRenderPass kvfCreateRenderPassWithSubpassDependencies(VkDevice device, VkAttachmentDescription* attachments, size_t attachments_count, VkPipelineBindPoint bind_point, VkSubpassDependency* dependencies, size_t dependencies_count);
|
||||||
@@ -1128,6 +1138,7 @@ __KvfQueueFamilies __kvfFindQueueFamilies(VkPhysicalDevice physical, VkSurfaceKH
|
|||||||
if(queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
|
if(queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT)
|
||||||
queues.graphics = i;
|
queues.graphics = i;
|
||||||
VkBool32 present_support = false;
|
VkBool32 present_support = false;
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
if(surface != VK_NULL_HANDLE)
|
if(surface != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR(physical, i, surface, &present_support);
|
vkGetPhysicalDeviceSurfaceSupportKHR(physical, i, surface, &present_support);
|
||||||
@@ -1136,6 +1147,7 @@ __KvfQueueFamilies __kvfFindQueueFamilies(VkPhysicalDevice physical, VkSurfaceKH
|
|||||||
if(queues.graphics != -1 && queues.present != -1 && queues.compute != -1)
|
if(queues.graphics != -1 && queues.present != -1 && queues.compute != -1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else if(queues.graphics != -1 && queues.compute != -1)
|
else if(queues.graphics != -1 && queues.compute != -1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1202,6 +1214,7 @@ int32_t __kvfScorePhysicalDevice(VkPhysicalDevice device, VkSurfaceKHR surface,
|
|||||||
if(queues.graphics == -1 || (surface != VK_NULL_HANDLE && queues.present == -1))
|
if(queues.graphics == -1 || (surface != VK_NULL_HANDLE && queues.present == -1))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
if(surface != VK_NULL_HANDLE)
|
if(surface != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
/* Check surface formats counts */
|
/* Check surface formats counts */
|
||||||
@@ -1210,6 +1223,7 @@ int32_t __kvfScorePhysicalDevice(VkPhysicalDevice device, VkSurfaceKHR surface,
|
|||||||
if(format_count == 0)
|
if(format_count == 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VkPhysicalDeviceProperties device_props;
|
VkPhysicalDeviceProperties device_props;
|
||||||
vkGetPhysicalDeviceProperties(device, &device_props);
|
vkGetPhysicalDeviceProperties(device, &device_props);
|
||||||
@@ -1401,6 +1415,7 @@ uint32_t kvfGetDeviceQueueFamily(VkDevice device, KvfQueueType queue)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
bool kvfQueuePresentKHR(VkDevice device, VkSemaphore wait, VkSwapchainKHR swapchain, uint32_t image_index)
|
bool kvfQueuePresentKHR(VkDevice device, VkSemaphore wait, VkSwapchainKHR swapchain, uint32_t image_index)
|
||||||
{
|
{
|
||||||
KVF_ASSERT(device != VK_NULL_HANDLE);
|
KVF_ASSERT(device != VK_NULL_HANDLE);
|
||||||
@@ -1418,6 +1433,7 @@ bool kvfQueuePresentKHR(VkDevice device, VkSemaphore wait, VkSwapchainKHR swapch
|
|||||||
__kvfCheckVk(result);
|
__kvfCheckVk(result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t kvfFindDeviceQueueFamily(VkPhysicalDevice physical, KvfQueueType type)
|
int32_t kvfFindDeviceQueueFamily(VkPhysicalDevice physical, KvfQueueType type)
|
||||||
{
|
{
|
||||||
@@ -1453,6 +1469,7 @@ int32_t kvfFindDeviceQueueFamily(VkPhysicalDevice physical, KvfQueueType type)
|
|||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
int32_t kvfFindDeviceQueueFamilyKHR(VkPhysicalDevice physical, VkSurfaceKHR surface, KvfQueueType type)
|
int32_t kvfFindDeviceQueueFamilyKHR(VkPhysicalDevice physical, VkSurfaceKHR surface, KvfQueueType type)
|
||||||
{
|
{
|
||||||
KVF_ASSERT(physical != VK_NULL_HANDLE);
|
KVF_ASSERT(physical != VK_NULL_HANDLE);
|
||||||
@@ -1480,6 +1497,7 @@ int32_t kvfFindDeviceQueueFamilyKHR(VkPhysicalDevice physical, VkSurfaceKHR surf
|
|||||||
KVF_FREE(queue_families);
|
KVF_FREE(queue_families);
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VkFence kvfCreateFence(VkDevice device)
|
VkFence kvfCreateFence(VkDevice device)
|
||||||
{
|
{
|
||||||
@@ -1525,6 +1543,7 @@ void kvfDestroySemaphore(VkDevice device, VkSemaphore semaphore)
|
|||||||
vkDestroySemaphore(device, semaphore, NULL);
|
vkDestroySemaphore(device, semaphore, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
__KvfSwapchainSupportInternal __kvfQuerySwapchainSupport(VkPhysicalDevice physical, VkSurfaceKHR surface)
|
__KvfSwapchainSupportInternal __kvfQuerySwapchainSupport(VkPhysicalDevice physical, VkSurfaceKHR surface)
|
||||||
{
|
{
|
||||||
__KvfSwapchainSupportInternal support;
|
__KvfSwapchainSupportInternal support;
|
||||||
@@ -1670,6 +1689,7 @@ void kvfDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain)
|
|||||||
KVF_ASSERT(device != VK_NULL_HANDLE);
|
KVF_ASSERT(device != VK_NULL_HANDLE);
|
||||||
__kvfDestroySwapchain(device, swapchain);
|
__kvfDestroySwapchain(device, swapchain);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VkImage kvfCreateImage(VkDevice device, uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, KvfImageType type)
|
VkImage kvfCreateImage(VkDevice device, uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, KvfImageType type)
|
||||||
{
|
{
|
||||||
@@ -2051,6 +2071,7 @@ VkAttachmentDescription kvfBuildAttachmentDescription(KvfImageType type, VkForma
|
|||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef KVF_NO_KHR
|
||||||
VkAttachmentDescription kvfBuildSwapchainAttachmentDescription(VkSwapchainKHR swapchain, bool clear)
|
VkAttachmentDescription kvfBuildSwapchainAttachmentDescription(VkSwapchainKHR swapchain, bool clear)
|
||||||
{
|
{
|
||||||
__KvfSwapchain* kvf_swapchain = __kvfGetKvfSwapchainFromVkSwapchainKHR(swapchain);
|
__KvfSwapchain* kvf_swapchain = __kvfGetKvfSwapchainFromVkSwapchainKHR(swapchain);
|
||||||
@@ -2058,6 +2079,7 @@ VkAttachmentDescription kvfBuildSwapchainAttachmentDescription(VkSwapchainKHR sw
|
|||||||
KVF_ASSERT(kvf_swapchain->images_count != 0);
|
KVF_ASSERT(kvf_swapchain->images_count != 0);
|
||||||
return kvfBuildAttachmentDescription(KVF_IMAGE_COLOR, kvf_swapchain->images_format, VK_IMAGE_LAYOUT_UNDEFINED,VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, clear, VK_SAMPLE_COUNT_1_BIT);
|
return kvfBuildAttachmentDescription(KVF_IMAGE_COLOR, kvf_swapchain->images_format, VK_IMAGE_LAYOUT_UNDEFINED,VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, clear, VK_SAMPLE_COUNT_1_BIT);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VkRenderPass kvfCreateRenderPass(VkDevice device, VkAttachmentDescription* attachments, size_t attachments_count, VkPipelineBindPoint bind_point)
|
VkRenderPass kvfCreateRenderPass(VkDevice device, VkAttachmentDescription* attachments, size_t attachments_count, VkPipelineBindPoint bind_point)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user