Sunshine v2026.319.132152
Self-hosted game stream host for Moonlight.
graphics.cpp File Reference

Definitions for graphics related functions. More...

#include <fcntl.h>
#include "graphics.h"
#include "src/file_handler.h"
#include "src/logging.h"
#include "src/video.h"
#include <libavutil/pixdesc.h>
Include dependency graph for graphics.cpp:

Classes

struct  egl::plane_attr_t
 

Macros

#define DRM_FORMAT_MOD_INVALID   fourcc_mod_code(0, ((1ULL << 56) - 1))
 
#define fourcc_code(a, b, c, d)
 
#define fourcc_mod_code(vendor, val)
 
#define SUNSHINE_SHADERS_DIR   SUNSHINE_ASSETS_DIR "/shaders/opengl"
 

Functions

rgb_t egl::create_blank (platf::img_t &img)
 Create a black RGB texture of the specified image size.
 
std::optional< nv12_t > egl::create_target (int width, int height, AVPixelFormat format)
 Create biplanar YUV textures to render into.
 
void gl::drain_errors (const std::string_view &prefix)
 
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC gl::egl_image_target_texture_2d ()
 
bool egl::fail ()
 
void free_frame (AVFrame *frame)
 
plane_attr_t egl::get_plane (std::uint32_t plane_indice)
 
std::optional< rgb_t > egl::import_source (display_t::pointer egl_display, const surface_descriptor_t &xrgb)
 
std::optional< nv12_t > egl::import_target (display_t::pointer egl_display, std::array< file_t, nv12_img_t::num_fds > &&fds, const surface_descriptor_t &y, const surface_descriptor_t &uv)
 
int gbm::init ()
 
std::optional< ctx_t > egl::make_ctx (display_t::pointer display)
 
std::vector< EGLAttrib > egl::surface_descriptor_to_egl_attribs (const surface_descriptor_t &surface)
 Get EGL attributes for eglCreateImage() to import the provided surface.
 

Variables

create_device_fn gbm::create_device
 
GladGLContext gl::ctx
 
device_destroy_fn gbm::device_destroy
 

Detailed Description

Definitions for graphics related functions.

Macro Definition Documentation

◆ fourcc_code

#define fourcc_code ( a,
b,
c,
d )
Value:
((std::uint32_t) (a) | ((std::uint32_t) (b) << 8) | ((std::uint32_t) (c) << 16) | ((std::uint32_t) (d) << 24))

◆ fourcc_mod_code

#define fourcc_mod_code ( vendor,
val )
Value:
((((uint64_t) vendor) << 56) | ((val) & 0x00ffffffffffffffULL))

Function Documentation

◆ create_blank()

rgb_t egl::create_blank ( platf::img_t & img)

Create a black RGB texture of the specified image size.

Parameters
imgThe image to use for texture sizing.
Returns
The new RGB texture.

◆ create_target()

std::optional< nv12_t > egl::create_target ( int width,
int height,
AVPixelFormat format )

Create biplanar YUV textures to render into.

Creates biplanar YUV textures to render into.

Parameters
widthWidth of the target frame.
heightHeight of the target frame.
formatFormat of the target frame.
Returns
The new RGB texture.

◆ surface_descriptor_to_egl_attribs()

std::vector< EGLAttrib > egl::surface_descriptor_to_egl_attribs ( const surface_descriptor_t & surface)

Get EGL attributes for eglCreateImage() to import the provided surface.

Parameters
surfaceThe surface descriptor.
Returns
Vector of EGL attributes.