CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
app_config.cpp
Go to the documentation of this file.
1
8#include "config/app_config.h"
9#include <spdlog/spdlog.h>
10
12
13// ============================================================
14// Static Member Initialization
15// ============================================================
16
17
18Halide::Target AppConfig::s_halide_target = Halide::get_host_target();
19
20// ============================================================
21// Singleton Instance
22// ============================================================
23
25{
26 // C++11 Magic Static: Thread-safe initialization.
27 static AppConfig s_instance;
28 return s_instance;
29}
30
31// ============================================================
32// Backend Configuration
33// ============================================================
34
36{
37 if (m_processing_backend != backend)
38 {
39 m_processing_backend = backend;
40
41 const auto backend_str = (backend == Common::MemoryType::CPU_RAM)
42 ? "CPU_RAM"
43 : "GPU_MEMORY";
44
45 spdlog::info("[AppConfig] Processing backend changed to: {}", backend_str);
46 }
47}
48
50{
51 return m_processing_backend;
52}
53
54// ============================================================
55// Halide Target Configuration
56// ============================================================
57
58void AppConfig::setHalideTarget(const Halide::Target& target)
59{
60 // Update the global static target
61 s_halide_target = target;
62
63 // Log the specific features configured in this target (helpful for debugging)
64 std::string features_str;
65 if (target.has_feature(Halide::Target::CUDA)) features_str += "CUDA ";
66 if (target.has_feature(Halide::Target::OpenCL)) features_str += "OpenCL ";
67 if (target.has_feature(Halide::Target::Vulkan)) features_str += "Vulkan ";
68 if (target.has_feature(Halide::Target::Metal)) features_str += "Metal ";
69 if (target.has_feature(Halide::Target::D3D12Compute)) features_str += "DirectX12 ";
70
71 spdlog::info("[AppConfig] Halide Target updated. Architecture: {}, Features: [{}]",
72 target.to_string(), features_str);
73}
74
75const Halide::Target& AppConfig::getHalideTarget()
76{
77 return s_halide_target;
78}
79
80// ============================================================
81// Testing Utilities
82// ============================================================
83
84#ifdef ENABLE_TESTS
85void AppConfig::reset()
86{
87 spdlog::debug("[AppConfig] Resetting configuration to defaults.");
88
89 // Reset backend to default
90 m_processing_backend = Common::MemoryType::CPU_RAM;
91
92 // Reset target to default host (removes GPU features)
93 s_halide_target = Halide::get_host_target();
94}
95#endif
96
97} // namespace CaptureMoment::Core::Config
Application-wide configuration singleton.
Singleton class for managing application-wide configuration settings.
Definition app_config.h:46
static void setHalideTarget(const Halide::Target &target)
Sets the configured Halide Target object.
Common::MemoryType getProcessingBackend() const noexcept
Gets the configured processing backend.
static AppConfig & instance()
Gets the singleton instance of AppConfig.
void setProcessingBackend(Common::MemoryType backend)
Sets the processing backend (CPU or GPU) for image operations.
static const Halide::Target & getHalideTarget()
Gets the configured Halide Target object.
MemoryType
Enum representing the memory type where image data is stored.
Definition memory_type.h:24
@ CPU_RAM
Data is stored in main CPU RAM.
CaptureMoment — footer