Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wlroots 0.18.1 #55

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
15 changes: 3 additions & 12 deletions include/render/egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image);

int wlr_egl_dup_drm_fd(struct wlr_egl *egl);

/**
* Save the current EGL context to the structure provided in the argument.
*
* This includes display, context, draw surface and read surface.
*/
void wlr_egl_save_context(struct wlr_egl_context *context);

/**
* Restore EGL context that was previously saved using wlr_egl_save_current().
*/
Expand All @@ -105,13 +98,11 @@ bool wlr_egl_restore_context(struct wlr_egl_context *context);
/**
* Make the EGL context current.
*
* Callers are expected to clear the current context when they are done by
* calling wlr_egl_unset_current().
* The old EGL context is saved. Callers are expected to clear the current
* context when they are done by calling wlr_egl_restore_context().
*/
bool wlr_egl_make_current(struct wlr_egl *egl);
bool wlr_egl_make_current(struct wlr_egl *egl, struct wlr_egl_context *save_context);

bool wlr_egl_unset_current(struct wlr_egl *egl);

bool wlr_egl_is_current(struct wlr_egl *egl);

#endif
47 changes: 30 additions & 17 deletions include/render/fx_renderer/fx_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@

#include "render/fx_renderer/shaders.h"

struct fx_framebuffer;

struct fx_pixel_format {
uint32_t drm_format;
// optional field, if empty then internalformat = format
GLint gl_internalformat;
GLint gl_format, gl_type;
bool has_alpha;
};

bool is_fx_pixel_format_supported(const struct fx_renderer *renderer,
const struct fx_pixel_format *format);
const struct fx_pixel_format *get_fx_format_from_drm(uint32_t fmt);
const struct fx_pixel_format *get_fx_format_from_gl(
GLint gl_format, GLint gl_type, bool alpha);
const uint32_t *get_fx_shm_formats(const struct fx_renderer *renderer,
size_t *len);
void get_fx_shm_formats(const struct fx_renderer *renderer,
struct wlr_drm_format_set *out);

GLuint fx_framebuffer_get_fbo(struct fx_framebuffer *buffer);

