Bug 1916566 - Add GL_EXT_semaphore and GL_EXT_semaphore_fd support to GLContext r=gfx-reviewers,nical

GL_EXT_semaphore and GL_EXT_semaphore_fd are used to import Vulkan semaphores into OpenGL from POSIX file descriptor external handles.

Differential Revision: https://phabricator.services.mozilla.com/D220978
This commit is contained in:
sotaro 2024-09-10 07:12:33 +00:00
Родитель c13c057bd3
Коммит a2adf2790f
3 изменённых файлов: 105 добавлений и 0 удалений

Просмотреть файл

@ -178,6 +178,8 @@ static const char* const sExtensionNames[] = {
"GL_EXT_timer_query",
"GL_EXT_transform_feedback",
"GL_EXT_unpack_subimage",
"GL_EXT_semaphore",
"GL_EXT_semaphore_fd",
"GL_IMG_read_format",
"GL_IMG_texture_compression_pvrtc",
"GL_IMG_texture_npot",
@ -1497,6 +1499,30 @@ void GLContext::LoadMoreSymbols(const SymbolLoader& loader) {
fnLoadForFeature(symbols, GLFeature::provoking_vertex);
}
if (IsExtensionSupported(EXT_semaphore)) {
const SymLoadStruct symbols[] = {
{(PRFuncPtr*)&mSymbols.fDeleteSemaphoresEXT,
{{"glDeleteSemaphoresEXT"}}},
{(PRFuncPtr*)&mSymbols.fGenSemaphoresEXT, {{"glGenSemaphoresEXT"}}},
{(PRFuncPtr*)&mSymbols.fGetSemaphoreParameterui64vEXT,
{{"glGetSemaphoreParameterui64vEXT"}}},
{(PRFuncPtr*)&mSymbols.fIsSemaphoreEXT, {{"glIsSemaphoreEXT"}}},
{(PRFuncPtr*)&mSymbols.fSemaphoreParameterui64vEXT,
{{"glSemaphoreParameterui64vEXT"}}},
{(PRFuncPtr*)&mSymbols.fSignalSemaphoreEXT, {{"glSignalSemaphoreEXT"}}},
{(PRFuncPtr*)&mSymbols.fWaitSemaphoreEXT, {{"glWaitSemaphoreEXT"}}},
END_SYMBOLS};
fnLoadForExt(symbols, EXT_semaphore);
}
if (IsExtensionSupported(EXT_semaphore_fd)) {
const SymLoadStruct symbols[] = {
{(PRFuncPtr*)&mSymbols.fImportSemaphoreFdEXT,
{{"glImportSemaphoreFdEXT"}}},
END_SYMBOLS};
fnLoadForExt(symbols, EXT_semaphore_fd);
}
// Load developer symbols, don't fail if we can't find them.
const SymLoadStruct devSymbols[] = {CORE_SYMBOL(GetTexImage),
CORE_SYMBOL(GetTexLevelParameteriv),

Просмотреть файл

@ -457,6 +457,8 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
EXT_timer_query,
EXT_transform_feedback,
EXT_unpack_subimage,
EXT_semaphore,
EXT_semaphore_fd,
IMG_read_format,
IMG_texture_compression_pvrtc,
IMG_texture_npot,
@ -3432,6 +3434,68 @@ class GLContext : public GenericAtomicRefCounted, public SupportsWeakPtr {
AFTER_GL_CALL;
}
// -----------------------------------------------------------------------------
// GL_EXT_semaphore
void fDeleteSemaphoresEXT(GLsizei n, const GLuint* semaphores) {
BEFORE_GL_CALL;
mSymbols.fDeleteSemaphoresEXT(n, semaphores);
AFTER_GL_CALL;
}
void fGenSemaphoresEXT(GLsizei n, GLuint* semaphores) {
BEFORE_GL_CALL;
mSymbols.fGenSemaphoresEXT(n, semaphores);
AFTER_GL_CALL;
}
void fGetSemaphoreParameterui64vEXT(GLuint semaphore, GLenum pname,
GLuint64* params) {
BEFORE_GL_CALL;
mSymbols.fGetSemaphoreParameterui64vEXT(semaphore, pname, params);
AFTER_GL_CALL;
}
realGLboolean fIsSemaphoreEXT(GLuint semaphore) {
realGLboolean ret = false;
BEFORE_GL_CALL;
ret = mSymbols.fIsSemaphoreEXT(semaphore);
AFTER_GL_CALL;
return ret;
}
void fSemaphoreParameterui64vEXT(GLuint semaphore, GLenum pname,
const GLuint64* params) {
BEFORE_GL_CALL;
mSymbols.fSemaphoreParameterui64vEXT(semaphore, pname, params);
AFTER_GL_CALL;
}
void fSignalSemaphoreEXT(GLuint semaphore, GLuint numBufferBarriers,
const GLuint* buffers, GLuint numTextureBarriers,
const GLuint* textures, const GLenum* dstLayouts) {
BEFORE_GL_CALL;
mSymbols.fSignalSemaphoreEXT(semaphore, numBufferBarriers, buffers,
numTextureBarriers, textures, dstLayouts);
AFTER_GL_CALL;
}
void fWaitSemaphoreEXT(GLuint semaphore, GLuint numBufferBarriers,
const GLuint* buffers, GLuint numTextureBarriers,
const GLuint* textures, const GLenum* srcLayouts) {
BEFORE_GL_CALL;
mSymbols.fWaitSemaphoreEXT(semaphore, numBufferBarriers, buffers,
numTextureBarriers, textures, srcLayouts);
AFTER_GL_CALL;
}
// -----------------------------------------------------------------------------
// GL_EXT_semaphore_fd
void fImportSemaphoreFdEXT(GLuint semaphore, GLenum handleType, GLint fd) {
BEFORE_GL_CALL;
mSymbols.fImportSemaphoreFdEXT(semaphore, handleType, fd);
AFTER_GL_CALL;
}
// -
#undef BEFORE_GL_CALL

Просмотреть файл

@ -459,6 +459,21 @@ struct GLContextSymbols final {
// provoking_vertex
void(GLAPIENTRY* fProvokingVertex)(GLenum);
// GL_EXT_semaphore
void(GLAPIENTRY* fDeleteSemaphoresEXT)(GLsizei, const GLuint*);
void(GLAPIENTRY* fGenSemaphoresEXT)(GLsizei, GLuint*);
void(GLAPIENTRY* fGetSemaphoreParameterui64vEXT)(GLuint, GLenum, GLuint64*);
realGLboolean(GLAPIENTRY* fIsSemaphoreEXT)(GLuint);
void(GLAPIENTRY* fSemaphoreParameterui64vEXT)(GLuint, GLenum,
const GLuint64*);
void(GLAPIENTRY* fSignalSemaphoreEXT)(GLuint, GLuint, const GLuint*, GLuint,
const GLuint*, const GLenum*);
void(GLAPIENTRY* fWaitSemaphoreEXT)(GLuint, GLuint, const GLuint*, GLuint,
const GLuint*, const GLenum*);
// GL_EXT_semaphore_fd
void(GLAPIENTRY* fImportSemaphoreFdEXT)(GLuint, GLenum, GLint);
};
} // namespace gl