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;
39 void drain_errors(
const std::string_view &prefix);
50 static tex_t make(std::size_t count);
64 inline void bind(std::nullptr_t, std::nullptr_t) {
66 for (
auto fb : (*this)) {
67 ctx.BindFramebuffer(GL_FRAMEBUFFER, fb);
68 ctx.FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + x, 0, 0);
76 void bind(It it_begin, It it_end) {
77 using namespace std::literals;
78 if (std::distance(it_begin, it_end) > size()) {
79 BOOST_LOG(warning) <<
"To many elements to bind"sv;
84 std::for_each(it_begin, it_end, [&](
auto tex) {
85 ctx.BindFramebuffer(GL_FRAMEBUFFER, (*
this)[x]);
86 ctx.BindTexture(GL_TEXTURE_2D, tex);
88 ctx.FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + x, tex, 0);
97 void copy(
int id,
int texture,
int offset_x,
int offset_y,
int width,
int height);
101 KITTY_USING_MOVE_T(shader_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
102 if (el != std::numeric_limits<GLuint>::max()) {
103 ctx.DeleteShader(el);
108 std::string err_str();
112 GLuint handle()
const;
115 shader_internal_t _shader;
119 KITTY_USING_MOVE_T(buffer_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
120 if (el != std::numeric_limits<GLuint>::max()) {
121 ctx.DeleteBuffers(1, &el);
128 GLuint handle()
const;
130 const char *block()
const;
132 void update(
const std::string_view &view, std::size_t offset = 0);
133 void update(std::string_view *members, std::size_t count, std::size_t offset = 0);
142 buffer_internal_t _buffer;
146 KITTY_USING_MOVE_T(program_internal_t, GLuint, std::numeric_limits<GLuint>::max(), {
147 if (el != std::numeric_limits<GLuint>::max()) {
148 ctx.DeleteProgram(el);
153 std::string err_str();
159 std::optional<buffer_t> uniform(
const char *block, std::pair<const char *, std::string_view> *members, std::size_t count);
161 GLuint handle()
const;
164 program_internal_t _program;
170 typedef void (*device_destroy_fn)(device *gbm);
171 typedef device *(*create_device_fn)(
int fd);
173 extern device_destroy_fn device_destroy;
174 extern create_device_fn create_device;
186 display_t::pointer display;
193 display_t::pointer display;
201 static constexpr std::size_t num_fds = 4;
203 std::array<file_t, num_fds> fds;
208 eglDestroyImage(el.display, el.xrgb8);
212 KITTY_USING_MOVE_T(nv12_t, nv12_img_t, , {
214 eglDestroyImage(el.display, el.r8);
218 eglDestroyImage(el.display, el.bg88);
222 KITTY_USING_MOVE_T(ctx_t, (std::tuple<display_t::pointer, EGLContext>), , {
223 TUPLE_2D_REF(disp, ctx, el);
225 eglMakeCurrent(disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
226 eglDestroyContext(disp, ctx);
234 std::uint32_t fourcc;
235 std::uint64_t modifier;
236 std::uint32_t pitches[4];
237 std::uint32_t offsets[4];
240 display_t make_display(std::variant<gbm::gbm_t::pointer, wl_display *, _XDisplay *> native_display);
241 std::optional<ctx_t> make_ctx(display_t::pointer display);
245 display_t::pointer egl_display,
251 std::optional<nv12_t> import_target(
252 display_t::pointer egl_display,
253 std::array<file_t, nv12_img_t::num_fds> &&fds,
265 std::optional<nv12_t>
create_target(
int width,
int height, AVPixelFormat format);
272 unsigned long serial;
274 std::vector<std::uint8_t> buffer;
285 for (
auto x = 0; x < 4; ++x) {
286 if (sd.fds[x] >= 0) {
297 std::uint64_t sequence;
302 static std::optional<sws_t> make(
int in_width,
int in_height,
int out_width,
int out_height,
gl::tex_t &&tex);
303 static std::optional<sws_t> make(
int in_width,
int in_height,
int out_width,
int out_height, AVPixelFormat format);
309 int blank(
gl::frame_buf_t &fb,
int offsetX,
int offsetY,
int width,
int height);
312 void load_vram(
img_descriptor_t &img,
int offset_x,
int offset_y,
int texture);
328 int out_width, out_height;
329 int in_width, in_height;
330 int offsetX, offsetY;
336 std::uint64_t serial;
Definition graphics.h:267
Definition graphics.h:278
Definition graphics.h:300
Definition graphics.h:118
void copy(int id, int texture, int offset_x, int offset_y, int width, int height)
Definition graphics.cpp:81
Definition graphics.h:145
Definition graphics.h:100
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:567
std::optional< nv12_t > create_target(int width, int height, AVPixelFormat format)
Create biplanar YUV textures to render into.
Definition graphics.cpp:646
Miscellaneous declarations for Linux.
Declarations for logging related functions.
Definition graphics.h:192
Definition graphics.h:185
Definition graphics.h:230
Definition video_colorspace.h:20
Declarations for utility functions.
Declarations for colorspace functions.