Modifying Shader Code for DirectX 9/10 Frames
You can create or modify shaders within the Graphics Frame Analyzer to see whether changes result in reduced rendering time with an acceptable level of overall scene quality.
Use one of the following methods to revise/replace a section of code:
To compute the shader performance, click the
Profile
button. Graphics Frame Analyzer calculates the total execution time for the analyzed shader, individual time for each shader instruction, and the number of clocks that occurred during the measured period.NOTE
Profiling is only supported on Intel® microarchitecture code name Ivy Bridge or higher. For
HLSL
, the profiling information is only available if you compiled the analyzed shader with D3D debug flag for the applicable version of Microsoft DirectX*. Otherwise profiling information is only available for IL Assembly
, and the Profile
button for HLSL
is disabled.Specifying a New Source
To replace the shader with another pre-existing one:
- Go to the Shaders tab.
- Select vertex/pixel/geometry/hull/domain/compute shader code in theShadercolumn.
- SelectIL AssemblyorHLSLfrom the drop-down list to edit assembly or HLSL code respectively.NOTE
- TheHLSLoption is only available if you compile the application shaders at run time using the Microsoft DirectX* API. If your application uses shaders compiled at build time, only theIL Assemblyoption is available for these shaders.
- You cannot change Assembly shader code for Microsoft DirectX* 10 or Microsoft DirectX* 11 frames.
- ClickReplace File....
- In theOpenwindow, select a file from which to load a new shader.
- ClickSettings...to specify the options to the compiler in theShader Settingsdialog box:
- In theInclude Pathfield, specify a path to the shader’s header files for use by the compiler. If the edited shader was loaded from a file, the default is the path to the file; otherwise, there is no default.
- For HLSL, in theEntry Pointfield, specify which function the compiler must treat as the main body for the shader. This option corresponds to thepFunctionNameparameter inD3DXCompileShaderfor Microsoft DirectX* 9, inD3DX10CompileFromMemoryfor Microsoft DirectX* 10, or inD3DX11CompileFromMemoryfor Microsoft DirectX* 11. If multiple entry points exist in the shader file, supply the name of the "main" shader function in the edit box.
- In theDefinesfield, specify macros that correspond to:
- thepDefinesparameter inD3DXCompileShaderfor Microsoft DirectX* 9
- thepDefinesparameter inD3DX10CompilerFromMemoryfor Microsoft DirectX* 10
- thepDefinesparameter inD3DX11CompilerFromMemoryfor Microsoft DirectX* 11.
- The format for theDefinesfield is SYMBOL=value; multiple entries are delimited by a semi-colon.
- ClickOK.
- In theShaderstab, clickApplyto apply these settings to the required shader any time, without opening theShader Settingsdialog every time.
- To reject the corrections you made while editing the file, clickUndo Edits. To revert the shader to the original state, clickRevert.
Editing the Existing Shader Code
You can edit only one shader at a time.
NOTE
If you apply the
Simple Pixel Shader
or Disable Erg(s)
experiment to a specific erg or a group of ergs, Graphics Frame Analyzer (DirectX 9, 10, 11) disables editing of the overridden shader and displays a corresponding warning in the Shaders
tab.
To edit the shader in the text buffer:
- Select the required ergs either in theVisualizationor in the.Scene Overview pane
- Go to the Shaders tab.
- Select vertex/pixel/geometry/hull/domain/compute shader code in theShadercolumn.
- SelectIL AssemblyorHLSLfrom the drop-down list to edit assembly or HLSL code respectively.NOTEYou cannot modify Assembly shader code for Microsoft DirectX* 10 or Microsoft DirectX* 11 frames.
- Edit code as required in the code field. To clear edits that have not yet been applied, clickUndo Edits.
- Once you have finished with the changes, clickSettings...to specify the options to the compiler in theShader Settingswindow.
- ClickApplyto apply the new shader to the selected ergs.
- To reject the corrections you made while editing the file, clickUndo Edits. To revert the shader to the original state, clickRevert.
All compilation errors appear in the
Errors View
and the Shader Replacer
window remains open.