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();
Performance question about effect files
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:
Is this ok, performance wise? Or is there a more efficient method?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement