Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


dx 11 hlsl, mapping source to assembly


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 quaikohc2   Members   -  Reputation: 452

Like
0Likes
Like

Posted 10 February 2014 - 03:57 AM

Hi,

In my simple shader editor i want to add the ability to look at shader's source code and corresponding assembly output for selected line or region. I know in a debug mode i can get line numbers in dissasembly but they are very innacurate (I have line 9 and next 20 for example). Anywas i want to have something similar i release mode. I know that code got reorganized a lot in the optimization process so this can be hard and it wont be accurate. Any ideas how to do this?

 

I guess it would be quite easy with volatile (is it still ignored by the compiler? was it ever working? why won't they just remove this keyword?). Do you know any other instruction I could use as a "marker". I mean it shouldn't do anything that would change normal shader execution and it shouldn't be optimized by a compiler so it's still visible in the assembly output?

 

 

cheers


Edited by quaikohc2, 10 February 2014 - 05:08 PM.


Sponsor:

#2 SeanMiddleditch   Members   -  Reputation: 7269

Like
0Likes
Like

Posted 10 February 2014 - 12:15 PM

Disable compiler optimization. There's simply no other way to get accurate source location information. D3DCOMPILE_DEBUG|D3DCOMPILE_OPTIMIZATION_LEVEL0. One does not automatically imply the other.

#3 quaikohc2   Members   -  Reputation: 452

Like
0Likes
Like

Posted 10 February 2014 - 05:06 PM

As i said I know that, but these line numbers in debug assembly are not useful at all because they are so innacurate, not to mention it doesn't make sense to analyse debug assembly output. In c++ to analyse disasm in release mode i just used to put few volatile variables or __asm nop. Is there really nothing similar in hlsl?


Edited by quaikohc2, 10 February 2014 - 05:07 PM.


#4 Hodgman   Moderators   -  Reputation: 32049

Like
1Likes
Like

Posted 10 February 2014 - 06:33 PM


In c++ to analyse disasm in release mode i just used to put few volatile variables or __asm nop. Is there really nothing similar in hlsl?
That's the same as disabling optimization -- it's not actually a release build any more if you do that, and you're still basically looking at a debug build...

#5 quaikohc2   Members   -  Reputation: 452

Like
0Likes
Like

Posted 12 February 2014 - 02:55 AM

 


In c++ to analyse disasm in release mode i just used to put few volatile variables or __asm nop. Is there really nothing similar in hlsl?
That's the same as disabling optimization -- it's not actually a release build any more if you do that, and you're still basically looking at a debug build...

 

 

How is that? Why two volatile variables that are not used in the actual code would disable code optimization, e.g:

volatile int marker = 34;

 

for(int i = (etc etc)

(few lines of code here doing something important)

 

volatile int marker2 = 777;



#6 MJP   Moderators   -  Reputation: 11846

Like
0Likes
Like

Posted 12 February 2014 - 03:48 PM

The HLSL compiler will aggressively inline, unroll, and reorder your code, much moreso than a C++ compiler. It can do this because the language is simple and generally free of side effects, and also because the virtual ISA provided by HLSL assembly is relatively simple. Anything you would do to prevent the compiler from doing this could potentially have a large effect on resulting performance, hence Hodgman's comment about it not actually being a Release build anymore.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS