systemshock icon indicating copy to clipboard operation
systemshock copied to clipboard

Hashing OpenGL textures using pointers

Open donnierussellii opened this issue 6 years ago • 3 comments

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 avatar Aug 19 '19 02:08 donnierussellii

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

donnierussellii avatar Aug 20 '19 12:08 donnierussellii

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

Interrupt avatar Dec 04 '19 18:12 Interrupt

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.

donnierussellii avatar Dec 04 '19 21:12 donnierussellii