keyhog_scanner/engine/
gpu_scan_wrappers.rs1use super::*;
2use crate::hw_probe::ScanBackend;
3
4pub enum GpuPhase1Output {
6 Hits(Vec<Vec<(u32, u32, u32)>>),
7 Done(Vec<Vec<keyhog_core::RawMatch>>),
8}
9
10impl CompiledScanner {
11 pub fn scan_coalesced_gpu(
12 &self,
13 chunks: &[keyhog_core::Chunk],
14 ) -> Vec<Vec<keyhog_core::RawMatch>> {
15 match self.scan_coalesced_gpu_phase1(chunks) {
16 GpuPhase1Output::Hits(hits) => self.scan_coalesced_gpu_phase2(chunks, hits),
17 GpuPhase1Output::Done(results) => results,
18 }
19 }
20
21 pub fn scan_coalesced_gpu_ac(
22 &self,
23 chunks: &[keyhog_core::Chunk],
24 ) -> Vec<Vec<keyhog_core::RawMatch>> {
25 match self.scan_coalesced_gpu_ac_phase1(chunks) {
26 GpuPhase1Output::Hits(hits) => self.scan_coalesced_gpu_phase2(chunks, hits),
27 GpuPhase1Output::Done(results) => results,
28 }
29 }
30
31 pub(crate) fn scan_coalesced_non_gpu(
32 &self,
33 chunks: &[keyhog_core::Chunk],
34 ) -> Vec<Vec<keyhog_core::RawMatch>> {
35 #[cfg(feature = "simd")]
36 {
37 self.scan_coalesced(chunks)
38 }
39 #[cfg(not(feature = "simd"))]
40 {
41 chunks.iter().map(|c| self.scan(c)).collect()
42 }
43 }
44
45 pub(crate) fn gpu_degrade_done_with_reason(
46 &self,
47 chunks: &[keyhog_core::Chunk],
48 backend: ScanBackend,
49 reason: Option<&str>,
50 ) -> GpuPhase1Output {
51 super::gpu_forced::deny_silent_gpu_degrade_with_reason(self, backend, reason);
52 if let Some(reason) = reason {
53 if let Ok(mut slot) = self.gpu_last_degrade_reason.lock() {
54 *slot = Some(reason.to_string());
55 }
56 }
57 GpuPhase1Output::Done(self.scan_coalesced_non_gpu(chunks))
58 }
59}