Skip to content

Commit

Permalink
cube: make Volk requirement explicit
Browse files Browse the repository at this point in the history
See also:

    Cannot build DEMOS.sln
    https://gitlab.khronos.org/vulkan/Vulkan-SDK-Packaging/-/issues/1417

Volk requires that VK_NO_PROTOTYPES be defined before vulkan.h or vulkan.hpp is
included.  Currently, the various flavors of vkcube hide this definition in the
cube/CMakeLists.txt file, which can confuse users who may copy the source for their
own use, and may require investigation to figure out why it doesn't "just work".

This change makes the #define explicit in the cube.c and cube.cpp source files,
which should both be clearer and be more similar to how most applications use Volk.
  • Loading branch information
lunarpapillo committed May 7, 2024
1 parent 8b6228a commit feab97d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions cube/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ else()
endif()

target_include_directories(vkcube PRIVATE .)
target_compile_definitions(vkcube PRIVATE VK_NO_PROTOTYPES)

if (ANDROID)
install(TARGETS vkcube DESTINATION ${CMAKE_INSTALL_LIBDIR})
Expand Down Expand Up @@ -307,7 +306,6 @@ else()
target_link_libraries(vkcubepp Vulkan::Headers volk::volk_headers)
endif()
target_include_directories(vkcubepp PRIVATE .)
target_compile_definitions(vkcubepp PRIVATE VK_NO_PROTOTYPES)

if(APPLE)
install(
Expand Down Expand Up @@ -351,7 +349,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
Threads::Threads
PkgConfig::WAYLAND_CLIENT
)
target_compile_definitions(vkcube-wayland PRIVATE VK_USE_PLATFORM_WAYLAND_KHR VK_NO_PROTOTYPES)
target_compile_definitions(vkcube-wayland PRIVATE VK_USE_PLATFORM_WAYLAND_KHR)
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS("rt" clock_gettime "" NEED_RT)
if (NEED_RT)
Expand Down
2 changes: 2 additions & 0 deletions cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#define APP_NAME_STR_LEN 80
#endif // _WIN32

// Volk requires VK_NO_PROTOTYPES before including vulkan.h
#define VK_NO_PROTOTYPES
#include <vulkan/vulkan.h>
#define VOLK_IMPLEMENTATION
#include "volk.h"
Expand Down
2 changes: 2 additions & 0 deletions cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
#define VULKAN_HPP_NO_EXCEPTIONS
#define VULKAN_HPP_TYPESAFE_CONVERSION 1
// Volk requires VK_NO_PROTOTYPES before including vulkan.hpp
#define VK_NO_PROTOTYPES
#include <vulkan/vulkan.hpp>

#define VOLK_IMPLEMENTATION
Expand Down

0 comments on commit feab97d

Please sign in to comment.