0

[MFVEA] Re-enable back D3DCopy/Scaling for texture on rendering device

A previous change in MF VEA disabled downscaling copy. Re-enable it back. Also restore a previous no-scaling copy that was removed to avoid jitter during encoding.

Bug: 384567067
Change-Id: I5fdd098e687b691bfd75305d11e8f2fe22172ef0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6096777
Commit-Queue: Jianlin Qiu <jianlin.qiu@intel.com>
Reviewed-by: Eugene Zemtsov <eugene@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1397682}
This commit is contained in:
Qiu Jianlin
2024-12-17 17:42:10 -08:00
committed by Chromium LUCI CQ
parent eb6d29be89
commit a72ed981ab

@ -2071,21 +2071,18 @@ HRESULT MediaFoundationVideoEncodeAccelerator::PopulateInputSampleBufferGpu(
hr = PerformD3DScaling(input_texture.Get(), frame->visible_rect());
RETURN_ON_HR_FAILURE(hr, "Failed to perform D3D video processing", hr);
sample_texture = scaled_d3d11_texture_;
} else if (frame->HasSharedImage()) {
// The texture is already a copied version so we can directly use it.
sample_texture = input_texture;
} else {
// Even though no scaling is needed we still need to copy the texture to
// avoid concurrent usage causing glitches (https://crbug.com/1462315). This
// is preferred over holding a keyed mutex for the duration of the encode
// operation since that can take a significant amount of time and mutex
// acquisitions (necessary even for read-only operations) are blocking.
ComD3D11Device texture_device;
input_texture->GetDevice(&texture_device);
if (texture_device == dxgi_device_manager_->GetDevice()) {
sample_texture = input_texture;
} else {
hr = PerformD3DCopy(input_texture.Get(), frame->visible_rect());
RETURN_ON_HR_FAILURE(hr, "Failed to perform D3D texture copy", hr);
sample_texture = copied_d3d11_texture_;
}
}
ComMFMediaBuffer input_buffer;
@ -2540,9 +2537,7 @@ HRESULT MediaFoundationVideoEncodeAccelerator::PerformD3DScaling(
video_context_->VideoProcessorSetOutputColorSpace(video_processor_.Get(),
&output_d3d11_color_space);
ComD3D11Device texture_device;
input_texture->GetDevice(&texture_device);
if (texture_device != dxgi_device_manager_->GetDevice()) {
{
std::optional<gpu::DXGIScopedReleaseKeyedMutex> release_keyed_mutex;
ComDXGIKeyedMutex keyed_mutex;
hr = input_texture->QueryInterface(IID_PPV_ARGS(&keyed_mutex));