The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aux/vk: Refactor out helper code into own library

+109 -35
+13
CMakeLists.txt
··· 178 178 set(BUILD_DRIVER_HYDRA TRUE) 179 179 endif() 180 180 181 + 182 + # Vulkan flags for the shared Vulkan code. 183 + if(BUILD_WITH_XCB) 184 + add_definitions(-DVK_USE_PLATFORM_XCB_KHR) 185 + endif() 186 + if(BUILD_WITH_XCB AND BUILD_WITH_XLIB) 187 + add_definitions(-DVK_USE_PLATFORM_XLIB_XRANDR_EXT) 188 + endif() 189 + if(BUILD_WITH_WAYLAND) 190 + add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR) 191 + endif() 192 + 193 + 181 194 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wno-unused-parameter") 182 195 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter") 183 196
+12
meson.build
··· 220 220 endif 221 221 222 222 223 + # Vulkan flags for the shared Vulkan code. 224 + if build_wayland 225 + add_project_arguments('-DVK_USE_PLATFORM_WAYLAND_KHR', language: ['c', 'cpp']) 226 + endif 227 + if build_xcb 228 + add_project_arguments('-DVK_USE_PLATFORM_XCB_KHR', language: ['c', 'cpp']) 229 + endif 230 + if build_xcb_xrandr_direct 231 + add_project_arguments('-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', language: ['c', 'cpp']) 232 + endif 233 + 234 + 223 235 # 224 236 # Go down sub directories 225 237 #
+14
src/xrt/auxiliary/CMakeLists.txt
··· 86 86 util/u_var.h 87 87 ) 88 88 89 + set(VK_SOURCE_FILES 90 + vk/vk_helpers.c 91 + vk/vk_helpers.h 92 + vk/vk_documentation.h 93 + ) 94 + 89 95 # Common includes 90 96 include_directories( 91 97 ${CMAKE_CURRENT_SOURCE_DIR}/../include ··· 136 142 ${OpenCV_INCLUDE_DIRS} 137 143 ) 138 144 endif() 145 + 146 + # Vulkan library. 147 + # Use OBJECT to not create a archive, since it just gets in the way. 148 + add_library(aux_vk OBJECT ${VK_SOURCE_FILES}) 149 + target_include_directories(aux_vk SYSTEM 150 + PRIVATE 151 + ${CMAKE_CURRENT_SOURCE_DIR}/../../external 152 + )
+19
src/xrt/auxiliary/meson.build
··· 147 147 link_with: lib_aux_tracking, 148 148 ) 149 149 150 + lib_aux_vk = static_library( 151 + 'aux_vk', 152 + files( 153 + 'vk/vk_helpers.h', 154 + 'vk/vk_helpers.c', 155 + 'vk/vk_documentation.h', 156 + ), 157 + include_directories: [ 158 + xrt_include, 159 + external_include, 160 + ], 161 + ) 162 + 163 + aux_vk = declare_dependency( 164 + include_directories: aux_include, 165 + link_with: lib_aux_vk, 166 + ) 167 + 168 + 150 169 all_aux = [aux_util, aux_os, aux_math, aux_tracking] 151 170 152 171 aux = declare_dependency(dependencies: all_aux)
+25
src/xrt/auxiliary/vk/vk_documentation.h
··· 1 + // Copyright 2020, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Header with just documentation. 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @ingroup aux_vk 8 + */ 9 + 10 + #pragma once 11 + 12 + 13 + /*! 14 + * @defgroup aux_vk Vulkan helper code 15 + * @ingroup aux 16 + * 17 + * @brief Vulkan helper structs and functions. 18 + */ 19 + 20 + /*! 21 + * @dir auxiliary/vk 22 + * @ingroup aux 23 + * 24 + * @brief Vulkan helper structs and functions. 25 + */
-6
src/xrt/compositor/CMakeLists.txt
··· 13 13 set(SOURCE_FILES 14 14 client/comp_vk_client.c 15 15 client/comp_vk_client.h 16 - common/comp_vk.c 17 - common/comp_vk.h 18 16 common/comp_vk_swapchain.h 19 17 common/comp_vk_swapchain.c 20 18 main/comp_client_interface.h ··· 33 31 ) 34 32 35 33 if(BUILD_WITH_XCB) 36 - add_definitions(-DVK_USE_PLATFORM_XCB_KHR) 37 34 list(APPEND SOURCE_FILES main/comp_window_xcb.cpp) 38 35 endif() 39 36 if(BUILD_WITH_XCB AND BUILD_WITH_XLIB) 40 - add_definitions(-DVK_USE_PLATFORM_XLIB_XRANDR_EXT) 41 37 list(APPEND SOURCE_FILES main/comp_window_direct_mode.cpp) 42 38 endif() 43 39 if(BUILD_WITH_OPENGL) ··· 84 80 85 81 set(WL_PROTOS_SRC ${WL_PROTOS_C} ${WL_PROTOS_H}) 86 82 list(APPEND SOURCE_FILES main/comp_window_wayland.c) 87 - 88 - add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR) 89 83 endif() 90 84 91 85 if (${VULKAN_ENABLE_VALIDATION})
+1 -1
src/xrt/compositor/client/comp_vk_client.h
··· 10 10 11 11 #pragma once 12 12 13 - #include "common/comp_vk.h" 13 + #include "vk/vk_helpers.h" 14 14 #include "xrt/xrt_gfx_vk.h" 15 15 16 16 #ifdef __cplusplus
+3 -3
src/xrt/compositor/common/comp_vk.c src/xrt/auxiliary/vk/vk_helpers.c
··· 1 - // Copyright 2019, Collabora, Ltd. 1 + // Copyright 2019-2020, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file 5 5 * @brief Common Vulkan code. 6 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 7 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com> 8 - * @ingroup comp_common 8 + * @ingroup aux_vk 9 9 */ 10 10 11 11 #include <stdio.h> ··· 15 15 #include "util/u_misc.h" 16 16 #include "util/u_debug.h" 17 17 18 - #include "common/comp_vk.h" 18 + #include "vk/vk_helpers.h" 19 19 20 20 21 21 /*
+19 -19
src/xrt/compositor/common/comp_vk.h src/xrt/auxiliary/vk/vk_helpers.h
··· 1 - // Copyright 2019, Collabora, Ltd. 1 + // Copyright 2019-2020, Collabora, Ltd. 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file 5 5 * @brief Common Vulkan code header. 6 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 7 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com> 8 - * @ingroup comp_common 8 + * @ingroup aux_vk 9 9 */ 10 10 11 11 #pragma once ··· 29 29 * comp_client. Note that they both have different instances of the object and 30 30 * as such VkInstance and so on. 31 31 * 32 - * @ingroup comp_common 32 + * @ingroup aux_vk 33 33 */ 34 34 struct vk_bundle 35 35 { ··· 224 224 } while (false) 225 225 226 226 /*! 227 - * @ingroup comp_common 227 + * @ingroup aux_vk 228 228 */ 229 229 void 230 230 vk_init_validation_callback(struct vk_bundle *vk); 231 231 232 232 /*! 233 - * @ingroup comp_common 233 + * @ingroup aux_vk 234 234 */ 235 235 void 236 236 vk_destroy_validation_callback(struct vk_bundle *vk); 237 237 238 238 /*! 239 - * @ingroup comp_common 239 + * @ingroup aux_vk 240 240 */ 241 241 VkResult 242 242 vk_get_loader_functions(struct vk_bundle *vk, PFN_vkGetInstanceProcAddr g); 243 243 244 244 /*! 245 - * @ingroup comp_common 245 + * @ingroup aux_vk 246 246 */ 247 247 VkResult 248 248 vk_get_instance_functions(struct vk_bundle *vk); 249 249 250 250 /*! 251 - * @ingroup comp_common 251 + * @ingroup aux_vk 252 252 */ 253 253 VkResult 254 254 vk_init_cmd_pool(struct vk_bundle *vk); 255 255 256 256 /*! 257 - * @ingroup comp_common 257 + * @ingroup aux_vk 258 258 */ 259 259 VkResult 260 260 vk_create_device(struct vk_bundle *vk, int forced_index); ··· 263 263 * Initialize a bundle with objects given to us by client code, 264 264 * used by @ref client_vk_compositor in @ref comp_client. 265 265 * 266 - * @ingroup comp_common 266 + * @ingroup aux_vk 267 267 */ 268 268 VkResult 269 269 vk_init_from_given(struct vk_bundle *vk, ··· 275 275 uint32_t queue_index); 276 276 277 277 /*! 278 - * @ingroup comp_common 278 + * @ingroup aux_vk 279 279 */ 280 280 bool 281 281 vk_get_memory_type(struct vk_bundle *vk, ··· 313 313 * If this fails, you may want to destroy your VkImage as well, since this 314 314 * routine is usually used in combination with vkCreateImage. 315 315 * 316 - * @ingroup comp_common 316 + * @ingroup aux_vk 317 317 */ 318 318 VkResult 319 319 vk_alloc_and_bind_image_memory(struct vk_bundle *vk, ··· 324 324 VkDeviceSize *out_size); 325 325 326 326 /*! 327 - * @ingroup comp_common 327 + * @ingroup aux_vk 328 328 */ 329 329 VkResult 330 330 vk_create_image_from_fd(struct vk_bundle *vk, ··· 339 339 VkDeviceMemory *out_mem); 340 340 341 341 /*! 342 - * @ingroup comp_common 342 + * @ingroup aux_vk 343 343 */ 344 344 VkResult 345 345 vk_create_image_simple(struct vk_bundle *vk, ··· 350 350 VkImage *out_image); 351 351 352 352 /*! 353 - * @ingroup comp_common 353 + * @ingroup aux_vk 354 354 */ 355 355 VkResult 356 356 vk_create_sampler(struct vk_bundle *vk, VkSampler *out_sampler); 357 357 358 358 /*! 359 - * @ingroup comp_common 359 + * @ingroup aux_vk 360 360 */ 361 361 VkResult 362 362 vk_create_view(struct vk_bundle *vk, ··· 366 366 VkImageView *out_view); 367 367 368 368 /*! 369 - * @ingroup comp_common 369 + * @ingroup aux_vk 370 370 */ 371 371 VkResult 372 372 vk_init_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd_buffer); 373 373 374 374 /*! 375 - * @ingroup comp_common 375 + * @ingroup aux_vk 376 376 */ 377 377 VkResult 378 378 vk_set_image_layout(struct vk_bundle *vk, ··· 385 385 VkImageSubresourceRange subresource_range); 386 386 387 387 /*! 388 - * @ingroup comp_common 388 + * @ingroup aux_vk 389 389 */ 390 390 VkResult 391 391 vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer);
+1 -1
src/xrt/compositor/common/comp_vk_swapchain.h
··· 10 10 11 11 #pragma once 12 12 13 - #include "common/comp_vk.h" 13 + #include "vk/vk_helpers.h" 14 14 15 15 #ifdef __cplusplus 16 16 extern "C" {
-5
src/xrt/compositor/meson.build
··· 9 9 compositor_srcs = [ 10 10 'client/comp_vk_client.c', 11 11 'client/comp_vk_client.h', 12 - 'common/comp_vk.c', 13 - 'common/comp_vk.h', 14 12 'common/comp_vk_swapchain.h', 15 13 'common/comp_vk_swapchain.c', 16 14 'main/comp_client_interface.h', ··· 31 29 compile_args = [] 32 30 33 31 if build_xcb 34 - compile_args += ['-DVK_USE_PLATFORM_XCB_KHR'] 35 32 compositor_srcs += ['main/comp_window_xcb.cpp'] 36 33 compositor_deps += [xcb] 37 34 endif 38 35 39 36 if build_xcb_xrandr_direct 40 - compile_args += ['-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'] 41 37 compositor_srcs += ['main/comp_window_direct_mode.cpp'] 42 38 compositor_deps += [xcb_randr] 43 39 endif ··· 103 99 sources: wl_protos_headers, 104 100 ) 105 101 106 - compile_args += ['-DVK_USE_PLATFORM_WAYLAND_KHR'] 107 102 compositor_srcs += ['main/comp_window_wayland.c'] 108 103 compositor_deps += [wayland, wl_protos] 109 104 endif
+1
src/xrt/targets/openxr/CMakeLists.txt
··· 34 34 ${MANIFEST_DEV_PATH} 35 35 ${MANIFEST_PATH} 36 36 ${SOURCE_FILES} 37 + $<TARGET_OBJECTS:aux_vk> 37 38 $<TARGET_OBJECTS:aux_os> 38 39 $<TARGET_OBJECTS:aux_ogl> 39 40 $<TARGET_OBJECTS:aux_util>
+1
src/xrt/targets/openxr/meson.build
··· 69 69 hack_src, 70 70 ), 71 71 link_whole: [ 72 + lib_aux_vk, 72 73 lib_aux_os, 73 74 lib_aux_ogl, 74 75 lib_aux_util,