1#ifndef ACMX2_SHADER_SELECTION_SHM_HPP
2#define ACMX2_SHADER_SELECTION_SHM_HPP
7#if defined(__linux__) || defined(__APPLE__)
22 inline constexpr const wchar_t *kShaderSelectionMappingNameWindows = L
"Local\\ACMX2ShaderSelectionV11";
23 inline constexpr const wchar_t *kShaderSelectionMutexNameWindows = L
"Local\\ACMX2ShaderSelectionMutexV11";
39 inline constexpr DWORD kShaderSelectionLockTimeoutMs = 1000;
98 static_assert(std::is_standard_layout_v<ShaderSelectionShmData>);
99 static_assert(std::is_trivially_copyable_v<ShaderSelectionShmData>);
102#if defined(__linux__) || defined(__APPLE__) || defined(_WIN32)
103 class ShaderSelectionLock {
105#if defined(__linux__) || defined(__APPLE__)
106 explicit ShaderSelectionLock(sem_t *semaphoreValue) : semaphore(semaphoreValue) {
107 if (semaphore ==
nullptr || semaphore == SEM_FAILED)
109 while (::sem_wait(semaphore) != 0) {
116 explicit ShaderSelectionLock(HANDLE mutexValue) : mutex(mutexValue) {
117 if (mutex ==
nullptr)
119 const DWORD result = ::WaitForSingleObject(mutex, kShaderSelectionLockTimeoutMs);
120 locked = result == WAIT_OBJECT_0 || result == WAIT_ABANDONED;
124 ~ShaderSelectionLock() {
127#if defined(__linux__) || defined(__APPLE__)
128 ::sem_post(semaphore);
130 ::ReleaseMutex(mutex);
134 ShaderSelectionLock(
const ShaderSelectionLock &) =
delete;
135 ShaderSelectionLock &operator=(
const ShaderSelectionLock &) =
delete;
137 explicit operator bool()
const {
return locked; }
140#if defined(__linux__) || defined(__APPLE__)
141 sem_t *semaphore =
nullptr;
143 HANDLE mutex =
nullptr;
constexpr std::uint32_t kShaderSelectionMaxDreamLayer
constexpr std::uint32_t kShaderSelectionMagic
constexpr std::size_t kShaderSelectionDataSize
constexpr std::uint32_t kShaderSelectionMaxShaderName
constexpr std::uint32_t kShaderSelectionMaxPassCount
constexpr std::uint32_t kShaderSelectionMaxUniformName
constexpr std::uint32_t kShaderSelectionVersion
constexpr std::uint32_t kShaderSelectionMaxWatermarkText
constexpr std::uint32_t kShaderSelectionMaxReloadPath
constexpr const char * kShaderSelectionShmName
constexpr const char * kShaderSelectionSemaphoreName
constexpr std::uint32_t kShaderSelectionMaxGpuFilterCount
constexpr std::uint32_t kShaderSelectionMaxCustomUniforms
constexpr std::uint32_t kShaderSelectionMaxDreamModelPath
constexpr std::uint32_t kShaderSelectionMaxAudioFilePath
std::uint8_t dream_gpu_filter_first
std::uint8_t audio_reserved
std::int32_t audio_output_device
std::uint8_t normalized_time_enabled
std::uint8_t shader_pass_enabled
char selected_shader_name[kShaderSelectionMaxShaderName]
std::uint8_t reserved_flags[3]
std::int32_t dream_channel
std::uint32_t shader_pass_count
std::int32_t gpu_filter_indices[kShaderSelectionMaxGpuFilterCount]
std::uint8_t dream_enabled
std::int32_t dream_smoothing
std::uint32_t gpu_filter_count
std::uint8_t repeat_enabled
char audio_file_path[kShaderSelectionMaxAudioFilePath]
char shader_pass_names[kShaderSelectionMaxPassCount][kShaderSelectionMaxShaderName]
char dream_model_path[kShaderSelectionMaxDreamModelPath]
std::uint8_t watermark_enabled
std::uint8_t audio_repeat
std::uint8_t gpu_buffer_size
std::uint8_t dream_reserved
std::uint8_t audio_pass_through
std::uint32_t audio_file_sequence
std::uint32_t reload_sequence
std::int32_t selected_index
char custom_uniform_names[kShaderSelectionMaxCustomUniforms][kShaderSelectionMaxUniformName]
std::uint8_t gpu_filter_enabled
char dream_layer[kShaderSelectionMaxDreamLayer]
std::uint8_t display_filter_enabled
std::int32_t dream_iterations
std::int32_t dream_jitter
std::int32_t dream_maximum_dimension
char reload_shader_path[kShaderSelectionMaxReloadPath]
std::int32_t shader_pass_indices[kShaderSelectionMaxPassCount]
std::int32_t dream_octaves
std::int32_t reload_shader_index
char watermark_text[kShaderSelectionMaxWatermarkText]
float custom_uniform_values[kShaderSelectionMaxCustomUniforms]
std::uint32_t custom_uniform_count