Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
blender
monado
Commits
09aa8794
Commit
09aa8794
authored
Feb 23, 2020
by
Jakob Bornecrantz
Browse files
aux/vk: Refactor out helper code into own library
parent
a7dff828
Changes
13
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
09aa8794
...
...
@@ -178,6 +178,19 @@ if(BUILD_WITH_HYDRA)
set
(
BUILD_DRIVER_HYDRA TRUE
)
endif
()
# Vulkan flags for the shared Vulkan code.
if
(
BUILD_WITH_XCB
)
add_definitions
(
-DVK_USE_PLATFORM_XCB_KHR
)
endif
()
if
(
BUILD_WITH_XCB AND BUILD_WITH_XLIB
)
add_definitions
(
-DVK_USE_PLATFORM_XLIB_XRANDR_EXT
)
endif
()
if
(
BUILD_WITH_WAYLAND
)
add_definitions
(
-DVK_USE_PLATFORM_WAYLAND_KHR
)
endif
()
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-pedantic -Wall -Wextra -Wno-unused-parameter"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wno-unused-parameter"
)
...
...
meson.build
View file @
09aa8794
...
...
@@ -220,6 +220,18 @@ if sdl2.found()
endif
# Vulkan flags for the shared Vulkan code.
if build_wayland
add_project_arguments('-DVK_USE_PLATFORM_WAYLAND_KHR', language: ['c', 'cpp'])
endif
if build_xcb
add_project_arguments('-DVK_USE_PLATFORM_XCB_KHR', language: ['c', 'cpp'])
endif
if build_xcb_xrandr_direct
add_project_arguments('-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', language: ['c', 'cpp'])
endif
#
# Go down sub directories
#
...
...
src/xrt/auxiliary/CMakeLists.txt
View file @
09aa8794
...
...
@@ -86,6 +86,12 @@ set(UTIL_SOURCE_FILES
util/u_var.h
)
set
(
VK_SOURCE_FILES
vk/vk_helpers.c
vk/vk_helpers.h
vk/vk_documentation.h
)
# Common includes
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../include
...
...
@@ -136,3 +142,11 @@ if(BUILD_TRACKING)
${
OpenCV_INCLUDE_DIRS
}
)
endif
()
# Vulkan library.
# Use OBJECT to not create a archive, since it just gets in the way.
add_library
(
aux_vk OBJECT
${
VK_SOURCE_FILES
}
)
target_include_directories
(
aux_vk SYSTEM
PRIVATE
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../external
)
src/xrt/auxiliary/meson.build
View file @
09aa8794
...
...
@@ -147,6 +147,25 @@ aux_tracking = declare_dependency(
link_with: lib_aux_tracking,
)
lib_aux_vk = static_library(
'aux_vk',
files(
'vk/vk_helpers.h',
'vk/vk_helpers.c',
'vk/vk_documentation.h',
),
include_directories: [
xrt_include,
external_include,
],
)
aux_vk = declare_dependency(
include_directories: aux_include,
link_with: lib_aux_vk,
)
all_aux = [aux_util, aux_os, aux_math, aux_tracking]
aux = declare_dependency(dependencies: all_aux)
src/xrt/auxiliary/vk/vk_documentation.h
0 → 100644
View file @
09aa8794
// Copyright 2020, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Header with just documentation.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup aux_vk
*/
#pragma once
/*!
* @defgroup aux_vk Vulkan helper code
* @ingroup aux
*
* @brief Vulkan helper structs and functions.
*/
/*!
* @dir auxiliary/vk
* @ingroup aux
*
* @brief Vulkan helper structs and functions.
*/
src/xrt/
compositor/common/comp_vk
.c
→
src/xrt/
auxiliary/vk/vk_helpers
.c
View file @
09aa8794
// Copyright 2019, Collabora, Ltd.
// Copyright 2019
-2020
, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Common Vulkan code.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
* @ingroup
comp_common
* @ingroup
aux_vk
*/
#include <stdio.h>
...
...
@@ -15,7 +15,7 @@
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "
common/comp_vk
.h"
#include "
vk/vk_helpers
.h"
/*
...
...
src/xrt/
compositor/common/comp_vk
.h
→
src/xrt/
auxiliary/vk/vk_helpers
.h
View file @
09aa8794
// Copyright 2019, Collabora, Ltd.
// Copyright 2019
-2020
, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Common Vulkan code header.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
* @ingroup
comp_common
* @ingroup
aux_vk
*/
#pragma once
...
...
@@ -29,7 +29,7 @@ extern "C" {
* comp_client. Note that they both have different instances of the object and
* as such VkInstance and so on.
*
* @ingroup
comp_common
* @ingroup
aux_vk
*/
struct
vk_bundle
{
...
...
@@ -224,37 +224,37 @@ vk_color_space_string(VkColorSpaceKHR code);
} while (false)
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
void
vk_init_validation_callback
(
struct
vk_bundle
*
vk
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
void
vk_destroy_validation_callback
(
struct
vk_bundle
*
vk
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_get_loader_functions
(
struct
vk_bundle
*
vk
,
PFN_vkGetInstanceProcAddr
g
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_get_instance_functions
(
struct
vk_bundle
*
vk
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_init_cmd_pool
(
struct
vk_bundle
*
vk
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_create_device
(
struct
vk_bundle
*
vk
,
int
forced_index
);
...
...
@@ -263,7 +263,7 @@ vk_create_device(struct vk_bundle *vk, int forced_index);
* Initialize a bundle with objects given to us by client code,
* used by @ref client_vk_compositor in @ref comp_client.
*
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_init_from_given
(
struct
vk_bundle
*
vk
,
...
...
@@ -275,7 +275,7 @@ vk_init_from_given(struct vk_bundle *vk,
uint32_t
queue_index
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
bool
vk_get_memory_type
(
struct
vk_bundle
*
vk
,
...
...
@@ -313,7 +313,7 @@ vk_get_memory_type(struct vk_bundle *vk,
* If this fails, you may want to destroy your VkImage as well, since this
* routine is usually used in combination with vkCreateImage.
*
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_alloc_and_bind_image_memory
(
struct
vk_bundle
*
vk
,
...
...
@@ -324,7 +324,7 @@ vk_alloc_and_bind_image_memory(struct vk_bundle *vk,
VkDeviceSize
*
out_size
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_create_image_from_fd
(
struct
vk_bundle
*
vk
,
...
...
@@ -339,7 +339,7 @@ vk_create_image_from_fd(struct vk_bundle *vk,
VkDeviceMemory
*
out_mem
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_create_image_simple
(
struct
vk_bundle
*
vk
,
...
...
@@ -350,13 +350,13 @@ vk_create_image_simple(struct vk_bundle *vk,
VkImage
*
out_image
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_create_sampler
(
struct
vk_bundle
*
vk
,
VkSampler
*
out_sampler
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_create_view
(
struct
vk_bundle
*
vk
,
...
...
@@ -366,13 +366,13 @@ vk_create_view(struct vk_bundle *vk,
VkImageView
*
out_view
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_init_cmd_buffer
(
struct
vk_bundle
*
vk
,
VkCommandBuffer
*
out_cmd_buffer
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_set_image_layout
(
struct
vk_bundle
*
vk
,
...
...
@@ -385,7 +385,7 @@ vk_set_image_layout(struct vk_bundle *vk,
VkImageSubresourceRange
subresource_range
);
/*!
* @ingroup
comp_common
* @ingroup
aux_vk
*/
VkResult
vk_submit_cmd_buffer
(
struct
vk_bundle
*
vk
,
VkCommandBuffer
cmd_buffer
);
...
...
src/xrt/compositor/CMakeLists.txt
View file @
09aa8794
...
...
@@ -13,8 +13,6 @@ spirv_shaders(SHADER_HEADERS
set
(
SOURCE_FILES
client/comp_vk_client.c
client/comp_vk_client.h
common/comp_vk.c
common/comp_vk.h
common/comp_vk_swapchain.h
common/comp_vk_swapchain.c
main/comp_client_interface.h
...
...
@@ -33,11 +31,9 @@ set(SOURCE_FILES
)
if
(
BUILD_WITH_XCB
)
add_definitions
(
-DVK_USE_PLATFORM_XCB_KHR
)
list
(
APPEND SOURCE_FILES main/comp_window_xcb.cpp
)
endif
()
if
(
BUILD_WITH_XCB AND BUILD_WITH_XLIB
)
add_definitions
(
-DVK_USE_PLATFORM_XLIB_XRANDR_EXT
)
list
(
APPEND SOURCE_FILES main/comp_window_direct_mode.cpp
)
endif
()
if
(
BUILD_WITH_OPENGL
)
...
...
@@ -84,8 +80,6 @@ if(BUILD_WITH_WAYLAND)
set
(
WL_PROTOS_SRC
${
WL_PROTOS_C
}
${
WL_PROTOS_H
}
)
list
(
APPEND SOURCE_FILES main/comp_window_wayland.c
)
add_definitions
(
-DVK_USE_PLATFORM_WAYLAND_KHR
)
endif
()
if
(
${
VULKAN_ENABLE_VALIDATION
}
)
...
...
src/xrt/compositor/client/comp_vk_client.h
View file @
09aa8794
...
...
@@ -10,7 +10,7 @@
#pragma once
#include "
common/comp_vk
.h"
#include "
vk/vk_helpers
.h"
#include "xrt/xrt_gfx_vk.h"
#ifdef __cplusplus
...
...
src/xrt/compositor/common/comp_vk_swapchain.h
View file @
09aa8794
...
...
@@ -10,7 +10,7 @@
#pragma once
#include "
common/comp_vk
.h"
#include "
vk/vk_helpers
.h"
#ifdef __cplusplus
extern
"C"
{
...
...
src/xrt/compositor/meson.build
View file @
09aa8794
...
...
@@ -9,8 +9,6 @@ compositor_deps = [aux, shaders, vulkan]
compositor_srcs = [
'client/comp_vk_client.c',
'client/comp_vk_client.h',
'common/comp_vk.c',
'common/comp_vk.h',
'common/comp_vk_swapchain.h',
'common/comp_vk_swapchain.c',
'main/comp_client_interface.h',
...
...
@@ -31,13 +29,11 @@ compositor_srcs = [
compile_args = []
if build_xcb
compile_args += ['-DVK_USE_PLATFORM_XCB_KHR']
compositor_srcs += ['main/comp_window_xcb.cpp']
compositor_deps += [xcb]
endif
if build_xcb_xrandr_direct
compile_args += ['-DVK_USE_PLATFORM_XLIB_XRANDR_EXT']
compositor_srcs += ['main/comp_window_direct_mode.cpp']
compositor_deps += [xcb_randr]
endif
...
...
@@ -103,7 +99,6 @@ if build_wayland
sources: wl_protos_headers,
)
compile_args += ['-DVK_USE_PLATFORM_WAYLAND_KHR']
compositor_srcs += ['main/comp_window_wayland.c']
compositor_deps += [wayland, wl_protos]
endif
...
...
src/xrt/targets/openxr/CMakeLists.txt
View file @
09aa8794
...
...
@@ -34,6 +34,7 @@ add_library(${RUNTIME_TARGET} SHARED
${
MANIFEST_DEV_PATH
}
${
MANIFEST_PATH
}
${
SOURCE_FILES
}
$<TARGET_OBJECTS:aux_vk>
$<TARGET_OBJECTS:aux_os>
$<TARGET_OBJECTS:aux_ogl>
$<TARGET_OBJECTS:aux_util>
...
...
src/xrt/targets/openxr/meson.build
View file @
09aa8794
...
...
@@ -69,6 +69,7 @@ openxr = library(
hack_src,
),
link_whole: [
lib_aux_vk,
lib_aux_os,
lib_aux_ogl,
lib_aux_util,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment