gallium, windows: Use HANDLE instead of FD for external objects
Reviewed-by: Emma Anholt <emma@anholt.net> Reviewed-by: Bill Kristiansen <billkris@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13054>
This commit is contained in:
@@ -1103,7 +1103,7 @@ llvmpipe_resource_get_param(struct pipe_screen *screen,
|
||||
|
||||
if (!llvmpipe_resource_get_handle(screen, context, resource, &whandle, handle_usage))
|
||||
return false;
|
||||
*value = whandle.handle;
|
||||
*value = (uint64_t)whandle.handle;
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
|
@@ -668,6 +668,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
|
||||
mai.pNext = &emai;
|
||||
}
|
||||
|
||||
#ifdef ZINK_USE_DMABUF
|
||||
VkImportMemoryFdInfoKHR imfi = {
|
||||
VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
|
||||
NULL,
|
||||
@@ -685,6 +686,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
|
||||
imfi.pNext = mai.pNext;
|
||||
mai.pNext = &imfi;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct wsi_memory_allocate_info memory_wsi_info = {
|
||||
VK_STRUCTURE_TYPE_WSI_MEMORY_ALLOCATE_INFO_MESA,
|
||||
@@ -931,6 +933,7 @@ zink_resource_get_param(struct pipe_screen *pscreen, struct pipe_context *pctx,
|
||||
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_SHARED:
|
||||
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_KMS:
|
||||
case PIPE_RESOURCE_PARAM_HANDLE_TYPE_FD: {
|
||||
#ifdef ZINK_USE_DMABUF
|
||||
memset(&whandle, 0, sizeof(whandle));
|
||||
if (param == PIPE_RESOURCE_PARAM_HANDLE_TYPE_SHARED)
|
||||
whandle.type = WINSYS_HANDLE_TYPE_SHARED;
|
||||
@@ -944,6 +947,10 @@ zink_resource_get_param(struct pipe_screen *pscreen, struct pipe_context *pctx,
|
||||
|
||||
*value = whandle.handle;
|
||||
break;
|
||||
#else
|
||||
(void)whandle;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@@ -2,6 +2,10 @@
|
||||
#ifndef _WINSYS_HANDLE_H_
|
||||
#define _WINSYS_HANDLE_H_
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -9,6 +13,8 @@ extern "C" {
|
||||
#define WINSYS_HANDLE_TYPE_SHARED 0
|
||||
#define WINSYS_HANDLE_TYPE_KMS 1
|
||||
#define WINSYS_HANDLE_TYPE_FD 2
|
||||
/* Win32 handles serve the same purpose as FD, just on Windows, so alias the value */
|
||||
#define WINSYS_HANDLE_TYPE_WIN32_HANDLE WINSYS_HANDLE_TYPE_FD
|
||||
#define WINSYS_HANDLE_TYPE_SHMID 3
|
||||
#define WINSYS_HANDLE_TYPE_D3D12_RES 4
|
||||
|
||||
@@ -38,7 +44,11 @@ struct winsys_handle
|
||||
* Input to texture_from_handle.
|
||||
* Output for texture_get_handle.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
HANDLE handle;
|
||||
#else
|
||||
unsigned handle;
|
||||
#endif
|
||||
/**
|
||||
* Input to texture_from_handle.
|
||||
* Output for texture_get_handle.
|
||||
|
@@ -70,6 +70,7 @@ st_import_memoryobj_fd(struct gl_context *ctx,
|
||||
GLuint64 size,
|
||||
int fd)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
struct st_memory_object *st_obj = st_memory_object(obj);
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_screen *screen = st->screen;
|
||||
@@ -85,7 +86,6 @@ st_import_memoryobj_fd(struct gl_context *ctx,
|
||||
&whandle,
|
||||
obj->Dedicated);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
/* We own fd, but we no longer need it. So get rid of it */
|
||||
close(fd);
|
||||
#endif
|
||||
|
@@ -844,7 +844,9 @@ void st_init_extensions(struct pipe_screen *screen,
|
||||
{ o(EXT_disjoint_timer_query), PIPE_CAP_QUERY_TIMESTAMP },
|
||||
{ o(EXT_draw_buffers2), PIPE_CAP_INDEP_BLEND_ENABLE },
|
||||
{ o(EXT_memory_object), PIPE_CAP_MEMOBJ },
|
||||
#ifndef _WIN32
|
||||
{ o(EXT_memory_object_fd), PIPE_CAP_MEMOBJ },
|
||||
#endif
|
||||
{ o(EXT_multisampled_render_to_texture), PIPE_CAP_SURFACE_SAMPLE_COUNT },
|
||||
{ o(EXT_semaphore), PIPE_CAP_FENCE_SIGNAL },
|
||||
{ o(EXT_semaphore_fd), PIPE_CAP_FENCE_SIGNAL },
|
||||
|
Reference in New Issue
Block a user