-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2013-08-19 12:29, schrieb Henri Verbeet:
I don't think this is a good idea. How about something like the following? The corresponding free function would be trivial.
I guess this works for the purposes of this patchset. However, in my command stream patches I am using a structure similar to this to cache allocated blocks of memory to handle WINED3D_MAP_DISCARD buffer maps. In that case the structure had additional size information and a struct list entry.
I guess in theory any kind of payload could be added to your implementation, but growing this larger than RESOURCE_ALIGNMENT(=16) bytes moots the point I guess. I'm not yet sure though if my cache is an actual improvement over just freeing and allocating new blocks of memory.
The other unknown is that some ddraw games write past the allocated surface memory. The extra 16 bytes took care of this, and before we aligned the memory we just allocated 4 extra bytes. I don't know which games are affected by this (it was from a comment in old ddraw), and I don't know if the problem only happened if the memory block wasn't properly aligned. Your code and mine differ when HeapAlloc happens to return an aligned pointer.