gpu: Capturer::on_device and Renderer::report

A capturer on a device already open (the app's), and the renderer's
JSON shared by every reply.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-16 08:27:21 -04:00
1 parent 7f0af28e9c
commit b655af305a
5 files changed
+18 -4

No files matched your search

+6
View File
@@ -61,6 +61,12 @@ impl Capturer {
.map_err(|e| GpuError::Device(e.to_string()))?;
// Errors outside a scope are logged, replacing wgpu's default handler, which panics.
device.on_uncaptured_error(Arc::new(|e: wgpu::Error| log::error!("graphics device error: {e}")));
Capturer::on_device(adapter, device, queue, tier)
}
/// A capturer on a device already open on `adapter` (the desktop app's), which keeps its
/// error handler: pictures share the window's device instead of opening another.
pub fn on_device(adapter: &wgpu::Adapter, device: wgpu::Device, queue: wgpu::Queue, tier: Tier) -> Result<Capturer> {
let samples = if adapter.get_texture_format_features(FORMAT).flags.sample_count_supported(SAMPLES)
&& adapter.get_texture_format_features(DEPTH).flags.sample_count_supported(SAMPLES)
{
+9
View File
@@ -69,4 +69,13 @@ impl Renderer {
Renderer::Cpu { .. } => "cpu",
}
}
/// What drew a picture, for a reply: `{kind, adapter, msaa}` on a GPU, `{kind, why}` on
/// the CPU (`why` null when the CPU was asked for).
pub fn report(&self) -> serde_json::Value {
match self {
Renderer::Gpu { adapter, samples, .. } => serde_json::json!({"kind": self.kind(), "adapter": adapter, "msaa": samples}),
Renderer::Cpu { why } => serde_json::json!({"kind": self.kind(), "why": why}),
}
}
}