Win10 the monitor fence that opened from nthandle fail to signal by D3DKMTSignalSynchronizationObjectFromGpu2

lambert liu 0 Reputation points
2024-03-07T04:48:02.73+00:00

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 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,620 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,748 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,593 questions
Windows Hardware Performance
Windows Hardware Performance
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Hardware Performance: Delivering / providing hardware or hardware systems or adjusting / adapting hardware or hardware systems.
1,543 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,168 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. lambert liu 0 Reputation points
    2024-03-07T07:07:39.19+00:00
    replace DXGI_SHARED_RESOURCE_READ|DXGI_SHARED_RESOURCE_WRITE with D3DDDI_SYNC_OBJECT_ALL_ACCESS can pass
    
    0 comments No comments