Sign in to follow this  
arc4nis

Performance question about effect files

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 );
    g_3dCeres->DrawSubset(0);

f_xLight->EndPass();
f_xLight->End();

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!

hth
Jack

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