Debian Codegraph @

xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.h

raw
1 /*
2 * Copyright (C) 2007-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include "utils/Geometry.h"
12
13 #include "platform/posix/utils/FileHandle.h"
14
15 #include <array>
16 #include <cstdint>
17
18 #include <va/va.h>
19
20 #include "system_egl.h"
21 #include "system_gl.h"
22
23 #include <EGL/eglext.h>
24
25 namespace VAAPI
26 {
27
28 class CVaapiRenderPicture;
29
30 struct InteropInfo
31 {
32 EGLDisplay eglDisplay = nullptr;
33 PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
34 PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
35 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
36 GLenum textureTarget;
37 };
38
39 class CVaapiTexture
40 {
41 public:
42 CVaapiTexture() = default;
43 virtual ~CVaapiTexture() = default;
44
45 virtual void Init(InteropInfo &interop) = 0;
46 virtual bool Map(CVaapiRenderPicture *pic) = 0;
47 virtual void Unmap() = 0;
48
49 virtual GLuint GetTextureY() = 0;
50 virtual GLuint GetTextureVU() = 0;
51 virtual CSizeInt GetTextureSize() = 0;
52 };
53
54 class CVaapi1Texture : public CVaapiTexture
55 {
56 public:
57 CVaapi1Texture() = default;
58
59 bool Map(CVaapiRenderPicture *pic) override;
60 void Unmap() override;
61 void Init(InteropInfo &interop) override;
62
63 GLuint GetTextureY() override;
64 GLuint GetTextureVU() override;
65 CSizeInt GetTextureSize() override;
66
67 static void TestInterop(VADisplay vaDpy, EGLDisplay eglDisplay, bool &general, bool &deepColor);
68
69 GLuint m_texture = 0;
70 GLuint m_textureY = 0;
71 GLuint m_textureVU = 0;
72 int m_texWidth = 0;
73 int m_texHeight = 0;
74
75 protected:
76 static bool TestInteropDeepColor(VADisplay vaDpy, EGLDisplay eglDisplay);
77
78 InteropInfo m_interop;
79 CVaapiRenderPicture *m_vaapiPic = nullptr;
80 struct GLSurface
81 {
82 VAImage vaImage;
83 VABufferInfo vBufInfo;
84 EGLImageKHR eglImage;
85 EGLImageKHR eglImageY, eglImageVU;
86 } m_glSurface;
87 };
88
89 class CVaapi2Texture : public CVaapiTexture
90 {
91 public:
92 bool Map(CVaapiRenderPicture *pic) override;
93 void Unmap() override;
94 void Init(InteropInfo &interop) override;
95
96 GLuint GetTextureY() override;
97 GLuint GetTextureVU() override;
98 CSizeInt GetTextureSize() override;
99
100 static void TestInterop(VADisplay vaDpy, EGLDisplay eglDisplay, bool &general, bool &deepColor);
101 static bool TestInteropGeneral(VADisplay vaDpy, EGLDisplay eglDisplay);
102
103 private:
104 static bool TestEsh(VADisplay vaDpy, EGLDisplay eglDisplay, std::uint32_t rtFormat, std::int32_t pixelFormat);
105
106 struct MappedTexture
107 {
108 EGLImageKHR eglImage{EGL_NO_IMAGE_KHR};
109 GLuint glTexture{};
110 };
111
112 InteropInfo m_interop;
113 CVaapiRenderPicture* m_vaapiPic{};
114 bool m_hasPlaneModifiers{false};
115 std::array<KODI::UTILS::POSIX::CFileHandle, 4> m_drmFDs;
116 MappedTexture m_y, m_vu;
117 CSizeInt m_textureSize;
118 };
119
120 }
121