What is VK_NO_PROTOTYPES?

 Hello friends. Please keep in mind. English is NOT my first language. Please correct me when you reads wrong sentences. I really want to enhance my English.


 As Vulkan developer, you have probably seen VK_NO_PROTOTYPES at once. Where did you see this? The answer is Vulkan header file.

#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
    const VkInstanceCreateInfo*                 pCreateInfo,
    const VkAllocationCallbacks*                pAllocator,
    VkInstance*                                 pInstance);

// ...

VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(
    VkCommandBuffer                             commandBuffer,
    uint32_t                                    commandBufferCount,
    const VkCommandBuffer*                      pCommandBuffers);
#endif

 VK_NO_PROTOTYPES is preprocessor directive. By default, Vulkan header file has definitions of all functions. It's very useful when we link with Vulkan loader library statically. But if you want to link with Vulkan loader library dynamically, must use VK_NO_PROTOTYPES preprocessor macro.

 So why dynamic linking is needed? Of course, you can save your linking but it's not enough. There is some reason. From my experience, dynamic linking is needed when you don't know the system supports Vulkan. For instance, you application can run on both OpenGL and Vulkan. You know Vulkan is better than OpenGL however some system doesn't support Vulkan. Thus before running your application, you need to check the system supports Vulkan or not.

constexpr auto kLibraryPath = "vulkan1-1.dll";

Library library(kLibraryPath);

if (library.IsLoaded())
{
    // Run on Vulkan
}
else
{
    // Run on OpenGL
}

 After checking your system supports Vulkan, we need to retrieves Vulkan loader functions. These functions allow us to create Vulkan instance.

#define APPLY_MACRO_TO_LOADER_CORE_FUNCTIONS(macro) \
    macro(vkGetInstanceProcAddr)                    \
    macro(vkCreateInstance)                         \
    macro(vkEnumerateInstanceExtensionProperties)

#define APPLY_MACRO_TO_LOADER_FUNCTIONS(macro)      \
    APPLY_MACRO_TO_LOADER_CORE_FUNCTIONS(macro)

#define DEFINE_LOADER_FUNCTION_MACRO(function)      \
    PFN_##function function;

#define GET_LOADER_FUNCTION_MACRO(function)         \
    function = library.LoadSymbol<PFN_##function>(#function);

APPLY_MACRO_TO_LOADER_FUNCTIONS(DEFINE_LOADER_FUNCTION_MACRO);
APPLY_MACRO_TO_LOADER_FUNCTIONS(GET_LOADER_FUNCTION_MACRO);

 This example shows how can you retrieves Vulkan loader functions.

 Now you can retrieves Vulkan instance functions. You can check what Vulkan hardware features are available and exposed from these functions.

#define APPLY_MACRO_TO_INSTANCE_CORE_FUNCTIONS(macro)            \
    macro(vkDestroyInstance)                                     \
    macro(vkEnumeratePhysicalDevices)                            \
    macro(vkGetPhysicalDeviceFeatures)                           \
    macro(vkGetPhysicalDeviceFormatProperties)                   \
    macro(vkGetPhysicalDeviceImageFormatProperties)              \
    macro(vkGetPhysicalDeviceProperties)                         \
    macro(vkGetPhysicalDeviceQueueFamilyProperties)              \
    macro(vkGetPhysicalDeviceMemoryProperties)                   \
    macro(vkGetDeviceProcAddr)                                   \
    macro(vkCreateDevice)

#define APPLY_MACRO_TO_INSTANCE_EXT_KHR_SURFACE_FUNCTIONS(macro) \
    macro(vkDestroySurfaceKHR)                                   \
    macro(vkGetPhysicalDeviceSurfaceSupportKHR)                  \
    macro(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)             \
    macro(vkGetPhysicalDeviceSurfaceFormatsKHR)                  \
    macro(vkGetPhysicalDeviceSurfacePresentModesKHR)

