SmartShiftMax

Demonstrates how to control AMD SmartShift Max when programming with ADLX.

Command Prompts

Command Prompt Description
1 Display AMD SmartShift Max support.
2 Display AMD SmartShift Max bias value, bias mode, and bias range.
3 Set SmartShift Max bias mode to Manual.
4 Set SmartShift Max bias mode to Auto.
5 Set SmartShift Max bias value.
M/m Show this menu.
Q/q Quit.

Sample Path

/Samples/C/PowerTuning/SmartShiftMax

Code

Copied!

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


#include "SDK/ADLXHelper/Windows/C/ADLXHelper.h"
#include "SDK/Include/IPowerTuning.h"
#include "SDK/Include/ISystem1.h"

// Display AMD SmartShift max support
void ShowSmartShiftMaxSupport(IADLXSmartShiftMax* ssm);

// Display current AMD SmartShift max state
void ShowSmartShiftMaxSate(IADLXSmartShiftMax* ssm);

// Set AMD SmartShift max bias mode
void SetSmartShiftMaxBiasMode(IADLXSmartShiftMax* ssm, int index);

// Set AMD SmartShift max bias value
void SetSmartShiftMaxBiasValue(IADLXSmartShiftMax* ssm);

// Main menu
void MainMenu();

// Menu action control
void MenuControl(IADLXSmartShiftMax* ssm);

int main()
{
    // Define return code
    ADLX_RESULT  res = ADLX_FAIL ;

    // Initialize ADLX
    res = ADLXHelper_Initialize();
    if (ADLX_SUCCEEDED (res))
    {
        // Get system services
        IADLXSystem* sys = ADLXHelper_GetSystemServices();

        // Get IADLXSystem1 interface
        IADLXSystem1* system1 = NULL;
        res = sys->pVtbl->QueryInterface(sys, IID_IADLXSystem1(), (void**)(&system1));
        if (ADLX_SUCCEEDED (res))
        {
            // Get power tuning services
            IADLXPowerTuningServices* powerTuningServices = NULL;
            res = system1->pVtbl->GetPowerTuningServices(system1, &powerTuningServices);

            // Get AMD SmartShift Max interface
            IADLXSmartShiftMax* ssm = NULL;
            res = powerTuningServices->pVtbl->GetSmartShiftMax(powerTuningServices, &ssm);
            if (ADLX_SUCCEEDED (res))
            {
                MainMenu();
                MenuControl(ssm);
            }

            // Release AMD SmartShift Max interface
            if (ssm != NULL)
            {
                ssm->pVtbl->Release(ssm);
                ssm = NULL;
            }

            // Release power tuning services interface
            if (powerTuningServices != NULL)
            {
                powerTuningServices->pVtbl->Release(powerTuningServices);
                powerTuningServices = NULL;
            }
        }
        else
        {
            printf("Failed to get IADLXSystem1 interface\\n");
        }

        // Release IADLXSystem1 interface
        if (system1 != NULL)
        {
            system1->pVtbl->Release(system1);
            system1 = NULL;
        }
    }
    else
    {
        printf("ADLX initialization failed\\n");
        return 0;
    }

    // Destroy ADLX
    res = ADLXHelper_Terminate();
    printf("Destroy ADLX res: %d\\n", res);

    // Pause to see the print out
    system("pause");

    return 0;
}

void ShowSmartShiftMaxSupport(IADLXSmartShiftMax* ssm)
{
    adlx_bool supported = false;
    ssm->pVtbl->IsSupported(ssm, &supported);
    printf("\\tIsSupported: %d\\n", supported);
}

void ShowSmartShiftMaxSate(IADLXSmartShiftMax* ssm)
{
    ADLX_SSM_BIAS_MODE  mode;
    ADLX_RESULT  ret = ssm->pVtbl->GetBiasMode(ssm, &mode);
    if (ADLX_SUCCEEDED (ret))
        printf("\\tBias mode: %s\\n", (mode == SSM_BIAS_MANUAL  ? "manual" : "auto"));
    else
        printf("\\tFailed to get bias mode, error code: %d\\n", ret);

    adlx_int bias = 0;
    ret = ssm->pVtbl->GetBias(ssm, &bias);
    if (ADLX_SUCCEEDED (ret))
        printf("\\tBias value: %d\\n", bias);
    else
        printf("\\tFailed to get bias value, error code: %d\\n", ret);

    ADLX_IntRange  range;
    ret = ssm->pVtbl->GetBiasRange(ssm, &range);
    if (ADLX_SUCCEEDED (ret))
        printf("\\tBias range: [ %d, %d ], step: %d\\n", range.minValue , range.maxValue , range.step );
    else
        printf("\\tFailed to get bias range, error code: %d\\n", ret);
}

void SetSmartShiftMaxBiasMode(IADLXSmartShiftMax* ssm, int index)
{
    ADLX_SSM_BIAS_MODE  mode = index == 0 ? SSM_BIAS_MANUAL  : SSM_BIAS_AUTO ;
    ADLX_RESULT  res = ssm->pVtbl->SetBiasMode(ssm, mode);
    printf("\\tSet bias mode %s, return code: %d\\n", (mode == SSM_BIAS_MANUAL  ? "manual" : "auto"), res);
}

void SetSmartShiftMaxBiasValue(IADLXSmartShiftMax* ssm)
{
    adlx_int bias = 0;
    ssm->pVtbl->GetBias(ssm, &bias);
    ADLX_IntRange  range;
    ssm->pVtbl->GetBiasRange(ssm, &range);
    adlx_int base = (range.maxValue  + range.minValue ) / 2;
    adlx_int value = bias == base ? base + range.step  : base;
    ADLX_RESULT  res = ssm->pVtbl->SetBias(ssm, value);
    printf("\\tSet bias value: %d, return code: %d\\n", value, res);
}

void MainMenu()
{
    printf("\\tChoose from the following options:\\n");
    printf("\\t->Press 1 to display AMD SmartShift Max support\\n");
    printf("\\t->Press 2 to display AMD SmartShift Max bias value, bias mode, and bias range\\n");
    printf("\\t->Press 3 to set AMD SmartShift Max bias mode to Manual\\n");
    printf("\\t->Press 4 to set AMD SmartShift Max bias mode to Auto\\n");
    printf("\\t->Press 5 to set AMD SmartShift Max bias value\\n");
    printf("\\t->Press Q/q to terminate the application\\n");
    printf("\\t->Press M/m to display main menu options\\n");
}

void MenuControl(IADLXSmartShiftMax* ssm)
{
    int num = 0;
    while ((num = getchar()) != 'q' && num != 'Q')
    {
        switch (num)
        {
            // Display AMD SmartShift max support
        case '1':
            ShowSmartShiftMaxSupport(ssm);
            break;

            // Display current AMD SmartShift max state
        case '2':
            ShowSmartShiftMaxSate(ssm);
            break;

            // Set AMD SmartShift max bias mode
        case '3':
        case '4':
            SetSmartShiftMaxBiasMode(ssm, num - '3');
            break;

            // Set AMD SmartShift max bias value
        case '5':
            SetSmartShiftMaxBiasValue(ssm);
            break;

            // Display menu options
        case 'm':
        case 'M':
            MainMenu();
            break;
        default:
            break;
        }
    }
}

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!