Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
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:

Go to the source code of this file.

Classes

struct  egl::plane_attr_t

Macros

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

Functions

void gl::drain_errors (const std::string_view &prefix)
int gbm::init ()
bool egl::fail ()
std::optional< ctx_t > egl::make_ctx (display_t::pointer display)
plane_attr_t egl::get_plane (std::uint32_t plane_indice)
std::vector< EGLAttrib > egl::surface_descriptor_to_egl_attribs (const surface_descriptor_t &surface)
 Get EGL attributes for eglCreateImage() to import the provided surface.
bool egl::bind_egl_image_texture_2d (EGLImage image)
 Bind an EGLImage to the currently bound GL_TEXTURE_2D.
std::optional< rgb_t > egl::import_source (display_t::pointer egl_display, const surface_descriptor_t &xrgb)
rgb_t egl::create_blank (platf::img_t &img)
 Create a black RGB texture of the specified image size.
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)
std::optional< nv12_t > egl::create_target (int width, int height, AVPixelFormat format)
 Create biplanar YUV textures to render into.
void free_frame (AVFrame *frame)

Variables

GladGLContext gl::ctx
device_destroy_fn gbm::device_destroy
create_device_fn gbm::create_device
constexpr auto egl::EGL_LINUX_DMA_BUF_EXT = 0x3270
constexpr auto egl::EGL_LINUX_DRM_FOURCC_EXT = 0x3271
constexpr auto egl::EGL_DMA_BUF_PLANE0_FD_EXT = 0x3272
constexpr auto egl::EGL_DMA_BUF_PLANE0_OFFSET_EXT = 0x3273
constexpr auto egl::EGL_DMA_BUF_PLANE0_PITCH_EXT = 0x3274
constexpr auto egl::EGL_DMA_BUF_PLANE1_FD_EXT = 0x3275
constexpr auto egl::EGL_DMA_BUF_PLANE1_OFFSET_EXT = 0x3276
constexpr auto egl::EGL_DMA_BUF_PLANE1_PITCH_EXT = 0x3277
constexpr auto egl::EGL_DMA_BUF_PLANE2_FD_EXT = 0x3278
constexpr auto egl::EGL_DMA_BUF_PLANE2_OFFSET_EXT = 0x3279
constexpr auto egl::EGL_DMA_BUF_PLANE2_PITCH_EXT = 0x327A
constexpr auto egl::EGL_DMA_BUF_PLANE3_FD_EXT = 0x3440
constexpr auto egl::EGL_DMA_BUF_PLANE3_OFFSET_EXT = 0x3441
constexpr auto egl::EGL_DMA_BUF_PLANE3_PITCH_EXT = 0x3442
constexpr auto egl::EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT = 0x3443
constexpr auto egl::EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT = 0x3444
constexpr auto egl::EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT = 0x3445
constexpr auto egl::EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT = 0x3446
constexpr auto egl::EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT = 0x3447
constexpr auto egl::EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT = 0x3448
constexpr auto egl::EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT = 0x3449
constexpr auto egl::EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT = 0x344A

Detailed Description

Definitions for graphics related functions.

Definition in file graphics.cpp.

Macro Definition Documentation

◆ DRM_FORMAT_MOD_INVALID

#define DRM_FORMAT_MOD_INVALID   fourcc_mod_code(0, ((1ULL << 56) - 1))

Definition at line 24 of file graphics.cpp.

◆ 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))

Definition at line 22 of file graphics.cpp.

◆ fourcc_mod_code

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

Definition at line 23 of file graphics.cpp.

◆ HERMES_SHADERS_DIR

#define HERMES_SHADERS_DIR   HERMES_ASSETS_DIR "/shaders/opengl"

Definition at line 27 of file graphics.cpp.

Function Documentation

◆ bind_egl_image_texture_2d()

bool egl::bind_egl_image_texture_2d ( EGLImage image)

Bind an EGLImage to the currently bound GL_TEXTURE_2D.

Tries the GLES-style OES bind first, then falls back to GL_EXT_EGL_image_storage. NVIDIA's desktop-GL driver rejects the OES bind for foreign (system-memory) DMA-BUF imports such as Hermes-KMS frames with GL_INVALID_OPERATION, but accepts the immutable-storage bind.

Definition at line 562 of file graphics.cpp.

◆ 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.

Definition at line 621 of file graphics.cpp.

◆ 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.

Definition at line 704 of file graphics.cpp.

