locked
HLSL Compiler in VS11 RRS feed

  • Question

  • Hello,

    I just got Visual Studio 11 to try it out and noticed it's able to compile HLSL code by default (no need to create custom build tool). However it doesn't specify optimization level, which gets defaulted to Level 1. I checked HLSL Compiler options, but I failed to find any option to change optimization level to Level 3. Did I miss this option or it does exist? Is there any workaround to compile HLSL code with highest optimization level?

    Thank you.

     

    P.S. I'm really sorry if this is wrong forum.

    • Edited by Ripiz Wednesday, September 28, 2011 6:39 PM
    Wednesday, September 28, 2011 6:36 PM

Answers

  • Hi Ripiz,

    Thank you for pointing this out.  As you describe, the VS11 Developer Preview currently doesn't have a way to specify the optimization flags for the HLSL compiler.  I have reported this to our product team for their review & consideration.

    Sincerely,

    Dan

    Tuesday, October 18, 2011 6:13 PM

All replies

  • Hi Pipiz,

    I did some investigate about HLSL programming language before this post. To specify optimization level, there're two ways:

    1. In Visual Studio, VC++ project Property Pages dialog, Configuration Properties->C++->Optimization, you can select Full Optimization(/Ox)
    2. From compiler command line, we can also set Optimization level. HLSL compiler I'm referring to: FXC.exe including in DirectX SDK, this way FXC.exe has four options: O0, O1, O2 and O3. O1 is the default level, and O2, O3 are same as O1 at this time, O2/O3 are reserved option. I'm referring to: http://msdn.microsoft.com/en-us/library/bb509709(v=VS.85).aspx

    I guess VS11 calls the fxc internally while compiling HLSL.

    Best Regards,


    Forrest | MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, September 29, 2011 3:56 PM
  • Hello,

    1. C++ Optimization level doesn't seem to affect FXC.exe optimization;
    2. Whole idea is to use VS11 HLSL compiler, without manually calling external application. Actually that's almost exactly what I was asking: how to set O3 for VS11 HLSL compiler?
    Thank you for reply.
    Saturday, October 1, 2011 3:17 PM
  • Hi Ripiz,

    Thank you for pointing this out.  As you describe, the VS11 Developer Preview currently doesn't have a way to specify the optimization flags for the HLSL compiler.  I have reported this to our product team for their review & consideration.

    Sincerely,

    Dan

    Tuesday, October 18, 2011 6:13 PM
  • I just checked in to this, and since VS doesn't allow one to specify the optimization level, it's producing output at the default level, which is O1. It turns out that O2 and O3 are just reserved for future use; setting these produces the same output as O1. For now, there's no point in specifying level 3. From the MSDN page on fxc.exe:

    /O0 /O1, /O2, /O3 Optimization levels. O1 is the default setting.
    • O0 - Disables instruction reordering. This helps reduce register load and enables faster loop simulation.
    • O1 - Disables instruction reordering for ps_3_0 and up.
    • O2 - Same as O1. Reserved for future use.
    • O3 - Same as O1. Reserved for future use.

    http://msdn.microsoft.com/en-us/library/bb509709(v=VS.85).aspx

    Thursday, March 28, 2013 10:10 PM