From 02c781b8f491ffc602943f41cc7591f6dbc0b3a3 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 14 Oct 2022 21:20:35 -0500 Subject: [PATCH] Increase the number of decoder surfaces for DXVA2/D3D11VA We forgot to take into account frames buffered within Moonlight itself --- app/streaming/video/ffmpeg-renderers/d3d11va.cpp | 3 ++- app/streaming/video/ffmpeg-renderers/d3d11va.h | 2 +- app/streaming/video/ffmpeg-renderers/dxva2.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp index c1e3a827..11b9120b 100644 --- a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp +++ b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp @@ -458,7 +458,8 @@ bool D3D11VARenderer::initialize(PDECODER_PARAMETERS params) framesContext->width = FFALIGN(params->width, m_TextureAlignment); framesContext->height = FFALIGN(params->height, m_TextureAlignment); - // We can have up to 16 reference frames plus a working surface + // We can have up to 16 reference frames plus a working surface plus the maximum + // number of frames in our various pacing and rendering queues. framesContext->initial_pool_size = DECODER_BUFFER_POOL_SIZE; AVD3D11VAFramesContext* d3d11vaFramesContext = (AVD3D11VAFramesContext*)framesContext->hwctx; diff --git a/app/streaming/video/ffmpeg-renderers/d3d11va.h b/app/streaming/video/ffmpeg-renderers/d3d11va.h index f489fa8c..12bc9ca4 100644 --- a/app/streaming/video/ffmpeg-renderers/d3d11va.h +++ b/app/streaming/video/ffmpeg-renderers/d3d11va.h @@ -60,7 +60,7 @@ private: ID3D11PixelShader* m_VideoBt2020LimPixelShader; ID3D11Buffer* m_VideoVertexBuffer; -#define DECODER_BUFFER_POOL_SIZE 17 +#define DECODER_BUFFER_POOL_SIZE 32 ID3D11ShaderResourceView* m_VideoTextureResourceViews[DECODER_BUFFER_POOL_SIZE][2]; SDL_SpinLock m_OverlayLock; diff --git a/app/streaming/video/ffmpeg-renderers/dxva2.h b/app/streaming/video/ffmpeg-renderers/dxva2.h index a2e23cb3..588eba29 100644 --- a/app/streaming/video/ffmpeg-renderers/dxva2.h +++ b/app/streaming/video/ffmpeg-renderers/dxva2.h @@ -55,7 +55,7 @@ private: int m_DisplayHeight; struct dxva_context m_DXVAContext; - IDirect3DSurface9* m_DecSurfaces[19]; + IDirect3DSurface9* m_DecSurfaces[32]; DXVA2_ConfigPictureDecode m_Config; IDirectXVideoDecoderService* m_DecService; IDirectXVideoDecoder* m_Decoder;