mesa: Support importing D3D12 fences as timeline semaphores

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17446>
This commit is contained in:
Jesse Natalie 2022-07-09 19:58:51 -07:00 committed by Marge Bot
parent 8cd391a63e
commit c760f0e8b8
2 changed files with 15 additions and 4 deletions

View File

@ -646,11 +646,13 @@ static void
import_semaphoreobj_win32(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
void *handle,
const void *name)
const void *name,
enum pipe_fd_type type)
{
struct pipe_context *pipe = ctx->pipe;
semObj->type = type;
pipe->screen->create_fence_win32(pipe->screen, &semObj->fence, handle, name, PIPE_FD_TYPE_SYNCOBJ);
pipe->screen->create_fence_win32(pipe->screen, &semObj->fence, handle, name, type);
}
static void
@ -1144,11 +1146,17 @@ _mesa_ImportSemaphoreWin32HandleEXT(GLuint semaphore,
return;
}
if (handleType != GL_HANDLE_TYPE_OPAQUE_WIN32_EXT) {
if (handleType != GL_HANDLE_TYPE_OPAQUE_WIN32_EXT &&
handleType != GL_HANDLE_TYPE_D3D12_FENCE_EXT) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s(handleType=%u)", func, handleType);
return;
}
if (handleType == GL_HANDLE_TYPE_D3D12_FENCE_EXT &&
!ctx->screen->get_param(ctx->screen, PIPE_CAP_TIMELINE_SEMAPHORE_IMPORT)) {
_mesa_error(ctx, GL_INVALID_ENUM, "%s(handleType=%u)", func, handleType);
}
struct gl_semaphore_object *semObj = _mesa_lookup_semaphore_object(ctx,
semaphore);
if (!semObj)
@ -1163,7 +1171,9 @@ _mesa_ImportSemaphoreWin32HandleEXT(GLuint semaphore,
_mesa_HashInsert(ctx->Shared->SemaphoreObjects, semaphore, semObj, true);
}
import_semaphoreobj_win32(ctx, semObj, handle, NULL);
enum pipe_fd_type type = handleType == GL_HANDLE_TYPE_D3D12_FENCE_EXT ?
PIPE_FD_TYPE_TIMELINE_SEMAPHORE : PIPE_FD_TYPE_SYNCOBJ;
import_semaphoreobj_win32(ctx, semObj, handle, NULL, type);
}
void GLAPIENTRY

View File

@ -3069,6 +3069,7 @@ struct gl_semaphore_object
{
GLuint Name; /**< hash table ID/name */
struct pipe_fence_handle *fence;
enum pipe_fd_type type;
};
/**