mirror of
https://github.com/InstanceBrick/nightcap.git
synced 2026-10-17 18:02:19 +02:00
Integrate Frame OpenXR input, SteamVR video controls, gaze foveation, native audio, frame pacing and source-based packaging.
90 lines
3.4 KiB
C++
90 lines
3.4 KiB
C++
// Modified by vii from komaruworld/mocktail. See README "About this fork".
|
|
#ifndef MOCKTAIL_RUNTIME_PERFORMANCE_POLICY_H_
|
|
#define MOCKTAIL_RUNTIME_PERFORMANCE_POLICY_H_
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "runtime/frame_rate_policy.h"
|
|
#include "runtime/game_mode.h"
|
|
|
|
namespace mocktail {
|
|
namespace runtime {
|
|
|
|
enum class PhysicsWorkerMode {
|
|
kAuto,
|
|
kLatency,
|
|
kThroughput,
|
|
};
|
|
|
|
bool ParsePhysicsWorkerMode(std::string_view value, PhysicsWorkerMode* mode);
|
|
std::string_view PhysicsWorkerModeName(PhysicsWorkerMode mode);
|
|
|
|
// Malformed topology still yields one worker.
|
|
int CalculateThroughputWorkerCount(int available_physical_cores);
|
|
|
|
struct PerformancePolicy {
|
|
bool multithreaded_rendering = false;
|
|
int physical_core_count = 0;
|
|
std::uint64_t memory_limit_mb = 0;
|
|
bool memory_limit_valid = true;
|
|
GameModePolicy game_mode = GameModePolicy::kAuto;
|
|
bool game_mode_valid = true;
|
|
PhysicsWorkerMode physics_worker_mode = PhysicsWorkerMode::kAuto;
|
|
bool physics_worker_mode_valid = true;
|
|
|
|
bool memory_limit_enabled() const {
|
|
return memory_limit_valid && memory_limit_mb != 0;
|
|
}
|
|
std::uint64_t memory_limit_bytes() const {
|
|
return memory_limit_mb * 1024U * 1024U;
|
|
}
|
|
};
|
|
|
|
PerformancePolicy ParsePerformancePolicy(
|
|
std::string_view multithreaded_rendering,
|
|
std::string_view memory_limit_mb = "0", std::string_view game_mode = "auto",
|
|
std::string_view physics_worker_mode = "auto");
|
|
|
|
// Respects CPU affinity and falls back to the available logical count.
|
|
int DetectAvailablePhysicalCoreCount();
|
|
|
|
// Disabled policy preserves overrides. A base_json value that differs from
|
|
// the preset is kept as-is and its key is appended to kept_overrides.
|
|
bool MergePerformanceClientSettingsOverrides(
|
|
const PerformancePolicy& policy, std::string_view base_json,
|
|
std::string* merged_json, std::string* error,
|
|
std::vector<std::string>* kept_overrides = nullptr);
|
|
|
|
// Applies mandatory HTTP and crash policies after caller settings.
|
|
bool MergeRuntimeClientSettingsOverrides(
|
|
const FrameRatePolicy& frame_rate, const PerformancePolicy& performance,
|
|
std::string_view base_json, std::string* merged_json, std::string* error,
|
|
std::vector<std::string>* kept_overrides = nullptr);
|
|
|
|
// The resolved VR mode owns these flags in both client-settings channels.
|
|
// Temporal depth preservation also requires non-memoryless native targets.
|
|
bool MergeVrClientSettingsOverrides(bool enabled, std::string_view base_json,
|
|
std::string* merged_json,
|
|
std::string* error,
|
|
bool preserve_temporal_depth = false);
|
|
|
|
// Keeps the legacy test bypass disabled. The host PermissionsProtocol now
|
|
// answers microphone authorization from capture configuration. No permission
|
|
// query opens a recording device.
|
|
bool MergeAudioDeviceMenuClientSettingsOverrides(std::string_view base_json,
|
|
std::string *merged_json,
|
|
std::string *error);
|
|
|
|
bool MergeAudioCaptureClientSettingsOverrides(bool microphone_enabled,
|
|
std::string_view base_json,
|
|
std::string* merged_json,
|
|
std::string* error);
|
|
|
|
} // namespace runtime
|
|
} // namespace mocktail
|
|
|
|
#endif // MOCKTAIL_RUNTIME_PERFORMANCE_POLICY_H_
|