GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
583 stars 149 forks source link

[Bug]: amd decode delay #367

Open 375583810a opened 1 year ago

375583810a commented 1 year ago

amf 解码存在帧延迟 这是一个奇怪的问题,当我的渲染组件与amf使用同一个d3d设备时无延迟问题,但会存在当SwapChain->Present阻塞时解码也同时被阻塞。

而当我用两个独立的d3d设备时渲染的第一帧是黑色,第二次才渲染出第一帧, 如果在我从amf调用CopySubresourceRegion拷贝是渲染表面后 立刻调用d3dDev->flush()第一帧正常,但第二次渲染的还是第一帧,第三次渲染第二帧, 而当我从amf每解码出一帧时在将它拷贝至主机内存时就没有渲染延迟问题,不拷贝就有延迟 感觉就像是当不执行拷贝至主机内存,amf根本就没有准备数据

rhutsAMD commented 1 year ago

What is the issue in the single device case? Present() is expected to block the pipeline under some conditions such as waiting for vsync or a full queue.

375583810a commented 1 year ago

image 就像图片中这样,解码队列实际上已堆积了很多帧了,但它却只能以vsync的速度工作

375583810a commented 1 year ago

image 当使用两个独立的d3d设备时,解码器就能在接收到帧时立刻开始工作

rhutsAMD commented 1 year ago

The HW decoder has a limited number of output surfaces/textures. Initially the app submits several decode jobs ASAP until all output surfaces/textures are reserved. After that, the Present() call releases output textures and triggers the next decode job. There is also some internal synchronization which forces the decoder to wait until the assigned output texture is used in another 3D job. This is normal. With two DX devices the timing is different but the synchronization is likely broken.

To see an example of ASAP decoding, please check the SimpleDecoder sample application.