Sign in to follow this  
Dtag

CG SetUniform Performance

Recommended Posts

Dtag    210
Hi Iam having problems with the performance of CGs setuniform calls. Im rendering around 2500 small objects. Each with a single drawcall ( Iam fully aware of the fact that one should use instancing or the like for that, and that this API abuse will cause problems on slow CPUs etc. ) - shader,texture binding etc is only done once. When Im commenting out the core drawing code which is iterated for each of the objects ( that is calculation of the modelviewprojection matrix, updating of the uniforms, and finally the drawcall ). Iam getting around 750 fps so its not the rest of my engine isnt using up alot of time ( only 1.3 ms for culling, sorting of the 2500 alphablended objects etc appears to be ok ). Now when Iam ONLY taking in the part where the uniforms are set, Iam down to 60 fps, so thats a whopping 15 ms just for updating the uniforms - unacceptable. Each of the shaders gets 3 uniforms right now ( 4x4 matrix, float, float ), and each is re-sent for every Object ( I know I could do an optimization so that static uniforms only get transmitted once, but ultimately Iam still left with at least one 4x4 matrix uniform setting per instance). So even if I reduce the number of uniforms to effectively 1, Id still be left with like 8 ms ( setting the matrix appears to be a little more expensive than the other 2 uniforms ) just for setting the uniforms, not drawing anything. I actually expected the drawcalls to be the limiting factor when rendering such high amounts of drawcalls, as all slides from nVidia/Ati point out their poor performance. As mentioned above, Iam using CG for the shaders, and Iam using the "cgD3D9SetUniform" call. The same performance problem Iam seeing here also exists in my GL codepath. Is setting uniforms really as slow as it seems? Am I doing something wrong? Could I do something better? Thanks in advance

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this