How do you view the asm code of your hlsl code?

Started by
8 comments, last by galop1n 6 years, 5 months ago

How do you view the assembly code of your hlsl code?

I am using visual studio 2017 and an nvidia graphics card.

I tried looking in the visual studio graphics analyzer ("debug - graphics - start graphics debugging" from visual studio opens that) but where I would expect it to be it says "Enable GPU disassembly via View->Options->Graphics Diagnostics->Enable gather of GPU Disassembly.
The vsglog must be re-opened for this change to take effect."

However that isnt an option you can select.

 

I would actually prefer a way to view the asm without having to capture a frame, as my program doesnt do well in the visual studio graphics analyzer

When I try to playback a captured frame I get "An error has occured. Playback of your application may be incomplete (HRESULT = 0x00630000)"

However I am able to play back captured frames of the microsoft samples, but I am still not able to see asm code with them.

Advertisement

When you say asm code do you mean the output of the HLSL compiler or the output of the driver (aka the actual asm the GPU uses)?

-potential energy is easily made kinetic-

Any assembly that can help me optimise my hlsl code, I dont mind which.

I believe its described here - https://msdn.microsoft.com/en-us/library/windows/desktop/hh447232(v=vs.85).aspx

 

 

I believe NVIDIA nSight will provide a shader asm output: http://www.nvidia.com/object/nsight.html.

They also have a VS plugin, if you prefer.

Admin for GameDev.net.

Thankyou I will check it out.

Is this peoples prefered way of viewing the hlsl assembly code ?

How do you compile your HLSL code? 

I use FXC.EXE, the command line tool. You can call it with "/?",  if I remember correctly, to see all the options. I output the compiled binary for the game to use and also the ASM in a text file in case I want to view it later. 

You can also choose your optimisation level and whether to embed debug information into the binary or not -- when trying to get visual debuggers working it's best to compile your shaders in that mode. 

Like Hodgman, I will usually use FXC if I want  to see the bytecode for a shader. FXC can also disassemble a shader that's saved as a binary file.

RenderDoc also works well if you want to see shaders from a running program. 

Thankyou everyone - the FXC.exe worked perfectly to make the assembly code.

Previously I had just been using the D3DCompileFromFile function to compile my hlsl.

 

Be careful about optimizing the directx bytecode. Optimization to it usually does not translate well to the final uCode of vendors and may even give the driver compiler a harder time.

 

This topic is closed to new replies.

Advertisement