[Mesa-dev] [PATCH 14/17] Modified i915 intel_bufferobj_data to use _mesa_align_malloc instead of malloc.
Chris Forbes
chrisf at ijw.co.nz
Sun Nov 24 23:17:38 PST 2013
I'm not convinced that just using _mesa_align_malloc() is sufficient
here. Issue 2 from the ARB_map_buffer_alignment spec says:
2) What alignment should be used for MapBufferRange when <offset> is
non-zero?
RESOLVED: The pointer returned should be consistent with the base of the
buffer being aligned. For example, if a buffer was mapped with an
<offset> of 24 bytes on an implementation with a
MIN_MAP_BUFFER_ALIGNMENT of 64, the value of the pointer returned
would have a value of the form 64*<N>+24 for some integer <N>.
Cc'ing Ian, since I assume this is based on his instructions.
-- Chris
On Mon, Nov 25, 2013 at 6:36 PM, Siavash Eliasi <siavashserver at gmail.com> wrote:
> ---
> src/mesa/drivers/dri/i915/intel_buffer_objects.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
> index bc58c70..4fbf954 100644
> --- a/src/mesa/drivers/dri/i915/intel_buffer_objects.c
> +++ b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
> @@ -137,7 +137,7 @@ intel_bufferobj_data(struct gl_context * ctx,
> * contents anyway.
> */
> if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
> - intel_obj->sys_buffer = malloc(size);
> + intel_obj->sys_buffer = _mesa_align_malloc(size, ctx->Const.MinMapBufferAlignment);
> if (intel_obj->sys_buffer != NULL) {
> if (data != NULL)
> memcpy(intel_obj->sys_buffer, data, size);
> @@ -337,7 +337,7 @@ intel_bufferobj_map_range(struct gl_context * ctx,
> if ((access & GL_MAP_INVALIDATE_RANGE_BIT) &&
> drm_intel_bo_busy(intel_obj->buffer)) {
> if (access & GL_MAP_FLUSH_EXPLICIT_BIT) {
> - intel_obj->range_map_buffer = malloc(length);
> + intel_obj->range_map_buffer = _mesa_align_malloc(length, ctx->Const.MinMapBufferAlignment);
> obj->Pointer = intel_obj->range_map_buffer;
> } else {
> intel_obj->range_map_bo = drm_intel_bo_alloc(intel->bufmgr,
> --
> 1.8.4.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list