2020-01-11 20:22:15 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
#include "pacer/pacer.h"
|
|
|
|
|
|
|
|
#include <d3d11_1.h>
|
|
|
|
#include <dxgi1_5.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavutil/hwcontext_d3d11va.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
class D3D11VARenderer : public IFFmpegRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
D3D11VARenderer();
|
|
|
|
virtual ~D3D11VARenderer() override;
|
|
|
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
|
|
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary**) override;
|
2022-02-05 03:51:34 +00:00
|
|
|
virtual bool prepareDecoderContextInGetFormat(AVCodecContext* context, AVPixelFormat pixelFormat) override;
|
2020-01-11 20:22:15 +00:00
|
|
|
virtual void renderFrame(AVFrame* frame) override;
|
2022-04-08 02:46:48 +00:00
|
|
|
virtual void waitToRender() override;
|
2020-01-11 20:22:15 +00:00
|
|
|
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
|
|
|
virtual void setHdrMode(bool enabled) override;
|
|
|
|
virtual int getRendererAttributes() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void lockContext(void* lock_ctx);
|
|
|
|
static void unlockContext(void* lock_ctx);
|
|
|
|
|
|
|
|
bool setupRenderingResources();
|
2022-02-05 20:49:08 +00:00
|
|
|
bool setupTexturePoolViews(AVD3D11VAFramesContext* frameContext);
|
2020-01-11 20:22:15 +00:00
|
|
|
void renderOverlay(Overlay::OverlayType type);
|
2022-02-10 02:46:02 +00:00
|
|
|
void bindColorConversion(AVFrame* frame);
|
2022-02-05 03:51:34 +00:00
|
|
|
void renderVideo(AVFrame* frame);
|
2020-01-11 20:22:15 +00:00
|
|
|
bool checkDecoderSupport(IDXGIAdapter* adapter);
|
|
|
|
|
|
|
|
IDXGIFactory5* m_Factory;
|
|
|
|
ID3D11Device* m_Device;
|
|
|
|
IDXGISwapChain4* m_SwapChain;
|
|
|
|
ID3D11DeviceContext* m_DeviceContext;
|
|
|
|
ID3D11RenderTargetView* m_RenderTargetView;
|
|
|
|
SDL_mutex* m_ContextLock;
|
|
|
|
|
|
|
|
DECODER_PARAMETERS m_DecoderParams;
|
2022-02-05 21:21:42 +00:00
|
|
|
int m_TextureAlignment;
|
2020-01-11 20:22:15 +00:00
|
|
|
int m_DisplayWidth;
|
|
|
|
int m_DisplayHeight;
|
|
|
|
bool m_Windowed;
|
2022-02-05 03:51:34 +00:00
|
|
|
AVColorSpace m_LastColorSpace;
|
|
|
|
AVColorRange m_LastColorRange;
|
2020-01-11 20:22:15 +00:00
|
|
|
|
|
|
|
bool m_AllowTearing;
|
|
|
|
HANDLE m_FrameWaitableObject;
|
2022-02-05 03:51:34 +00:00
|
|
|
|
2022-02-10 02:46:02 +00:00
|
|
|
ID3D11PixelShader* m_VideoGenericPixelShader;
|
|
|
|
ID3D11PixelShader* m_VideoBt601LimPixelShader;
|
|
|
|
ID3D11PixelShader* m_VideoBt2020LimPixelShader;
|
2022-02-05 03:51:34 +00:00
|
|
|
ID3D11Buffer* m_VideoVertexBuffer;
|
2020-01-11 20:22:15 +00:00
|
|
|
|
2022-02-05 20:49:08 +00:00
|
|
|
#define DECODER_BUFFER_POOL_SIZE 17
|
|
|
|
ID3D11ShaderResourceView* m_VideoTextureResourceViews[DECODER_BUFFER_POOL_SIZE][2];
|
|
|
|
|
2020-01-11 20:22:15 +00:00
|
|
|
SDL_SpinLock m_OverlayLock;
|
|
|
|
ID3D11Buffer* m_OverlayVertexBuffers[Overlay::OverlayMax];
|
|
|
|
ID3D11Texture2D* m_OverlayTextures[Overlay::OverlayMax];
|
|
|
|
ID3D11ShaderResourceView* m_OverlayTextureResourceViews[Overlay::OverlayMax];
|
|
|
|
ID3D11PixelShader* m_OverlayPixelShader;
|
|
|
|
|
2022-02-05 03:51:34 +00:00
|
|
|
AVBufferRef* m_HwDeviceContext;
|
|
|
|
AVBufferRef* m_HwFramesContext;
|
2020-01-11 20:22:15 +00:00
|
|
|
};
|
|
|
|
|