mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-27 14:59:02 +08:00
vram avoid always fallback to gdi (#8272)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
parent
9562768a04
commit
9d42ee9df8
@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
collections::{HashMap, HashSet},
|
||||
ffi::c_void,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
@ -30,6 +30,7 @@ use hwcodec::{
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getadapterluid#remarks
|
||||
lazy_static::lazy_static! {
|
||||
static ref ENOCDE_NOT_USE: Arc<Mutex<HashMap<usize, bool>>> = Default::default();
|
||||
static ref FALLBACK_GDI_DISPLAYS: Arc<Mutex<HashSet<usize>>> = Default::default();
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -212,6 +213,11 @@ impl VRamEncoder {
|
||||
}
|
||||
|
||||
pub fn available(format: CodecFormat) -> Vec<FeatureContext> {
|
||||
let fallbacks = FALLBACK_GDI_DISPLAYS.lock().unwrap().clone();
|
||||
if !fallbacks.is_empty() {
|
||||
log::info!("fallback gdi displays not empty: {fallbacks:?}");
|
||||
return vec![];
|
||||
}
|
||||
let not_use = ENOCDE_NOT_USE.lock().unwrap().clone();
|
||||
if not_use.values().any(|not_use| *not_use) {
|
||||
log::info!("currently not use vram encoders: {not_use:?}");
|
||||
@ -298,6 +304,14 @@ impl VRamEncoder {
|
||||
log::info!("set display#{display} not use vram encode to {not_use}");
|
||||
ENOCDE_NOT_USE.lock().unwrap().insert(display, not_use);
|
||||
}
|
||||
|
||||
pub fn set_fallback_gdi(display: usize, fallback: bool) {
|
||||
if fallback {
|
||||
FALLBACK_GDI_DISPLAYS.lock().unwrap().insert(display);
|
||||
} else {
|
||||
FALLBACK_GDI_DISPLAYS.lock().unwrap().remove(&display);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VRamDecoder {
|
||||
|
@ -528,6 +528,7 @@ fn run(vs: VideoService) -> ResultType<()> {
|
||||
#[cfg(all(windows, feature = "vram"))]
|
||||
if c.is_gdi() && encoder.input_texture() {
|
||||
log::info!("changed to gdi when using vram");
|
||||
VRamEncoder::set_fallback_gdi(display_idx, true);
|
||||
bail!("SWITCH");
|
||||
}
|
||||
check_privacy_mode_changed(&sp, c.privacy_mode_id)?;
|
||||
@ -568,6 +569,10 @@ fn run(vs: VideoService) -> ResultType<()> {
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
#[cfg(feature = "vram")]
|
||||
if try_gdi == 1 && !c.is_gdi() {
|
||||
VRamEncoder::set_fallback_gdi(display_idx, false);
|
||||
}
|
||||
try_gdi = 0;
|
||||
}
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user