Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Monado
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Simon Ser
Monado
Commits
7d9ef2f3
Commit
7d9ef2f3
authored
Oct 25, 2019
by
Christoph Haag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comp: Add setting to force a vulkan gpu index
parent
186f3ff7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
13 deletions
+27
-13
src/xrt/compositor/common/comp_vk.c
src/xrt/compositor/common/comp_vk.c
+19
-10
src/xrt/compositor/common/comp_vk.h
src/xrt/compositor/common/comp_vk.h
+1
-1
src/xrt/compositor/main/comp_compositor.c
src/xrt/compositor/main/comp_compositor.c
+2
-2
src/xrt/compositor/main/comp_settings.c
src/xrt/compositor/main/comp_settings.c
+2
-0
src/xrt/compositor/main/comp_settings.h
src/xrt/compositor/main/comp_settings.h
+3
-0
No files found.
src/xrt/compositor/common/comp_vk.c
View file @
7d9ef2f3
...
...
@@ -825,7 +825,7 @@ vk_get_device_functions(struct vk_bundle *vk)
*/
static
VkResult
vk_select_physical_device
(
struct
vk_bundle
*
vk
)
vk_select_physical_device
(
struct
vk_bundle
*
vk
,
int
forced_index
)
{
VkPhysicalDevice
physical_devices
[
16
];
uint32_t
gpu_count
=
ARRAY_SIZE
(
physical_devices
);
...
...
@@ -848,14 +848,23 @@ vk_select_physical_device(struct vk_bundle *vk)
VK_DEBUG
(
vk
,
"Can not deal well with multiple devices."
);
}
// as a first-step to 'intelligent' selection, prefer a 'discrete' gpu
// if it is present
VK_DEBUG
(
vk
,
"Choosing Vulkan device index"
);
uint32_t
gpu_index
=
0
;
for
(
uint32_t
i
=
0
;
i
<
gpu_count
;
i
++
)
{
VkPhysicalDeviceProperties
pdp
;
vk
->
vkGetPhysicalDeviceProperties
(
physical_devices
[
i
],
&
pdp
);
if
(
pdp
.
deviceType
==
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
)
{
gpu_index
=
i
;
if
(
forced_index
>
-
1
)
{
gpu_index
=
forced_index
;
VK_DEBUG
(
vk
,
"Forced use of Vulkan device index %d."
,
gpu_index
);
}
else
{
// as a first-step to 'intelligent' selection, prefer a
// 'discrete' gpu if it is present
for
(
uint32_t
i
=
0
;
i
<
gpu_count
;
i
++
)
{
VkPhysicalDeviceProperties
pdp
;
vk
->
vkGetPhysicalDeviceProperties
(
physical_devices
[
i
],
&
pdp
);
if
(
pdp
.
deviceType
==
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
)
{
gpu_index
=
i
;
}
}
}
...
...
@@ -929,11 +938,11 @@ err_free:
}
VkResult
vk_create_device
(
struct
vk_bundle
*
vk
)
vk_create_device
(
struct
vk_bundle
*
vk
,
int
forced_index
)
{
VkResult
ret
;
ret
=
vk_select_physical_device
(
vk
);
ret
=
vk_select_physical_device
(
vk
,
forced_index
);
if
(
ret
!=
VK_SUCCESS
)
{
return
ret
;
}
...
...
src/xrt/compositor/common/comp_vk.h
View file @
7d9ef2f3
...
...
@@ -253,7 +253,7 @@ vk_init_cmd_pool(struct vk_bundle *vk);
* @ingroup comp_common
*/
VkResult
vk_create_device
(
struct
vk_bundle
*
vk
);
vk_create_device
(
struct
vk_bundle
*
vk
,
int
forced_index
);
/*!
* Initialize a bundle with objects given to us by client code,
...
...
src/xrt/compositor/main/comp_compositor.c
View file @
7d9ef2f3
...
...
@@ -442,7 +442,7 @@ compositor_init_vulkan(struct comp_compositor *c)
return
false
;
}
ret
=
vk_create_device
(
&
c
->
vk
);
ret
=
vk_create_device
(
&
c
->
vk
,
c
->
settings
.
gpu_index
);
if
(
ret
!=
VK_SUCCESS
)
{
return
false
;
}
...
...
@@ -531,7 +531,7 @@ compositor_check_vulkan_caps(struct comp_compositor *c)
}
// follow same device selection logic as subsequent calls
ret
=
vk_create_device
(
&
temp_vk
);
ret
=
vk_create_device
(
&
temp_vk
,
c
->
settings
.
gpu_index
);
if
(
ret
!=
VK_SUCCESS
)
{
COMP_ERROR
(
c
,
"Failed to create VkDevice: %s"
,
vk_result_string
(
ret
));
...
...
src/xrt/compositor/main/comp_settings.c
View file @
7d9ef2f3
...
...
@@ -18,6 +18,7 @@ DEBUG_GET_ONCE_BOOL_OPTION(force_nvidia, "XRT_COMPOSITOR_FORCE_NVIDIA", false)
DEBUG_GET_ONCE_BOOL_OPTION
(
force_xcb
,
"XRT_COMPOSITOR_FORCE_XCB"
,
false
)
DEBUG_GET_ONCE_BOOL_OPTION
(
force_wayland
,
"XRT_COMPOSITOR_FORCE_WAYLAND"
,
false
)
DEBUG_GET_ONCE_BOOL_OPTION
(
validate_vulkan
,
"XRT_COMPOSITOR_VULKAN_VALIDATION"
,
false
)
DEBUG_GET_ONCE_NUM_OPTION
(
force_gpu_index
,
"XRT_COMPOSITOR_FORCE_GPU_INDEX"
,
-
1
)
// clang-format on
void
...
...
@@ -43,6 +44,7 @@ comp_settings_init(struct comp_settings *s, struct xrt_device *xdev)
s
->
print_spew
=
debug_get_bool_option_print_spew
();
s
->
print_debug
=
debug_get_bool_option_print_debug
();
s
->
validate_vulkan
=
debug_get_bool_option_validate_vulkan
();
s
->
gpu_index
=
debug_get_num_option_force_gpu_index
();
if
(
debug_get_bool_option_force_nvidia
())
{
s
->
window_type
=
WINDOW_DIRECT_NVIDIA
;
...
...
src/xrt/compositor/main/comp_settings.h
View file @
7d9ef2f3
...
...
@@ -84,6 +84,9 @@ struct comp_settings
//! Enable vulkan validation for compositor
bool
validate_vulkan
;
//! Run the compositor on this Vulkan physical device
int
gpu_index
;
};
/*!
...
...
Write
Preview
Markdown
is supported
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