1b8e80941Smrg/*
2b8e80941Smrg * Mesa 3-D graphics library
3b8e80941Smrg *
4b8e80941Smrg * Copyright (C) 2017 Red Hat.
5b8e80941Smrg *
6b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
7b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
8b8e80941Smrg * to deal in the Software without restriction, including without limitation
9b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
11b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
12b8e80941Smrg *
13b8e80941Smrg * The above copyright notice and this permission notice shall be included
14b8e80941Smrg * in all copies or substantial portions of the Software.
15b8e80941Smrg *
16b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22b8e80941Smrg * DEALINGS IN THE SOFTWARE.
23b8e80941Smrg *
24b8e80941Smrg * Authors: Dave Airlie <airlied@gmail.com>
25b8e80941Smrg * 	    Andres Rodriguez <andresx7@gmail.com>
26b8e80941Smrg */
27b8e80941Smrg
28b8e80941Smrg/**
29b8e80941Smrg * \file externalobjects.h
30b8e80941Smrg *
31b8e80941Smrg * Declarations of functions related to the API interop extensions.
32b8e80941Smrg */
33b8e80941Smrg
34b8e80941Smrg#ifndef EXTERNALOBJECTS_H
35b8e80941Smrg#define EXTERNALOBJECTS_H
36b8e80941Smrg
37b8e80941Smrg#include "glheader.h"
38b8e80941Smrg#include "hash.h"
39b8e80941Smrg
40b8e80941Smrgstatic inline struct gl_memory_object *
41b8e80941Smrg_mesa_lookup_memory_object(struct gl_context *ctx, GLuint memory)
42b8e80941Smrg{
43b8e80941Smrg   if (!memory)
44b8e80941Smrg      return NULL;
45b8e80941Smrg
46b8e80941Smrg   return (struct gl_memory_object *)
47b8e80941Smrg      _mesa_HashLookup(ctx->Shared->MemoryObjects, memory);
48b8e80941Smrg}
49b8e80941Smrg
50b8e80941Smrgstatic inline struct gl_memory_object *
51b8e80941Smrg_mesa_lookup_memory_object_locked(struct gl_context *ctx, GLuint memory)
52b8e80941Smrg{
53b8e80941Smrg   if (!memory)
54b8e80941Smrg      return NULL;
55b8e80941Smrg
56b8e80941Smrg   return (struct gl_memory_object *)
57b8e80941Smrg      _mesa_HashLookupLocked(ctx->Shared->MemoryObjects, memory);
58b8e80941Smrg}
59b8e80941Smrg
60b8e80941Smrgstatic inline struct gl_semaphore_object *
61b8e80941Smrg_mesa_lookup_semaphore_object(struct gl_context *ctx, GLuint semaphore)
62b8e80941Smrg{
63b8e80941Smrg   if (!semaphore)
64b8e80941Smrg      return NULL;
65b8e80941Smrg
66b8e80941Smrg   return (struct gl_semaphore_object *)
67b8e80941Smrg      _mesa_HashLookup(ctx->Shared->SemaphoreObjects, semaphore);
68b8e80941Smrg}
69b8e80941Smrg
70b8e80941Smrgstatic inline struct gl_semaphore_object *
71b8e80941Smrg_mesa_lookup_semaphore_object_locked(struct gl_context *ctx, GLuint semaphore)
72b8e80941Smrg{
73b8e80941Smrg   if (!semaphore)
74b8e80941Smrg      return NULL;
75b8e80941Smrg
76b8e80941Smrg   return (struct gl_semaphore_object *)
77b8e80941Smrg      _mesa_HashLookupLocked(ctx->Shared->SemaphoreObjects, semaphore);
78b8e80941Smrg}
79b8e80941Smrg
80b8e80941Smrgextern void
81b8e80941Smrg_mesa_init_memory_object_functions(struct dd_function_table *driver);
82b8e80941Smrg
83b8e80941Smrgextern void
84b8e80941Smrg_mesa_initialize_memory_object(struct gl_context *ctx,
85b8e80941Smrg                               struct gl_memory_object *obj,
86b8e80941Smrg                               GLuint name);
87b8e80941Smrgextern void
88b8e80941Smrg_mesa_delete_memory_object(struct gl_context *ctx,
89b8e80941Smrg                           struct gl_memory_object *semObj);
90b8e80941Smrg
91b8e80941Smrgextern void
92b8e80941Smrg_mesa_initialize_semaphore_object(struct gl_context *ctx,
93b8e80941Smrg                                  struct gl_semaphore_object *obj,
94b8e80941Smrg                                  GLuint name);
95b8e80941Smrgextern void
96b8e80941Smrg_mesa_delete_semaphore_object(struct gl_context *ctx,
97b8e80941Smrg                              struct gl_semaphore_object *semObj);
98b8e80941Smrg
99b8e80941Smrgextern void GLAPIENTRY
100b8e80941Smrg_mesa_DeleteMemoryObjectsEXT(GLsizei n, const GLuint *memoryObjects);
101b8e80941Smrg
102b8e80941Smrgextern GLboolean GLAPIENTRY
103b8e80941Smrg_mesa_IsMemoryObjectEXT(GLuint memoryObject);
104b8e80941Smrg
105b8e80941Smrgextern void GLAPIENTRY
106b8e80941Smrg_mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects);
107b8e80941Smrg
108b8e80941Smrgextern void GLAPIENTRY
109b8e80941Smrg_mesa_MemoryObjectParameterivEXT(GLuint memoryObject,
110b8e80941Smrg                                 GLenum pname,
111b8e80941Smrg                                 const GLint *params);
112b8e80941Smrg
113b8e80941Smrgextern void GLAPIENTRY
114b8e80941Smrg_mesa_GetMemoryObjectParameterivEXT(GLuint memoryObject,
115b8e80941Smrg                                    GLenum pname,
116b8e80941Smrg                                    GLint *params);
117b8e80941Smrg
118b8e80941Smrgextern void GLAPIENTRY
119b8e80941Smrg_mesa_TexStorageMem2DEXT(GLenum target,
120b8e80941Smrg                         GLsizei levels,
121b8e80941Smrg                         GLenum internalFormat,
122b8e80941Smrg                         GLsizei width,
123b8e80941Smrg                         GLsizei height,
124b8e80941Smrg                         GLuint memory,
125b8e80941Smrg                         GLuint64 offset);
126b8e80941Smrg
127b8e80941Smrgextern void GLAPIENTRY
128b8e80941Smrg_mesa_TexStorageMem2DMultisampleEXT(GLenum target,
129b8e80941Smrg                                    GLsizei samples,
130b8e80941Smrg                                    GLenum internalFormat,
131b8e80941Smrg                                    GLsizei width,
132b8e80941Smrg                                    GLsizei height,
133b8e80941Smrg                                    GLboolean fixedSampleLocations,
134b8e80941Smrg                                    GLuint memory,
135b8e80941Smrg                                    GLuint64 offset);
136b8e80941Smrg
137b8e80941Smrgextern void GLAPIENTRY
138b8e80941Smrg_mesa_TexStorageMem3DEXT(GLenum target,
139b8e80941Smrg                         GLsizei levels,
140b8e80941Smrg                         GLenum internalFormat,
141b8e80941Smrg                         GLsizei width,
142b8e80941Smrg                         GLsizei height,
143b8e80941Smrg                         GLsizei depth,
144b8e80941Smrg                         GLuint memory,
145b8e80941Smrg                         GLuint64 offset);
146b8e80941Smrg
147b8e80941Smrgextern void GLAPIENTRY
148b8e80941Smrg_mesa_TexStorageMem3DMultisampleEXT(GLenum target,
149b8e80941Smrg                                    GLsizei samples,
150b8e80941Smrg                                    GLenum internalFormat,
151b8e80941Smrg                                    GLsizei width,
152b8e80941Smrg                                    GLsizei height,
153b8e80941Smrg                                    GLsizei depth,
154b8e80941Smrg                                    GLboolean fixedSampleLocations,
155b8e80941Smrg                                    GLuint memory,
156b8e80941Smrg                                    GLuint64 offset);
157b8e80941Smrg
158b8e80941Smrgextern void GLAPIENTRY
159b8e80941Smrg_mesa_TextureStorageMem2DEXT(GLuint texture,
160b8e80941Smrg                             GLsizei levels,
161b8e80941Smrg                             GLenum internalFormat,
162b8e80941Smrg                             GLsizei width,
163b8e80941Smrg                             GLsizei height,
164b8e80941Smrg                             GLuint memory,
165b8e80941Smrg                             GLuint64 offset);
166b8e80941Smrg
167b8e80941Smrgextern void GLAPIENTRY
168b8e80941Smrg_mesa_TextureStorageMem2DMultisampleEXT(GLuint texture,
169b8e80941Smrg                                        GLsizei samples,
170b8e80941Smrg                                        GLenum internalFormat,
171b8e80941Smrg                                        GLsizei width,
172b8e80941Smrg                                        GLsizei height,
173b8e80941Smrg                                        GLboolean fixedSampleLocations,
174b8e80941Smrg                                        GLuint memory,
175b8e80941Smrg                                        GLuint64 offset);
176b8e80941Smrg
177b8e80941Smrgextern void GLAPIENTRY
178b8e80941Smrg_mesa_TextureStorageMem3DEXT(GLuint texture,
179b8e80941Smrg                             GLsizei levels,
180b8e80941Smrg                             GLenum internalFormat,
181b8e80941Smrg                             GLsizei width,
182b8e80941Smrg                             GLsizei height,
183b8e80941Smrg                             GLsizei depth,
184b8e80941Smrg                             GLuint memory,
185b8e80941Smrg                             GLuint64 offset);
186b8e80941Smrg
187b8e80941Smrgextern void GLAPIENTRY
188b8e80941Smrg_mesa_TextureStorageMem3DMultisampleEXT(GLuint texture,
189b8e80941Smrg                                        GLsizei samples,
190b8e80941Smrg                                        GLenum internalFormat,
191b8e80941Smrg                                        GLsizei width,
192b8e80941Smrg                                        GLsizei height,
193b8e80941Smrg                                        GLsizei depth,
194b8e80941Smrg                                        GLboolean fixedSampleLocations,
195b8e80941Smrg                                        GLuint memory,
196b8e80941Smrg                                        GLuint64 offset);
197b8e80941Smrg
198b8e80941Smrgextern void GLAPIENTRY
199b8e80941Smrg_mesa_TexStorageMem1DEXT(GLenum target,
200b8e80941Smrg                         GLsizei levels,
201b8e80941Smrg                         GLenum internalFormat,
202b8e80941Smrg                         GLsizei width,
203b8e80941Smrg                         GLuint memory,
204b8e80941Smrg                         GLuint64 offset);
205b8e80941Smrg
206b8e80941Smrgextern void GLAPIENTRY
207b8e80941Smrg_mesa_TextureStorageMem1DEXT(GLuint texture,
208b8e80941Smrg                             GLsizei levels,
209b8e80941Smrg                             GLenum internalFormat,
210b8e80941Smrg                             GLsizei width,
211b8e80941Smrg                             GLuint memory,
212b8e80941Smrg                             GLuint64 offset);
213b8e80941Smrg
214b8e80941Smrgextern void GLAPIENTRY
215b8e80941Smrg_mesa_GenSemaphoresEXT(GLsizei n, GLuint *semaphores);
216b8e80941Smrg
217b8e80941Smrgextern void GLAPIENTRY
218b8e80941Smrg_mesa_DeleteSemaphoresEXT(GLsizei n, const GLuint *semaphores);
219b8e80941Smrg
220b8e80941Smrgextern GLboolean GLAPIENTRY
221b8e80941Smrg_mesa_IsSemaphoreEXT(GLuint semaphore);
222b8e80941Smrg
223b8e80941Smrgextern void GLAPIENTRY
224b8e80941Smrg_mesa_SemaphoreParameterui64vEXT(GLuint semaphore,
225b8e80941Smrg                                 GLenum pname,
226b8e80941Smrg                                 const GLuint64 *params);
227b8e80941Smrg
228b8e80941Smrgextern void GLAPIENTRY
229b8e80941Smrg_mesa_GetSemaphoreParameterui64vEXT(GLuint semaphore,
230b8e80941Smrg                                    GLenum pname,
231b8e80941Smrg                                    GLuint64 *params);
232b8e80941Smrg
233b8e80941Smrgextern void GLAPIENTRY
234b8e80941Smrg_mesa_WaitSemaphoreEXT(GLuint semaphore,
235b8e80941Smrg                       GLuint numBufferBarriers,
236b8e80941Smrg                       const GLuint *buffers,
237b8e80941Smrg                       GLuint numTextureBarriers,
238b8e80941Smrg                       const GLuint *textures,
239b8e80941Smrg                       const GLenum *srcLayouts);
240b8e80941Smrg
241b8e80941Smrgextern void GLAPIENTRY
242b8e80941Smrg_mesa_SignalSemaphoreEXT(GLuint semaphore,
243b8e80941Smrg                         GLuint numBufferBarriers,
244b8e80941Smrg                         const GLuint *buffers,
245b8e80941Smrg                         GLuint numTextureBarriers,
246b8e80941Smrg                         const GLuint *textures,
247b8e80941Smrg                         const GLenum *dstLayouts);
248b8e80941Smrg
249b8e80941Smrgextern void GLAPIENTRY
250b8e80941Smrg_mesa_ImportMemoryFdEXT(GLuint memory,
251b8e80941Smrg                        GLuint64 size,
252b8e80941Smrg                        GLenum handleType,
253b8e80941Smrg                        GLint fd);
254b8e80941Smrg
255b8e80941Smrgextern void GLAPIENTRY
256b8e80941Smrg_mesa_ImportSemaphoreFdEXT(GLuint semaphore,
257b8e80941Smrg                           GLenum handleType,
258b8e80941Smrg                           GLint fd);
259b8e80941Smrg
260b8e80941Smrg#endif
261