Performance question about effect files

Started by
1 comment, last by arc4nis 16 years, 2 months ago
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?
Advertisement
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Thanks! Now I understand it :)

This topic is closed to new replies.

Advertisement