Skip to content

Commit

Permalink
rebase: wlroots 0.18.1 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikReider authored and WillPower3309 committed Nov 14, 2024
1 parent d1323e6 commit 9453304
Show file tree
Hide file tree
Showing 41 changed files with 857 additions and 4,340 deletions.
5 changes: 2 additions & 3 deletions examples/scene-graph.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define _POSIX_C_SOURCE 200112L
#include <assert.h>
#include <getopt.h>
#include <scenefx/render/fx_renderer/fx_renderer.h>
Expand Down Expand Up @@ -94,7 +93,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_commit_state(wlr_output, &state);
wlr_output_state_finish(&state);

wlr_output_create_global(wlr_output);
wlr_output_create_global(wlr_output, server->display);
}

static void surface_handle_commit(struct wl_listener *listener, void *data) {
Expand Down Expand Up @@ -176,7 +175,7 @@ int main(int argc, char *argv[]) {
struct server server = {0};
server.surface_offset = 0;
server.display = wl_display_create();
server.backend = wlr_backend_autocreate(server.display, NULL);
server.backend = wlr_backend_autocreate(wl_display_get_event_loop(server.display), NULL);
server.scene = wlr_scene_create();

server.renderer = fx_renderer_create(server.backend);
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let
mkPackages = pkgs: {
scenefx = pkgs.callPackage (
{ wlroots_0_17, ... }:
{ wlroots_0_18, ... }:
pkgs.stdenv.mkDerivation {
pname = "scenefx";
version = "0.1.0-git";
Expand All @@ -33,7 +33,7 @@
mesa # gbm
wayland # wayland-server
wayland-protocols
wlroots_0_17
wlroots_0_18
];

meta = with pkgs.lib; {
Expand Down Expand Up @@ -69,13 +69,13 @@
name = "scenefx-shell";
inputsFrom = [
self.packages.${pkgs.system}.scenefx
pkgs.wlroots_0_17
pkgs.wlroots_0_18
];
shellHook = ''
(
# Copy the nix version of wlroots into the project
mkdir -p "$PWD/subprojects" && cd "$PWD/subprojects"
cp -R --no-preserve=mode,ownership ${pkgs.wlroots_0_17.src} wlroots
cp -R --no-preserve=mode,ownership ${pkgs.wlroots_0_18.src} wlroots
)'';
};
});
Expand Down
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 @@ -186,9 +202,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
2 changes: 2 additions & 0 deletions include/scenefx/render/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <wlr/render/pass.h>
#include <wlr/render/interface.h>

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

struct fx_gles_render_pass {
Expand All @@ -13,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 @@ -102,17 +102,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 @@ -203,6 +202,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 @@ -222,6 +228,8 @@ struct wlr_scene_output {

// private state

pixman_region32_t pending_commit_damage;

uint8_t index;
bool prev_scanout;

Expand Down Expand Up @@ -317,15 +325,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 @@ -532,6 +531,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 @@ -612,7 +619,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
Loading

0 comments on commit 9453304

Please sign in to comment.