DisplayInfo

Demonstrates how to obtain the display information when programming with ADLX to perform related tests.

Sample Path

/Samples/csharp/DisplayInfo

Code

Copied!

//
// Copyright (c) 2021 - 2025 Advanced Micro Devices, Inc. All rights reserved.
//
//-------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DisplayInfo
{
    class mainDisplayInfo
    {
        static void Main(string[] args) {

            // Initialize ADLX with ADLXHelper
            ADLXHelper help = new ADLXHelper();
            ADLX_RESULT  res = help.Initialize();

            if (res == ADLX_RESULT .ADLX_OK)
            {
                // Get system services
                IADLXSystem sys = help.GetSystemServices();

                if (sys != null)
                {
                    // Get display services
                    SWIGTYPE_p_p_adlx__IADLXDisplayServices s = ADLX.new_displaySerP_Ptr();
                    res = sys.GetDisplaysServices(s);
                    IADLXDisplayServices displayService = ADLX.displaySerP_Ptr_value(s);

                    if (res == ADLX_RESULT .ADLX_OK)
                    {
                        // Get display list
                        SWIGTYPE_p_p_adlx__IADLXDisplayList ppDisplayList = ADLX.new_displayListP_Ptr();
                        res = displayService.GetDisplays(ppDisplayList);
                        IADLXDisplayList displayList = ADLX.displayListP_Ptr_value(ppDisplayList);

                        if (res == ADLX_RESULT .ADLX_OK)
                        {
                            // Iterate through the display list
                            uint it = displayList.Begin();
                            for (; it != displayList.Size(); it++)
                            {
                                SWIGTYPE_p_p_adlx__IADLXDisplay ppDisplay = ADLX.new_displayP_Ptr();
                                res = displayList.At(it, ppDisplay);
                                IADLXDisplay display = ADLX.displayP_Ptr_value(ppDisplay);

                                if (res == ADLX_RESULT .ADLX_OK)
                                {
                                    SWIGTYPE_p_p_char ppName = ADLX.new_charP_Ptr();
                                    display.Name(ppName);
                                    String name = ADLX.charP_Ptr_value(ppName);

                                    SWIGTYPE_p_ADLX_DISPLAY_TYPE pDisType = ADLX.new_displayTypeP();
                                    display.DisplayType(pDisType);
                                    ADLX_DISPLAY_TYPE  disType = ADLX.displayTypeP_value(pDisType);

                                    SWIGTYPE_p_unsigned_int pMID = ADLX.new_uintP();
                                    display.ManufacturerID(pMID);
                                    long mid = ADLX.uintP_value(pMID);

                                    SWIGTYPE_p_ADLX_DISPLAY_CONNECTOR_TYPE pConnect = ADLX.new_disConnectTypeP();
                                    display.ConnectorType(pConnect);
                                    ADLX_DISPLAY_CONNECTOR_TYPE  connect = ADLX.disConnectTypeP_value(pConnect);

                                    SWIGTYPE_p_p_char ppEDIE = ADLX.new_charP_Ptr();
                                    display.EDID(ppEDIE);
                                    String edid = ADLX.charP_Ptr_value(ppEDIE);

                                    SWIGTYPE_p_int pH = ADLX.new_intP();
                                    SWIGTYPE_p_int pV = ADLX.new_intP();
                                    display.NativeResolution(pH, pV);
                                    int h = ADLX.intP_value(pH);
                                    int v = ADLX.intP_value(pV);

                                    SWIGTYPE_p_double pRefRate = ADLX.new_doubleP();
                                    display.RefreshRate(pRefRate);
                                    double refRate = ADLX.doubleP_value(pRefRate);

                                    SWIGTYPE_p_unsigned_int pPixClock = ADLX.new_uintP();
                                    display.PixelClock(pPixClock);
                                    long pixClock = ADLX.uintP_value(pPixClock);

                                    SWIGTYPE_p_ADLX_DISPLAY_SCAN_TYPE pScanType = ADLX.new_disScanTypeP();
                                    display.ScanType(pScanType);
                                    ADLX_DISPLAY_SCAN_TYPE  scanType = ADLX.disScanTypeP_value(pScanType);

                                    SWIGTYPE_p_size_t pID = ADLX.new_adlx_sizeP();
                                    display.UniqueId(pID);
                                    uint id = ADLX.adlx_sizeP_value(pID);

                                    Console.WriteLine(String.Format("\\nThe display [{0}]:", it));
                                    Console.WriteLine(String.Format("\\tName: {0}", name));
                                    Console.WriteLine(String.Format("\\tType: {0}", disType));
                                    Console.WriteLine(String.Format("\\tConnector type: {0}", connect));
                                    Console.WriteLine(String.Format("\\tManufacturer id: {0}", mid));
                                    Console.WriteLine(String.Format("\\tEDID: {0}", edid));
                                    Console.WriteLine(String.Format("\\tResolution:  h: {0}  v: {1}", h, v));
                                    Console.WriteLine(String.Format("\\tRefresh rate: {0}", refRate));
                                    Console.WriteLine(String.Format("\\tPixel clock: {0}", pixClock));
                                    Console.WriteLine(String.Format("\\tScan type: {0}", scanType));
                                    Console.WriteLine(String.Format("\\tUnique id: {0}", id));

                                    // Release display interface
                                    display.Release();
                                }
                            }

                            // Release display list interface
                            displayList.Release();
                        }

                        // Release display services interface
                        displayService.Release();
                    }
                }
            }
            else
            {
                Console.WriteLine(String.Format("ADLX helper init res:: {0}", res));
            }

            // Terminate ADLX
            res = help.Terminate();
            Console.WriteLine(String.Format("ADLX Terminate res: {0}", res));
            Console.ReadKey();
        }
    }
}

Related pages

  • Visit the Adlx product page for download links and more information.

Looking for more documentation on GPUOpen?

AMD GPUOpen software blogs

Our handy software release blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.

GPUOpen Manuals

Don’t miss our manual documentation! And if slide decks are what you’re after, you’ll find 100+ of our finest presentations here.

AMD GPUOpen Performance Guides

The home of great performance and optimization advice for AMD RDNA™ 2 GPUs, AMD Ryzen™ CPUs, and so much more.

Getting started: AMD GPUOpen software

New or fairly new to AMD’s tools, libraries, and effects? This is the best place to get started on GPUOpen!

AMD GPUOpen Getting Started Development and Performance

Looking for tips on getting started with developing and/or optimizing your game, whether on AMD hardware or generally? We’ve got you covered!

AMD GPUOpen Technical blogs

Browse our technical blogs, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan®, DirectX®, Unreal Engine, and lots more.

Find out more about our software!

AMD GPUOpen Effects - AMD FidelityFX technologies

Create wonder. No black boxes. Meet the AMD FidelityFX SDK!

AMD GPUOpen Samples

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

AMD GPUOpen developer SDKs

Discover what our SDK technologies can offer you. Query hardware or software, manage memory, create rendering applications or machine learning, and much more!

AMD GPUOpen Developer Tools

Analyze, Optimize, Profile, Benchmark. We provide you with the developer tools you need to make sure your game is the best it can be!