Avatar

graphicsguy

graphicsguy@programming.dev
Joined
1 posts • 13 comments
Direct message

Also if you branch on a GPU, the compiler has to reserve enough registers to walk through both branches (handwavey), which means lower occupancy.

Often you have no choice, or removing the branch leaves you with just as much code so it’s irrelevant. But sometimes it matters. If you know that a particular draw call will always use one side of the branch but not the other, a typical optimization is to compile a separate version of the shader that removes the unused branch and saves on registers

permalink
report
parent
reply

Pointers also allow you to do fun and dangerous things like casting between types!

For example, if you’re implementing your own memory allocator, at the base level your allocator only really cares about how many bytes are being requested (along with alignment, offset, other things) so you’d probably just implement it to return a char*, u8*, or void* pointing to the blob of memory you allocated with new, malloc, or whatever scheme you’ve cooked up. The calling code or higher level allocator code could then cast it to the actual type

permalink
report
reply

RenderDoc is made by one person. It’s used by every graphics programmer. It’s free, open source, faster + better than anything else. I love it.

permalink
report
reply