fix the failures that were failing quietly

This commit is contained in:
2026-09-21 06:22:44 +03:00
parent 371c910068
commit b33ce5bf77
8 changed files with 110 additions and 35 deletions
+7 -6
View File
@@ -8,9 +8,9 @@ fn main() {
/// Compile the HDR tonemap HLSL to bytecode at build time so we can embed it
/// via `include_bytes`! and avoid a runtime dependency on `d3dcompiler_47.dll`.
/// Looks for fxc.exe in the installed Windows SDK. If fxc is unavailable the
/// .cso files are emitted empty and capture.rs falls back to runtime
/// `D3DCompile` (so a clean checkout without the SDK still builds).
/// Looks for fxc.exe in the installed Windows SDK. Without the SDK the .cso
/// files are emitted empty so the build still succeeds, and there is no runtime
/// compile path: capture.rs refuses to start on empty bytecode and says why.
fn compile_shaders() {
// Cargo always sets OUT_DIR for a build script; if it is missing the build
// is broken in a way we cannot paper over, so say so plainly.
@@ -56,15 +56,16 @@ fn compile_shaders() {
}
}
None => {
// No SDK on the build machine - emit an empty .cso; capture.rs
// detects the zero size and compiles the HLSL at runtime.
// No SDK on the build machine - emit an empty .cso so the build
// still succeeds; capture.rs rejects it at startup and points at
// the SDK rather than failing opaquely on the first frame.
drop(std::fs::write(&dst, []));
}
}
}
if fxc.is_none() {
println!("cargo:warning=fxc.exe not found - shaders will be compiled at runtime");
println!("cargo:warning=fxc.exe not found - shaders cannot be compiled, capture will refuse to start");
}
println!("cargo:rerun-if-changed=shaders/tonemap.hlsl");
}
+39 -16
View File
@@ -41,20 +41,31 @@ struct Source {
release_api_url: &'static str,
asset_name_suffix: &'static str,
kind: ArchiveKind,
/// Release download directory, used to fetch the sibling `.sha256`. None
/// when the project publishes no checksums at all.
download_base: Option<&'static str>,
}
// `releases/latest` rather than `releases/tags/latest` for both: the latter
// only resolves for a repo that happens to have a tag literally named "latest",
// which GyanD does not - its tag is the version, so that URL 404s.
//
// BtbN is first because its zip is the path that actually installs today; the
// 7z branch below is the fallback.
const SOURCES: &[Source] = &[
Source {
name: "GyanD",
release_api_url: "https://api.github.com/repos/GyanD/codexffmpeg/releases/tags/latest",
asset_name_suffix: "full_build.7z",
kind: ArchiveKind::SevenZ,
},
Source {
name: "BtbN",
release_api_url: "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/tags/latest",
release_api_url: "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest",
asset_name_suffix: "win64-gpl.zip",
kind: ArchiveKind::Zip,
download_base: None,
},
Source {
name: "GyanD",
release_api_url: "https://api.github.com/repos/GyanD/codexffmpeg/releases/latest",
asset_name_suffix: "full_build.7z",
kind: ArchiveKind::SevenZ,
download_base: Some("https://github.com/GyanD/codexffmpeg/releases/download"),
},
];
@@ -104,17 +115,29 @@ where
let (asset, version) = pick_asset(&client, source).await?;
// GyanD publishes a .sha256 file alongside each release.
// BtbN does not, so we skip verification for BtbN.
let expected = if source.name == "GyanD" {
let checksum_url = format!(
"https://github.com/GyanD/codexffmpeg/releases/download/{}/{}.sha256",
version,
// Verify against the published checksum when there is one. GyanD used to
// ship a .sha256 next to each asset and no longer does, so a missing
// checksum downgrades to a logged warning rather than failing the source -
// aborting on it would just push the user onto the unverified build anyway.
let expected = if let Some(base) = source.download_base {
let checksum_url = format!("{base}/{version}/{}.sha256", asset.name);
match fetch_sha256(&client, &checksum_url).await {
Ok(hash) => Some(hash),
Err(e) => {
tracing::warn!(
"{} publishes no usable checksum for {} ({e:#}), continuing unverified",
source.name,
asset.name
);
None
}
}
} else {
tracing::warn!(
"{} publishes no checksums, downloading {} unverified",
source.name,
asset.name
);
Some(fetch_sha256(&client, &checksum_url).await?)
} else {
tracing::warn!("BtbN build: skipping SHA-256 verification (no checksum file)");
None
};
+9
View File
@@ -213,6 +213,15 @@ fn new_vertex_buffer() -> (D3D11_BUFFER_DESC, D3D11_SUBRESOURCE_DATA) {
impl TonemapPipeline {
fn new(device: &ID3D11Device, width: u32, height: u32) -> Result<Self> {
// build.rs emits empty .cso files when fxc was missing at build time.
// Without this the only symptom is an opaque CreateVertexShader failure
// on the first frame of every recording.
if FULLSCREEN_VS.is_empty() || TONEMAP_PS.is_empty() {
bail!(
"shader bytecode is empty - rebuild with the Windows SDK installed so build.rs can run fxc"
);
}
// Vertex shader: fullscreen-triangle pass-through (no vertex buffer).
let mut vs = None;
unsafe {
+26 -5
View File
@@ -1045,11 +1045,29 @@ const GIF_ESTIMATE_GRID: &[u64] = &[
104_857_600, 209_715_200,
];
/// The size-table scan sweeps target sizes itself, so it needs only the inputs
/// that shape a GIF budget - not the single requested target that
/// `PreviewRequest` requires.
#[derive(Debug, Deserialize)]
pub struct GifTableRequest {
pub fps: u32,
#[serde(default)]
pub gif_budget_mode: GifBudgetMode,
#[serde(default)]
pub gif_colors: Option<u16>,
#[serde(default)]
pub clip_width: u32,
#[serde(default)]
pub clip_height: u32,
#[serde(default)]
pub duration_secs: Option<f64>,
}
/// Return estimates for a grid of `target_bytes` values so the frontend can
/// interpolate on slider drag without an IPC per debounce tick. The grid is
/// geometric from 100KB to 200MB.
#[tauri::command]
fn estimate_gif_params_table(request: PreviewRequest) -> GifEstimateTable {
fn estimate_gif_params_table(request: GifTableRequest) -> GifEstimateTable {
let colors = request.gif_colors.unwrap_or(256);
let dur = request.duration_secs.unwrap_or(0.0).max(0.1);
let fps = request.fps;
@@ -2214,13 +2232,16 @@ pub fn run() {
Ok(Some(info)) => {
tracing::info!(version = info.version, "update available");
drop(handle.emit("update-available", &info));
updates::stamp_check(&app_dir);
}
Ok(None) => tracing::debug!("no update available"),
Ok(None) => {
tracing::debug!("no update available");
updates::stamp_check(&app_dir);
}
// No stamp on failure, so a transient network error does
// not silence the check for the whole TTL.
Err(e) => tracing::warn!("update check failed: {e:#}"),
}
// Stamp success on Ok results so a future launch won't
// re-check until the TTL elapses. Errors don't stamp.
updates::stamp_check(&app_dir);
});
}
Ok(())