Skip to content

Commit

Permalink
Added APIs to share object with host and creation of sync files
Browse files Browse the repository at this point in the history
  • Loading branch information
Iouri Tarassov committed Oct 28, 2021
1 parent bf4f9b6 commit 5fbdca4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 28 additions & 1 deletion include/d3dkmthk.h
Original file line number Diff line number Diff line change
Expand Up @@ -4978,6 +4978,28 @@ typedef struct _D3DKMT_SHAREOBJECTS {
D3DKMT_PTR(HANDLE*, pSharedNtHandle); // out
} D3DKMT_SHAREOBJECTS;

typedef struct _D3DKMT_SHAREOBJECTWITHHOST
{
D3DKMT_HANDLE hDevice; // in
D3DKMT_HANDLE hObject; // in
D3DKMT_ALIGN64 UINT64 Reserved; // in Must be zero. Reserved for future use
D3DKMT_ALIGN64 UINT64 hVailProcessNtHandle; // out
} D3DKMT_SHAREOBJECTWITHHOST;

//
// This API is used to support sync_file in Android.
// A sync_file is a wrapper around the given monitored fence and the fence value.
// When a sync_file is created, a wait for sync object on CPU is issued
// and a file descriptor (FD) it returned to the app. The app can wait on the FD,
// which will be unblocked when the sync object with this fence value is signaled.
//
typedef struct _D3DKMT_CREATESYNCFILE
{
D3DKMT_HANDLE hDevice; // in: Device owner of the monitored fence.
D3DKMT_HANDLE hMonitoredFence; // in: Monitored fence object
D3DKMT_ALIGN64 UINT64 FenceValue; // in: Fence value to wait for
D3DKMT_ALIGN64 UINT64 hSyncFile; // out: File descriptor on Android or a NT handle on Windows (when implemented)
} D3DKMT_CREATESYNCFILE;

typedef struct _D3DKMT_TRIMNOTIFICATION
{
Expand Down Expand Up @@ -5625,9 +5647,14 @@ typedef _Check_return_ NTSTATUS (APIENTRY *PFND3DKMT_DISPLAYPORT_OPERATION)(_Ino

typedef _Check_return_ NTSTATUS (APIENTRY *PFND3DKMT_CANCELPRESENTS)(_In_ D3DKMT_CANCEL_PRESENTS*);


#endif

EXTERN_C _Check_return_ NTSTATUS APIENTRY D3DKMTShareObjectWithHost(_Inout_ D3DKMT_SHAREOBJECTWITHHOST*);
EXTERN_C _Check_return_ NTSTATUS APIENTRY D3DKMTCreateSyncFile(_Inout_ D3DKMT_CREATESYNCFILE*);

// Used in WSL to close the internal file descriptor to /dev/dxg
EXTERN_C VOID APIENTRY D3DKMTCloseDxCoreDevice();

#if !defined(D3DKMDT_SPECIAL_MULTIPLATFORM_TOOL)

#ifdef __cplusplus
Expand Down
2 changes: 2 additions & 0 deletions src/d3dkmt-wsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ DEFINE_KMT(OpenSyncObjectFromNtHandle2, D3DKMT_OPENSYNCOBJECTFROMNTHANDLE2, 0x40
DEFINE_KMT(QueryResourceInfoFromNtHandle, D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE, 0x41, NONCONST)
DEFINE_KMT(OpenResourceFromNtHandle, D3DKMT_OPENRESOURCEFROMNTHANDLE, 0x42, NONCONST)
DEFINE_KMT(QueryStatistics, D3DKMT_QUERYSTATISTICS, 0x43, CONST)
DEFINE_KMT(ShareObjectWithHost, D3DKMT_SHAREOBJECTWITHHOST, 0x44, NONCONST)
DEFINE_KMT(CreateSyncFile, D3DKMT_CREATESYNCFILE, 0x45, NONCONST)

// Not-implemented thunks (NT handles, or not in the compute interface subset we're using)
DEFINE_KMT_NOT_IMPL(GetMultisampleMethodList, D3DKMT_GETMULTISAMPLEMETHODLIST, NONCONST)
Expand Down

0 comments on commit 5fbdca4

Please sign in to comment.