PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
launch_gpu_defaults_internal.h
1#pragma once
2
3#include "pixelbullet/application/specification.h"
4
5#include <filesystem>
6#include <optional>
7#include <string>
8#include <string_view>
9
10namespace pixelbullet::application_internal
11{
13{
14 std::optional<uint32_t> gpu_index;
15 std::optional<GraphicsDevicePreference> gpu_preference;
16};
17
18enum class LaunchGpuSelectorSource : uint8_t
19{
20 ImplicitAuto,
21 ExplicitGpuPreference,
22 ExplicitGpuIndex,
23 SavedGpuPreference,
24 SavedGpuIndex,
25};
26
28{
29 std::filesystem::path path;
30 std::optional<SavedGpuLaunchDefault> saved_default;
31 std::string warning_message;
32};
33
35{
36 ApplicationBootstrap effective_bootstrap;
37 std::filesystem::path path;
38 std::optional<SavedGpuLaunchDefault> saved_default;
39 LaunchGpuSelectorSource selector_source = LaunchGpuSelectorSource::ImplicitAuto;
40 bool applied_saved_default = false;
41 std::string warning_message;
42};
43
44class ScopedPendingLaunchGpuDefaults
45{
46public:
47 explicit ScopedPendingLaunchGpuDefaults(ResolvedLaunchGpuDefaults resolved_defaults);
48 ~ScopedPendingLaunchGpuDefaults();
49
50 ScopedPendingLaunchGpuDefaults(const ScopedPendingLaunchGpuDefaults&) = delete;
51 ScopedPendingLaunchGpuDefaults& operator=(const ScopedPendingLaunchGpuDefaults&) = delete;
52 ScopedPendingLaunchGpuDefaults(ScopedPendingLaunchGpuDefaults&&) = delete;
53 ScopedPendingLaunchGpuDefaults& operator=(ScopedPendingLaunchGpuDefaults&&) = delete;
54
55private:
56 bool installed_ = false;
57};
58
59[[nodiscard]] bool HasExplicitGpuSelector(const ApplicationLaunchOptions& launch_options) noexcept;
60[[nodiscard]] std::filesystem::path BuildLaunchGpuDefaultsPath(const std::filesystem::path& binary_path,
61 const std::filesystem::path& app_data_root);
62[[nodiscard]] std::filesystem::path GetDefaultLaunchGpuDefaultsPath(const std::filesystem::path& binary_path);
63[[nodiscard]] LaunchGpuDefaultsLoadResult LoadLaunchGpuDefaults(const std::filesystem::path& path);
64[[nodiscard]] bool SaveLaunchGpuDefault(const std::filesystem::path& path, const SavedGpuLaunchDefault& saved_default,
65 std::string* error_message);
66[[nodiscard]] bool ClearLaunchGpuDefault(const std::filesystem::path& path, std::string* error_message);
67[[nodiscard]] ResolvedLaunchGpuDefaults ResolveLaunchGpuDefaults(const ApplicationBootstrap& bootstrap);
68[[nodiscard]] ResolvedLaunchGpuDefaults ResolveLaunchGpuDefaults(const ApplicationBootstrap& bootstrap,
69 const std::filesystem::path& app_data_root);
70[[nodiscard]] ResolvedLaunchGpuDefaults ConsumePendingLaunchGpuDefaults(const ApplicationBootstrap& bootstrap);
71[[nodiscard]] std::string DescribeSavedGpuLaunchDefault(const SavedGpuLaunchDefault& saved_default);
72[[nodiscard]] std::string DescribeResolvedGpuSelector(const ResolvedLaunchGpuDefaults& resolved_defaults);
73} // namespace pixelbullet::application_internal
Definition specification.h:79
Definition specification.h:69
Definition launch_gpu_defaults_internal.h:28
Definition launch_gpu_defaults_internal.h:35
Definition launch_gpu_defaults_internal.h:13