User Guide

  • 2021.2
  • 06/24/2021
  • Public Content
Contents

Optimize Shaders

To determine whether shaders cause a performance bottleneck for the selected draw calls, you can do the following:
  • Change the shader code inside Graphics Frame Analyzer
  • Check the performance effect without recompiling your code
  • View performance data per shader code line

Experiment with Shader Code

  1. Select one or more draw calls for which you would like to analyze the shader code.
  2. From the Resource List, choose the shader used in the selected draw calls. Graphics Frame Analyzer displays the shader source code and all the resources used by the shader.
  3. In the
    Shader Resource List
    , analyze resources used in the shaders grouped by type:
    • Constant Buffer View (CBV) (DirectX only)
    • Render Target View (RTV)
    • Sampler
    • Shader Resource View (SRV) (DirectX only)
    • Storage Buffer Object (SBO) (Vulkan only)
    • Storage Texture (Vulkan only)
    • Texture (Vulkan only)
    • Uniform Buffer Object (UBO) (Vulkan only)
    • Unordered Access View (UAV) (DirectX only)
    • Vertext Buffer View (VBV) (Vulkan only)
    Graphics Frame Analyzer displays various resource parameters, the shader type using the resource, and shader registers each resource is bound to. Resources are listed in the following format:
    <shader name>:<register ID> <resource type>:<resource ID> (<view type><view ID>) <resource debug name>
    To open a resource, click the desired resource name.
  4. From the
    Shader Type
    drop-down list, select the type of shader you would like to analyze. The shader code opens in the
    Shader Editor
    . For easier reading, you can click the button to indent the code, and the button to preprocess the selected shader and hide the code paths that do not get executed.
  5. While Assembly code is read-only, you can experiment with the HLSL code for DirectX* and HLSL and GLSL for Vulkan*, if these codes are available for your shader. In this case, select HLSL or GLSL from the respective drop-down menu and edit the code directly in the Shader Viewer. The shader recompiles on the fly. If you introduced any errors, you can see the corresponding message in the Notification pane below the Shader Editor.
  6. If the code looks fine, click the button to save the changes. Graphics Frame Analyzer recalculates all metrics and displays new data in the Metrics pane and in the Main bar chart.
    When you click the button, Graphics Frame Analyzer saves all the shaders. This enables you to write your own code and replace the whole shader to experiment.
  7. If you want to undo your edits, click the button. The original shaders are restored.

Profile Shader Code

  1. Open Shader Viewer and click the
    Shader Profiler
    button. The shader viewer displays all versions of Gen ISA code and the profiling data column.
  2. Click the
    Show source-assembly mapping
    button to view the source code and the assembly code side-by-side, and to map individual source or assembly lines to their counterparts.
    The Shader Profiler offers two modes for displaying profiling data:
    • Duration: shows the estimated portion of time in percents a line of code took, relative to the execution time of all shader stages.
    • Execution Time: shows the total number of times the exact line of code was executed.
  3. Use this information to experiment with your shader code by modifying the shader directly in the Shader Profiler view. You can edit your code and evaluate the impact on visuals and performance in real time. Click the button to save the changes, or click the button to revert your changes.
  • Shader profiling is only available for DirectX* 11 and DirectX* 12 APIs.
  • Source-assembly mapping is not available for shaders compiled without debug information. To enable source-assembly mapping, you can:
    • compile a shader with debug information in your application
    • modify a shader in Frame Analyzer
  • For DirectX* 11 shaders without debug information, DXBC-ISA mapping is available instead of HLSL-ISA mapping.
  • Source-assembly mapping is not supported for Shader Model 5 shaders on DirectX* 12 applications. To enable it, recompile the shaders for Shared Model 6.
  • Shader Profiler requires Intel® Graphics Driver version 26.20.100.7755 or higher.
  • This feature is supported on 9th Generation (code names Skylake, Coffee Lake, Kaby Lake), and 11th Generation (codenamed Ice Lake) Intel® Graphics hardware.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.