#define APPLY_MACRO_TO_INSTANCE_FUNCTIONS(macro)                 \
    APPLY_MACRO_TO_INSTANCE_CORE_FUNCTIONS(macro)                \
    APPLY_MACRO_TO_INSTANCE_EXT_KHR_SURFACE_FUNCTIONS(macro)

#define DEFINE_INSTANCE_FUNCTION_MACRO(function)                 \
    PFN_##function function;

#define GET_INSTANCE_FUNCTION_MACRO(function)                    \
    function = reinterpret_cast<PFN_##function>(loader.GetInstanceProcAddr(mHandle, #function));

APPLY_MACRO_TO_INSTANCE_FUNCTIONS(DEFINE_INSTANCE_FUNCTION_MACRO);
APPLY_MACRO_TO_INSTANCE_FUNCTIONS(GET_INSTANCE_FUNCTION_MACRO);

 This example shows how can you retrieves Vulkan instance functions.

 Lastly you can retrieves Vulkan device functions. You can create Vulkan resources and record Vulkan commands from these functions.

#define APPLY_MACRO_TO_DEVICE_CORE_FUNCTIONS(macro)              \
    macro(vkDestroyDevice)                                       \
    macro(vkEnumerateDeviceExtensionProperties)                  \
    macro(vkEnumerateDeviceLayerProperties)                      \
    macro(vkGetDeviceQueue)                                      \
    macro(vkQueueSubmit)                                         \
    macro(vkQueueWaitIdle)                                       \
    macro(vkDeviceWaitIdle)                                      \
    macro(vkAllocateMemory)                                      \
    macro(vkFreeMemory)                                          \
    macro(vkMapMemory)                                           \
    macro(vkUnmapMemory)                                         \
    macro(vkFlushMappedMemoryRanges)                             \
    macro(vkInvalidateMappedMemoryRanges)                        \
    macro(vkGetDeviceMemoryCommitment)                           \
    macro(vkBindBufferMemory)                                    \
    macro(vkBindImageMemory)                                     \
    macro(vkGetBufferMemoryRequirements)                         \
    macro(vkGetImageMemoryRequirements)                          \
    macro(vkGetImageSparseMemoryRequirements)                    \
    macro(vkGetPhysicalDeviceSparseImageFormatProperties)        \
    macro(vkQueueBindSparse)                                     \
    macro(vkCreateFence)                                         \
    macro(vkDestroyFence)                                        \
    macro(vkResetFences)                                         \
    macro(vkGetFenceStatus)                                      \
    macro(vkWaitForFences)                                       \
    macro(vkCreateSemaphore)                                     \
    macro(vkDestroySemaphore)                                    \
    macro(vkCreateEvent)                                         \
    macro(vkDestroyEvent)                                        \
    macro(vkGetEventStatus)                                      \
    macro(vkSetEvent)                                            \
    macro(vkResetEvent)                                          \
    macro(vkCreateQueryPool)                                     \
    macro(vkDestroyQueryPool)                                    \
    macro(vkGetQueryPoolResults)                                 \
    macro(vkCreateBuffer)                                        \
    macro(vkDestroyBuffer)                                       \
    macro(vkCreateBufferView)                                    \
    macro(vkDestroyBufferView)                                   \
    macro(vkCreateImage)                                         \
    macro(vkDestroyImage)                                        \
    macro(vkGetImageSubresourceLayout)                           \
    macro(vkCreateImageView)                                     \
    macro(vkDestroyImageView)                                    \
    macro(vkCreateShaderModule)                                  \
    macro(vkDestroyShaderModule)                                 \
    macro(vkCreatePipelineCache)                                 \
    macro(vkDestroyPipelineCache)                                \
    macro(vkGetPipelineCacheData)                                \
    macro(vkMergePipelineCaches)                                 \
    macro(vkCreateGraphicsPipelines)                             \
    macro(vkCreateComputePipelines)                              \
    macro(vkDestroyPipeline)                                     \
    macro(vkCreatePipelineLayout)                                \
    macro(vkDestroyPipelineLayout)                               \
    macro(vkCreateSampler)                                       \
    macro(vkDestroySampler)                                      \
    macro(vkCreateDescriptorSetLayout)                           \
    macro(vkDestroyDescriptorSetLayout)                          \
    macro(vkCreateDescriptorPool)                                \
    macro(vkDestroyDescriptorPool)                               \
    macro(vkResetDescriptorPool)                                 \
    macro(vkAllocateDescriptorSets)                              \
    macro(vkFreeDescriptorSets)                                  \
    macro(vkUpdateDescriptorSets)                                \
    macro(vkCreateFramebuffer)                                   \
    macro(vkDestroyFramebuffer)                                  \
    macro(vkCreateRenderPass)                                    \
    macro(vkDestroyRenderPass)                                   \
    macro(vkGetRenderAreaGranularity)                            \
    macro(vkCreateCommandPool)                                   \
    macro(vkDestroyCommandPool)                                  \
    macro(vkResetCommandPool)                                    \
    macro(vkAllocateCommandBuffers)                              \
    macro(vkFreeCommandBuffers)                                  \
    macro(vkBeginCommandBuffer)                                  \
    macro(vkEndCommandBuffer)                                    \
    macro(vkResetCommandBuffer)                                  \
    macro(vkCmdBindPipeline)                                     \
    macro(vkCmdSetViewport)                                      \
    macro(vkCmdSetScissor)                                       \
    macro(vkCmdSetLineWidth)                                     \
    macro(vkCmdSetDepthBias)                                     \
    macro(vkCmdSetBlendConstants)                                \
    macro(vkCmdSetDepthBounds)                                   \
    macro(vkCmdSetStencilCompareMask)                            \
    macro(vkCmdSetStencilWriteMask)                              \
    macro(vkCmdSetStencilReference)                              \
    macro(vkCmdBindDescriptorSets)                               \
    macro(vkCmdBindIndexBuffer)                                  \
    macro(vkCmdBindVertexBuffers)                                \
    macro(vkCmdDraw)                                             \
    macro(vkCmdDrawIndexed)                                      \
    macro(vkCmdDrawIndirect)                                     \
    macro(vkCmdDrawIndexedIndirect)                              \
    macro(vkCmdDispatch)                                         \
    macro(vkCmdDispatchIndirect)                                 \
    macro(vkCmdCopyBuffer)                                       \
    macro(vkCmdCopyImage)                                        \
    macro(vkCmdBlitImage)                                        \
    macro(vkCmdCopyBufferToImage)                                \
    macro(vkCmdCopyImageToBuffer)                                \
    macro(vkCmdUpdateBuffer)                                     \
    macro(vkCmdFillBuffer)                                       \
    macro(vkCmdClearColorImage)                                  \
    macro(vkCmdClearDepthStencilImage)                           \
    macro(vkCmdClearAttachments)                                 \
    macro(vkCmdResolveImage)                                     \
    macro(vkCmdSetEvent)                                         \
    macro(vkCmdResetEvent)                                       \
    macro(vkCmdWaitEvents)                                       \
    macro(vkCmdPipelineBarrier)                                  \
    macro(vkCmdBeginQuery)                                       \
    macro(vkCmdEndQuery)                                         \
    macro(vkCmdResetQueryPool)                                   \
    macro(vkCmdWriteTimestamp)                                   \
    macro(vkCmdCopyQueryPoolResults)                             \
    macro(vkCmdPushConstants)                                    \
    macro(vkCmdBeginRenderPass)                                  \
    macro(vkCmdNextSubpass)                                      \
    macro(vkCmdEndRenderPass)                                    \
    macro(vkCmdExecuteCommands)

