replace DXGI_SHARED_RESOURCE_READ|DXGI_SHARED_RESOURCE_WRITE with D3DDDI_SYNC_OBJECT_ALL_ACCESS can pass
Win10 the monitor fence that opened from nthandle fail to signal by D3DKMTSignalSynchronizationObjectFromGpu2
lambert liu
0
Reputation points
D3DKMTSignalSynchronizationObjectFromGpu2 fail to signal the opened monitor fence that opened from the nthandle return from D3DKMTCreateSynchronizationObject2, with return value 0xc0000022. here is the sample code.
//1. create nt shared monitor fence
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 arg={0}
arg.hDevice = device_handle;
arg.Info.Type = D3DDDI_MONITORED_FENCE;
arg.Flags.Shared = 1;
arg.Flags.NtSecuritySharing = 1;
NTSTATUS ret = D3DKMTCreateSynchronizationObject2(arg);// ret is STATUS_SUCCESS
//2. get shared nt handle
HANDLE nt_handle = 0;
OBJECT_ATTRIBUTES objAttr = {};
objAttr.Length = sizeof(OBJECT_ATTRIBUTES);
NTSTATUS ret1 = D3DKMTShareObjects(1, &arg.hSyncObject, &objAttr,
DXGI_SHARED_RESOURCE_READ|DXGI_SHARED_RESOURCE_WRITE, &nt_handle);//ret1 is STATUS_SUCCESS
//3. duplicate a new_nt_handle from nt_handle.
HANDLE new_nt_handle = 0;
DuplicateHandle(GetCurrentProcess(), nt_handle, GetCurrentProcess(),
&new_nt_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)
//4. open the duplicate new_nt_handle
D3DKMT_OPENSYNCOBJECTFROMNTHANDLE2 arg2 = {0};
arg2.hDevice = device_handle;
arg2.hNtHandle = new_nt_handle;
arg2.Flags.Shared = 1;
arg2.Flags.NtSecuritySharing = 1;
NTSTATUS ret2 = D3DKMTOpenSyncObjectFromNtHandle2(&arg2); //ret2 is STATUS_SUCCESS
//5. signale from gpu
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT2 arg3 = {0};
arg3.ObjectCount = 1;
arg3.ObjectHandleArray = &new_nt_handle;
arg3.BroadcastContextCount = 1;
arg3.BroadcastContextArray = &context_handle;
arg3.MonitoredFenceValueArray = &MonitoredFenceValue;
NTSTATUS ret3 = D3DKMTSignalSynchronizationObjectFromGpu2(&arg3);//ret3 is 0xC0000022
anyone can figure out why the opened monitor fence can't be signal from D3DKMTSignalSynchronizationObjectFromGpu2, I do share it as read&write access.
Windows for business | Windows Client for IT Pros | Devices and deployment | Other
Windows for business | Windows Client for IT Pros | User experience | Other
Microsoft Security | Microsoft Graph
Microsoft Security | Microsoft Graph
An API that connects multiple Microsoft services, enabling data access and automation across platforms
1 answer
Sort by: Most helpful
-
lambert liu 0 Reputation points
2024-03-07T07:07:39.19+00:00