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 <airlied@gmail.com>
25 * 	    Andres Rodriguez <andresx7@gmail.com>
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 "glheader.h"
38#include "hash.h"
39
40static inline struct gl_memory_object *
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
50static inline struct gl_memory_object *
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
60static inline struct gl_semaphore_object *
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
70static inline struct gl_semaphore_object *
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
80extern void
81_mesa_delete_memory_object(struct gl_context *ctx,
82                           struct gl_memory_object *semObj);
83
84extern void
85_mesa_delete_semaphore_object(struct gl_context *ctx,
86                              struct gl_semaphore_object *semObj);
87
88#endif
89