Mesa (main): i965: Write a custom allocator for the intel memobj struct

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 29 13:14:03 UTC 2021


Module: Mesa
Branch: main
Commit: 9375f62a54c9e2e5ec79e544116dc1117113019d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9375f62a54c9e2e5ec79e544116dc1117113019d

Author: Rohan Garg <rohan.garg at collabora.com>
Date:   Tue Jul 27 12:32:24 2021 +0200

i965: Write a custom allocator for the intel memobj struct

This helps ensure we're not doing out of bounds access later.

Signed-off-by: Rohan Garg <rohan.garg at collabora.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12075>

---

 src/mesa/drivers/dri/i965/brw_context.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 0d4c8317ea0..097dd9cb1dc 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -139,6 +139,17 @@ brw_set_background_context(struct gl_context *ctx,
    backgroundCallable->setBackgroundContext(driContext->loaderPrivate);
 }
 
+static struct gl_memory_object *
+brw_new_memoryobj(struct gl_context *ctx, GLuint name)
+{
+   struct brw_memory_object *memory_object = CALLOC_STRUCT(brw_memory_object);
+   if (!memory_object)
+      return NULL;
+
+   _mesa_initialize_memory_object(ctx, &memory_object->Base, name);
+   return &memory_object->Base;
+}
+
 static void
 brw_delete_memoryobj(struct gl_context *ctx, struct gl_memory_object *memObj)
 {
@@ -441,6 +452,7 @@ brw_init_driver_functions(struct brw_context *brw,
 
    functions->SetBackgroundContext = brw_set_background_context;
 
+   functions->NewMemoryObject = brw_new_memoryobj;
    functions->DeleteMemoryObject = brw_delete_memoryobj;
    functions->ImportMemoryObjectFd = brw_import_memoryobj_fd;
    functions->GetDeviceUuid = brw_get_device_uuid;



More information about the mesa-commit mailing list