microsoft / microsoft/DirectX-Graphics-Samples
Direct3D 12 Motion Estimation (sample ?)
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 6.8k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
I trying to add hardware Motion Estimation support to freeware Avisynth plugin mvtoots based on new Microsoft API Direct3D Motion Estimation. Unfortunately the description at https://docs.microsoft.com/en-us/windows/win32/medfound/direct3d-video-motion-estimation is very incomplete and do not shows how to load source and ref frames to Motion Estimator input resources and get data back.
Current progress - the InitD3D12 and each pairs frames processing is mostly done (in this commit - https://github.com/DTL2020/mvtools/commit/ed95355629cd294181b90747e32ac261b683ade9 ) :
Init is function https://github.com/DTL2020/mvtools/blob/ed95355629cd294181b90747e32ac261b683ade9/Sources/MVAnalyse.cpp#L1046
and processing is inside block:
https://github.com/DTL2020/mvtools/blob/ed95355629cd294181b90747e32ac261b683ade9/Sources/MVAnalyse.cpp#L701
Current state: the all called from Direct3D functions returns non-error HRs but the final mapping of the readback buffer
https://github.com/DTL2020/mvtools/blob/ed95355629cd294181b90747e32ac261b683ade9/Sources/MVAnalyse.cpp#L883
return error 'D3D device disconnected' (DXGI_ERROR_DEVICE_REMOVED error 0x887A0005) and error-reason
https://github.com/DTL2020/mvtools/blob/ed95355629cd294181b90747e32ac261b683ade9/Sources/MVAnalyse.cpp#L886
'application have bugs and need debug' (DXGI_ERROR_INVALID_CALL 0x887A0001 | The application provided invalid parameter data; this must be debugged and fixed before the application is released.) Very unclear where may be an error in many of API calls.
Also of really visible differences from the described Motion Estimation API: I still do not found how to switch source resources state from 'resource write' (required to copy input data into resource) to state 'D3D12_RESOURCE_STATE_VIDEO_ENCODE_READ required before call to EstimateMotion().
When I try to add resourcebarrier
https://github.com/DTL2020/mvtools/blob/ed95355629cd294181b90747e32ac261b683ade9/Sources/MVAnalyse.cpp#L722
to change resource state from D3D12_RESOURCE_STATE_COPY_DEST to D3D12_RESOURCE_STATE_VIDEO_ENCODE_READ
the CommandList->Close(); function returns error indicating in the command sequence there is an error somewhere.
Are there any working sample of feeding frames data in the D3D12 video encoder or motion estimator available ? Or what is the preffered way to get an support on Direct3D 12 video API if possible ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked commit and Sources/MVAnalyse.cpp, especially InitD3D12 around line 1046, frame processing around line 701, the barrier around line 722, and readback mapping around line 883. Trace the Direct3D 12 calls and resource states to determine the cause of device removal and define what a working motion-estimation sample or documented support path would need to demonstrate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100