diff --git a/airdef-mod/src/capabilities.rs b/airdef-mod/src/capabilities.rs index 8bc7418..e4a902f 100644 --- a/airdef-mod/src/capabilities.rs +++ b/airdef-mod/src/capabilities.rs @@ -95,6 +95,7 @@ pub fn diagnostics() -> String { let lights = render::point_lights_status(); let sources = render::sound_sources_status(); let cameras = render::camera_status(); + let dlss = render::dlss_status(); let smoke_reason = match smoke.reason { render::SmokeReason::AwaitingFrame => "awaiting-frame", render::SmokeReason::Disabled => "disabled", @@ -102,7 +103,7 @@ pub fn diagnostics() -> String { render::SmokeReason::Ready => "ready", }; [ - "Возможности движка (API 31; подготовка не означает готовый GPU-кадр, слышимый звук или файл):".into(), + "Возможности движка (API 33; подготовка не означает готовый GPU-кадр, слышимый звук или файл):".into(), line( "Дым", smoke.generation, @@ -149,6 +150,10 @@ pub fn diagnostics() -> String { capture.prepared, reason(capture.reason), ), + format!( + "DLSS: устройство={}, включено={} (выкл — родной TAAU; вкл без устройства — при следующем запуске)", + dlss.available, dlss.enabled + ), ] .join("\n") } diff --git a/airdef-mod/src/layout.rs b/airdef-mod/src/layout.rs index 21c18f6..dc46d67 100644 --- a/airdef-mod/src/layout.rs +++ b/airdef-mod/src/layout.rs @@ -48,6 +48,9 @@ pub struct Layout { pub wave: Option>, pub far: Option, pub acoustics: Option, + /// The player's DLSS request; absent in older saves (the engine's own + /// default applies: on where supported). + pub dlss: Option, pub effects: Option<(bool, bool)>, pub roles: Vec<(SamKind, u8)>, /// Fire doctrines by the system's place in the file (#47). @@ -188,6 +191,7 @@ impl Layout { "strikes" => out.strikes = Some((l.need(1, "запас", 0.0, COUNT)? as u32, l.num(2, "до следующей", 0.0, COUNT)?.map_or(0, |v| v as u32))), "far" => out.far = l.flag(1, "значение")?, "acoustics" => out.acoustics = l.flag(1, "значение")?, + "dlss" => out.dlss = l.flag(1, "значение")?, "effects" => out.effects = Some((l.flag(1, "шейдер")?.unwrap_or(true), l.flag(2, "HD")?.unwrap_or(false))), "seed" => { let v = l.w.get(1).ok_or_else(|| l.bad("значение", "строка оборвана"))?; @@ -279,6 +283,15 @@ mod tests { assert!(Layout::parse(&many).is_err(), "no limit on the number of objects"); } + #[test] + fn the_dlss_request_round_trips_and_old_saves_keep_the_engine_default() { + assert_eq!(Layout::parse("dlss false\n").unwrap().dlss, Some(false)); + assert_eq!(Layout::parse("dlss true\n").unwrap().dlss, Some(true)); + assert!(Layout::parse("dlss maybe\n").is_err()); + // Older saves have no line: the engine's own default (on) applies. + assert_eq!(Layout::parse("damage true\n").unwrap().dlss, None); + } + #[test] fn radar_profile_ids_round_trip_and_old_roles_map_to_them() { let old = "sam radar 1 70 0 0 0 1 0 0 0 0 0 - - - 1 1 1 1 1 1 0 0 0 integrated search"; diff --git a/airdef-mod/src/lib.rs b/airdef-mod/src/lib.rs index daadd8a..f05fcd4 100644 --- a/airdef-mod/src/lib.rs +++ b/airdef-mod/src/lib.rs @@ -64,6 +64,9 @@ struct AirDef { far: bool, /// The acoustics asked for, until the game has them (its answer comes a tick later). acoustics: Option, + /// The DLSS request saved for this world; None leaves the engine's own + /// choice (on where supported). The live state is `render::dlss_status`. + dlss: Option, /// The game's log of block changes (`render.world-log-start`): a replay shows the world as /// it was at its moment, not the holes the raid left (None where the game has no such log). block_log: Option, @@ -258,6 +261,7 @@ const BTN_FULL: u32 = 41; const BTN_REEL: u32 = 42; const BTN_FAR: u32 = 19; const BTN_ACOUSTICS: u32 = 20; +const BTN_DLSS: u32 = 24; const BTN_DOCTRINE: u32 = 21; const FLEET_ROWS: u32 = 4; const BTN_RESERVE: u32 = 50; @@ -553,6 +557,11 @@ impl AirDef { self.acoustics.unwrap_or_else(render::acoustics) } + /// The DLSS request: this world's saved one, else the engine's live state. + fn dlss_on(&self) -> bool { + self.dlss.unwrap_or_else(|| render::dlss_status().enabled) + } + /// The effects preset: none, the post pass, or the post pass under the HD lighting. fn set_effects(&mut self, shader: bool, hd: bool) { self.sim.shader = shader; @@ -963,6 +972,7 @@ impl AirDef { if view { text += &format!("far {}\n", self.far); text += &format!("acoustics {}\n", self.acoustics_on()); + text += &format!("dlss {}\n", self.dlss_on()); text += &format!("effects {} {}\n", self.sim.shader, self.hd); } for (kind, roles) in &self.sim.roles { @@ -1125,6 +1135,10 @@ impl AirDef { self.acoustics = Some(a); render::set_acoustics(a); } + if let Some(d) = layout.dlss { + self.dlss = Some(d); + render::set_dlss(d); + } if let Some(f) = layout.far { self.far = f; } @@ -1727,6 +1741,18 @@ impl AirDef { widgets.push(Widget::Button(ButtonWidget { id: BTN_DAMAGE, label: format!("Разрушения: {}", onoff(self.sim.damage)) })); widgets.push(Widget::Button(ButtonWidget { id: BTN_FAR, label: format!("Дальний ландшафт: {}", onoff(self.far)) })); widgets.push(Widget::Button(ButtonWidget { id: BTN_ACOUSTICS, label: format!("Акустика (преграды, эхо): {}", onoff(self.acoustics_on())) })); + // DLSS: the request shows at once; the engine's live state + // answers availability. Without a DLSS device an on-request + // applies at the next launch. + let dlss = render::dlss_status(); + let dlss_label = if dlss.available { + format!("DLSS (сглаживание NVIDIA): {}", onoff(self.dlss_on())) + } else if self.dlss_on() { + "DLSS (NVIDIA): вкл — применится при перезапуске".to_string() + } else { + "DLSS (NVIDIA): выкл (недоступен на этом устройстве)".to_string() + }; + widgets.push(Widget::Button(ButtonWidget { id: BTN_DLSS, label: dlss_label })); widgets.push(Widget::Button(ButtonWidget { id: BTN_BACK, label: "← Назад".into() })); } Page::Wave => { @@ -1941,6 +1967,7 @@ impl Mod for AirDef { smoke: Default::default(), far: true, acoustics: None, + dlss: None, moving: None, hd: false, world: None, @@ -2453,6 +2480,20 @@ impl Mod for AirDef { render::set_acoustics(on); self.dirty = true; } + (Page::More, BTN_DLSS) => { + // The request is always kept (the engine persists it too); + // without a DLSS device it is a graceful no-op until a start + // that can open one. Resolution stays the player's own choice + // in Horizon's settings — this toggle is graphics-only. + let status = render::dlss_status(); + let on = !self.dlss_on(); + self.dlss = Some(on); + render::set_dlss(on); + self.dirty = true; + if on && !status.available { + say("DLSS сохранён: включится при следующем запуске, если устройство его поддерживает"); + } + } (Page::More, BTN_DAMAGE) => { self.sim.damage = !self.sim.damage; self.dirty = true; @@ -2896,6 +2937,7 @@ mod tests { smoke: Default::default(), far: true, acoustics: None, + dlss: None, moving: None, hd: false, world: None, diff --git a/docs/DLSS-TESTING.md b/docs/DLSS-TESTING.md index 9b90080..c300ebd 100644 --- a/docs/DLSS-TESTING.md +++ b/docs/DLSS-TESTING.md @@ -2,6 +2,18 @@ Это тестовая, а не релизная сборка #124. Она включает native DLSS Super Resolution через Vulkan и сохраняет обычный TAAU как fallback. Frame generation здесь нет; RTX 3060 его и не поддерживает. +## Переключатель DLSS + +В сборках с фичей `dlss` DLSS теперь включён по умолчанию, а не только через `HORIZON_DLSS=1`: + +- Меню мода: **N → Огонь, ремонт, эффекты… → DLSS (NVIDIA)**. Строка показывает состояние; на устройстве без DLSS переключение — мягкий no-op («недоступен»), запрос сохраняется и применяется при следующем запуске, если устройство его поддерживает. +- Команда контрольного сокета: `dlss on|off|status` (`available` — открыт ли DLSS-девайс, `dlss` — запрос игрока). +- Настройка `dlss:true|false` в `horizon-graphics.txt`; `HORIZON_DLSS=1|0` по-прежнему переопределяет её при старте. + +Выключение переходит на native TAAU со следующего кадра: разделённые истории #137 делают переход чистым в обе стороны (NGX сбрасывается при возобновлении, первый native кадр не читает устаревшую историю). Включение после старта с выключенным DLSS применяется при следующем запуске — девайс открывается под DLSS только при старте. Разрешение рендера остаётся выбором игрока в настройках Horizon: масштаб 2/3 по умолчанию действует, только когда DLSS включён и реально доступен. + +Для A/B ниже `test-dlss.bat`/`test-native.bat` работают как раньше; если старт был с DLSS, оба режима можно снять и одним прогоном через `dlss off`/`dlss on` без перезапуска. + ## Быстрый старт 1. Один раз запусти обычный Horizon Launcher, чтобы он подготовил ресурсы Minecraft 26.3. diff --git a/horizon b/horizon index 48eff0f..b2cc11c 160000 --- a/horizon +++ b/horizon @@ -1 +1 @@ -Subproject commit 48eff0fcbbed6e98265377b80311d3538c88a933 +Subproject commit b2cc11c45980343c5dba520d48f7daf9c95331bd