ResetShaderCache

Demonstrates how to access reset shader cache options, and perform related testing when programming with ADLX.

Command Prompts

Command Prompt Description
1 Display reset shader cache support
2 Reset GPU shader cache
M/m Display the main menu
Q/q Quit the application

Sample Path

/Samples/C/3DGraphics/ResetShaderCache

Code

Copied!

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


#include "SDK/ADLXHelper/Windows/C/ADLXHelper.h"
#include "SDK/Include/I3DSettings.h"

// Display reset shader cache support
void ShowSupport(IADLX3DResetShaderCache* resetShaderCache);

// Reset GPU shader cache
void ResetShaderCache(IADLX3DResetShaderCache* resetShaderCache);

// Menu
void MainMenu();

// Menu control
void MenuControl(IADLX3DResetShaderCache* resetShaderCache);

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 GPUs
        IADLXGPUList* gpus = NULL;
        res = sys->pVtbl->GetGPUs(sys, &gpus);

        // Get 3DSettings service
        IADLX3DSettingsServices* d3dSettingSrv = NULL;
        res = sys->pVtbl->Get3DSettingsServices(sys, &d3dSettingSrv);

        if (ADLX_SUCCEEDED (res))
        {
            // Get GPU interface
            IADLXGPU* gpu = NULL;
            adlx_uint index = 0;
            res = gpus->pVtbl->At_GPUList(gpus, index, &gpu);

            // Get ResetShaderCache interface
            IADLX3DResetShaderCache* resetShaderCache = NULL;
            res = d3dSettingSrv->pVtbl->GetResetShaderCache(d3dSettingSrv, gpu, &resetShaderCache);
            if (ADLX_SUCCEEDED (res))
            {
                MainMenu();
                MenuControl(resetShaderCache);
            }

            // Release the ResetShaderCache interface
            if (resetShaderCache != NULL)
            {
                resetShaderCache->pVtbl->Release(resetShaderCache);
                resetShaderCache = NULL;
            }

            // Release the GPU interface
            if (gpu != NULL)
            {
                gpu->pVtbl->Release(gpu);
                gpu = NULL;
            }
        }
        else
        {
            printf("Failed to get 3DSettings services\\n");
        }

        // Release the 3DSettingsService interface
        if (d3dSettingSrv != NULL)
        {
            d3dSettingSrv->pVtbl->Release(d3dSettingSrv);
            d3dSettingSrv = NULL;
        }

        // Release the GPUs list interface
        if (gpus != NULL)
        {
            gpus->pVtbl->Release(gpus);
            gpus = 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 ShowSupport(IADLX3DResetShaderCache* resetShaderCache)
{
    adlx_bool supported = false;
    ADLX_RESULT  res = resetShaderCache->pVtbl->IsSupported(resetShaderCache, &supported);
    printf("\\tIsSupported: %d, return code is: %d(0 means success)\\n", supported, res);
}

void ResetShaderCache(IADLX3DResetShaderCache* resetShaderCache)
{
    ADLX_RESULT  res = resetShaderCache->pVtbl->ResetShaderCache(resetShaderCache);
    printf("\\tReturn code is: %d (0 means success)\\n", res);
}

void MainMenu()
{
    printf("\\tChoose from the following options:\\n");
    printf("\\t->Press 1 to display reset shader cache support\\n");
    printf("\\t->Press 2 to reset GPU shader cache\\n");
    printf("\\t->Press Q/q to quit the application\\n");
    printf("\\t->Press M/m to display menu options\\n");
}

void MenuControl(IADLX3DResetShaderCache* resetShaderCache)
{
    int num = 0;
    while ((num = getchar()) != 'q' && num != 'Q')
    {
        switch (num)
        {
            // Display reset shader cache support
        case '1':
            ShowSupport(resetShaderCache);
            break;

            // Reset GPU shader cache
        case '2':
            ResetShaderCache(resetShaderCache);
            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!