22#define SUNSHINE_STRINGIFY_HELPER(x) #x
23#define SUNSHINE_STRINGIFY(x) SUNSHINE_STRINGIFY_HELPER(x)
24#define gl_drain_errors_helper(x) gl::drain_errors(x)
25#define gl_drain_errors gl_drain_errors_helper(__FILE__ ":" SUNSHINE_STRINGIFY(__LINE__))
27extern "C" int close(
int __fd);
30extern "C" struct _XDisplay;
33void free_frame(AVFrame *frame);
38 extern GladGLContext ctx;
43 using PFNGLEGLIMAGETARGETTEXTURE2DOESPROC = void (*)(GLenum target,
void *image);
44 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC egl_image_target_texture_2d();
46 void drain_errors(
const std::string_view &prefix);
57 static tex_t make(std::size_t count);
71 inline void bind(std::nullptr_t, std::nullptr_t) {
73 for (
auto fb : (*
this)) {
74 ctx.BindFramebuffer(GL_FRAMEBUFFER, fb);
75 ctx.FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + x, 0, 0);
83 void bind(It it_begin, It it_end) {
84 using namespace std::literals;
85 if (std::distance(it_begin, it_end) > size()) {
86 BOOST_LOG(warning) <<
"To many elements to bind"sv;
91 std::for_each(it_begin, it_end, [&](
auto tex) {
92 ctx.BindFramebuffer(GL_FRAMEBUFFER, (*
this)[x]);
93 ctx.BindTexture(GL_TEXTURE_2D, tex);
95 ctx.FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + x, tex, 0);
104 void copy(
int id,
int texture,
int offset_x,
int offset_y,
int width,
int height);
108 KITTY_USING_MOVE_T(shader_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
109 if (el != std::numeric_limits<GLuint>::max()) {
110 ctx.DeleteShader(el);
115 std::string err_str();
119 GLuint handle()
const;
122 shader_internal_t _shader;
126 KITTY_USING_MOVE_T(buffer_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
127 if (el != std::numeric_limits<GLuint>::max()) {
128 ctx.DeleteBuffers(1, &el);
135 GLuint handle()
const;
137 const char *block()
const;
139 void update(
const std::string_view &view, std::size_t offset = 0);
140 void update(std::string_view *members, std::size_t count, std::size_t offset = 0);
149 buffer_internal_t _buffer;
153 KITTY_USING_MOVE_T(program_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
154 if (el != std::numeric_limits<GLuint>::max()) {
155 ctx.DeleteProgram(el);
160 std::string err_str();
166 std::optional<buffer_t> uniform(
const char *block, std::pair<const char *, std::string_view> *members, std::size_t count);
168 GLuint handle()
const;
171 program_internal_t _program;
177 typedef void (*device_destroy_fn)(device *gbm);
178 typedef device *(*create_device_fn)(
int fd);
180 extern device_destroy_fn device_destroy;
181 extern create_device_fn create_device;
193 display_t::pointer display;
200 display_t::pointer display;
208 static constexpr std::size_t num_fds = 4;
210 std::array<file_t, num_fds> fds;
215 eglDestroyImage(el.display, el.xrgb8);
219 KITTY_USING_MOVE_T(nv12_t, nv12_img_t, , {
221 eglDestroyImage(el.display, el.r8);
225 eglDestroyImage(el.display, el.bg88);
229 KITTY_USING_MOVE_T(ctx_t, (std::tuple<display_t::pointer, EGLContext>), , {
230 TUPLE_2D_REF(disp, ctx, el);
232 eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
233 eglDestroyContext(disp, ctx);
241 std::uint32_t fourcc;
242 std::uint64_t modifier;
243 std::uint32_t pitches[4];
244 std::uint32_t offsets[4];
247 display_t make_display(std::variant<gbm::gbm_t::pointer, wl_display *, _XDisplay *> native_display);
248 std::optional<ctx_t> make_ctx(display_t::pointer display);
252 display_t::pointer egl_display,
258 std::optional<nv12_t> import_target(
259 display_t::pointer egl_display,
260 std::array<file_t, nv12_img_t::num_fds> &&fds,
272 std::optional<nv12_t>
create_target(
int width,
int height, AVPixelFormat format);
281 unsigned long serial;
283 std::vector<std::uint8_t> buffer;
294 for (
auto x = 0; x < 4; ++x) {
295 if (sd.fds[x] >= 0) {
306 std::uint64_t sequence;
309 std::optional<uint64_t> pts;
310 std::optional<uint64_t> seq;
311 std::optional<bool> pw_damage;
312 std::optional<uint32_t> pw_flags;
317 static std::optional<sws_t> make(
int in_width,
int in_height,
int out_width,
int out_height,
gl::tex_t &&tex);
318 static std::optional<sws_t> make(
int in_width,
int in_height,
int out_width,
int out_height, AVPixelFormat format);
324 int blank(
gl::frame_buf_t &fb,
int offsetX,
int offsetY,
int width,
int height);
327 void load_vram(
img_descriptor_t &img,
int offset_x,
int offset_y,
int texture);
354 std::uint64_t serial;
Definition graphics.h:274
Definition graphics.h:287
Definition graphics.h:315
Definition graphics.h:125
void copy(int id, int texture, int offset_x, int offset_y, int width, int height)
Definition graphics.cpp:87
Definition graphics.h:152
Definition graphics.h:107
Declarations for common platform specific utilities.
rgb_t create_blank(platf::img_t &img)
Create a black RGB texture of the specified image size.
Definition graphics.cpp:583
std::optional< nv12_t > create_target(int width, int height, AVPixelFormat format)
Create biplanar YUV textures to render into.
Definition graphics.cpp:666
Miscellaneous declarations for Linux.
Declarations for logging related functions.
Definition graphics.h:199
Definition graphics.h:192
Definition graphics.h:237
Definition video_colorspace.h:20
Declarations for utility functions.
Declarations for colorspace functions.