1 #include "main/imports.h"
2 #include "main/mtypes.h"
4 #include "main/externalobjects.h"
6 #include "st_context.h"
7 #include "st_cb_memoryobjects.h"
9 #include "state_tracker/drm_driver.h"
10 #include "pipe/p_context.h"
11 #include "pipe/p_screen.h"
13 static struct gl_memory_object
*
14 st_memoryobj_alloc(struct gl_context
*ctx
, GLuint name
)
16 struct st_memory_object
*st_obj
= ST_CALLOC_STRUCT(st_memory_object
);
20 _mesa_initialize_memory_object(ctx
, &st_obj
->Base
, name
);
25 st_memoryobj_free(struct gl_context
*ctx
,
26 struct gl_memory_object
*obj
)
28 _mesa_delete_memory_object(ctx
, obj
);
33 st_import_memoryobj_fd(struct gl_context
*ctx
,
34 struct gl_memory_object
*obj
,
38 struct st_memory_object
*st_obj
= st_memory_object(obj
);
39 struct st_context
*st
= st_context(ctx
);
40 struct pipe_context
*pipe
= st
->pipe
;
41 struct pipe_screen
*screen
= pipe
->screen
;
42 struct winsys_handle whandle
;
44 whandle
.type
= DRM_API_HANDLE_TYPE_FD
;
50 st_obj
->memory
= screen
->memobj_create_from_handle(screen
,
54 /* We own fd, but we no longer need it. So get rid of it */
59 st_init_memoryobject_functions(struct dd_function_table
*functions
)
61 functions
->NewMemoryObject
= st_memoryobj_alloc
;
62 functions
->DeleteMemoryObject
= st_memoryobj_free
;
63 functions
->ImportMemoryObjectFd
= st_import_memoryobj_fd
;