mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
st/oxr: Avoid using sprintf
This commit is contained in:
parent
545ad5c1bf
commit
428e46617a
|
@ -25,8 +25,31 @@
|
||||||
#include "oxr_two_call.h"
|
#include "oxr_two_call.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Helpers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#define GET_PROC(name) PFN_##name name = (PFN_##name)getProc(vkInstance, #name)
|
#define GET_PROC(name) PFN_##name name = (PFN_##name)getProc(vkInstance, #name)
|
||||||
|
|
||||||
|
#define UUID_STR_SIZE (XRT_GPU_UUID_SIZE * 3 + 1)
|
||||||
|
|
||||||
|
static void
|
||||||
|
snprint_uuid(char *str, size_t size, uint8_t uuid[XRT_GPU_UUID_SIZE])
|
||||||
|
{
|
||||||
|
for (size_t i = 0, offset = 0; i < XRT_GPU_UUID_SIZE && offset < size; i++, offset += 3) {
|
||||||
|
snprintf(str + offset, size - offset, "%02x ", uuid[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Misc functions (to be organized).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
XrResult
|
XrResult
|
||||||
oxr_vk_get_instance_exts(struct oxr_logger *log,
|
oxr_vk_get_instance_exts(struct oxr_logger *log,
|
||||||
struct oxr_system *sys,
|
struct oxr_system *sys,
|
||||||
|
@ -415,10 +438,8 @@ oxr_vk_get_physical_device(struct oxr_logger *log,
|
||||||
"VkPhysicalDevices");
|
"VkPhysicalDevices");
|
||||||
}
|
}
|
||||||
|
|
||||||
char suggested_uuid_str[XRT_GPU_UUID_SIZE * 3 + 1] = {0};
|
char suggested_uuid_str[UUID_STR_SIZE] = {0};
|
||||||
for (int i = 0; i < XRT_GPU_UUID_SIZE; i++) {
|
snprint_uuid(suggested_uuid_str, ARRAY_SIZE(suggested_uuid_str), sys->xsysc->info.client_vk_deviceUUID);
|
||||||
sprintf(suggested_uuid_str + i * 3, "%02x ", sys->xsysc->info.client_vk_deviceUUID[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum u_logging_level log_level = debug_get_log_option_compositor_log();
|
enum u_logging_level log_level = debug_get_log_option_compositor_log();
|
||||||
int gpu_index = -1;
|
int gpu_index = -1;
|
||||||
|
@ -430,18 +451,16 @@ oxr_vk_get_physical_device(struct oxr_logger *log,
|
||||||
|
|
||||||
vkGetPhysicalDeviceProperties2(phys[i], &pdp2);
|
vkGetPhysicalDeviceProperties2(phys[i], &pdp2);
|
||||||
|
|
||||||
char uuid_str[XRT_GPU_UUID_SIZE * 3 + 1] = {0};
|
char uuid_str[UUID_STR_SIZE] = {0};
|
||||||
if (log_level <= U_LOGGING_DEBUG) {
|
if (log_level <= U_LOGGING_DEBUG) {
|
||||||
for (int i = 0; i < XRT_GPU_UUID_SIZE; i++) {
|
snprint_uuid(uuid_str, ARRAY_SIZE(uuid_str), pdidp.deviceUUID);
|
||||||
sprintf(uuid_str + i * 3, "%02x ", pdidp.deviceUUID[i]);
|
oxr_log(log, "GPU: #%d, uuid: %s", i, uuid_str);
|
||||||
}
|
|
||||||
oxr_log(log, "GPU %d: uuid %s", i, uuid_str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(pdidp.deviceUUID, sys->xsysc->info.client_vk_deviceUUID, XRT_GPU_UUID_SIZE) == 0) {
|
if (memcmp(pdidp.deviceUUID, sys->xsysc->info.client_vk_deviceUUID, XRT_GPU_UUID_SIZE) == 0) {
|
||||||
gpu_index = i;
|
gpu_index = i;
|
||||||
if (log_level <= U_LOGGING_DEBUG) {
|
if (log_level <= U_LOGGING_DEBUG) {
|
||||||
oxr_log(log, "Using GPU %d with uuid %s suggested by runtime", gpu_index, uuid_str);
|
oxr_log(log, "Using GPU #%d with uuid %s suggested by runtime", gpu_index, uuid_str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue