Skip to content

Commit 5aac257

Browse files
committed
cube: Make Volk requirement explicit
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. cube/CMakeLists.txt: - remove - vulkaninfo already had a #VK_NO_PROTOTYPES somewhere - macOS DemoViewController includes of mvk_vulkan.h are confusing Volk and don't seem to be necessary, since cube.c and cube.cpp #include vulkan.h and vulkan.hpp, respectively
1 parent d67a9d3 commit 5aac257

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

cube/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ else()
259259
endif()
260260

261261
target_include_directories(vkcube PRIVATE .)
262-
target_compile_definitions(vkcube PRIVATE VK_NO_PROTOTYPES)
263262

264263
if (ANDROID)
265264
install(TARGETS vkcube DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -307,7 +306,6 @@ else()
307306
target_link_libraries(vkcubepp Vulkan::Headers volk::volk_headers)
308307
endif()
309308
target_include_directories(vkcubepp PRIVATE .)
310-
target_compile_definitions(vkcubepp PRIVATE VK_NO_PROTOTYPES)
311309

312310
if(APPLE)
313311
install(
@@ -351,7 +349,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD")
351349
Threads::Threads
352350
PkgConfig::WAYLAND_CLIENT
353351
)
354-
target_compile_definitions(vkcube-wayland PRIVATE VK_USE_PLATFORM_WAYLAND_KHR VK_NO_PROTOTYPES)
352+
target_compile_definitions(vkcube-wayland PRIVATE VK_USE_PLATFORM_WAYLAND_KHR)
355353
include(CheckLibraryExists)
356354
CHECK_LIBRARY_EXISTS("rt" clock_gettime "" NEED_RT)
357355
if (NEED_RT)

cube/cube.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#define APP_NAME_STR_LEN 80
5050
#endif // _WIN32
5151

52+
// Volk requires VK_NO_PROTOTYPES before including vulkan.h
53+
#define VK_NO_PROTOTYPES
5254
#include <vulkan/vulkan.h>
5355
#define VOLK_IMPLEMENTATION
5456
#include "volk.h"

cube/cube.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
4242
#define VULKAN_HPP_NO_EXCEPTIONS
4343
#define VULKAN_HPP_TYPESAFE_CONVERSION 1
44+
45+
// Volk requires VK_NO_PROTOTYPES before including vulkan.hpp
46+
#define VK_NO_PROTOTYPES
4447
#include <vulkan/vulkan.hpp>
4548

4649
#define VOLK_IMPLEMENTATION

cube/macOS/cube/DemoViewController.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#import "DemoViewController.h"
2020
#import <QuartzCore/CAMetalLayer.h>
2121

22-
#include <MoltenVK/mvk_vulkan.h>
23-
2422
#include "cube.c"
2523

2624
#pragma mark -

cube/macOS/cubepp/DemoViewController.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#import "DemoViewController.h"
2020
#import <QuartzCore/CAMetalLayer.h>
2121

22-
#include <MoltenVK/mvk_vulkan.h>
23-
2422
#include "cube.cpp"
2523

2624
#pragma mark -

0 commit comments

Comments
 (0)