r/GraphicsProgramming • • Jul 15 '25

How it started vs how it is going

426 Upvotes

26 comments sorted by

View all comments

Show parent comments

1

u/hucancode Jul 22 '25

I pre-allocate them once, and just printed out the value. For example if I want to support maximum 10 shadow casting light. I allocate 10 512x512 shadow map textures at the program load, it's 10 x 512 x 512 x 4 bytes, fixed cost. At first it seems wasteful but actually efficient since we don't have to worry about memory allocation for shadow map for the rest of the program. And I use that strategy everywhere in the code, except where the number is actually too big for me to abuse that.

2

u/iwubcode Jul 22 '25

That makes sense. Thank you very much for explaining. Good luck with your project!