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#include "pixelbullet/graphics/gpu_session.h"
5
6#include <filesystem>
7#include <optional>
8#include <string>
9#include <string_view>
10
11namespace pixelbullet::application_internal
12{
14{
15 std::optional<uint32_t> gpu_index;
16 std::optional<GraphicsDevicePreference> gpu_preference;
17};
18
19enum class LaunchGpuSelectorSource : uint8_t
20{
21 ImplicitAuto,
22 ExplicitGpuPreference,
23 ExplicitGpuIndex,
24 SavedGpuPreference,
25 SavedGpuIndex,
26};
27
29{
30 std::filesystem::path path;
31 std::optional<SavedGpuLaunchDefault> saved_default;
32 std::string warning_message;
33};
34
36{
37 GraphicsDeviceSelection effective_selection;
38 std::filesystem::path path;
39 std::optional<SavedGpuLaunchDefault> saved_default;
40 LaunchGpuSelectorSource selector_source = LaunchGpuSelectorSource::ImplicitAuto;
41 bool applied_saved_default = false;
42 std::string warning_message;
43};
44
45class ScopedPendingLaunchGpuDefaults
46{
47public:
48 explicit ScopedPendingLaunchGpuDefaults(ResolvedLaunchGpuDefaults resolved_defaults);
49 ~ScopedPendingLaunchGpuDefaults();
50
51 ScopedPendingLaunchGpuDefaults(const ScopedPendingLaunchGpuDefaults&) = delete;
52 ScopedPendingLaunchGpuDefaults& operator=(const ScopedPendingLaunchGpuDefaults&) = delete;
53 ScopedPendingLaunchGpuDefaults(ScopedPendingLaunchGpuDefaults&&) = delete;
54 ScopedPendingLaunchGpuDefaults& operator=(ScopedPendingLaunchGpuDefaults&&) = delete;
55
56private:
57 bool installed_ = false;
58};
59
60[[nodiscard]] bool HasExplicitGpuSelector(const ApplicationLaunchOptions& launch_options) noexcept;
61[[nodiscard]] std::filesystem::path BuildLaunchGpuDefaultsPath(const std::filesystem::path& binary_path,
62 const std::filesystem::path& app_data_root);
63[[nodiscard]] std::filesystem::path GetDefaultLaunchGpuDefaultsPath(const std::filesystem::path& binary_path);
64[[nodiscard]] LaunchGpuDefaultsLoadResult LoadLaunchGpuDefaults(const std::filesystem::path& path);
65[[nodiscard]] bool SaveLaunchGpuDefault(const std::filesystem::path& path, const SavedGpuLaunchDefault& saved_default,
66 std::string* error_message);
67[[nodiscard]] bool ClearLaunchGpuDefault(const std::filesystem::path& path, std::string* error_message);
68[[nodiscard]] ResolvedLaunchGpuDefaults ResolveLaunchGpuDefaults(const ApplicationBootstrap& bootstrap);
69[[nodiscard]] ResolvedLaunchGpuDefaults ResolveLaunchGpuDefaults(const ApplicationBootstrap& bootstrap,
70 const std::filesystem::path& app_data_root);
71[[nodiscard]] ResolvedLaunchGpuDefaults ConsumePendingLaunchGpuDefaults(const ApplicationBootstrap& bootstrap);
72[[nodiscard]] GraphicsDeviceSelectionSession BuildGraphicsDeviceSelectionSession(const ResolvedLaunchGpuDefaults& resolved_defaults);
73[[nodiscard]] std::string DescribeSavedGpuLaunchDefault(const SavedGpuLaunchDefault& saved_default);
74[[nodiscard]] std::string DescribeResolvedGpuSelector(const ResolvedLaunchGpuDefaults& resolved_defaults);
75} // namespace pixelbullet::application_internal
Definition specification.h:61
Definition specification.h:53
Definition gpu_selection.h:18
Definition launch_gpu_defaults_internal.h:29
Definition launch_gpu_defaults_internal.h:36
Definition launch_gpu_defaults_internal.h:14