[Mesa-dev] [PATCH 6/7] i965: Don't use PREAD for glGetBufferSubData().

Chris Wilson chris at chris-wilson.co.uk
Thu Jul 6 11:21:28 UTC 2017


Quoting Kenneth Graunke (2017-07-05 21:56:53)
> diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> index a9ac29a6a81..2b0f7b9a698 100644
> --- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> +++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> @@ -289,7 +289,10 @@ brw_get_buffer_subdata(struct gl_context *ctx,
>     if (brw_batch_references(&brw->batch, intel_obj->buffer)) {
>        intel_batchbuffer_flush(brw);
>     }
> -   brw_bo_get_subdata(intel_obj->buffer, offset, size, data);
> +
> +   void *map = brw_bo_map(brw, intel_obj->buffer, MAP_READ);

Be paranoid and wrap this in a if (map). Data pointer is provided by the
user? otherwise you probably want to memset it on failure.

> +   memcpy(data, map + offset, size);
> +   brw_bo_unmap(intel_obj->buffer);
>  
>     mark_buffer_inactive(intel_obj);
>  }


More information about the mesa-dev mailing list