◆ drain_errors()

void gl::drain_errors ( const std::string_view & prefix)

Definition at line 35 of file graphics.cpp.

◆ fail()

bool egl::fail ( )

Definition at line 323 of file graphics.cpp.

◆ free_frame()

void free_frame ( AVFrame * frame)

Definition at line 1106 of file graphics.cpp.

◆ get_plane()

plane_attr_t egl::get_plane ( std::uint32_t plane_indice)
inline

Definition at line 466 of file graphics.cpp.

◆ import_source()

std::optional< rgb_t > egl::import_source ( display_t::pointer egl_display,
const surface_descriptor_t & xrgb )

Definition at line 588 of file graphics.cpp.

◆ import_target()

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 )

Definition at line 645 of file graphics.cpp.

◆ init()

int gbm::init ( )

Definition at line 270 of file graphics.cpp.

◆ make_ctx()

std::optional< ctx_t > egl::make_ctx ( display_t::pointer display)

Definition at line 406 of file graphics.cpp.

◆ 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.

Definition at line 511 of file graphics.cpp.

Variable Documentation

◆ create_device

create_device_fn gbm::create_device

Definition at line 268 of file graphics.cpp.

◆ ctx

GladGLContext gl::ctx

Definition at line 33 of file graphics.cpp.

◆ device_destroy

device_destroy_fn gbm::device_destroy

Definition at line 267 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE0_FD_EXT

auto egl::EGL_DMA_BUF_PLANE0_FD_EXT = 0x3272
constexpr

Definition at line 302 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT

auto egl::EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT = 0x3444
constexpr

Definition at line 315 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT

auto egl::EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT = 0x3443
constexpr

Definition at line 314 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE0_OFFSET_EXT

auto egl::EGL_DMA_BUF_PLANE0_OFFSET_EXT = 0x3273
constexpr

Definition at line 303 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE0_PITCH_EXT

auto egl::EGL_DMA_BUF_PLANE0_PITCH_EXT = 0x3274
constexpr

Definition at line 304 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE1_FD_EXT

auto egl::EGL_DMA_BUF_PLANE1_FD_EXT = 0x3275
constexpr

Definition at line 305 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT

auto egl::EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT = 0x3446
constexpr

Definition at line 317 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT

auto egl::EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT = 0x3445
constexpr

Definition at line 316 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE1_OFFSET_EXT

auto egl::EGL_DMA_BUF_PLANE1_OFFSET_EXT = 0x3276
constexpr

Definition at line 306 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE1_PITCH_EXT

auto egl::EGL_DMA_BUF_PLANE1_PITCH_EXT = 0x3277
constexpr

Definition at line 307 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE2_FD_EXT

auto egl::EGL_DMA_BUF_PLANE2_FD_EXT = 0x3278
constexpr

Definition at line 308 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT

auto egl::EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT = 0x3448
constexpr

Definition at line 319 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT

auto egl::EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT = 0x3447
constexpr

Definition at line 318 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE2_OFFSET_EXT

auto egl::EGL_DMA_BUF_PLANE2_OFFSET_EXT = 0x3279
constexpr

Definition at line 309 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE2_PITCH_EXT

auto egl::EGL_DMA_BUF_PLANE2_PITCH_EXT = 0x327A
constexpr

Definition at line 310 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE3_FD_EXT

auto egl::EGL_DMA_BUF_PLANE3_FD_EXT = 0x3440
constexpr

Definition at line 311 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT

auto egl::EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT = 0x344A
constexpr

Definition at line 321 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT

auto egl::EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT = 0x3449
constexpr

Definition at line 320 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE3_OFFSET_EXT

auto egl::EGL_DMA_BUF_PLANE3_OFFSET_EXT = 0x3441
constexpr

Definition at line 312 of file graphics.cpp.

◆ EGL_DMA_BUF_PLANE3_PITCH_EXT

auto egl::EGL_DMA_BUF_PLANE3_PITCH_EXT = 0x3442
constexpr

Definition at line 313 of file graphics.cpp.

◆ EGL_LINUX_DMA_BUF_EXT

auto egl::EGL_LINUX_DMA_BUF_EXT = 0x3270
constexpr

Definition at line 300 of file graphics.cpp.

◆ EGL_LINUX_DRM_FOURCC_EXT

auto egl::EGL_LINUX_DRM_FOURCC_EXT = 0x3271
constexpr

Definition at line 301 of file graphics.cpp.