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"
35 * Allocate and initialize a new memory object. But don't put it into the
36 * memory object hash table.
38 * Called via ctx->Driver.NewMemoryObject, unless overridden by a device
41 * \return pointer to new memory object.
43 static struct gl_memory_object
*
44 _mesa_new_memory_object(struct gl_context
*ctx
, GLuint name
)
46 struct gl_memory_object
*obj
= MALLOC_STRUCT(gl_memory_object
);
50 _mesa_initialize_memory_object(ctx
, obj
, name
);
55 * Delete a memory object. Called via ctx->Driver.DeleteMemory().
56 * Not removed from hash table here.
59 _mesa_delete_memory_object(struct gl_context
*ctx
,
60 struct gl_memory_object
*memObj
)
66 _mesa_init_memory_object_functions(struct dd_function_table
*driver
)
68 driver
->NewMemoryObject
= _mesa_new_memory_object
;
69 driver
->DeleteMemoryObject
= _mesa_delete_memory_object
;
73 * Initialize a buffer object to default values.
76 _mesa_initialize_memory_object(struct gl_context
*ctx
,
77 struct gl_memory_object
*obj
,
80 memset(obj
, 0, sizeof(struct gl_memory_object
));
82 obj
->Dedicated
= GL_FALSE
;
86 _mesa_DeleteMemoryObjectsEXT(GLsizei n
, const GLuint
*memoryObjects
)
88 GET_CURRENT_CONTEXT(ctx
);
90 if (MESA_VERBOSE
& (VERBOSE_API
)) {
91 _mesa_debug(ctx
, "glDeleteMemoryObjectsEXT(%d, %p)\n", n
,
95 if (!ctx
->Extensions
.EXT_memory_object
) {
96 _mesa_error(ctx
, GL_INVALID_OPERATION
,
97 "glDeleteMemoryObjectsEXT(unsupported)");
102 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteMemoryObjectsEXT(n < 0)");
109 _mesa_HashLockMutex(ctx
->Shared
->MemoryObjects
);
110 for (GLint i
= 0; i
< n
; i
++) {
111 if (memoryObjects
[i
] > 0) {
112 struct gl_memory_object
*delObj
113 = _mesa_lookup_memory_object_locked(ctx
, memoryObjects
[i
]);
116 _mesa_HashRemoveLocked(ctx
->Shared
->MemoryObjects
,
118 ctx
->Driver
.DeleteMemoryObject(ctx
, delObj
);
122 _mesa_HashUnlockMutex(ctx
->Shared
->MemoryObjects
);
126 _mesa_IsMemoryObjectEXT(GLuint memoryObject
)
128 GET_CURRENT_CONTEXT(ctx
);
130 if (!ctx
->Extensions
.EXT_memory_object
) {
131 _mesa_error(ctx
, GL_INVALID_OPERATION
,
132 "glIsMemoryObjectEXT(unsupported)");
136 struct gl_memory_object
*obj
=
137 _mesa_lookup_memory_object(ctx
, memoryObject
);
139 return obj
? GL_TRUE
: GL_FALSE
;
143 _mesa_CreateMemoryObjectsEXT(GLsizei n
, GLuint
*memoryObjects
)
145 GET_CURRENT_CONTEXT(ctx
);
147 const char *func
= "glCreateMemoryObjectsEXT";
149 if (MESA_VERBOSE
& (VERBOSE_API
))
150 _mesa_debug(ctx
, "%s(%d, %p)", func
, n
, memoryObjects
);
152 if (!ctx
->Extensions
.EXT_memory_object
) {
153 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
158 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n < 0)", func
);
165 _mesa_HashLockMutex(ctx
->Shared
->MemoryObjects
);
166 GLuint first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->MemoryObjects
, n
);
168 for (GLsizei i
= 0; i
< n
; i
++) {
169 struct gl_memory_object
*memObj
;
171 memoryObjects
[i
] = first
+ i
;
173 /* allocate memory object */
174 memObj
= ctx
->Driver
.NewMemoryObject(ctx
, memoryObjects
[i
]);
176 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s()", func
);
177 _mesa_HashUnlockMutex(ctx
->Shared
->MemoryObjects
);
181 /* insert into hash table */
182 _mesa_HashInsertLocked(ctx
->Shared
->MemoryObjects
,
188 _mesa_HashUnlockMutex(ctx
->Shared
->MemoryObjects
);
192 _mesa_MemoryObjectParameterivEXT(GLuint memoryObject
,
196 GET_CURRENT_CONTEXT(ctx
);
197 struct gl_memory_object
*memObj
;
199 const char *func
= "glMemoryObjectParameterivEXT";
201 if (!ctx
->Extensions
.EXT_memory_object
) {
202 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
206 memObj
= _mesa_lookup_memory_object(ctx
, memoryObject
);
210 if (memObj
->Immutable
) {
211 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(memoryObject is immutable", func
);
216 case GL_DEDICATED_MEMORY_OBJECT_EXT
:
217 memObj
->Dedicated
= (GLboolean
) params
[0];
219 case GL_PROTECTED_MEMORY_OBJECT_EXT
:
220 /* EXT_protected_textures not supported */
228 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", func
, pname
);
232 _mesa_GetMemoryObjectParameterivEXT(GLuint memoryObject
,
236 GET_CURRENT_CONTEXT(ctx
);
237 struct gl_memory_object
*memObj
;
239 const char *func
= "glMemoryObjectParameterivEXT";
241 if (!ctx
->Extensions
.EXT_memory_object
) {
242 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
246 memObj
= _mesa_lookup_memory_object(ctx
, memoryObject
);
251 case GL_DEDICATED_MEMORY_OBJECT_EXT
:
252 *params
= (GLint
) memObj
->Dedicated
;
254 case GL_PROTECTED_MEMORY_OBJECT_EXT
:
255 /* EXT_protected_textures not supported */
263 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", func
, pname
);
266 static struct gl_memory_object
*
267 lookup_memory_object_err(struct gl_context
*ctx
, unsigned memory
,
271 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(memory=0)", func
);
275 struct gl_memory_object
*memObj
= _mesa_lookup_memory_object(ctx
, memory
);
279 if (!memObj
->Immutable
) {
280 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no associated memory)",
289 * Helper used by _mesa_TexStorageMem1/2/3DEXT().
292 texstorage_memory(GLuint dims
, GLenum target
, GLsizei levels
,
293 GLenum internalFormat
, GLsizei width
, GLsizei height
,
294 GLsizei depth
, GLuint memory
, GLuint64 offset
,
297 struct gl_texture_object
*texObj
;
298 struct gl_memory_object
*memObj
;
300 GET_CURRENT_CONTEXT(ctx
);
302 if (!ctx
->Extensions
.EXT_memory_object
) {
303 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
307 texObj
= _mesa_get_current_tex_object(ctx
, target
);
311 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
315 _mesa_texture_storage_memory(ctx
, dims
, texObj
, memObj
, target
,
316 levels
, internalFormat
,
317 width
, height
, depth
, offset
, false);
321 texstorage_memory_ms(GLuint dims
, GLenum target
, GLsizei samples
,
322 GLenum internalFormat
, GLsizei width
, GLsizei height
,
323 GLsizei depth
, GLboolean fixedSampleLocations
,
324 GLuint memory
, GLuint64 offset
, const char* func
)
326 struct gl_texture_object
*texObj
;
327 struct gl_memory_object
*memObj
;
329 GET_CURRENT_CONTEXT(ctx
);
331 if (!ctx
->Extensions
.EXT_memory_object
) {
332 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
336 texObj
= _mesa_get_current_tex_object(ctx
, target
);
340 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
344 _mesa_texture_storage_ms_memory(ctx
, dims
, texObj
, memObj
, target
, samples
,
345 internalFormat
, width
, height
, depth
,
346 fixedSampleLocations
, offset
, func
);
350 * Helper used by _mesa_TextureStorageMem1/2/3DEXT().
353 texturestorage_memory(GLuint dims
, GLuint texture
, GLsizei levels
,
354 GLenum internalFormat
, GLsizei width
, GLsizei height
,
355 GLsizei depth
, GLuint memory
, GLuint64 offset
,
358 struct gl_texture_object
*texObj
;
359 struct gl_memory_object
*memObj
;
361 GET_CURRENT_CONTEXT(ctx
);
363 if (!ctx
->Extensions
.EXT_memory_object
) {
364 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
368 texObj
= _mesa_lookup_texture(ctx
, texture
);
372 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
376 _mesa_texture_storage_memory(ctx
, dims
, texObj
, memObj
, texObj
->Target
,
377 levels
, internalFormat
,
378 width
, height
, depth
, offset
, true);
382 texturestorage_memory_ms(GLuint dims
, GLuint texture
, GLsizei samples
,
383 GLenum internalFormat
, GLsizei width
, GLsizei height
,
384 GLsizei depth
, GLboolean fixedSampleLocations
,
385 GLuint memory
, GLuint64 offset
, const char* func
)
387 struct gl_texture_object
*texObj
;
388 struct gl_memory_object
*memObj
;
390 GET_CURRENT_CONTEXT(ctx
);
392 if (!ctx
->Extensions
.EXT_memory_object
) {
393 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
397 texObj
= _mesa_lookup_texture(ctx
, texture
);
401 memObj
= lookup_memory_object_err(ctx
, memory
, func
);
405 _mesa_texture_storage_ms_memory(ctx
, dims
, texObj
, memObj
, texObj
->Target
,
406 samples
, internalFormat
, width
, height
,
407 depth
, fixedSampleLocations
, offset
, func
);
411 _mesa_TexStorageMem2DEXT(GLenum target
,
413 GLenum internalFormat
,
419 texstorage_memory(2, target
, levels
, internalFormat
, width
, height
, 1,
420 memory
, offset
, "glTexStorageMem2DEXT");
424 _mesa_TexStorageMem2DMultisampleEXT(GLenum target
,
426 GLenum internalFormat
,
429 GLboolean fixedSampleLocations
,
433 texstorage_memory_ms(2, target
, samples
, internalFormat
, width
, height
, 1,
434 fixedSampleLocations
, memory
, offset
,
435 "glTexStorageMem2DMultisampleEXT");
439 _mesa_TexStorageMem3DEXT(GLenum target
,
441 GLenum internalFormat
,
448 texstorage_memory(3, target
, levels
, internalFormat
, width
, height
, depth
,
449 memory
, offset
, "glTexStorageMem3DEXT");
453 _mesa_TexStorageMem3DMultisampleEXT(GLenum target
,
455 GLenum internalFormat
,
459 GLboolean fixedSampleLocations
,
463 texstorage_memory_ms(3, target
, samples
, internalFormat
, width
, height
,
464 depth
, fixedSampleLocations
, memory
, offset
,
465 "glTexStorageMem3DMultisampleEXT");
469 _mesa_TextureStorageMem2DEXT(GLuint texture
,
471 GLenum internalFormat
,
477 texturestorage_memory(2, texture
, levels
, internalFormat
, width
, height
, 1,
478 memory
, offset
, "glTexureStorageMem2DEXT");
482 _mesa_TextureStorageMem2DMultisampleEXT(GLuint texture
,
484 GLenum internalFormat
,
487 GLboolean fixedSampleLocations
,
491 texturestorage_memory_ms(2, texture
, samples
, internalFormat
, width
, height
,
492 1, fixedSampleLocations
, memory
, offset
,
493 "glTextureStorageMem2DMultisampleEXT");
497 _mesa_TextureStorageMem3DEXT(GLuint texture
,
499 GLenum internalFormat
,
506 texturestorage_memory(3, texture
, levels
, internalFormat
, width
, height
,
507 depth
, memory
, offset
, "glTextureStorageMem3DEXT");
511 _mesa_TextureStorageMem3DMultisampleEXT(GLuint texture
,
513 GLenum internalFormat
,
517 GLboolean fixedSampleLocations
,
521 texturestorage_memory_ms(3, texture
, samples
, internalFormat
, width
, height
,
522 depth
, fixedSampleLocations
, memory
, offset
,
523 "glTextureStorageMem3DMultisampleEXT");
527 _mesa_TexStorageMem1DEXT(GLenum target
,
529 GLenum internalFormat
,
534 texstorage_memory(1, target
, levels
, internalFormat
, width
, 1, 1, memory
,
535 offset
, "glTexStorageMem1DEXT");
539 _mesa_TextureStorageMem1DEXT(GLuint texture
,
541 GLenum internalFormat
,
546 texturestorage_memory(1, texture
, levels
, internalFormat
, width
, 1, 1,
547 memory
, offset
, "glTextureStorageMem1DEXT");
551 * Used as a placeholder for semaphore objects between glGenSemaphoresEXT()
552 * and glImportSemaphoreFdEXT(), so that glIsSemaphoreEXT() can work correctly.
554 static struct gl_semaphore_object DummySemaphoreObject
;
557 * Delete a semaphore object. Called via ctx->Driver.DeleteSemaphore().
558 * Not removed from hash table here.
561 _mesa_delete_semaphore_object(struct gl_context
*ctx
,
562 struct gl_semaphore_object
*semObj
)
564 if (semObj
!= &DummySemaphoreObject
)
569 * Initialize a semaphore object to default values.
572 _mesa_initialize_semaphore_object(struct gl_context
*ctx
,
573 struct gl_semaphore_object
*obj
,
576 memset(obj
, 0, sizeof(struct gl_semaphore_object
));
581 _mesa_GenSemaphoresEXT(GLsizei n
, GLuint
*semaphores
)
583 GET_CURRENT_CONTEXT(ctx
);
585 const char *func
= "glGenSemaphoresEXT";
587 if (MESA_VERBOSE
& (VERBOSE_API
))
588 _mesa_debug(ctx
, "%s(%d, %p)", func
, n
, semaphores
);
590 if (!ctx
->Extensions
.EXT_semaphore
) {
591 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
596 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n < 0)", func
);
603 _mesa_HashLockMutex(ctx
->Shared
->SemaphoreObjects
);
604 GLuint first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->SemaphoreObjects
, n
);
606 for (GLsizei i
= 0; i
< n
; i
++) {
607 semaphores
[i
] = first
+ i
;
608 _mesa_HashInsertLocked(ctx
->Shared
->SemaphoreObjects
,
609 semaphores
[i
], &DummySemaphoreObject
);
613 _mesa_HashUnlockMutex(ctx
->Shared
->SemaphoreObjects
);
617 _mesa_DeleteSemaphoresEXT(GLsizei n
, const GLuint
*semaphores
)
619 GET_CURRENT_CONTEXT(ctx
);
621 const char *func
= "glDeleteSemaphoresEXT";
623 if (MESA_VERBOSE
& (VERBOSE_API
)) {
624 _mesa_debug(ctx
, "%s(%d, %p)\n", func
, n
, semaphores
);
627 if (!ctx
->Extensions
.EXT_semaphore
) {
628 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
633 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(n < 0)", func
);
640 _mesa_HashLockMutex(ctx
->Shared
->SemaphoreObjects
);
641 for (GLint i
= 0; i
< n
; i
++) {
642 if (semaphores
[i
] > 0) {
643 struct gl_semaphore_object
*delObj
644 = _mesa_lookup_semaphore_object_locked(ctx
, semaphores
[i
]);
647 _mesa_HashRemoveLocked(ctx
->Shared
->SemaphoreObjects
,
649 ctx
->Driver
.DeleteSemaphoreObject(ctx
, delObj
);
653 _mesa_HashUnlockMutex(ctx
->Shared
->SemaphoreObjects
);
657 _mesa_IsSemaphoreEXT(GLuint semaphore
)
659 GET_CURRENT_CONTEXT(ctx
);
661 if (!ctx
->Extensions
.EXT_semaphore
) {
662 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glIsSemaphoreEXT(unsupported)");
666 struct gl_semaphore_object
*obj
=
667 _mesa_lookup_semaphore_object(ctx
, semaphore
);
669 return obj
? GL_TRUE
: GL_FALSE
;
673 * Helper that outputs the correct error status for parameter
674 * calls where no pnames are defined
677 semaphore_parameter_stub(const char* func
, GLenum pname
)
679 GET_CURRENT_CONTEXT(ctx
);
681 if (!ctx
->Extensions
.EXT_semaphore
) {
682 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
686 /* EXT_semaphore and EXT_semaphore_fd define no parameters */
687 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", func
, pname
);
691 _mesa_SemaphoreParameterui64vEXT(GLuint semaphore
,
693 const GLuint64
*params
)
695 const char *func
= "glSemaphoreParameterui64vEXT";
697 semaphore_parameter_stub(func
, pname
);
701 _mesa_GetSemaphoreParameterui64vEXT(GLuint semaphore
,
705 const char *func
= "glGetSemaphoreParameterui64vEXT";
707 semaphore_parameter_stub(func
, pname
);
711 _mesa_WaitSemaphoreEXT(GLuint semaphore
,
712 GLuint numBufferBarriers
,
713 const GLuint
*buffers
,
714 GLuint numTextureBarriers
,
715 const GLuint
*textures
,
716 const GLenum
*srcLayouts
)
718 GET_CURRENT_CONTEXT(ctx
);
719 struct gl_semaphore_object
*semObj
= NULL
;
720 struct gl_buffer_object
**bufObjs
= NULL
;
721 struct gl_texture_object
**texObjs
= NULL
;
723 const char *func
= "glWaitSemaphoreEXT";
725 if (!ctx
->Extensions
.EXT_semaphore
) {
726 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
730 ASSERT_OUTSIDE_BEGIN_END(ctx
);
732 semObj
= _mesa_lookup_semaphore_object(ctx
, semaphore
);
736 FLUSH_VERTICES(ctx
, 0);
737 FLUSH_CURRENT(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);
798 FLUSH_CURRENT(ctx
, 0);
800 bufObjs
= malloc(sizeof(struct gl_buffer_object
*) * numBufferBarriers
);
802 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s(numBufferBarriers=%u)",
803 func
, numBufferBarriers
);
807 for (unsigned i
= 0; i
< numBufferBarriers
; i
++) {
808 bufObjs
[i
] = _mesa_lookup_bufferobj(ctx
, buffers
[i
]);
811 texObjs
= malloc(sizeof(struct gl_texture_object
*) * numTextureBarriers
);
813 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s(numTextureBarriers=%u)",
814 func
, numTextureBarriers
);
818 for (unsigned i
= 0; i
< numTextureBarriers
; i
++) {
819 texObjs
[i
] = _mesa_lookup_texture(ctx
, textures
[i
]);
822 ctx
->Driver
.ServerSignalSemaphoreObject(ctx
, semObj
,
823 numBufferBarriers
, bufObjs
,
824 numTextureBarriers
, texObjs
,
833 _mesa_ImportMemoryFdEXT(GLuint memory
,
838 GET_CURRENT_CONTEXT(ctx
);
840 const char *func
= "glImportMemoryFdEXT";
842 if (!ctx
->Extensions
.EXT_memory_object_fd
) {
843 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
847 if (handleType
!= GL_HANDLE_TYPE_OPAQUE_FD_EXT
) {
848 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(handleType=%u)", func
, handleType
);
852 struct gl_memory_object
*memObj
= _mesa_lookup_memory_object(ctx
, memory
);
856 ctx
->Driver
.ImportMemoryObjectFd(ctx
, memObj
, size
, fd
);
857 memObj
->Immutable
= GL_TRUE
;
861 _mesa_ImportSemaphoreFdEXT(GLuint semaphore
,
865 GET_CURRENT_CONTEXT(ctx
);
867 const char *func
= "glImportSemaphoreFdEXT";
869 if (!ctx
->Extensions
.EXT_semaphore_fd
) {
870 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(unsupported)", func
);
874 if (handleType
!= GL_HANDLE_TYPE_OPAQUE_FD_EXT
) {
875 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(handleType=%u)", func
, handleType
);
879 struct gl_semaphore_object
*semObj
= _mesa_lookup_semaphore_object(ctx
,
884 if (semObj
== &DummySemaphoreObject
) {
885 semObj
= ctx
->Driver
.NewSemaphoreObject(ctx
, semaphore
);
887 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", func
);
890 _mesa_HashInsert(ctx
->Shared
->SemaphoreObjects
, semaphore
, semObj
);
893 ctx
->Driver
.ImportSemaphoreFd(ctx
, semObj
, fd
);