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"
29
#include "externalobjects.h"
32
#include "glformats.h"
33
#include "texstorage.h"
34
#include "util/u_memory.h"
36
#include "pipe/p_context.h"
37
#include "pipe/p_screen.h"
38
#include "api_exec_decl.h"
40
#include "state_tracker/st_cb_bitmap.h"
41
#include "state_tracker/st_texture.h"
45
#include "frontend/drm_driver.h"
47
#include "drm-uapi/drm_fourcc.h"
50
static struct gl_memory_object *
51
memoryobj_alloc(struct gl_context *ctx, GLuint name)
53
struct gl_memory_object *obj = CALLOC_STRUCT(gl_memory_object);
58
obj->Dedicated = GL_FALSE;
63
import_memoryobj_fd(struct gl_context *ctx,
64
struct gl_memory_object *obj,
69
struct pipe_screen *screen = ctx->pipe->screen;
70
struct winsys_handle whandle = {
71
.type = WINSYS_HANDLE_TYPE_FD,
74
.modifier = DRM_FORMAT_MOD_INVALID,
78
obj->memory = screen->memobj_create_from_handle(screen,
82
/* We own fd, but we no longer need it. So get rid of it */
88
* Delete a memory object.
89
* Not removed from hash table here.
92
_mesa_delete_memory_object(struct gl_context *ctx,
93
struct gl_memory_object *memObj)
95
struct pipe_screen *screen = ctx->pipe->screen;
97
screen->memobj_destroy(screen, memObj->memory);
102
_mesa_DeleteMemoryObjectsEXT(GLsizei n, const GLuint *memoryObjects)
104
GET_CURRENT_CONTEXT(ctx);
106
if (MESA_VERBOSE & (VERBOSE_API)) {
107
_mesa_debug(ctx, "glDeleteMemoryObjectsEXT(%d, %p)\n", n,
111
if (!ctx->Extensions.EXT_memory_object) {
112
_mesa_error(ctx, GL_INVALID_OPERATION,
113
"glDeleteMemoryObjectsEXT(unsupported)");
118
_mesa_error(ctx, GL_INVALID_VALUE, "glDeleteMemoryObjectsEXT(n < 0)");
125
_mesa_HashLockMutex(ctx->Shared->MemoryObjects);
126
for (GLint i = 0; i < n; i++) {
127
if (memoryObjects[i] > 0) {
128
struct gl_memory_object *delObj
129
= _mesa_lookup_memory_object_locked(ctx, memoryObjects[i]);
132
_mesa_HashRemoveLocked(ctx->Shared->MemoryObjects,
134
_mesa_delete_memory_object(ctx, delObj);
138
_mesa_HashUnlockMutex(ctx->Shared->MemoryObjects);
142
_mesa_IsMemoryObjectEXT(GLuint memoryObject)
144
GET_CURRENT_CONTEXT(ctx);
146
if (!ctx->Extensions.EXT_memory_object) {
147
_mesa_error(ctx, GL_INVALID_OPERATION,
148
"glIsMemoryObjectEXT(unsupported)");
152
struct gl_memory_object *obj =
153
_mesa_lookup_memory_object(ctx, memoryObject);
155
return obj ? GL_TRUE : GL_FALSE;
159
_mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects)
161
GET_CURRENT_CONTEXT(ctx);
163
const char *func = "glCreateMemoryObjectsEXT";
165
if (MESA_VERBOSE & (VERBOSE_API))
166
_mesa_debug(ctx, "%s(%d, %p)", func, n, memoryObjects);
168
if (!ctx->Extensions.EXT_memory_object) {
169
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
174
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
181
_mesa_HashLockMutex(ctx->Shared->MemoryObjects);
182
if (_mesa_HashFindFreeKeys(ctx->Shared->MemoryObjects, memoryObjects, n)) {
183
for (GLsizei i = 0; i < n; i++) {
184
struct gl_memory_object *memObj;
186
/* allocate memory object */
187
memObj = memoryobj_alloc(ctx, memoryObjects[i]);
189
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", func);
190
_mesa_HashUnlockMutex(ctx->Shared->MemoryObjects);
194
/* insert into hash table */
195
_mesa_HashInsertLocked(ctx->Shared->MemoryObjects,
201
_mesa_HashUnlockMutex(ctx->Shared->MemoryObjects);
205
_mesa_MemoryObjectParameterivEXT(GLuint memoryObject,
209
GET_CURRENT_CONTEXT(ctx);
210
struct gl_memory_object *memObj;
212
const char *func = "glMemoryObjectParameterivEXT";
214
if (!ctx->Extensions.EXT_memory_object) {
215
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
219
memObj = _mesa_lookup_memory_object(ctx, memoryObject);
223
if (memObj->Immutable) {
224
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(memoryObject is immutable", func);
229
case GL_DEDICATED_MEMORY_OBJECT_EXT:
230
memObj->Dedicated = (GLboolean) params[0];
232
case GL_PROTECTED_MEMORY_OBJECT_EXT:
233
/* EXT_protected_textures not supported */
241
_mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
245
_mesa_GetMemoryObjectParameterivEXT(GLuint memoryObject,
249
GET_CURRENT_CONTEXT(ctx);
250
struct gl_memory_object *memObj;
252
const char *func = "glMemoryObjectParameterivEXT";
254
if (!ctx->Extensions.EXT_memory_object) {
255
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
259
memObj = _mesa_lookup_memory_object(ctx, memoryObject);
264
case GL_DEDICATED_MEMORY_OBJECT_EXT:
265
*params = (GLint) memObj->Dedicated;
267
case GL_PROTECTED_MEMORY_OBJECT_EXT:
268
/* EXT_protected_textures not supported */
276
_mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
279
static struct gl_memory_object *
280
lookup_memory_object_err(struct gl_context *ctx, unsigned memory,
284
_mesa_error(ctx, GL_INVALID_VALUE, "%s(memory=0)", func);
288
struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, memory);
292
if (!memObj->Immutable) {
293
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(no associated memory)",
302
* Helper used by _mesa_TexStorageMem1/2/3DEXT().
305
texstorage_memory(GLuint dims, GLenum target, GLsizei levels,
306
GLenum internalFormat, GLsizei width, GLsizei height,
307
GLsizei depth, GLuint memory, GLuint64 offset,
310
struct gl_texture_object *texObj;
311
struct gl_memory_object *memObj;
313
GET_CURRENT_CONTEXT(ctx);
315
if (!ctx->Extensions.EXT_memory_object) {
316
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
320
if (!_mesa_is_legal_tex_storage_target(ctx, dims, target)) {
321
_mesa_error(ctx, GL_INVALID_ENUM,
322
"%s(illegal target=%s)",
323
func, _mesa_enum_to_string(target));
327
/* Check the format to make sure it is sized. */
328
if (!_mesa_is_legal_tex_storage_format(ctx, internalFormat)) {
329
_mesa_error(ctx, GL_INVALID_ENUM,
330
"%s(internalformat = %s)", func,
331
_mesa_enum_to_string(internalFormat));
335
texObj = _mesa_get_current_tex_object(ctx, target);
339
memObj = lookup_memory_object_err(ctx, memory, func);
343
_mesa_texture_storage_memory(ctx, dims, texObj, memObj, target,
344
levels, internalFormat,
345
width, height, depth, offset, false);
349
texstorage_memory_ms(GLuint dims, GLenum target, GLsizei samples,
350
GLenum internalFormat, GLsizei width, GLsizei height,
351
GLsizei depth, GLboolean fixedSampleLocations,
352
GLuint memory, GLuint64 offset, const char* func)
354
struct gl_texture_object *texObj;
355
struct gl_memory_object *memObj;
357
GET_CURRENT_CONTEXT(ctx);
359
if (!ctx->Extensions.EXT_memory_object) {
360
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
364
texObj = _mesa_get_current_tex_object(ctx, target);
368
memObj = lookup_memory_object_err(ctx, memory, func);
372
_mesa_texture_storage_ms_memory(ctx, dims, texObj, memObj, target, samples,
373
internalFormat, width, height, depth,
374
fixedSampleLocations, offset, func);
378
* Helper used by _mesa_TextureStorageMem1/2/3DEXT().
381
texturestorage_memory(GLuint dims, GLuint texture, GLsizei levels,
382
GLenum internalFormat, GLsizei width, GLsizei height,
383
GLsizei depth, GLuint memory, GLuint64 offset,
386
struct gl_texture_object *texObj;
387
struct gl_memory_object *memObj;
389
GET_CURRENT_CONTEXT(ctx);
391
if (!ctx->Extensions.EXT_memory_object) {
392
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
396
/* Check the format to make sure it is sized. */
397
if (!_mesa_is_legal_tex_storage_format(ctx, internalFormat)) {
398
_mesa_error(ctx, GL_INVALID_ENUM,
399
"%s(internalformat = %s)", func,
400
_mesa_enum_to_string(internalFormat));
404
texObj = _mesa_lookup_texture(ctx, texture);
408
if (!_mesa_is_legal_tex_storage_target(ctx, dims, texObj->Target)) {
409
_mesa_error(ctx, GL_INVALID_OPERATION,
410
"%s(illegal target=%s)", func,
411
_mesa_enum_to_string(texObj->Target));
415
memObj = lookup_memory_object_err(ctx, memory, func);
419
_mesa_texture_storage_memory(ctx, dims, texObj, memObj, texObj->Target,
420
levels, internalFormat,
421
width, height, depth, offset, true);
425
texturestorage_memory_ms(GLuint dims, GLuint texture, GLsizei samples,
426
GLenum internalFormat, GLsizei width, GLsizei height,
427
GLsizei depth, GLboolean fixedSampleLocations,
428
GLuint memory, GLuint64 offset, const char* func)
430
struct gl_texture_object *texObj;
431
struct gl_memory_object *memObj;
433
GET_CURRENT_CONTEXT(ctx);
435
if (!ctx->Extensions.EXT_memory_object) {
436
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
440
texObj = _mesa_lookup_texture(ctx, texture);
444
memObj = lookup_memory_object_err(ctx, memory, func);
448
_mesa_texture_storage_ms_memory(ctx, dims, texObj, memObj, texObj->Target,
449
samples, internalFormat, width, height,
450
depth, fixedSampleLocations, offset, func);
454
_mesa_TexStorageMem2DEXT(GLenum target,
456
GLenum internalFormat,
462
texstorage_memory(2, target, levels, internalFormat, width, height, 1,
463
memory, offset, "glTexStorageMem2DEXT");
467
_mesa_TexStorageMem2DMultisampleEXT(GLenum target,
469
GLenum internalFormat,
472
GLboolean fixedSampleLocations,
476
texstorage_memory_ms(2, target, samples, internalFormat, width, height, 1,
477
fixedSampleLocations, memory, offset,
478
"glTexStorageMem2DMultisampleEXT");
482
_mesa_TexStorageMem3DEXT(GLenum target,
484
GLenum internalFormat,
491
texstorage_memory(3, target, levels, internalFormat, width, height, depth,
492
memory, offset, "glTexStorageMem3DEXT");
496
_mesa_TexStorageMem3DMultisampleEXT(GLenum target,
498
GLenum internalFormat,
502
GLboolean fixedSampleLocations,
506
texstorage_memory_ms(3, target, samples, internalFormat, width, height,
507
depth, fixedSampleLocations, memory, offset,
508
"glTexStorageMem3DMultisampleEXT");
512
_mesa_TextureStorageMem2DEXT(GLuint texture,
514
GLenum internalFormat,
520
texturestorage_memory(2, texture, levels, internalFormat, width, height, 1,
521
memory, offset, "glTexureStorageMem2DEXT");
525
_mesa_TextureStorageMem2DMultisampleEXT(GLuint texture,
527
GLenum internalFormat,
530
GLboolean fixedSampleLocations,
534
texturestorage_memory_ms(2, texture, samples, internalFormat, width, height,
535
1, fixedSampleLocations, memory, offset,
536
"glTextureStorageMem2DMultisampleEXT");
540
_mesa_TextureStorageMem3DEXT(GLuint texture,
542
GLenum internalFormat,
549
texturestorage_memory(3, texture, levels, internalFormat, width, height,
550
depth, memory, offset, "glTextureStorageMem3DEXT");
554
_mesa_TextureStorageMem3DMultisampleEXT(GLuint texture,
556
GLenum internalFormat,
560
GLboolean fixedSampleLocations,
564
texturestorage_memory_ms(3, texture, samples, internalFormat, width, height,
565
depth, fixedSampleLocations, memory, offset,
566
"glTextureStorageMem3DMultisampleEXT");
570
_mesa_TexStorageMem1DEXT(GLenum target,
572
GLenum internalFormat,
577
texstorage_memory(1, target, levels, internalFormat, width, 1, 1, memory,
578
offset, "glTexStorageMem1DEXT");
582
_mesa_TextureStorageMem1DEXT(GLuint texture,
584
GLenum internalFormat,
589
texturestorage_memory(1, texture, levels, internalFormat, width, 1, 1,
590
memory, offset, "glTextureStorageMem1DEXT");
593
static struct gl_semaphore_object *
594
semaphoreobj_alloc(struct gl_context *ctx, GLuint name)
596
struct gl_semaphore_object *obj = CALLOC_STRUCT(gl_semaphore_object);
605
import_semaphoreobj_fd(struct gl_context *ctx,
606
struct gl_semaphore_object *semObj,
609
struct pipe_context *pipe = ctx->pipe;
611
pipe->create_fence_fd(pipe, &semObj->fence, fd, PIPE_FD_TYPE_SYNCOBJ);
614
/* We own fd, but we no longer need it. So get rid of it */
620
server_wait_semaphore(struct gl_context *ctx,
621
struct gl_semaphore_object *semObj,
622
GLuint numBufferBarriers,
623
struct gl_buffer_object **bufObjs,
624
GLuint numTextureBarriers,
625
struct gl_texture_object **texObjs,
626
const GLenum *srcLayouts)
628
struct st_context *st = ctx->st;
629
struct pipe_context *pipe = ctx->pipe;
630
struct gl_buffer_object *bufObj;
631
struct gl_texture_object *texObj;
633
/* The driver is allowed to flush during fence_server_sync, be prepared */
634
st_flush_bitmap_cache(st);
635
pipe->fence_server_sync(pipe, semObj->fence);
638
* According to the EXT_external_objects spec, the memory operations must
639
* follow the wait. This is to make sure the flush is executed after the
640
* other party is done modifying the memory.
642
* Relevant excerpt from section "4.2.3 Waiting for Semaphores":
644
* Following completion of the semaphore wait operation, memory will also be
645
* made visible in the specified buffer and texture objects.
648
for (unsigned i = 0; i < numBufferBarriers; i++) {
654
pipe->flush_resource(pipe, bufObj->buffer);
657
for (unsigned i = 0; i < numTextureBarriers; i++) {
663
pipe->flush_resource(pipe, texObj->pt);
668
server_signal_semaphore(struct gl_context *ctx,
669
struct gl_semaphore_object *semObj,
670
GLuint numBufferBarriers,
671
struct gl_buffer_object **bufObjs,
672
GLuint numTextureBarriers,
673
struct gl_texture_object **texObjs,
674
const GLenum *dstLayouts)
676
struct st_context *st = ctx->st;
677
struct pipe_context *pipe = ctx->pipe;
678
struct gl_buffer_object *bufObj;
679
struct gl_texture_object *texObj;
681
for (unsigned i = 0; i < numBufferBarriers; i++) {
687
pipe->flush_resource(pipe, bufObj->buffer);
690
for (unsigned i = 0; i < numTextureBarriers; i++) {
696
pipe->flush_resource(pipe, texObj->pt);
699
/* The driver is allowed to flush during fence_server_signal, be prepared */
700
st_flush_bitmap_cache(st);
701
pipe->fence_server_signal(pipe, semObj->fence);
705
* Used as a placeholder for semaphore objects between glGenSemaphoresEXT()
706
* and glImportSemaphoreFdEXT(), so that glIsSemaphoreEXT() can work correctly.
708
static struct gl_semaphore_object DummySemaphoreObject;
711
* Delete a semaphore object.
712
* Not removed from hash table here.
715
_mesa_delete_semaphore_object(struct gl_context *ctx,
716
struct gl_semaphore_object *semObj)
718
if (semObj != &DummySemaphoreObject)
723
_mesa_GenSemaphoresEXT(GLsizei n, GLuint *semaphores)
725
GET_CURRENT_CONTEXT(ctx);
727
const char *func = "glGenSemaphoresEXT";
729
if (MESA_VERBOSE & (VERBOSE_API))
730
_mesa_debug(ctx, "%s(%d, %p)", func, n, semaphores);
732
if (!ctx->Extensions.EXT_semaphore) {
733
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
738
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
745
_mesa_HashLockMutex(ctx->Shared->SemaphoreObjects);
746
if (_mesa_HashFindFreeKeys(ctx->Shared->SemaphoreObjects, semaphores, n)) {
747
for (GLsizei i = 0; i < n; i++) {
748
_mesa_HashInsertLocked(ctx->Shared->SemaphoreObjects,
749
semaphores[i], &DummySemaphoreObject, true);
753
_mesa_HashUnlockMutex(ctx->Shared->SemaphoreObjects);
757
_mesa_DeleteSemaphoresEXT(GLsizei n, const GLuint *semaphores)
759
GET_CURRENT_CONTEXT(ctx);
761
const char *func = "glDeleteSemaphoresEXT";
763
if (MESA_VERBOSE & (VERBOSE_API)) {
764
_mesa_debug(ctx, "%s(%d, %p)\n", func, n, semaphores);
767
if (!ctx->Extensions.EXT_semaphore) {
768
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
773
_mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
780
_mesa_HashLockMutex(ctx->Shared->SemaphoreObjects);
781
for (GLint i = 0; i < n; i++) {
782
if (semaphores[i] > 0) {
783
struct gl_semaphore_object *delObj
784
= _mesa_lookup_semaphore_object_locked(ctx, semaphores[i]);
787
_mesa_HashRemoveLocked(ctx->Shared->SemaphoreObjects,
789
_mesa_delete_semaphore_object(ctx, delObj);
793
_mesa_HashUnlockMutex(ctx->Shared->SemaphoreObjects);
797
_mesa_IsSemaphoreEXT(GLuint semaphore)
799
GET_CURRENT_CONTEXT(ctx);
801
if (!ctx->Extensions.EXT_semaphore) {
802
_mesa_error(ctx, GL_INVALID_OPERATION, "glIsSemaphoreEXT(unsupported)");
806
struct gl_semaphore_object *obj =
807
_mesa_lookup_semaphore_object(ctx, semaphore);
809
return obj ? GL_TRUE : GL_FALSE;
813
* Helper that outputs the correct error status for parameter
814
* calls where no pnames are defined
817
semaphore_parameter_stub(const char* func, GLenum pname)
819
GET_CURRENT_CONTEXT(ctx);
821
if (!ctx->Extensions.EXT_semaphore) {
822
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
826
/* EXT_semaphore and EXT_semaphore_fd define no parameters */
827
_mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
831
_mesa_SemaphoreParameterui64vEXT(GLuint semaphore,
833
const GLuint64 *params)
835
const char *func = "glSemaphoreParameterui64vEXT";
837
semaphore_parameter_stub(func, pname);
841
_mesa_GetSemaphoreParameterui64vEXT(GLuint semaphore,
845
const char *func = "glGetSemaphoreParameterui64vEXT";
847
semaphore_parameter_stub(func, pname);
851
_mesa_WaitSemaphoreEXT(GLuint semaphore,
852
GLuint numBufferBarriers,
853
const GLuint *buffers,
854
GLuint numTextureBarriers,
855
const GLuint *textures,
856
const GLenum *srcLayouts)
858
GET_CURRENT_CONTEXT(ctx);
859
struct gl_semaphore_object *semObj = NULL;
860
struct gl_buffer_object **bufObjs = NULL;
861
struct gl_texture_object **texObjs = NULL;
863
const char *func = "glWaitSemaphoreEXT";
865
if (!ctx->Extensions.EXT_semaphore) {
866
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
870
ASSERT_OUTSIDE_BEGIN_END(ctx);
872
semObj = _mesa_lookup_semaphore_object(ctx, semaphore);
876
FLUSH_VERTICES(ctx, 0, 0);
878
bufObjs = malloc(sizeof(struct gl_buffer_object *) * numBufferBarriers);
880
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numBufferBarriers=%u)",
881
func, numBufferBarriers);
885
for (unsigned i = 0; i < numBufferBarriers; i++) {
886
bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
889
texObjs = malloc(sizeof(struct gl_texture_object *) * numTextureBarriers);
891
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numTextureBarriers=%u)",
892
func, numTextureBarriers);
896
for (unsigned i = 0; i < numTextureBarriers; i++) {
897
texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
900
server_wait_semaphore(ctx, semObj,
901
numBufferBarriers, bufObjs,
902
numTextureBarriers, texObjs,
911
_mesa_SignalSemaphoreEXT(GLuint semaphore,
912
GLuint numBufferBarriers,
913
const GLuint *buffers,
914
GLuint numTextureBarriers,
915
const GLuint *textures,
916
const GLenum *dstLayouts)
918
GET_CURRENT_CONTEXT(ctx);
919
struct gl_semaphore_object *semObj = NULL;
920
struct gl_buffer_object **bufObjs = NULL;
921
struct gl_texture_object **texObjs = NULL;
923
const char *func = "glSignalSemaphoreEXT";
925
if (!ctx->Extensions.EXT_semaphore) {
926
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
930
ASSERT_OUTSIDE_BEGIN_END(ctx);
932
semObj = _mesa_lookup_semaphore_object(ctx, semaphore);
936
FLUSH_VERTICES(ctx, 0, 0);
938
bufObjs = malloc(sizeof(struct gl_buffer_object *) * numBufferBarriers);
940
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numBufferBarriers=%u)",
941
func, numBufferBarriers);
945
for (unsigned i = 0; i < numBufferBarriers; i++) {
946
bufObjs[i] = _mesa_lookup_bufferobj(ctx, buffers[i]);
949
texObjs = malloc(sizeof(struct gl_texture_object *) * numTextureBarriers);
951
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(numTextureBarriers=%u)",
952
func, numTextureBarriers);
956
for (unsigned i = 0; i < numTextureBarriers; i++) {
957
texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
960
server_signal_semaphore(ctx, semObj,
961
numBufferBarriers, bufObjs,
962
numTextureBarriers, texObjs,
971
_mesa_ImportMemoryFdEXT(GLuint memory,
976
GET_CURRENT_CONTEXT(ctx);
978
const char *func = "glImportMemoryFdEXT";
980
if (!ctx->Extensions.EXT_memory_object_fd) {
981
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
985
if (handleType != GL_HANDLE_TYPE_OPAQUE_FD_EXT) {
986
_mesa_error(ctx, GL_INVALID_ENUM, "%s(handleType=%u)", func, handleType);
990
struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, memory);
994
import_memoryobj_fd(ctx, memObj, size, fd);
995
memObj->Immutable = GL_TRUE;
999
_mesa_ImportSemaphoreFdEXT(GLuint semaphore,
1003
GET_CURRENT_CONTEXT(ctx);
1005
const char *func = "glImportSemaphoreFdEXT";
1007
if (!ctx->Extensions.EXT_semaphore_fd) {
1008
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported)", func);
1012
if (handleType != GL_HANDLE_TYPE_OPAQUE_FD_EXT) {
1013
_mesa_error(ctx, GL_INVALID_ENUM, "%s(handleType=%u)", func, handleType);
1017
struct gl_semaphore_object *semObj = _mesa_lookup_semaphore_object(ctx,
1022
if (semObj == &DummySemaphoreObject) {
1023
semObj = semaphoreobj_alloc(ctx, semaphore);
1025
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
1028
_mesa_HashInsert(ctx->Shared->SemaphoreObjects, semaphore, semObj, true);
1031
import_semaphoreobj_fd(ctx, semObj, fd);