///
/// fx_framebuffer
Expand All @@ -37,10 +40,12 @@ struct fx_framebuffer {
struct wlr_buffer *buffer;
struct fx_renderer *renderer;
struct wl_list link; // fx_renderer.buffers
bool external_only;

EGLImageKHR image;
GLuint rbo;
GLuint fbo;
GLuint tex;
GLuint sb; // Stencil

struct wlr_addon addon;
Expand All @@ -66,21 +71,18 @@ struct fx_texture {
struct fx_renderer *fx_renderer;
struct wl_list link; // fx_renderer.textures

// Basically:
// GL_TEXTURE_2D == mutable
// GL_TEXTURE_EXTERNAL_OES == immutable
GLuint target;
GLuint tex;

EGLImageKHR image;
// If this texture is imported from a buffer, the texture is does not own
// these states. These cannot be destroyed along with the texture in this
// case.
GLuint tex;
GLuint fbo;

bool has_alpha;

// Only affects target == GL_TEXTURE_2D
uint32_t drm_format; // used to interpret upload data
// If imported from a wlr_buffer
struct wlr_buffer *buffer;
struct wlr_addon buffer_addon;
uint32_t drm_format; // for mutable textures only, used to interpret upload data
struct fx_framebuffer *buffer; // for DMA-BUF imports only
};

struct fx_texture *fx_get_texture(struct wlr_texture *wlr_texture);
Expand Down Expand Up @@ -124,13 +126,27 @@ bool wlr_render_timer_is_fx(struct wlr_render_timer *timer);
/// fx_renderer
///

/**
* OpenGL ES 2 renderer.
*
* Care must be taken to avoid stepping each other's toes with EGL contexts:
* the current EGL is global state. The GLES2 renderer operations will save
* and restore any previous EGL context when called. A render pass is seen as
* a single operation.
*
* The GLES2 renderer doesn't support arbitrarily nested render passes. It
* supports a subset only: after a nested render pass is created, any parent
* render pass can't be used before the nested render pass is submitted.
*/

struct fx_renderer {
struct wlr_renderer wlr_renderer;

float projection[9];
struct wlr_egl *egl;
int drm_fd;

struct wlr_drm_format_set shm_texture_formats;

const char *exts_str;
struct {
bool EXT_read_format_bgra;
Expand Down Expand Up @@ -179,9 +195,6 @@ struct fx_renderer {
struct wl_list buffers; // fx_framebuffer.link
struct wl_list textures; // fx_texture.link

struct fx_framebuffer *current_buffer;
uint32_t viewport_width, viewport_height;

// Set to true when 'wlr_renderer_begin_buffer_pass' is called instead of
// our custom 'fx_renderer_begin_buffer_pass' function
bool basic_renderer;
Expand Down
8 changes: 5 additions & 3 deletions include/render/pixel_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ struct wlr_pixel_format_info {
uint32_t bytes_per_block;
/* Size of a block in pixels (zero for 1×1) */
uint32_t block_width, block_height;

/* True if the format has an alpha channel */
bool has_alpha;
};

/**
Expand Down Expand Up @@ -61,4 +58,9 @@ uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt);
*/
enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt);

/**
* Return true if the DRM FourCC fmt has an alpha channel, false otherwise.
*/
bool pixel_format_has_alpha(uint32_t fmt);

#endif
3 changes: 3 additions & 0 deletions include/scenefx/render/fx_renderer/fx_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ struct wlr_renderer *fx_renderer_create(struct wlr_backend *backend);
struct fx_renderer *fx_get_renderer(
struct wlr_renderer *wlr_renderer);

bool fx_renderer_check_ext(struct wlr_renderer *renderer, const char *ext);
GLuint fx_renderer_get_buffer_fbo(struct wlr_renderer *renderer, struct wlr_buffer *buffer);

//
// fx_texture
//
Expand Down
3 changes: 3 additions & 0 deletions include/scenefx/render/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stdbool.h>
#include <wlr/render/pass.h>
#include <wlr/render/interface.h>

#include "render/egl.h"
#include "scenefx/types/fx/shadow_data.h"

struct fx_gles_render_pass {
Expand All @@ -12,6 +14,7 @@ struct fx_gles_render_pass {
struct fx_effect_framebuffers *fx_effect_framebuffers;
struct wlr_output *output;
float projection_matrix[9];
struct wlr_egl_context prev_ctx;
struct fx_render_timer *timer;
};

Expand Down
31 changes: 19 additions & 12 deletions include/scenefx/types/wlr_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,16 @@ struct wlr_scene {
struct wl_list outputs; // wlr_scene_output.link

// May be NULL
struct wlr_presentation *presentation;
struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;

// private state

struct wl_listener presentation_destroy;
struct wl_listener linux_dmabuf_v1_destroy;

enum wlr_scene_debug_damage_option debug_damage_option;
bool direct_scanout;
bool calculate_visibility;
bool highlight_transparent_region;
};

/** A scene-graph node displaying a single surface. */
Expand Down Expand Up @@ -191,6 +190,13 @@ struct wlr_scene_buffer {
uint64_t active_outputs;
struct wlr_texture *texture;
struct wlr_linux_dmabuf_feedback_v1_init_options prev_feedback_options;

bool own_buffer;
int buffer_width, buffer_height;
bool buffer_is_opaque;

struct wl_listener buffer_release;
struct wl_listener renderer_destroy;
};

/** A viewport for an output in the scene-graph */
Expand All @@ -210,6 +216,8 @@ struct wlr_scene_output {

// private state

pixman_region32_t pending_commit_damage;

uint8_t index;
bool prev_scanout;

Expand Down Expand Up @@ -305,15 +313,6 @@ struct wlr_scene_node *wlr_scene_node_at(struct wlr_scene_node *node,
*/
struct wlr_scene *wlr_scene_create(void);

/**
* Handle presentation feedback for all surfaces in the scene, assuming that
* scene outputs and the scene rendering functions are used.
*
* Asserts that a struct wlr_presentation hasn't already been set for the scene.
*/
void wlr_scene_set_presentation(struct wlr_scene *scene,
struct wlr_presentation *presentation);

/**
* Handles linux_dmabuf_v1 feedback for all surfaces in the scene.
*
Expand Down Expand Up @@ -487,6 +486,14 @@ void wlr_scene_output_set_position(struct wlr_scene_output *scene_output,

struct wlr_scene_output_state_options {
struct wlr_scene_timer *timer;
struct wlr_color_transform *color_transform;

/**
* Allows use of a custom swapchain. This can be useful when trying out an
* output configuration. The swapchain dimensions must match the respective
* wlr_output_state or output size if not specified.
*/
struct wlr_swapchain *swapchain;
};

/**
Expand Down Expand Up @@ -567,7 +574,7 @@ struct wlr_scene_tree *wlr_scene_subsurface_tree_create(
* A NULL or empty clip will disable clipping
*/
void wlr_scene_subsurface_tree_set_clip(struct wlr_scene_node *node,
struct wlr_box *clip);
const struct wlr_box *clip);

/**
* Add a node displaying an xdg_surface and all of its sub-surfaces to the
Expand Down
49 changes: 19 additions & 30 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
project(
'scenefx',
'c',
version: '0.1',
version: '0.2',
license: 'MIT',
meson_version: '>=0.59.0',
default_options: [
'c_std=c11',
'c_std=' + (meson.version().version_compare('>=1.3.0') ? 'c23,c11' : 'c11'),
'warning_level=2',
'werror=true',
],
)

# When doing a major or minor release, *always* increase soversion. This isn't
# necessary for bugfix releases. Increasing soversion is required because
# SceneFX never guarantees ABI stability -- only API stability is guaranteed
# between minor releases.
soversion = 1
version = meson.project_version().split('-')[0]
version_major = version.split('.')[0]
version_minor = version.split('.')[1]
versioned_name = '@0@-@1@.@2@'.format(meson.project_name(), version_major, version_minor)

little_endian = target_machine.endian() == 'little'
big_endian = target_machine.endian() == 'big'

add_project_arguments([
'-D_POSIX_C_SOURCE=200809L',
'-DWLR_USE_UNSTABLE',
'-DWLR_LITTLE_ENDIAN=@0@'.format(little_endian.to_int()),
'-DWLR_BIG_ENDIAN=@0@'.format(big_endian.to_int()),
Expand Down Expand Up @@ -87,21 +87,21 @@ endif

wayland_project_options = ['tests=false', 'documentation=false']
wayland_server = dependency('wayland-server',
version: '>=1.22',
version: '>=1.23',
fallback: 'wayland',
default_options: wayland_project_options,
)

wlroots_options = [ 'examples=false' ]
wlroots_version = ['>=0.17.0', '<0.18.0']
wlroots = dependency('wlroots',
wlroots_version = ['>=0.18.1', '<0.19.0']
wlroots = dependency('wlroots-0.18',
version: wlroots_version,
default_options: wlroots_options,
required: false,
)
if not wlroots.found()
wlroots_proj = subproject(
'wlroots',
'wlroots-0.18',
default_options: wlroots_options,
version: wlroots_version,
)
Expand All @@ -110,23 +110,10 @@ endif


drm = dependency('libdrm',
version: '>=2.4.114',
version: '>=2.4.122',
fallback: 'libdrm',
default_options: [
'intel=disabled',
'radeon=disabled',
'amdgpu=disabled',
'nouveau=disabled',
'vmwgfx=disabled',
'omap=disabled',
'exynos=disabled',
'freedreno=disabled',
'tegra=disabled',
'vc4=disabled',
'etnaviv=disabled',
'cairo-tests=disabled',
'man-pages=disabled',
'valgrind=disabled',
'auto_features=disabled',
'tests=false',
],
)
Expand Down Expand Up @@ -161,8 +148,7 @@ subdir('include')
scenefx_inc = include_directories('include')

lib_scenefx = library(
meson.project_name(), scenefx_files,
soversion: soversion.to_string(),
versioned_name, scenefx_files,
dependencies: scenefx_deps,
include_directories: [ scenefx_inc ],
install: true,
Expand All @@ -175,17 +161,20 @@ scenefx = declare_dependency(
include_directories: scenefx_inc,
)

meson.override_dependency('scenefx', scenefx)
meson.override_dependency(versioned_name, scenefx)

if get_option('examples')
# TODO: subdir('examples')
subdir('tinywl')
endif

pkgconfig = import('pkgconfig')
pkgconfig.generate(lib_scenefx,
pkgconfig.generate(
lib_scenefx,
name: versioned_name,
version: meson.project_version(),
filebase: meson.project_name(),
name: meson.project_name(),
description: 'Wlroots effects library',
subdirs: versioned_name,
)
Loading