Re: [PATCH 1/5] wined3d: Add a function for allocating aligned resource memory (try 2)
On 20 August 2013 12:07, Stefan Dösinger <stefan(a)codeweavers.com> wrote:
+void *wined3d_alloc_resource_mem(SIZE_T size) +{ + void **p; + SIZE_T align = RESOURCE_ALIGNMENT - 1 + sizeof(*p); + void *mem; + + if (!(mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + align))) + return NULL; + + p = (void **)(((ULONG_PTR)mem + align) & ~(RESOURCE_ALIGNMENT - 1)) - 1; + *p = mem; + + return ++p; +}
I think this should either be called wined3d_resource_allocate_sysmem() and live in resource.c, or accept any np2 alignment and be called something along the lines of wined3d_memalign(). The former probably makes the most sense at this point. Somewhat related, I don't think there's really a reason to have both "allocatedMemory" and "heap_memory" anymore. It should probably just be called "sysmem". That's a cleanup that doesn't necessarily belong in this patch though.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 2013-08-20 13:12, schrieb Henri Verbeet:
I think this should either be called wined3d_resource_allocate_sysmem() and live in resource.c, or accept any np2 alignment and be called something along the lines of wined3d_memalign(). The former probably makes the most sense at this point. Ok.
Somewhat related, I don't think there's really a reason to have both "allocatedMemory" and "heap_memory" anymore. It should probably just be called "sysmem". That's a cleanup that doesn't necessarily belong in this patch though. Surfaces can still have DIBs. We're also assigning memory returned by glMapBuffer[Range] to resource.allocatedMemory, although that should probably be changed. The main problem with the latter is that buffers can be mapped multiple times.
Stefan -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJSE1AZAAoJEN0/YqbEcdMwgVYP/irliNpSGEvrH/kIwQHrVD7U Xq0umCSvvZm1K2V1FysG/27L7FB1GNQaD/mMH9mTIKVUUKrC+CciTnNqi42ki1I9 PtdfqRemQ7e/+GoAyfNwP7coIuRKbBH5ZvTVPRvy0rNHW9IEUwr7mWOBbE2NZgeJ eBoHIjwoKCw7oeWV8CYbjhINeJlYoOAva2pAFE/d0D629mielIRdKIc4oc0fa+oD f9LPKOe4NTPP/3Xu87PVg5QfnlpZu78h+WmTNJRwCi8GdzXKL6zTPeKFGOn9/+5T 6i/i7oYxw84R1R13Vv2BxgHoqkC93CUofDKGPGViGG/cxr5q22+VnHScWp2YrEGN 7Fjey+6TIeTd+h4urxNhNdfDerigIKMTTl4yBVtL9VNagxv2E1ow2m08NeaUF+9J /5MHq5cWjRi+34V2mD2N1sU6LcwCCVPTq/xL7lYLgHWYL7LTAkQau113nzgrwrT9 EVieN5od56oyCdzmQFqX3z7IBSZ9l/kirMjcGQeFnD4eaF1v2uE+/73X955HgbqW 3pjqXEEPsPLXllh5hnm86Bt5XbbSrY42Gx4o5X4uWn/OSt6oZctoh3mXTxgW7eIQ qBcFR4i2WIvk++ZM6cSNkKHbUNXR1DEb5YUo2NtiU4y3WTDg6qA3kKC+Wf1vQS69 aFF9hb7e9dr4BCCnt66k =ecTB -----END PGP SIGNATURE-----
On 20 August 2013 13:16, Stefan Dösinger <stefan(a)codeweavers.com> wrote:
Am 2013-08-20 13:12, schrieb Henri Verbeet:
Somewhat related, I don't think there's really a reason to have both "allocatedMemory" and "heap_memory" anymore. It should probably just be called "sysmem". That's a cleanup that doesn't necessarily belong in this patch though. Surfaces can still have DIBs. We're also assigning memory returned by glMapBuffer[Range] to resource.allocatedMemory,
Yeah, but you should be able to tell what kind of memory "sysmem" is from the resource flags, you don't need the extra pointer for that.
participants (2)
-
Henri Verbeet -
Stefan Dösinger