Interrupt / systemshock

Shockolate - A minimalist and cross platform System Shock source port.
GNU General Public License v3.0
802 stars 62 forks source link

Hashing OpenGL textures using pointers #321

Open donnierussellii opened 4 years ago

donnierussellii commented 4 years ago

In my PR #264 I shifted the bmp width and height (16 bits each) onto the bmp ptr (32), making a 64-bit hash to prevent a bug with some textures having the same ptr but a different size. I was getting garbage pixels on invisible mutants.

This fix was only a stopgap until we moved to 64 bits. So, can we use a 96-bit hash here? or is there something better?

donnierussellii commented 4 years ago

My idea is to use the pointer to the last byte of the bmp, keeping the hash at 64 bits.

Interrupt commented 4 years ago

Would this lock us into only supporting OpenGL on 64 bit machines? I'd like to avoid that issue if at all possible.

donnierussellii commented 4 years ago

I think we could just use a 64-bit hash for all platforms (on 32-bit cpus, slower, though), but if it's a 32-bit pointer simply cast it to a 64-bit value, with the upper bits unused. Up to date compilers should support uint64_t or unsigned long long.