# Can someone explain to me how setting shader parameters aren't a bottleneck?

I am trying to understand this. So I have a bunch of models that need to be rendered. Each model most likely has various "sub meshes" with their own diffuse, specular, etc textures. So for each of these models I have to loop through set the diffuse, specular, etc and then a draw call. Now lets say I do this a couple times for each model, and I have 100 models in a scene. Since my C++ code that sets these per model parameters is called by the CPU, doesn't it have to bus all that data to the GPU a ridiculous amount of times. Even if it doesn't and the GPU is caching, wouldn't the CPU still need to make several inquires to make sure the correct resources are cached? I am asking because I have a, single, high res model I am rendering and once textures are applied I drop from 1000 FPS to 70. This model has about 20 different textures, and isn't something that will be used in a game, solely using it to stress test and locate bottlenecks. Thanks!

• Group shader settings into a material object then sort render batches by material object. One easy way is to use a std::multimap<Material *, RenderBatch *> all render batches using the same material will be grouped on the same key (the material pointer). You can then iterate over the multimap and only update GPU states when the material (iterator->first) changes. – Stephane Hockenhull Jan 6 '15 at 0:24