2 * Copyright © 2016 Red Hat.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
26 #include "bufferobj.h"
28 #include "externalobjects.h"
31 #include "glformats.h"
32 #include "texstorage.h"
33 #include "util/u_memory.h"
36 * Allocate and initialize a new memory object. But don't put it into the
37 * memory object hash table.
39 * Called via ctx->Driver.NewMemoryObject, unless overridden by a device
42 * \return pointer to new memory object.
44 static struct gl_memory_object
*
45 _mesa_new_memory_object(struct gl_context
*ctx
, GLuint name
)
47 struct gl_memory_object
*obj
= MALLOC_STRUCT(gl_memory_object
);
51 _mesa_initialize_memory_object(ctx
, obj
, name
);
56 * Delete a memory object. Called via ctx->Driver.DeleteMemory().
57 * Not removed from hash table here.
60 _mesa_delete_memory_object(struct gl_context
*ctx
,
61 struct gl_memory_object
*memObj
)
67 _mesa_init_memory_object_functions(struct dd_function_table
*driver
)
69 driver
->NewMemoryObject
= _mesa_new_memory_object
;
70 driver
->DeleteMemoryObject
= _mesa_delete_memory_object
;
74 * Initialize a buffer object to default values.
77 _mesa_initialize_memory_object(struct gl_context
*ctx
,
78 struct gl_memory_object
*obj
,
81 memset(obj
, 0, sizeof(struct gl_memory_object
));
83 obj
->Dedicated
= GL_FALSE
;
87 _mesa_DeleteMemoryObjectsEXT(GLsizei n
, const GLuint
*memoryObjects
)
89 GET_CURRENT_CONTEXT(ctx
);
91 if (MESA_VERBOSE
& (VERBOSE_API
)) {
92 _mesa_debug(ctx
, "glDeleteMemoryObjectsEXT(%d, %p)\n", n
,
96 if (!ctx
->Extensions
.EXT_memory_object
) {
97 _mesa_error(ctx
, GL_INVALID_OPERATION
,
98 "glDeleteMemoryObjectsEXT(unsupported)");
103 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteMemoryObjectsEXT(n < 0)");
110 _mesa_HashLockMutex(ctx
->Shared
->MemoryObjects
);
111 for (GLint i
= 0; i
< n
; i
++) {
112 if (memoryObjects
[i
] > 0) {
113 struct gl_memory_object
*delObj
114 = _mesa_lookup_memory_object_locked(ctx
, memoryObjects
[i
]);
117 _mesa_HashRemoveLocked(ctx
->Shared
->MemoryObjects
,
119 ctx
->Driver
.DeleteMemoryObject(ctx
, delObj
);
123 _mesa_HashUnlockMutex(ctx
->Shared
->MemoryObjects
);
127 _mesa_IsMemoryObjectEXT(GLuint memoryObject
)
129 GET_CURRENT_CONTEXT(ctx
);
131 if (!ctx
->Extensions
.EXT_memory_object
) {
132 _mesa_error(ctx
, GL_INVALID_OPERATION
,
133 "glIsMemoryObjectEXT(unsupported)");
137 struct gl_memory_object
*obj
=
138 _mesa_lookup_memory_object(ctx
, memoryObject
);
140 return obj
? GL_TRUE
: GL_FALSE
;
144 _mesa_CreateMemoryObjectsEXT(GLsizei n
, GLuint
*memoryObjects
)
146 GET_CURRENT_CONTEXT(ctx
);
148 const char *func
= "glCreateMemoryObjectsEXT";
150 if (MESA_VERBOSE
& (VERBOSE_API
))
151 _mesa_debug(ctx
, "%s(%d, %p)", func
, n
, memoryObjects
);
153 if (!ctx
->Extensions
.EXT_memory_object
) {
154 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
159 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n < 0)", func
);
166 _mesa_HashLockMutex(ctx
->Shared
->MemoryObjects
);
167 GLuint first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->MemoryObjects
, n
);
169 for (GLsizei i
= 0; i
< n
; i
++) {
170 struct gl_memory_object
*memObj
;
172 memoryObjects
[i
] = first
+ i
;
174 /* allocate memory object */
175 memObj
= ctx
->Driver
.NewMemoryObject(ctx
, memoryObjects
[i
]);
177 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s()", func
);
178 _mesa_HashUnlockMutex(ctx
->Shared
->MemoryObjects
);
182 /* insert into hash table */
183 _mesa_HashInsertLocked(ctx
->Shared
->MemoryObjects
,
189 _mesa_HashUnlockMutex(ctx
->Shared
->MemoryObjects
);
193 _mesa_MemoryObjectParameterivEXT(GLuint memoryObject
,
197 GET_CURRENT_CONTEXT(ctx
);
198 struct gl_memory_object
*memObj
;
200 const char *func
= "glMemoryObjectParameterivEXT";
202 if (!ctx
->Extensions
.EXT_memory_object
) {
203 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
207 memObj
= _mesa_lookup_memory_object(ctx
, memoryObject
);
211 if (memObj
->Immutable
) {
212 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(memoryObject is immutable", func
);
217 case GL_DEDICATED_MEMORY_OBJECT_EXT
:
218 memObj
->Dedicated
= (GLboolean
) params
[0];
220 case GL_PROTECTED_MEMORY_OBJECT_EXT
:
221 /* EXT_protected_textures not supported */
229 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", func
, pname
);
233 _mesa_GetMemoryObjectParameterivEXT(GLuint memoryObject
,
237 GET_CURRENT_CONTEXT(ctx
);
238 struct gl_memory_object
*memObj
;
240 const char *func
= "glMemoryObjectParameterivEXT";
242 if (!ctx
->Extensions
.EXT_memory_object
) {
243 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
247 memObj
= _mesa_lookup_memory_object(ctx
, memoryObject
);
252 case GL_DEDICATED_MEMORY_OBJECT_EXT
:
253 *params
= (GLint
) memObj
->Dedicated
;
255 case GL_PROTECTED_MEMORY_OBJECT_EXT
:
256 /* EXT_protected_textures not supported */
264 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", func
, pname
);
267 static struct gl_memory_object
*
268 lookup_memory_object_err(struct gl_context
*ctx
, unsigned memory
,
272 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(memory=0)", func
);
276 struct gl_memory_object
*memObj
= _mesa_lookup_memory_object(ctx
, memory
);
280 if (!memObj
->Immutable
) {
281 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no associated memory)",
290 * Helper used by _mesa_TexStorageMem1/2/3DEXT().
293 texstorage_memory(GLuint dims
, GLenum target
, GLsizei levels
,
294 GLenum internalFormat
, GLsizei width
, GLsizei height
,
295 GLsizei depth
, GLuint memory
, GLuint64 offset
,
298 struct gl_texture_object
*texObj
;
299 struct gl_memory_object
*memObj
;
301 GET_CURRENT_CONTEXT(ctx
);
303 if (!ctx
->Extensions
.EXT_memory_object
) {
304 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
308 texObj
= _mesa_get_current_tex_object(ctx
, target
);
312 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
316 _mesa_texture_storage_memory(ctx
, dims
, texObj
, memObj
, target
,
317 levels
, internalFormat
,
318 width
, height
, depth
, offset
, false);
322 texstorage_memory_ms(GLuint dims
, GLenum target
, GLsizei samples
,
323 GLenum internalFormat
, GLsizei width
, GLsizei height
,
324 GLsizei depth
, GLboolean fixedSampleLocations
,
325 GLuint memory
, GLuint64 offset
, const char* func
)
327 struct gl_texture_object
*texObj
;
328 struct gl_memory_object
*memObj
;
330 GET_CURRENT_CONTEXT(ctx
);
332 if (!ctx
->Extensions
.EXT_memory_object
) {
333 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
337 texObj
= _mesa_get_current_tex_object(ctx
, target
);
341 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
345 _mesa_texture_storage_ms_memory(ctx
, dims
, texObj
, memObj
, target
, samples
,
346 internalFormat
, width
, height
, depth
,
347 fixedSampleLocations
, offset
, func
);
351 * Helper used by _mesa_TextureStorageMem1/2/3DEXT().
354 texturestorage_memory(GLuint dims
, GLuint texture
, GLsizei levels
,
355 GLenum internalFormat
, GLsizei width
, GLsizei height
,
356 GLsizei depth
, GLuint memory
, GLuint64 offset
,
359 struct gl_texture_object
*texObj
;
360 struct gl_memory_object
*memObj
;
362 GET_CURRENT_CONTEXT(ctx
);
364 if (!ctx
->Extensions
.EXT_memory_object
) {
365 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
369 texObj
= _mesa_lookup_texture(ctx
, texture
);
373 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
377 _mesa_texture_storage_memory(ctx
, dims
, texObj
, memObj
, texObj
->Target
,
378 levels
, internalFormat
,
379 width
, height
, depth
, offset
, true);
383 texturestorage_memory_ms(GLuint dims
, GLuint texture
, GLsizei samples
,
384 GLenum internalFormat
, GLsizei width
, GLsizei height
,
385 GLsizei depth
, GLboolean fixedSampleLocations
,
386 GLuint memory
, GLuint64 offset
, const char* func
)
388 struct gl_texture_object
*texObj
;
389 struct gl_memory_object
*memObj
;
391 GET_CURRENT_CONTEXT(ctx
);
393 if (!ctx
->Extensions
.EXT_memory_object
) {
394 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
398 texObj
= _mesa_lookup_texture(ctx
, texture
);
402 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
406 _mesa_texture_storage_ms_memory(ctx
, dims
, texObj
, memObj
, texObj
->Target
,
407 samples
, internalFormat
, width
, height
,
408 depth
, fixedSampleLocations
, offset
, func
);
412 _mesa_TexStorageMem2DEXT(GLenum target
,
414 GLenum internalFormat
,
420 texstorage_memory(2, target
, levels
, internalFormat
, width
, height
, 1,
421 memory
, offset
, "glTexStorageMem2DEXT");
425 _mesa_TexStorageMem2DMultisampleEXT(GLenum target
,
427 GLenum internalFormat
,
430 GLboolean fixedSampleLocations
,
434 texstorage_memory_ms(2, target
, samples
, internalFormat
, width
, height
, 1,
435 fixedSampleLocations
, memory
, offset
,
436 "glTexStorageMem2DMultisampleEXT");
440 _mesa_TexStorageMem3DEXT(GLenum target
,
442 GLenum internalFormat
,
449 texstorage_memory(3, target
, levels
, internalFormat
, width
, height
, depth
,
450 memory
, offset
, "glTexStorageMem3DEXT");
454 _mesa_TexStorageMem3DMultisampleEXT(GLenum target
,
456 GLenum internalFormat
,
460 GLboolean fixedSampleLocations
,
464 texstorage_memory_ms(3, target
, samples
, internalFormat
, width
, height
,
465 depth
, fixedSampleLocations
, memory
, offset
,
466 "glTexStorageMem3DMultisampleEXT");
470 _mesa_TextureStorageMem2DEXT(GLuint texture
,
472 GLenum internalFormat
,
478 texturestorage_memory(2, texture
, levels
, internalFormat
, width
, height
, 1,
479 memory
, offset
, "glTexureStorageMem2DEXT");
483 _mesa_TextureStorageMem2DMultisampleEXT(GLuint texture
,
485 GLenum internalFormat
,
488 GLboolean fixedSampleLocations
,
492 texturestorage_memory_ms(2, texture
, samples
, internalFormat
, width
, height
,
493 1, fixedSampleLocations
, memory
, offset
,
494 "glTextureStorageMem2DMultisampleEXT");
498 _mesa_TextureStorageMem3DEXT(GLuint texture
,
500 GLenum internalFormat
,
507 texturestorage_memory(3, texture
, levels
, internalFormat
, width
, height
,
508 depth
, memory
, offset
, "glTextureStorageMem3DEXT");
512 _mesa_TextureStorageMem3DMultisampleEXT(GLuint texture
,
514 GLenum internalFormat
,
518 GLboolean fixedSampleLocations
,
522 texturestorage_memory_ms(3, texture
, samples
, internalFormat
, width
, height
,
523 depth
, fixedSampleLocations
, memory
, offset
,
524 "glTextureStorageMem3DMultisampleEXT");
528 _mesa_TexStorageMem1DEXT(GLenum target
,
530 GLenum internalFormat
,
535 texstorage_memory(1, target
, levels
, internalFormat
, width
, 1, 1, memory
,
536 offset
, "glTexStorageMem1DEXT");
540 _mesa_TextureStorageMem1DEXT(GLuint texture
,
542 GLenum internalFormat
,
547 texturestorage_memory(1, texture
, levels
, internalFormat
, width
, 1, 1,
548 memory
, offset
, "glTextureStorageMem1DEXT");
552 * Used as a placeholder for semaphore objects between glGenSemaphoresEXT()
553 * and glImportSemaphoreFdEXT(), so that glIsSemaphoreEXT() can work correctly.
555 static struct gl_semaphore_object DummySemaphoreObject
;
558 * Delete a semaphore object. Called via ctx->Driver.DeleteSemaphore().
559 * Not removed from hash table here.
562 _mesa_delete_semaphore_object(struct gl_context
*ctx
,
563 struct gl_semaphore_object
*semObj
)
565 if (semObj
!= &DummySemaphoreObject
)
570 * Initialize a semaphore object to default values.
573 _mesa_initialize_semaphore_object(struct gl_context
*ctx
,
574 struct gl_semaphore_object
*obj
,
577 memset(obj
, 0, sizeof(struct gl_semaphore_object
));
582 _mesa_GenSemaphoresEXT(GLsizei n
, GLuint
*semaphores
)
584 GET_CURRENT_CONTEXT(ctx
);
586 const char *func
= "glGenSemaphoresEXT";
588 if (MESA_VERBOSE
& (VERBOSE_API
))
589 _mesa_debug(ctx
, "%s(%d, %p)", func
, n
, semaphores
);
591 if (!ctx
->Extensions
.EXT_semaphore
) {
592 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
597 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n < 0)", func
);
604 _mesa_HashLockMutex(ctx
->Shared
->SemaphoreObjects
);
605 GLuint first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SemaphoreObjects
, n
);
607 for (GLsizei i
= 0; i
< n
; i
++) {
608 semaphores
[i
] = first
+ i
;
609 _mesa_HashInsertLocked(ctx
->Shared
->SemaphoreObjects
,
610 semaphores
[i
], &DummySemaphoreObject
);
614 _mesa_HashUnlockMutex(ctx
->Shared
->SemaphoreObjects
);
618 _mesa_DeleteSemaphoresEXT(GLsizei n
, const GLuint
*semaphores
)
620 GET_CURRENT_CONTEXT(ctx
);
622 const char *func
= "glDeleteSemaphoresEXT";
624 if (MESA_VERBOSE
& (VERBOSE_API
)) {
625 _mesa_debug(ctx
, "%s(%d, %p)\n", func
, n
, semaphores
);
628 if (!ctx
->Extensions
.EXT_semaphore
) {
629 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
634 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n < 0)", func
);
641 _mesa_HashLockMutex(ctx
->Shared
->SemaphoreObjects
);
642 for (GLint i
= 0; i
< n
; i
++) {
643 if (semaphores
[i
] > 0) {
644 struct gl_semaphore_object
*delObj
645 = _mesa_lookup_semaphore_object_locked(ctx
, semaphores
[i
]);
648 _mesa_HashRemoveLocked(ctx
->Shared
->SemaphoreObjects
,
650 ctx
->Driver
.DeleteSemaphoreObject(ctx
, delObj
);
654 _mesa_HashUnlockMutex(ctx
->Shared
->SemaphoreObjects
);
658 _mesa_IsSemaphoreEXT(GLuint semaphore
)
660 GET_CURRENT_CONTEXT(ctx
);
662 if (!ctx
->Extensions
.EXT_semaphore
) {
663 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glIsSemaphoreEXT(unsupported)");
667 struct gl_semaphore_object
*obj
=
668 _mesa_lookup_semaphore_object(ctx
, semaphore
);
670 return obj
? GL_TRUE
: GL_FALSE
;
674 * Helper that outputs the correct error status for parameter
675 * calls where no pnames are defined
678 semaphore_parameter_stub(const char* func
, GLenum pname
)
680 GET_CURRENT_CONTEXT(ctx
);
682 if (!ctx
->Extensions
.EXT_semaphore
) {
683 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
687 /* EXT_semaphore and EXT_semaphore_fd define no parameters */
688 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", func
, pname
);
692 _mesa_SemaphoreParameterui64vEXT(GLuint semaphore
,
694 const GLuint64
*params
)
696 const char *func
= "glSemaphoreParameterui64vEXT";
698 semaphore_parameter_stub(func
, pname
);
702 _mesa_GetSemaphoreParameterui64vEXT(GLuint semaphore
,
706 const char *func
= "glGetSemaphoreParameterui64vEXT";
708 semaphore_parameter_stub(func
, pname
);
712 _mesa_WaitSemaphoreEXT(GLuint semaphore
,
713 GLuint numBufferBarriers
,
714 const GLuint
*buffers
,
715 GLuint numTextureBarriers
,
716 const GLuint
*textures
,
717 const GLenum
*srcLayouts
)
719 GET_CURRENT_CONTEXT(ctx
);
720 struct gl_semaphore_object
*semObj
= NULL
;
721 struct gl_buffer_object
**bufObjs
= NULL
;
722 struct gl_texture_object
**texObjs
= NULL
;
724 const char *func
= "glWaitSemaphoreEXT";
726 if (!ctx
->Extensions
.EXT_semaphore
) {
727 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
731 ASSERT_OUTSIDE_BEGIN_END(ctx
);
733 semObj
= _mesa_lookup_semaphore_object(ctx
, semaphore
);
737 FLUSH_VERTICES(ctx
, 0);
739 bufObjs
= malloc(sizeof(struct gl_buffer_object
*) * numBufferBarriers
);
741 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s(numBufferBarriers=%u)",
742 func
, numBufferBarriers
);
746 for (unsigned i
= 0; i
< numBufferBarriers
; i
++) {
747 bufObjs
[i
] = _mesa_lookup_bufferobj(ctx
, buffers
[i
]);
750 texObjs
= malloc(sizeof(struct gl_texture_object
*) * numTextureBarriers
);
752 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s(numTextureBarriers=%u)",
753 func
, numTextureBarriers
);
757 for (unsigned i
= 0; i
< numTextureBarriers
; i
++) {
758 texObjs
[i
] = _mesa_lookup_texture(ctx
, textures
[i
]);
761 ctx
->Driver
.ServerWaitSemaphoreObject(ctx
, semObj
,
762 numBufferBarriers
, bufObjs
,
763 numTextureBarriers
, texObjs
,
772 _mesa_SignalSemaphoreEXT(GLuint semaphore
,
773 GLuint numBufferBarriers
,
774 const GLuint
*buffers
,
775 GLuint numTextureBarriers
,
776 const GLuint
*textures
,
777 const GLenum
*dstLayouts
)
779 GET_CURRENT_CONTEXT(ctx
);
780 struct gl_semaphore_object
*semObj
= NULL
;
781 struct gl_buffer_object
**bufObjs
= NULL
;
782 struct gl_texture_object
**texObjs
= NULL
;
784 const char *func
= "glSignalSemaphoreEXT";
786 if (!ctx
->Extensions
.EXT_semaphore
) {
787 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
791 ASSERT_OUTSIDE_BEGIN_END(ctx
);
793 semObj
= _mesa_lookup_semaphore_object(ctx
, semaphore
);
797 FLUSH_VERTICES(ctx
, 0);
799 bufObjs
= malloc(sizeof(struct gl_buffer_object
*) * numBufferBarriers
);
801 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s(numBufferBarriers=%u)",
802 func
, numBufferBarriers
);
806 for (unsigned i
= 0; i
< numBufferBarriers
; i
++) {
807 bufObjs
[i
] = _mesa_lookup_bufferobj(ctx
, buffers
[i
]);
810 texObjs
= malloc(sizeof(struct gl_texture_object
*) * numTextureBarriers
);
812 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s(numTextureBarriers=%u)",
813 func
, numTextureBarriers
);
817 for (unsigned i
= 0; i
< numTextureBarriers
; i
++) {
818 texObjs
[i
] = _mesa_lookup_texture(ctx
, textures
[i
]);
821 ctx
->Driver
.ServerSignalSemaphoreObject(ctx
, semObj
,
822 numBufferBarriers
, bufObjs
,
823 numTextureBarriers
, texObjs
,
832 _mesa_ImportMemoryFdEXT(GLuint memory
,
837 GET_CURRENT_CONTEXT(ctx
);
839 const char *func
= "glImportMemoryFdEXT";
841 if (!ctx
->Extensions
.EXT_memory_object_fd
) {
842 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
846 if (handleType
!= GL_HANDLE_TYPE_OPAQUE_FD_EXT
) {
847 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(handleType=%u)", func
, handleType
);
851 struct gl_memory_object
*memObj
= _mesa_lookup_memory_object(ctx
, memory
);
855 ctx
->Driver
.ImportMemoryObjectFd(ctx
, memObj
, size
, fd
);
856 memObj
->Immutable
= GL_TRUE
;
860 _mesa_ImportSemaphoreFdEXT(GLuint semaphore
,
864 GET_CURRENT_CONTEXT(ctx
);
866 const char *func
= "glImportSemaphoreFdEXT";
868 if (!ctx
->Extensions
.EXT_semaphore_fd
) {
869 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
873 if (handleType
!= GL_HANDLE_TYPE_OPAQUE_FD_EXT
) {
874 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(handleType=%u)", func
, handleType
);
878 struct gl_semaphore_object
*semObj
= _mesa_lookup_semaphore_object(ctx
,
883 if (semObj
== &DummySemaphoreObject
) {
884 semObj
= ctx
->Driver
.NewSemaphoreObject(ctx
, semaphore
);
886 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", func
);
889 _mesa_HashInsert(ctx
->Shared
->SemaphoreObjects
, semaphore
, semObj
);
892 ctx
->Driver
.ImportSemaphoreFd(ctx
, semObj
, fd
);