Jump to content
  • Advertisement
Sign in to follow this  

Performance question about effect files

This topic is 3775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using effect files to store my shaders, and passing all the data to the global variables with ->SetFloatArray ... etc... However I'm not sure if this is the right method, becouse every time I render, I pass all those strings (the names of the variables) to the graphic card, which is expensive (if I'm not mistaken). This is how it looks:
f_xLight->SetMatrix( "worldViewProj", &worldViewProjection );
f_xLight->SetMatrix( "matRotation", &matRotation );
f_xLight->SetFloatArray("lightDir1", light, 3);
f_xLight->SetFloatArray("lightColor1", lightcolor, 3);
f_xLight->SetFloatArray("ambientColor", lightcolor, 3);
f_xLight->SetFloatArray("fogColor", fogcolor, 4);
f_xLight->SetInt("numberOfLight", 1);
f_xLight->Begin( NULL, 0 );
f_xLight->BeginPass( 0 );

    g_pd3dDevice->SetTexture( 0, g_tCeres );


Is this ok, performance wise? Or is there a more efficient method?

Share this post

Link to post
Share on other sites
Yes, it can be inefficient to set constants the way you are - have a read about handles in the documentation.

Ultimately, for performance questions you should be using a profiling tool like NVPerfHUD. Efficient use of the D3D9 API (optimized state switching and batching) is crucial, but without any performance metrics you'll have no idea where your real performance bottlenecks are, nor will you know if any changes you make are actually beneficial!


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!