Use ComPtr for lifetime management in D3D11VA

This commit is contained in:
Cameron Gutman
2024-07-30 22:29:38 -05:00
parent 0bb0d27d64
commit 9e811f54f1
2 changed files with 112 additions and 184 deletions
+15 -13
View File
@@ -9,6 +9,8 @@ extern "C" {
#include <libavutil/hwcontext_d3d11va.h>
}
#include <wrl/client.h>
class D3D11VARenderer : public IFFmpegRenderer
{
public:
@@ -51,11 +53,11 @@ private:
int m_DevicesWithFL11Support;
int m_DevicesWithCodecSupport;
IDXGIFactory5* m_Factory;
ID3D11Device* m_Device;
IDXGISwapChain4* m_SwapChain;
ID3D11DeviceContext* m_DeviceContext;
ID3D11RenderTargetView* m_RenderTargetView;
Microsoft::WRL::ComPtr<IDXGIFactory5> m_Factory;
Microsoft::WRL::ComPtr<ID3D11Device> m_Device;
Microsoft::WRL::ComPtr<IDXGISwapChain4> m_SwapChain;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_DeviceContext;
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_RenderTargetView;
SDL_mutex* m_ContextLock;
bool m_BindDecoderOutputTextures;
@@ -70,21 +72,21 @@ private:
bool m_AllowTearing;
std::array<ID3D11PixelShader*, PixelShaders::_COUNT> m_VideoPixelShaders;
ID3D11Buffer* m_VideoVertexBuffer;
std::array<Microsoft::WRL::ComPtr<ID3D11PixelShader>, PixelShaders::_COUNT> m_VideoPixelShaders;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_VideoVertexBuffer;
// Only valid if !m_BindDecoderOutputTextures
ID3D11Texture2D* m_VideoTexture;
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_VideoTexture;
// Only index 0 is valid if !m_BindDecoderOutputTextures
#define DECODER_BUFFER_POOL_SIZE 17
ID3D11ShaderResourceView* m_VideoTextureResourceViews[DECODER_BUFFER_POOL_SIZE][2];
std::array<std::array<Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>, 2>, DECODER_BUFFER_POOL_SIZE> m_VideoTextureResourceViews;
SDL_SpinLock m_OverlayLock;
ID3D11Buffer* m_OverlayVertexBuffers[Overlay::OverlayMax];
ID3D11Texture2D* m_OverlayTextures[Overlay::OverlayMax];
ID3D11ShaderResourceView* m_OverlayTextureResourceViews[Overlay::OverlayMax];
ID3D11PixelShader* m_OverlayPixelShader;
std::array<Microsoft::WRL::ComPtr<ID3D11Buffer>, Overlay::OverlayMax> m_OverlayVertexBuffers;
std::array<Microsoft::WRL::ComPtr<ID3D11Texture2D>, Overlay::OverlayMax> m_OverlayTextures;
std::array<Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>, Overlay::OverlayMax> m_OverlayTextureResourceViews;
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_OverlayPixelShader;
AVBufferRef* m_HwDeviceContext;
AVBufferRef* m_HwFramesContext;