Suppose I have a reasonable amount of light sources that I upload at once in my forward rendering and accumulate them in shader.

Now that I am willing to move to deferred, and so one pass per light, I have a design doubt. Suppose my light struct is no more than 64B, I have two options:

  1. Still upload them to GPU once and then using a uniform to get the right index for each pass.

  2. Upload for each pass the correspondent light info.

With option 1 I have the advantage of not uploading info at each frame, but just once. On the other hand, option 2 allow to have less data on memory, with the downside of having to load about 64B per pass per frame.

Whilst I am leaning towards option 1, I am no expert and kinda new to the field. Knowing I don't think I'll have more than 100 lights, what's the option you'd choose? Any trade off/aspect I am missing?

EDIT: If there's no much difference, I already have all the code ready for option 1, so that's another factor that lead me towards it. However, to be honest, I am more than happy to refactor if it means an advantage.


  • \$\begingroup\$ 64KB is quite a bit...I'm assuming that was just exaggeration :) Anyway, I'd probably go with #2. If there isn't much data per light then I'd go with the simplest method first. I think that other optimisations such as light volumes etc are potentially more significant, but see if it is a performance issue first. \$\endgroup\$ – parar Oct 12 '14 at 9:44
  • 1
    \$\begingroup\$ Oops pardon, 64B. The thing is, and I'll update the Q, is that with option 1 I need less refactoring of the code :\ Is there another pro other than being it simpler? \$\endgroup\$ – gufranc Oct 12 '14 at 9:52
  • 1
    \$\begingroup\$ No, I wouldn't really worry about it in that case. I made my comment from the point of view of you spending more time to achieve option #1. Either is fine. Good luck. \$\endgroup\$ – parar Oct 12 '14 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.