Search Unity

multithreading rendering in psm ?

Discussion in 'PSM' started by blackbird, Dec 27, 2014.

  1. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    592
    why there is no multithreading rendering on psm ? unlike android ... i think that make things much easier to run on vita i really struggle to get a good stable frame rate i m big believer in the vita but i think psm doesn't use the full potential ... so is there any chance to get that option like for the android build
     

    Attached Files:

    Last edited: Dec 27, 2014
  2. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    I think you are confused by the fact that there is no Player Setting for Multithreaded Rendering for PSM?
    PSM is normally always running with the rendering on a separate thread, i.e. "multi-threaded".
     
    blackbird likes this.
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Before focussing on PS4 dev we had vignetting, noise, bloom, depth of field, unlimited lights, subsurface scattering, BRDF/conserving IBL shaders, fog, full 3D, realtime shadows on everything, custom gi and 200 verts/frame on Vita.

    We're not on PSM but PSN, but I don't think there was much difference. This little thing (and particularly the awesome work Unity's done on it) is incredibly strong, however you may need to totally rethink how you're doing things. You need to roll tight shaders and avoid alpha test. You need to pretty much butcher the precision of every shader or use things like echologin's shaders.

    So I disagree pretty strongly with your comments, considering we were able to push visuals easily as good as PS3 from it.

    If you understand that AAA console development is typical (in terms of having to optimise everything) of what I advise above you will go far. Can I ask what android phone you're using where you're getting a better framerate?
     
    blackbird likes this.
  4. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    592
    @hippocoder i m using nvidia shield too and i didn t say that i got better performance on android i m just asking about that option thats all in hope to get more from the vita

    @eriQue thank you for clarification it's true i m confused because i read in the documentation that the CPU has 3 hardware threads available to the application. Unity uses at least 2 (main and rendering), so creating more than one additional worker thread from managed code is not likely to yield any additional benefit. But this of course depends on how the application itself is behaving.
    and as far as i know the GPU is quad core too so i thought that only one core is active for psm games
     
    Last edited: Dec 31, 2014
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The shield is really grunty, you can't compare the two. The vita is more of an ipad2/ipad3. Tegra 4 handles alpha test better than power VR as well, so ensure you're not using any cutout shaders.

    You're making this assumption that its about cores or whatever, it's not. If the shader uses functions simply unsupported by the target hardware, it will use a branch on the gpu for PVR gpus, and this is slow.

    Please show profiler statistics or more information if you need help optimising. FYI our game was running at roughly 62fps on vita with those effects all active.

    The key is to go custom with it all, and identify where the bottlenecks are. In the case of vita I was able to get much higher performance from not using static batching and doing manual batching, perhaps that would help you too?
     
    blackbird likes this.
  6. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Wait - this is not how it works.

    Yes, the CPU has 3 HW threads / cores available to the application. And yes, Unity uses at least 2 (main + rendering), and then additional CPU time depending on how much audio is being processed, etc.

    The GPU is also multicore - internally. Slightly simplified it means the GPU can do shader processing in parallel (i.e process more than one tile at a time).

    But creating additional CPU threads doesn't mean more GPU core usage - the GPU will always try to use all cores to finish the rendering as fast as possible.
    How the GPU load-balances its workload is completely opaque from an application point-of-view.
     
    blackbird likes this.
  7. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    592
    i got it now ! thank you very much guys i think i know now what make the frame rate low !!! i was so focused on Graphics that completely forgot about the audio
     
  8. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there hippocoder,

    Its hard to believe that all the post-process effects you mention run smooth with ps vita.
    Unlimited lights? how? using more than 2 lights in forward mode (not using vertex lightning ) is dropping fps to 50, and using defferred rendering method from unity 4 is worse.
    Realtime shadows? What custom method you use? Using unity default shadow system set to lowest shadow resolution drops fps to 30/40.
    All that post-process together ( vignetting, noise, bloom, depth of field, unlimited lights, subsurface scattering, BRDF/conserving IBL shaders, fog, full 3D.....) hard to believe you archived 60fps (hard to believe even on ps3)...What custom shader do you use? Any way we can see a demo of all this working at stable 60 fps?
     
    blackbird likes this.
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I wrote all the post fx and lighting system myself plus all the shaders. Unity's pretty cool in that *if* you know what you're doing you can replace it all.

    Oh yeah it had film grain too :)

    I'll attempt an explanation of the process, but I don't have time to package up any source until after my game is launched.

    1. first pass is rendered to texture. This includes shadows which I butcher from Unity's to remove absolutely everything that's slow. This doubled framerate - so the base game was running at around 160fps with realtime shadows on Vita.

    This pass stores the z value of every pixel rendered in the texture's alpha channel. This is done via my own shader on everything (which has unlimited per-vertex lights, brdf, ibl etc)

    2. I then copy this texture and render any distortion meshes with the same scene data. For water, heat shimmer and so on.

    2. Next, I box blur and render to smaller textures a quad containing the scene so far.

    4. Then another camera renders a very fast vignette + noise + depth of field post shader to combine everything so far for the end result. Here, I do a grid mesh for global illumination and blend into the main scene, it's subtle but very nice.


    Having said that, I've thrown it all in the bin for now to focus on Unity 5 for PS4. If I do the Vita back port, I will instead tweak my rendering to match Unity 5's rendering as close as possible, so I need to focus on PS4 at the moment.

    But suffice to say you can't use *anything* whatsoever shader or fx wise on Vita except custom if you want to get the framerates I was pulling. Don't forget I've got 4 years experience coding mobile shaders, I know the PVR chipset well.

    All the lighting calculations in the shader were hand optimised for speed. Tricks like stacking texture reads to mask the delay from reading were used. You will find many great tips on ImgTec's website about PVR shaders, the bottlenecks, and so on. Less cycles doesn't always mean more speed. So you need to trial and error in endless fashion.

    The end result was vita running non-native resolution, (about 80% res) at a solid 65-75 fps. We showed sony and they were very, very pleased with us. I hope to share when I have time but between trying to develop the game, doing moderation on forums and being on Unity's Alpha/Beta I don't get much time to post source.

    I'm very proud of what I did - I doubt many worldwide got this kind of performance out of the device, so I would love to share the sources. Just no time and it won't work in isolation as if you replace things entirely like Unity's lights with custom lights, you need to control every aspect of the shader including passing in custom lighting data.

    So hopefully sometime in future I'll be able to.
     
    Last edited: Jan 6, 2015
  10. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Really thanks for the full explanation. Seems that this is the difference between experienced mobile developers and ppl like me.
    If you get some time, release a package in asset store, a system like Post FX Studio, could be amazing for psvita indie developers. I would pay 40/50$ for it.
     
    blackbird likes this.
  11. blackbird

    blackbird

    Joined:
    Aug 9, 2011
    Posts:
    592
    me too i would even pay more than 50 euros