Search Unity

RenderTexture.SetActive() but no Image effects used

Discussion in 'Developer Preview Archive' started by tomworcom, Feb 4, 2012.

  1. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    50
    I'm experiencing a problem I think is related to a bug with Imageffects, maybe only in 3.5RC1.

    If I'm not mistaken, the RenderTexture.SetActive() function is used when e.g. Image effects are used or a Texture is created procedurally. I've enabled the Glow effect once in my project, but disabled it later and even completely removed the script it from the project.

    Sometime around that experiment I noticed a serious drop from 60FPS down to 30FPS - and it won't go away anymore. I was digging deeper and used the Profiler to look at the cause and I found RenderTexture.SetActive() being called. Is that a bug?

    [UPDATE: I am mistaken... it's always used. That sudden FPS-drop is still there though - can't figure it out.]

    Thanks for any help,
    Thomas
     
    Last edited: Feb 4, 2012
  2. Poupi

    Poupi

    Joined:
    Jan 11, 2012
    Posts:
    111
    We're experiencing the same problem with the 3.5RC1, and not with the 3.5b6, so it seems to be a bug.



    The 'RenderTexture.SetActive' is the purple part in the GPU Usage curves.

    Robin
     
  3. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I am seeing this as well and trying to figure out where it is coming from.
     
  4. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    BTW: I see those spike when running the editor but if I compile a debug version and attach the Profiler to it, those spikes are pretty much all gone. See if you get the same results.
     
  5. Rush3fan

    Rush3fan

    Joined:
    Nov 2, 2011
    Posts:
    87
    Me too.. This purple stuff is dropping below 100fps, which throws everything else below 60fps.

    It also does really sharp spikes which looks really bad when you range from 30 to 60 fps.
     
  6. Matt-Downey

    Matt-Downey

    Joined:
    Apr 22, 2012
    Posts:
    11
    I'm having problems with this as well. I have a Nvidia GeForce 555M 1G. I think this picture is hilarious because... 99.9% @ 332.175ms (3FPS)?!?!?



    As you can see in the picture, this state would probably be running at about 650FPS if it weren't in the middle of a GPU spike.

    Granted, I haven't switched my graphics, so this test is only tapping 64Mb out of the 970Mb of Vram I'm able to get out of Unity3D. I don't use RenderTextures, so I'm not certain what the problem is. Literally nothing fancy in my game. I'm using unlit diffuse (mobile) and Mobile Particle VertexLitBlended right here. Primitive Cubes and Spheres. Orthogonal Camera angle. Of note: the main character consists of a primitive sphere with the renderer removed and childed to that sphere is another sphere which is closer to the camera, but without a collider.

    Not positive, but in my case the problem should carry over to iPhone/Android (can't test it via profiler). I say this because my game is normally smooth but is randomly interrupted by spikes. At first I thought it was from garbage collection, but after manually calling garbage collection I could swear the problem got worse.

    I used this garbage collection code:

    using UnityEngine;

    class GarbageCollectManager : MonoBehaviour {
    public int frameFreq = 30;
    void Update() {
    if (Time.frameCount % frameFreq == 0)
    System.GC.Collect();
    }
    }

    (*modified for Javascript*)

    from here: http://www.cratesmith.com/archives/183

    The last thing I'd like to mention is that Unity keeps on spamming "Profiler is only supported in Unity Pro," when I have Unity Pro (reg Android/iPhone). I am still able to use the profiler, but it constantly nags at me nonetheless (probably 4 times a second during play mode).

    I've reactivated my license numerous times, but this glitch (if it is a glitch? might it be talking about Android/iPhone?) seems to be benign, so I don't worry about it. It could be related though, so I thought I'd mention it.
     
    Last edited: Apr 22, 2012
  7. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    Hi Leq, I found your post while googling "Profiler is only supported in Unity Pro."

    I just wanted to say that I'm also experiencing this issue. I've got pro/android-basic/iphone-basic licence active. The profiler works, but the log is spammed with this error message.

    This is on a Macbook Pro running Lion, Unity 3.5.1f2.

    Edit: bug report submitted.
     
    Last edited: May 1, 2012
  8. alleycatsphinx

    alleycatsphinx

    Joined:
    Jan 25, 2012
    Posts:
    57
    Is that render texture by any chance being called by the gui itself, say for a texture preview?
     
  9. Matt-Downey

    Matt-Downey

    Joined:
    Apr 22, 2012
    Posts:
    11
    Sorry for the really late reply.

    @alleycatsphinx

    I disable the only GUI script I had, which just drew the replay/quit stuff on the screen. It didn't solve anything though. I went one step further and removed the script component just in case, and the GPU is still as slow as ever.

    I'm not using GUI textures/previews at all. For one thing, I only code physics, so the GUI itself was for replaying/quitting the app for android.

    I regularly update drivers trying to fix these sorts of problems to no avail.

    For instance: http://unity3d.com/support/documentation/Manual/TroubleShooting.html

    "Slow framerate and/or visual artifacts.
    This may occur if your video card drivers are not up to date. Make sure you have the latest official drivers from your card vendor."

    *Yes, I do occasionally have buggy artifacts*

    It might be Lenovo being lazy with drivers. For instance, in order to get my computer to tap 970Mb of GPU in the first place, I had to change some Nvidia settings, I'll try to check if one of those is making things slow.

    @Tinus

    Thanks for reporting it.



    All in all, I find that my unity3d experience is a very isolated, often glitchy experience, but I still program almost every day, because all I need to see with this laptop is how the physics systems handle.

    Every glitch I've mentioned so far has been benign (if a little annoying), so I just ignore them.

    If I get a breakthrough on why these spikes happen, I'll share it.
     
  10. Matt-Downey

    Matt-Downey

    Joined:
    Apr 22, 2012
    Posts:
    11
    Figured out the problem immediately, and with any hope this might deliver insight to anyone else who has had the same issue. My GPU went from approximately 100FPS to 2000FPS by switching the "maximum prerendered frames" property in the Nvidia control panel for Unity.exe from 0 to 3. 3 is the default number, but it's worth checking, especially if you might have changed it. (You have to exit Unity after changing the setting.) You could potentially set the number even higher, and maybe it will fix something.

    [edit:] the spikes themselves still seem to happen, but the FPS on average has become a lot faster, so I can't complain. Plus the highest spike I've seen yet is 45ms compared to 332ms before.

    [edit2:] Currently wondering when my FPS from this project went from 650ish to 100. Regardless, I'm happy with this.
     
    Last edited: May 23, 2012