Optimize CUDA GL interop and provide fallback
This commit is contained in:
parent
c4d85cf928
commit
36e0468a99
4 changed files with 168 additions and 62 deletions
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
#include "renderer.h"
|
||||
|
||||
#include <ffnvcodec/dynlink_loader.h>
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/hwcontext_cuda.h>
|
||||
}
|
||||
|
||||
class CUDARenderer : public IFFmpegRenderer {
|
||||
public:
|
||||
CUDARenderer();
|
||||
|
|
@ -12,10 +18,25 @@ public:
|
|||
virtual bool needsTestFrame() override;
|
||||
virtual bool isDirectRenderingSupported() override;
|
||||
|
||||
// Helper function used by SDLRenderer to read our CUDA frame
|
||||
static bool copyCudaFrameToBoundTexture(AVFrame* frame);
|
||||
|
||||
private:
|
||||
AVBufferRef* m_HwContext;
|
||||
};
|
||||
|
||||
#define NV12_PLANES 2
|
||||
|
||||
// Helper class used by SDLRenderer to read our CUDA frame
|
||||
class CUDAGLInteropHelper {
|
||||
public:
|
||||
CUDAGLInteropHelper(AVHWDeviceContext* context);
|
||||
~CUDAGLInteropHelper();
|
||||
|
||||
bool registerBoundTextures();
|
||||
void unregisterTextures();
|
||||
|
||||
bool copyCudaFrameToTextures(AVFrame* frame);
|
||||
|
||||
private:
|
||||
CudaFunctions* m_Funcs;
|
||||
AVCUDADeviceContext* m_Context;
|
||||
CUgraphicsResource m_Resources[NV12_PLANES];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue