Home Unreal Engine

Shader Profiling/Performance Measurement?

polycounter lvl 14
Offline / Send Message
d1ver polycounter lvl 14
Hey guys. I was just curious about something:

I've been doing some shaders with custom code recently. And from what I hear you probably wouldn't want to trust UDKs material editors instruction counter to see how much your custom nodes "weigh". So I was just curious, how else do I track shader performance?

I had a kind soul from polycount help me do it before, but he seems unavailable right now and I'd just like to be able to do this by myself.
I heared him mention "shader profiling" if it would be of any use.

It's for my "Procedural" Materials. I redid most of the custom code and would like to test how efficient it is.

Thanks a lot in advance and looking forward to your help.

Cheers!

Replies

  • EmAr
    Options
    Offline / Send Message
    EmAr polycounter lvl 18
    I don't use custom code at all but I need help with this one too.

    I think I saw this in a 3dmotive video. The instructor would use the A instead of B in the picture below. Even though the material editor displays the same number of instructions, my brother told me that the multiply node is the way to go, as the instructor does, the reason being the power node works with a recursive function.

    16316269.jpg

    So, I'm also wondering how I can measure the performance of my materials/particles.

    Thanks in advance :)
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Are you sure? In my editor, the instruction count stays the same, if you use a Power of 2 for the Node, but anything else will increase slightly more.

    On the other hand, using the Mul node is only a viable solution for about 3 or 4 more times before it starts becoming junk code.

    I honestly wish there was a way to profile UDK's material without the Instruction counter or Complexity viewport that gave out hard numbers, but so far there isn't.
  • AzzaMat
    Options
    Offline / Send Message
    AzzaMat polycounter lvl 9
    What I want to know is why he is multiplying a constant .5 by itself. Surely just get rid of the multiply and change the constant to .25
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    That's just an example of how Mul a number by itself manually has performance > using the Power node, unless you use a Power of 2, it doesn't serve a purpose.
  • EmAr
    Options
    Offline / Send Message
    EmAr polycounter lvl 18
    He was not multiplying a constant, he was using a number which comes from another part of the material. I just tried to isolate the example. Sorry for the confusion.

    I checked it out and I think what the material editor does here is that it uses one less instruction when the result of the power node is 1 by definition(Exp = 0 or base = 1). I hadn't noticed this before, thanks for reminding it actually is sensitive to the input Ace-Angel.

    Edit: I am pretty slow when typing :)
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Yep, this especially is prominent for the Blinn Specular setup, I think at one point my instructions jumped by about 10-15 points because I used something like 1.35 in my roughness value.
  • LoTekK
    Options
    Offline / Send Message
    LoTekK polycounter lvl 17
    I'm not sure if Unreal's compiler will optimise the pow statement (ie, if it's doing an exponent to an integer power, it will just compile down to a multiplication (or a constant)), but in raw shader code, a pow statement is way more expensive than a multiplication, simply because pow needs to deal with floats, not just integers.
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    Ace-Angel wrote: »
    Are you sure? In my editor, the instruction count stays the same, if you use a Power of 2 for the Node, but anything else will increase slightly more.

    On the other hand, using the Mul node is only a viable solution for about 3 or 4 more times before it starts becoming junk code.

    I honestly wish there was a way to profile UDK's material without the Instruction counter or Complexity viewport that gave out hard numbers, but so far there isn't.


    The problem with profiling is that it's very platform dependent. There are some things which work fine on one kind of video hardware that will slow down another.

    The only true way to profile something is with profiling tools from the manufacturer of the hardware. So while the instruction count is only a guide it's also the only reliable performance hit across multiple platforms.
  • EmAr
    Options
    Offline / Send Message
    EmAr polycounter lvl 18
    Thanks for the info sprunghunt, now it makes sense. I remember reading that PS3 would perform better with workarounds involving Lerp nodes instead of direct use of if nodes. I guess that's just one example.
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    sprunghunt wrote: »
    The problem with profiling is that it's very platform dependent. There are some things which work fine on one kind of video hardware that will slow down another.

    The only true way to profile something is with profiling tools from the manufacturer of the hardware. So while the instruction count is only a guide it's also the only reliable performance hit across multiple platforms.

    Hmm, would it be possible to profile the code (in case of the PC) via the DX Toolkit?
  • leleuxart
    Options
    Offline / Send Message
    leleuxart polycounter lvl 10
    Ace-Angel wrote: »
    Hmm, would it be possible to profile the code (in case of the PC) via the DX Toolkit?

    I wish there was a program that could run side-by-side with UDK and would measure FPS and other performance issues through calculations based on the hardware you're running, Xbox 360, PS3, etc. I'm not too experienced with managing draw calls, material instructions, and everything else we have to consider when doing a level.
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    leleuxart wrote: »
    I wish there was a program that could run side-by-side with UDK and would measure FPS and other performance issues through calculations based on the hardware you're running, Xbox 360, PS3, etc. I'm not too experienced with managing draw calls, material instructions, and everything else we have to consider when doing a level.

    There are tools for both the XBOX(PIX) and the PS3(GPAD) that do this. At least as far as gpu profiling goes. I don't know if you can get access to them without being a registered developer.

    I'm not sure about PC because I don't have to worry about PC performance as much.
  • leleuxart
    Options
    Offline / Send Message
    leleuxart polycounter lvl 10
    sprunghunt wrote: »
    There are tools for both the XBOX(PIX) and the PS3(GPAD) that do this. At least as far as gpu profiling goes. I don't know if you can get access to them without being a registered developer.

    I'm not sure about PC because I don't have to worry about PC performance as much.

    Hmm, I'll have to take a look at those. Thanks! I don't have to worry about performance, but it's nice to be able to build portfolio/class levels around real life industry standards.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    I cant remember what the program was called but there was a program someone showed me to get the different rendering passes etc. I tried googling it since I knew it was Nvidia but got this.

    http://developer.nvidia.com/content/nvidia-perfhud
  • leleuxart
    Options
    Offline / Send Message
    leleuxart polycounter lvl 10
    I cant remember what the program was called but there was a program someone showed me to get the different rendering passes etc. I tried googling it since I knew it was Nvidia but got this.

    http://developer.nvidia.com/content/nvidia-perfhud

    Thanks for that link! It doesn't seem to be up-to-date though. They mention DX9 at the top, but DX10 is mentioned for screen captures in 6.70 feature list. The most recent update supports Fermi GPUs too, which I think came out a few years ago? I Googled around for "real time performance monitors in game engines", but I didn't really find anything. Nothing close to this at least.
  • leleuxart
    Options
    Offline / Send Message
    leleuxart polycounter lvl 10
    Just came across this. All you have to do is add a few strings to the shortcut for UDK. It seems like it has all of the important information.
Sign In or Register to comment.