#define APPLY_MACRO_TO_DEVICE_EXT_KHR_SWAPCHAIN_FUNCTIONS(macro) \
    macro(vkCreateSwapchainKHR)                                  \
    macro(vkDestroySwapchainKHR)                                 \
    macro(vkGetSwapchainImagesKHR)                               \
    macro(vkAcquireNextImageKHR)                                 \
    macro(vkQueuePresentKHR)

#define APPLY_MACRO_TO_DEVICE_FUNCTIONS(macro)                   \
    APPLY_MACRO_TO_DEVICE_CORE_FUNCTIONS(macro)                  \
    APPLY_MACRO_TO_DEVICE_EXT_KHR_SWAPCHAIN_FUNCTIONS(macro)

#define DEFINE_DEVICE_FUNCTION_MACRO(function)                   \
    PFN_##function function;

#define GET_DEVICE_FUNCTION_MACRO(function)                      \
    function = reinterpret_cast<PFN_##function>(instancePtr->GetDeviceProcAddr(mHandle, #function));

APPLY_MACRO_TO_DEVICE_FUNCTIONS(DEFINE_DEVICE_FUNCTION_MACRO);
APPLY_MACRO_TO_DEVICE_FUNCTIONS(GET_DEVICE_FUNCTION_MACRO);

 This example shows how can you retrieves Vulkan device functions.

 Now you are ready to use Vulkan without static linking to Vulkan loader.

댓글

  1. При составлении рейтинга казино по выплатам предусматривается доступность методов оплаты. Представленные в РБ площадки принимают взносы онлайн через банковские карты, электрические кошельки. Некоторые предлагают восполнить банкролл криптовалютой. Отдельные порталы поддерживают в банковские, денежные переводы, оплату ваучеров. Большинство компаний разрешают делать вывод на назначение рейтинг онлайн казино, откуда на баланс пришли средства. Такой расклад помогает избежать воровства средств со счетов посетителей.

    답글삭제
  2. При составлении рейтинга казино по выплатам учитывается доступность способов оплаты. Представленные в РБ площадки принимают взносы интернет через банковские карты, электронные кошельки. Некоторые предлагают пополнить банкролл криптовалютой. Отдельные порталы поддерживают числе банковские, валютные переводы, оплату ваучеров. Большинство фирм позволяют делать вывод на направление казино топ, откуда на баланс пришли свои. Такой расклад может избежать воровства денег со счетов клиентов.

    답글삭제
  3. Посевы на этих площадках я советую делать где разместить ссылку для продвижения сайта как колличество раза ежемесячно. Это возможность разыскать реальных клиентов и получить качественные переходы на интернет-сайт. Все перечисленные способы относятся к крауд-маркетингу, а он густо связан с нативной рекламой.

    답글삭제
  4. 1 x bet Live Playing: main rules 1x bet - Betting in real time first time used betting site 1xbet login korea. Demand for the direction appeared instantly. Therefore similar options began to use other bookmakers. Now approximately 50% of wagers placed on meetings in real time. We will tell how to play correctly. 1xbet korea Selection of a bookmaker 1xbet korean First client required select betting site. This process is complex. Brands works very many. As a result of this users should consider several of options: 1xbet korea Recommendations by game in live 1xbet주소 First of all must evaluate match. This required perform before start of the game. The specified solution will the user estimate chances winning certain results. After that need wait for the start match. User must watch performance of athletes. Similar action help set chance of entry of the event. Also required generate ticket. This advice help the player eliminate risks loss of time in the future. Next step required estimate movement of coefficients. Necessary wait optimal values and make a bet. Required for indicator to be in the range 1.5-2.0. Such values are most optimal. They allow to make maximum profit with small risks. 1xbet 가입 Instead of results Users 1x bet should bet only on sports that a real for them. Such advice helps increase quality of forecasts. Analyze interesting sport easier http://dobrodelica.blogspot.com/2014/05/Golub-kryuchkom-Master-klass.html
    http://stellawhisper.blogspot.com/2015/07/welcome-to-montenegro.html.

    답글삭제

댓글 쓰기