- AMD Device Library eXtra v2.0
-
Programming with ADLX
- Index
-
ADLX Samples
- Index
-
C Samples
- Index
-
Display
- Index
- Display3DLUT
- DisplayBlanking
- DisplayColorDepth
- DisplayConnectivityExperience
- DisplayCustomColor
- DisplayCustomResolution
- DisplayDynamicRefreshRateControl
- DisplayEvents
- DisplayFreeSync
- DisplayFreeSyncColorAccuracy
- DisplayGamma
- DisplayGamut
- DisplayGPUScaling
- DisplayHDCP
- DisplayInfo
- DisplayIntegerScaling
- DisplayPixelFormat
- DisplayScalingMode
- DisplayVariBright
- DisplayVSR
-
Receiving Events Notifications
-
C++ Samples
- Index
-
Display
- Index
- Display3DLUT
- DisplayBlanking
- DisplayColorDepth
- DisplayConnectivityExperience
- DisplayCustomColor
- DisplayCustomResolution
- DisplayDynamicRefreshRateControl
- DisplayEvents
- DisplayFreeSync
- DisplayFreeSyncColorAccuracy
- DisplayGamma
- DisplayGamut
- DisplayGPUScaling
- DisplayHDCP
- DisplayInfo
- DisplayIntegerScaling
- DisplayPixelFormat
- DisplayScalingMode
- DisplayVariBright
- DisplayVSR
-
Receiving Events Notifications
-
ADLX SDK References
- Index
-
ADLX Helpers
-
ADLX Interfaces
- Index
-
3D Graphics
- Index
-
IADLX3DChill
-
IADLX3DFidelityFXFrameGenUpgrade
-
IADLX3DImageSharpening
-
IADLX3DRadeonSuperResolution
-
IADLX3DSettingsChangedEvent
- Index
- GetGPU
- IsAnisotropicFilteringChanged
- IsAntiAliasingChanged
- IsAntiLagChanged
- IsBoostChanged
- IsChillChanged
- IsEnhancedSyncChanged
- IsFrameRateTargetControlChanged
- IsImageSharpeningChanged
- IsMorphologicalAntiAliasingChanged
- IsRadeonSuperResolutionChanged
- IsResetShaderCache
- IsTessellationModeChanged
- IsWaitForVerticalRefreshChanged
-
IADLX3DSettingsChangedEvent3
-
IADLX3DSettingsServices
-
Display
- Index
-
IADLXDisplay3DLUT
- Index
- ClearUser3DLUT
- GetAllUser3DLUT
- GetHDRUser3DLUT
- GetSCEDynamicContrast
- GetSCEDynamicContrastRange
- GetSDRUser3DLUT
- GetUser3DLUTIndex
- IsCurrentSCEDisabled
- IsCurrentSCEDynamicContrast
- IsCurrentSCEVividGaming
- IsSupportedSCE
- IsSupportedSCEDynamicContrast
- IsSupportedSCEVividGaming
- IsSupportedUser3DLUT
- SetAllUser3DLUT
- SetHDRUser3DLUT
- SetSCEDisabled
- SetSCEDynamicContrast
- SetSCEVividGaming
- SetSDRUser3DLUT
-
IADLXDisplayChangedHandling
- Index
- AddDisplay3DLUTEventListener
- AddDisplayGammaEventListener
- AddDisplayGamutEventListener
- AddDisplayListEventListener
- AddDisplaySettingsEventListener
- RemoveDisplay3DLUTEventListener
- RemoveDisplayGammaEventListener
- RemoveDisplayGamutEventListener
- RemoveDisplayListEventListener
- RemoveDisplaySettingsEventListener
-
IADLXDisplayConnectivityExperience
-
IADLXDisplayCustomColor
- Index
- GetBrightness
- GetBrightnessRange
- GetContrast
- GetContrastRange
- GetHue
- GetHueRange
- GetSaturation
- GetSaturationRange
- GetTemperature
- GetTemperatureRange
- IsBrightnessSupported
- IsContrastSupported
- IsHueSupported
- IsSaturationSupported
- IsTemperatureSupported
- SetBrightness
- SetContrast
- SetHue
- SetSaturation
- SetTemperature
-
IADLXDisplayCustomResolution
-
IADLXDisplayGamma
- Index
- GetGammaCoefficient
- GetGammaRamp
- IsCurrentDeGammaRamp
- IsCurrentReGamma36
- IsCurrentReGammaBT709
- IsCurrentRegammaCoefficient
- IsCurrentReGammaPQ
- IsCurrentReGammaPQ2084Interim
- IsCurrentReGammaRamp
- IsCurrentReGammaSRGB
- IsSupportedReGamma36
- IsSupportedReGammaBT709
- IsSupportedReGammaPQ
- IsSupportedReGammaPQ2084Interim
- IsSupportedReGammaSRGB
- ResetGammaRamp
- SetDeGammaRamp
- SetReGamma36
- SetReGammaBT709
- SetReGammaCoefficient
- SetReGammaPQ
- SetReGammaPQ2084Interim
- SetReGammaRamp
- SetReGammaSRGB
-
IADLXDisplayGammaChangedEvent
-
IADLXDisplayGamut
- Index
- GetGamutColorSpace
- GetWhitePoint
- IsCurrent5000kWhitePoint
- IsCurrent6500kWhitePoint
- IsCurrent7500kWhitePoint
- IsCurrent9300kWhitePoint
- IsCurrentAdobeRgbColorSpace
- IsCurrentCCIR2020ColorSpace
- IsCurrentCCIR601ColorSpace
- IsCurrentCCIR709ColorSpace
- IsCurrentCIERgbColorSpace
- IsCurrentCustomColorSpace
- IsCurrentCustomWhitePoint
- IsSupported5000kWhitePoint
- IsSupported6500kWhitePoint
- IsSupported7500kWhitePoint
- IsSupported9300kWhitePoint
- IsSupportedAdobeRgbColorSpace
- IsSupportedCCIR2020ColorSpace
- IsSupportedCCIR601ColorSpace
- IsSupportedCCIR709ColorSpace
- IsSupportedCIERgbColorSpace
- IsSupportedCustomColorSpace
- IsSupportedCustomWhitePoint
- SetGamut
-
IADLXDisplaySettingsChangedEvent
- Index
- GetDisplay
- IsColorDepthChanged
- IsCustomColorBrightnessChanged
- IsCustomColorContrastChanged
- IsCustomColorHueChanged
- IsCustomColorSaturationChanged
- IsCustomColorTemperatureChanged
- IsCustomResolutionChanged
- IsFreeSyncChanged
- IsGPUScalingChanged
- IsHDCPChanged
- IsIntegerScalingChanged
- IsPixelFormatChanged
- IsScalingModeChanged
- IsVariBrightChanged
- IsVSRChanged
-
IADLXDisplaySettingsChangedEvent3
-
IADLXDisplayVariBright1
- Index
- IsBacklightAdaptiveEnabled
- IsBacklightAdaptiveSupported
- IsBatteryLifeEnabled
- IsBatteryLifeSupported
- IsFullScreenVideoEnabled
- IsFullScreenVideoSupported
- IsWindowsPowerModeEnabled
- IsWindowsPowerModeSupported
- SetBacklightAdaptiveEnabled
- SetBatteryLifeEnabled
- SetFullScreenVideoEnabled
- SetWindowsPowerModeEnabled
-
GPU
-
GPU Tuning
- Index
-
IADLXGPUAutoTuningCompleteEvent
-
IADLXGPUTuningServices
- Index
- GetAutoTuning
- GetGPUTuningChangedHandling
- GetManualFanTuning
- GetManualGFXTuning
- GetManualPowerTuning
- GetManualVRAMTuning
- GetPresetTuning
- IsAtFactory
- IsSupportedAutoTuning
- IsSupportedManualFanTuning
- IsSupportedManualGFXTuning
- IsSupportedManualPowerTuning
- IsSupportedManualVRAMTuning
- IsSupportedPresetTuning
- ResetToFactory
-
IADLXManualFanTuning
- Index
- GetEmptyFanTuningStates
- GetFanTuningRanges
- GetFanTuningStates
- GetMinAcousticLimit
- GetMinAcousticLimitRange
- GetMinFanSpeed
- GetMinFanSpeedRange
- GetTargetFanSpeed
- GetTargetFanSpeedRange
- GetZeroRPMState
- IsSupportedMinAcousticLimit
- IsSupportedMinFanSpeed
- IsSupportedTargetFanSpeed
- IsSupportedZeroRPM
- IsValidFanTuningStates
- SetFanTuningStates
- SetMinAcousticLimit
- SetMinFanSpeed
- SetTargetFanSpeed
- SetZeroRPMState
-
IADLXManualGraphicsTuning1
-
IADLXManualGraphicsTuning2_1
-
IADLXManualPowerTuning
-
Miscellaneous
-
Performance Monitoring
- Index
-
IADLXGPUMetricsSupport
- Index
- GetGPUClockSpeedRange
- GetGPUFanSpeedRange
- GetGPUHotspotTemperatureRange
- GetGPUIntakeTemperatureRange
- GetGPUPowerRange
- GetGPUTemperatureRange
- GetGPUTotalBoardPowerRange
- GetGPUUsageRange
- GetGPUVoltageRange
- GetGPUVRAMClockSpeedRange
- GetGPUVRAMRange
- IsSupportedGPUClockSpeed
- IsSupportedGPUFanSpeed
- IsSupportedGPUHotspotTemperature
- IsSupportedGPUIntakeTemperature
- IsSupportedGPUPower
- IsSupportedGPUTemperature
- IsSupportedGPUTotalBoardPower
- IsSupportedGPUUsage
- IsSupportedGPUVoltage
- IsSupportedGPUVRAM
- IsSupportedGPUVRAMClockSpeed
-
IADLXPerformanceMonitoringServices
- Index
- ClearPerformanceMetricsHistory
- GetAllMetricsHistory
- GetCurrentAllMetrics
- GetCurrentFPS
- GetCurrentGPUMetrics
- GetCurrentPerformanceMetricsHistorySize
- GetCurrentSystemMetrics
- GetFPSHistory
- GetGPUMetricsHistory
- GetMaxPerformanceMetricsHistorySize
- GetMaxPerformanceMetricsHistorySizeRange
- GetSamplingInterval
- GetSamplingIntervalRange
- GetSupportedGPUMetrics
- GetSupportedSystemMetrics
- GetSystemMetricsHistory
- SetMaxPerformanceMetricsHistorySize
- SetSamplingInterval
- StartPerformanceMetricsTracking
- StopPerformanceMetricsTracking
-
IADLXSystemMetricsSupport
DisplayEvents
Navigation: Programming with ADLX → ADLX Samples → Rust Samples
Rust
Code
C++
//// Copyright Advanced Micro Devices, Inc. All rights reserved.////-------------------------------------------------------------------------------------------------
//! Demonstrates how to handle notifications about display list changes with ADLX.//! This is the Rust counterpart of `Samples/C/Display/DisplayEvents` (display-list//! listener only).//!//! ADLX calls back into the application through an application-provided interface//! whose memory layout must match `IADLXDisplayListChangedListener`: a single//! `pVtbl` pointer to a table holding one `OnDisplayListChanged` function pointer.
use std::io::{self, Read};
use amd_adlx::*;
/// Callback invoked by ADLX when the display list changes.////// # Safety/// Called by ADLX with a valid listener pointer and a valid display list pointer./// Returning a non-zero value tells ADLX to keep notifying the next listener.unsafe extern "system" fn on_display_list_changed( _p_this: *mut IADLXDisplayListChangedListener, _p_new_displays: *mut IADLXDisplayList,) -> adlx_bool { println!("Display list has been changed"); // Return true so ADLX continues to notify the next listener. 1}
fn pause_prompt() { println!("->Plug or unplug a display to trigger DisplayListChanged."); println!("->Press Q/q then Enter to terminate the loop."); let stdin = io::stdin(); let mut byte = [0u8; 1]; loop { if stdin.lock().read_exact(&mut byte).is_err() { break; } if byte[0] == b'q' || byte[0] == b'Q' { break; } }}
fn wait_and_exit(msg: &str) { if !msg.is_empty() { println!("{}", msg); } print!("Press Enter to continue . . . "); use std::io::Write; let _ = io::stdout().flush(); let _ = io::stdin().read(&mut [0u8]);}
fn main() { // Initialize ADLX. let helper = match AdlxHelper::new() { Ok(helper) => helper, Err(_) => { wait_and_exit("ADLX initialization failed"); return; } };
// The listener vtable is 'static so ADLX can call it for the whole registration. static LISTENER_VTBL: IADLXDisplayListChangedListenerVtbl = IADLXDisplayListChangedListenerVtbl { OnDisplayListChanged: on_display_list_changed, }; let mut listener = IADLXDisplayListChangedListener { pVtbl: &LISTENER_VTBL, };
unsafe { let sys = helper.system_services(); let sys_vtbl = &*(*sys).pVtbl;
// Get the display services. let mut display_service: *mut IADLXDisplayServices = std::ptr::null_mut(); let res = (sys_vtbl.GetDisplaysServices)(sys, &mut display_service); if adlx_succeeded(res) { let ds_vtbl = &*(*display_service).pVtbl;
// Get the display change handling interface. let mut change_handling: *mut IADLXDisplayChangedHandling = std::ptr::null_mut(); let res = (ds_vtbl.GetDisplayChangedHandling)(display_service, &mut change_handling); if adlx_succeeded(res) { let ch_vtbl = &*(*change_handling).pVtbl;
// Register the display-list listener. (ch_vtbl.AddDisplayListEventListener)(change_handling, &mut listener);
// Wait for events until the user quits. pause_prompt();
// Unregister the listener before releasing the handle. (ch_vtbl.RemoveDisplayListEventListener)(change_handling, &mut listener);
// Release the display change handling interface. (ch_vtbl.Release)(change_handling); }
// Release the display services interface. (ds_vtbl.Release)(display_service); } }
// ADLX is terminated and the library is unloaded when `helper` is dropped. drop(helper); println!("Destroy ADLX finished");
wait_and_exit("");}