xref: /aosp_15_r20/external/mesa3d/src/mesa/main/externalobjects.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 2017 Red Hat.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  *
24  * Authors: Dave Airlie <[email protected]>
25  * 	    Andres Rodriguez <[email protected]>
26  */
27 
28 /**
29  * \file externalobjects.h
30  *
31  * Declarations of functions related to the API interop extensions.
32  */
33 
34 #ifndef EXTERNALOBJECTS_H
35 #define EXTERNALOBJECTS_H
36 
37 #include "util/glheader.h"
38 #include "hash.h"
39 
40 static inline struct gl_memory_object *
_mesa_lookup_memory_object(struct gl_context * ctx,GLuint memory)41 _mesa_lookup_memory_object(struct gl_context *ctx, GLuint memory)
42 {
43    if (!memory)
44       return NULL;
45 
46    return (struct gl_memory_object *)
47       _mesa_HashLookup(&ctx->Shared->MemoryObjects, memory);
48 }
49 
50 static inline struct gl_memory_object *
_mesa_lookup_memory_object_locked(struct gl_context * ctx,GLuint memory)51 _mesa_lookup_memory_object_locked(struct gl_context *ctx, GLuint memory)
52 {
53    if (!memory)
54       return NULL;
55 
56    return (struct gl_memory_object *)
57       _mesa_HashLookupLocked(&ctx->Shared->MemoryObjects, memory);
58 }
59 
60 static inline struct gl_semaphore_object *
_mesa_lookup_semaphore_object(struct gl_context * ctx,GLuint semaphore)61 _mesa_lookup_semaphore_object(struct gl_context *ctx, GLuint semaphore)
62 {
63    if (!semaphore)
64       return NULL;
65 
66    return (struct gl_semaphore_object *)
67       _mesa_HashLookup(&ctx->Shared->SemaphoreObjects, semaphore);
68 }
69 
70 static inline struct gl_semaphore_object *
_mesa_lookup_semaphore_object_locked(struct gl_context * ctx,GLuint semaphore)71 _mesa_lookup_semaphore_object_locked(struct gl_context *ctx, GLuint semaphore)
72 {
73    if (!semaphore)
74       return NULL;
75 
76    return (struct gl_semaphore_object *)
77       _mesa_HashLookupLocked(&ctx->Shared->SemaphoreObjects, semaphore);
78 }
79 
80 extern void
81 _mesa_delete_memory_object(struct gl_context *ctx,
82                            struct gl_memory_object *semObj);
83 
84 extern void
85 _mesa_delete_semaphore_object(struct gl_context *ctx,
86                               struct gl_semaphore_object *semObj);
87 
88 #endif
89