upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-21 23:15:35 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-21 23:15:35 -0500
commit5ff488901c1e6e037ae64b4d996a4e31535d9e23 (patch)
treedd17c97ab137d2a99efeb5a9e8a8f666351fcaee /runtime/src
parent9b21cde473da186ea978b7a84a6a2528717f8041 (diff)
parent77f42e09c09e74d21603c448bc2a1c766bb51597 (diff)
Merge pull request #861 from adonizm
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/vulkan_device_filter.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/runtime/src/vulkan_device_filter.h b/runtime/src/vulkan_device_filter.h
new file mode 100644
index 000000000..1e7a12e37
--- /dev/null
+++ b/runtime/src/vulkan_device_filter.h
@@ -0,0 +1,39 @@
1#pragma once
2
3// LEONIDA_VK_DEVICE: which Vulkan GPU the runtime and its tests take on a machine with more than one. The value is
4// part of the device name, compared without case ("5070", "radeon"); unset or empty takes every device, and the
5// caller then picks as before (the last discrete GPU, else the first that fits). Several GPUs of one vendor share
6// one driver, so the loader's own driver filters cannot tell them apart. A value that matches no device must fail
7// the caller, not fall back, so a typo cannot silently test another GPU (as LEONIDA_HOST_ADAPTER does).
8
9#include <cctype>
10#include <cstdlib>
11#include <string>
12
13namespace leonida {
14
15// The filter, lower-cased; empty when unset.
16inline std::string vulkan_device_filter() {
17#ifdef _MSC_VER
18#pragma warning(push)
19#pragma warning(disable : 4996) // getenv: read at device selection only
20#endif
21 const char* value = std::getenv("LEONIDA_VK_DEVICE");
22#ifdef _MSC_VER
23#pragma warning(pop)
24#endif
25 std::string out = value ? value : "";
26 for (char& c : out) c = char(std::tolower(static_cast<unsigned char>(c)));
27 return out;
28}
29
30// True when `device_name` (VkPhysicalDeviceProperties::deviceName) is wanted.
31inline bool vulkan_device_wanted(const char* device_name) {
32 const std::string filter = vulkan_device_filter();
33 if (filter.empty()) return true;
34 std::string name = device_name ? device_name : "";
35 for (char& c : name) c = char(std::tolower(static_cast<unsigned char>(c)));
36 return name.find(filter) != std::string::npos;
37}
38
39} // namespace leonida