Bug 1903047 - Wait ID3D11Query of D3D11Texture2D copy complete before color conversion if ID3D11Query of DXGITextureHostD3D11 exists r=gfx-reviewers,lsalzman

It is necessary to wait ID3D11Query of before color conversion if the ID3D11Query exists in DXGITextureHostD3D11::GetAsSurfaceWithDevice() like Bug 1817617. Since the color conversion seems to use VideoProcessor internally.

Differential Revision: https://phabricator.services.mozilla.com/D215580
This commit is contained in:
sotaro
2024-07-03 06:26:30 +00:00
parent e5f81768cd
commit 8a9c009b8d
2 changed files with 19 additions and 2 deletions

View File

@@ -51,8 +51,6 @@ void GpuProcessD3D11QueryMap::Unregister(GpuProcessQueryId aQueryId) {
RefPtr<ID3D11Query> GpuProcessD3D11QueryMap::GetQuery(
GpuProcessQueryId aQueryId) {
MOZ_ASSERT(wr::RenderThread::IsInRenderThread());
MonitorAutoLock lock(mMonitor);
auto it = mD3D11QueriesById.find(aQueryId);

View File

@@ -1029,6 +1029,25 @@ DXGITextureHostD3D11::GetAsSurfaceWithDevice(ID3D11Device* const aDevice) {
return nullptr;
}
RefPtr<ID3D11DeviceContext> context;
device->GetImmediateContext(getter_AddRefs(context));
auto* queryMap = GpuProcessD3D11QueryMap::Get();
if (queryMap && mGpuProcessQueryId.isSome()) {
auto query = queryMap->GetQuery(mGpuProcessQueryId.ref());
if (query) {
// Wait ID3D11Query of D3D11Texture2D copy complete just before blitting
// for video overlay with non Intel GPUs. See Bug 1817617.
BOOL result;
bool ret = layers::WaitForFrameGPUQuery(device, context, query, &result);
if (!ret) {
gfxCriticalNoteOnce << "WaitForFrameGPUQuery() failed";
}
} else {
gfxCriticalNoteOnce << "Failed to get ID3D11Query";
}
}
nsAutoCString error;
std::unique_ptr<DXVA2Manager> manager(
DXVA2Manager::CreateD3D11DXVA(nullptr, error, device));