2023-06-02 12:10:35 +02:00
|
|
|
#define _POSIX_C_SOURCE 199309L
|
2017-06-08 21:52:42 +02:00
|
|
|
#include <assert.h>
|
2021-02-16 19:30:26 +01:00
|
|
|
#include <drm_fourcc.h>
|
2017-06-23 17:38:45 +02:00
|
|
|
#include <GLES2/gl2.h>
|
2017-08-09 21:25:34 +02:00
|
|
|
#include <GLES2/gl2ext.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <stdint.h>
|
2018-03-20 19:14:33 +01:00
|
|
|
#include <stdio.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <stdlib.h>
|
2023-06-02 12:10:35 +02:00
|
|
|
#include <time.h>
|
2020-06-10 14:47:12 +02:00
|
|
|
#include <unistd.h>
|
2017-06-08 21:52:42 +02:00
|
|
|
#include <wayland-server-protocol.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <wayland-util.h>
|
2017-10-21 03:48:58 +02:00
|
|
|
#include <wlr/render/egl.h>
|
2017-06-08 21:52:42 +02:00
|
|
|
#include <wlr/render/interface.h>
|
2018-03-20 19:14:33 +01:00
|
|
|
#include <wlr/render/wlr_renderer.h>
|
2018-03-15 09:11:03 +01:00
|
|
|
#include <wlr/types/wlr_matrix.h>
|
2021-07-01 22:36:01 +02:00
|
|
|
#include <wlr/util/box.h>
|
2017-06-21 18:10:07 +02:00
|
|
|
#include <wlr/util/log.h>
|
2021-06-24 12:10:12 +02:00
|
|
|
#include "render/egl.h"
|
2018-03-24 23:30:28 +01:00
|
|
|
#include "render/gles2.h"
|
2021-03-24 15:10:52 +01:00
|
|
|
#include "render/pixel_format.h"
|
2022-06-07 23:15:34 +02:00
|
|
|
#include "types/wlr_matrix.h"
|
2023-06-02 12:10:35 +02:00
|
|
|
#include "util/time.h"
|
2017-06-08 21:52:42 +02:00
|
|
|
|
2022-10-27 16:05:50 +02:00
|
|
|
#include "common_vert_src.h"
|
2022-10-26 12:03:50 +02:00
|
|
|
#include "quad_frag_src.h"
|
|
|
|
#include "tex_rgba_frag_src.h"
|
|
|
|
#include "tex_rgbx_frag_src.h"
|
|
|
|
#include "tex_external_frag_src.h"
|
|
|
|
|
2018-03-20 19:14:33 +01:00
|
|
|
static const struct wlr_renderer_impl renderer_impl;
|
2023-06-02 12:10:35 +02:00
|
|
|
static const struct wlr_render_timer_impl render_timer_impl;
|
2017-06-08 21:52:42 +02:00
|
|
|
|
2021-05-28 08:06:49 +02:00
|
|
|
bool wlr_renderer_is_gles2(struct wlr_renderer *wlr_renderer) {
|
|
|
|
return wlr_renderer->impl == &renderer_impl;
|
|
|
|
}
|
|
|
|
|
2020-07-28 13:45:24 +02:00
|
|
|
struct wlr_gles2_renderer *gles2_get_renderer(
|
2018-03-20 19:14:33 +01:00
|
|
|
struct wlr_renderer *wlr_renderer) {
|
2021-05-28 08:06:49 +02:00
|
|
|
assert(wlr_renderer_is_gles2(wlr_renderer));
|
2023-07-11 17:54:08 +02:00
|
|
|
struct wlr_gles2_renderer *renderer = wl_container_of(wlr_renderer, renderer, wlr_renderer);
|
|
|
|
return renderer;
|
2018-03-24 23:30:28 +01:00
|
|
|
}
|
|
|
|
|
2023-06-02 12:10:35 +02:00
|
|
|
bool wlr_render_timer_is_gles2(struct wlr_render_timer *timer) {
|
|
|
|
return timer->impl == &render_timer_impl;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wlr_gles2_render_timer *gles2_get_render_timer(struct wlr_render_timer *wlr_timer) {
|
|
|
|
assert(wlr_render_timer_is_gles2(wlr_timer));
|
|
|
|
struct wlr_gles2_render_timer *timer = wl_container_of(wlr_timer, timer, base);
|
|
|
|
return timer;
|
|
|
|
}
|
|
|
|
|
2020-07-28 16:56:23 +02:00
|
|
|
static void destroy_buffer(struct wlr_gles2_buffer *buffer) {
|
|
|
|
wl_list_remove(&buffer->link);
|
2021-08-11 10:00:50 +02:00
|
|
|
wlr_addon_finish(&buffer->addon);
|
2020-07-28 16:56:23 +02:00
|
|
|
|
2021-01-14 12:00:06 +01:00
|
|
|
struct wlr_egl_context prev_ctx;
|
|
|
|
wlr_egl_save_context(&prev_ctx);
|
2021-01-09 12:13:35 +01:00
|
|
|
wlr_egl_make_current(buffer->renderer->egl);
|
2020-07-28 16:56:23 +02:00
|
|
|
|
|
|
|
push_gles2_debug(buffer->renderer);
|
|
|
|
|
|
|
|
glDeleteFramebuffers(1, &buffer->fbo);
|
|
|
|
glDeleteRenderbuffers(1, &buffer->rbo);
|
2023-06-25 11:36:11 +02:00
|
|
|
glDeleteTextures(1, &buffer->tex);
|
2020-07-28 16:56:23 +02:00
|
|
|
|
|
|
|
pop_gles2_debug(buffer->renderer);
|
|
|
|
|
|
|
|
wlr_egl_destroy_image(buffer->renderer->egl, buffer->image);
|
2021-01-14 12:00:06 +01:00
|
|
|
|
|
|
|
wlr_egl_restore_context(&prev_ctx);
|
|
|
|
|
2020-07-28 16:56:23 +02:00
|
|
|
free(buffer);
|
|
|
|
}
|
|
|
|
|
2021-08-11 10:00:50 +02:00
|
|
|
static void handle_buffer_destroy(struct wlr_addon *addon) {
|
|
|
|
struct wlr_gles2_buffer *buffer =
|
|
|
|
wl_container_of(addon, buffer, addon);
|
|
|
|
destroy_buffer(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wlr_addon_interface buffer_addon_impl = {
|
|
|
|
.name = "wlr_gles2_buffer",
|
|
|
|
.destroy = handle_buffer_destroy,
|
|
|
|
};
|
|
|
|
|
2023-11-29 19:58:42 +01:00
|
|
|
GLuint gles2_buffer_get_fbo(struct wlr_gles2_buffer *buffer) {
|
2023-11-30 16:13:14 +01:00
|
|
|
if (buffer->external_only) {
|
|
|
|
wlr_log(WLR_ERROR, "DMA-BUF format is external-only");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-11-29 19:58:42 +01:00
|
|
|
if (buffer->fbo) {
|
|
|
|
return buffer->fbo;
|
|
|
|
}
|
|
|
|
|
|
|
|
push_gles2_debug(buffer->renderer);
|
|
|
|
|
|
|
|
if (!buffer->rbo) {
|
|
|
|
glGenRenderbuffers(1, &buffer->rbo);
|
|
|
|
glBindRenderbuffer(GL_RENDERBUFFER, buffer->rbo);
|
|
|
|
buffer->renderer->procs.glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER,
|
|
|
|
buffer->image);
|
|
|
|
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
glGenFramebuffers(1, &buffer->fbo);
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, buffer->fbo);
|
|
|
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
|
|
|
GL_RENDERBUFFER, buffer->rbo);
|
|
|
|
GLenum fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
|
|
|
|
|
|
if (fb_status != GL_FRAMEBUFFER_COMPLETE) {
|
|
|
|
wlr_log(WLR_ERROR, "Failed to create FBO");
|
|
|
|
glDeleteFramebuffers(1, &buffer->fbo);
|
|
|
|
buffer->fbo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pop_gles2_debug(buffer->renderer);
|
|
|
|
|
|
|
|
return buffer->fbo;
|
|
|
|
}
|
|
|
|
|
2023-06-25 11:36:11 +02:00
|
|
|
struct wlr_gles2_buffer *gles2_buffer_get_or_create(struct wlr_gles2_renderer *renderer,
|
2020-07-28 16:56:23 +02:00
|
|
|
struct wlr_buffer *wlr_buffer) {
|
2021-08-11 10:00:50 +02:00
|
|
|
struct wlr_addon *addon =
|
|
|
|
wlr_addon_find(&wlr_buffer->addons, renderer, &buffer_addon_impl);
|
2023-05-22 22:20:26 +02:00
|
|
|
if (addon) {
|
|
|
|
struct wlr_gles2_buffer *buffer = wl_container_of(addon, buffer, addon);
|
|
|
|
return buffer;
|
2020-07-28 16:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct wlr_gles2_buffer *buffer = calloc(1, sizeof(*buffer));
|
|
|
|
if (buffer == NULL) {
|
|
|
|
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
buffer->buffer = wlr_buffer;
|
|
|
|
buffer->renderer = renderer;
|
|
|
|
|
|
|
|
struct wlr_dmabuf_attributes dmabuf = {0};
|
|
|
|
if (!wlr_buffer_get_dmabuf(wlr_buffer, &dmabuf)) {
|
|
|
|
goto error_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer->image = wlr_egl_create_image_from_dmabuf(renderer->egl,
|
2023-11-30 16:13:14 +01:00
|
|
|
&dmabuf, &buffer->external_only);
|
2020-07-28 16:56:23 +02:00
|
|
|
if (buffer->image == EGL_NO_IMAGE_KHR) {
|
|
|
|
goto error_buffer;
|
|
|
|
}
|
|
|
|
|
2021-08-11 10:00:50 +02:00
|
|
|
wlr_addon_init(&buffer->addon, &wlr_buffer->addons, renderer,
|
|
|
|
&buffer_addon_impl);
|
2020-07-28 16:56:23 +02:00
|
|
|
|
|
|
|
wl_list_insert(&renderer->buffers, &buffer->link);
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, "Created GL FBO for buffer %dx%d",
|
|
|
|
wlr_buffer->width, wlr_buffer->height);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
|
|
|
|
error_buffer:
|
|
|
|
free(buffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-02-16 19:20:00 +01:00
|
|
|
static const uint32_t *gles2_get_shm_texture_formats(
|
2018-03-21 08:50:59 +01:00
|
|
|
struct wlr_renderer *wlr_renderer, size_t *len) {
|
2021-07-30 05:53:22 +02:00
|
|
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
|
|
|
return get_gles2_shm_formats(renderer, len);
|
2018-10-31 17:20:27 +01:00
|
|
|
}
|
|
|
|
|
2020-11-18 14:53:13 +01:00
|
|
|
static const struct wlr_drm_format_set *gles2_get_dmabuf_texture_formats(
|
2019-04-01 18:17:23 +02:00
|
|
|
struct wlr_renderer *wlr_renderer) {
|
2018-04-08 17:00:56 +02:00
|
|
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
2020-11-18 14:53:13 +01:00
|
|
|
return wlr_egl_get_dmabuf_texture_formats(renderer->egl);
|
2018-04-08 17:00:56 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 16:22:06 +02:00
|
|
|
static const struct wlr_drm_format_set *gles2_get_render_formats(
|
2020-11-18 14:16:22 +01:00
|
|
|
struct wlr_renderer *wlr_renderer) {
|
|
|
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
|
|
|
return wlr_egl_get_dmabuf_render_formats(renderer->egl);
|
|
|
|
}
|
|
|
|
|
2020-06-10 14:47:12 +02:00
|
|
|
static int gles2_get_drm_fd(struct wlr_renderer *wlr_renderer) {
|
|
|
|
struct wlr_gles2_renderer *renderer =
|
|
|
|
gles2_get_renderer(wlr_renderer);
|
|
|
|
|
|
|
|
if (renderer->drm_fd < 0) {
|
|
|
|
renderer->drm_fd = wlr_egl_dup_drm_fd(renderer->egl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return renderer->drm_fd;
|
|
|
|
}
|
|
|
|
|
2021-06-08 18:57:15 +02:00
|
|
|
static uint32_t gles2_get_render_buffer_caps(struct wlr_renderer *wlr_renderer) {
|
2021-04-23 19:51:05 +02:00
|
|
|
return WLR_BUFFER_CAP_DMABUF;
|
|
|
|
}
|
|
|
|
|
2019-11-07 19:38:45 +01:00
|
|
|
struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *wlr_renderer) {
|
|
|
|
struct wlr_gles2_renderer *renderer =
|
|
|
|
gles2_get_renderer(wlr_renderer);
|
|
|
|
return renderer->egl;
|
|
|
|
}
|
|
|
|
|
2018-03-20 19:14:33 +01:00
|
|
|
static void gles2_destroy(struct wlr_renderer *wlr_renderer) {
|
|
|
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
|
|
|
|
2021-01-09 12:13:35 +01:00
|
|
|
wlr_egl_make_current(renderer->egl);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
2021-04-21 12:02:16 +02:00
|
|
|
struct wlr_gles2_texture *tex, *tex_tmp;
|
|
|
|
wl_list_for_each_safe(tex, tex_tmp, &renderer->textures, link) {
|
2021-05-29 10:25:25 +02:00
|
|
|
gles2_texture_destroy(tex);
|
2021-04-21 12:02:16 +02:00
|
|
|
}
|
|
|
|
|
2023-07-05 19:08:55 +02:00
|
|
|
struct wlr_gles2_buffer *buffer, *buffer_tmp;
|
|
|
|
wl_list_for_each_safe(buffer, buffer_tmp, &renderer->buffers, link) {
|
|
|
|
destroy_buffer(buffer);
|
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
push_gles2_debug(renderer);
|
2018-06-03 00:20:09 +02:00
|
|
|
glDeleteProgram(renderer->shaders.quad.program);
|
|
|
|
glDeleteProgram(renderer->shaders.tex_rgba.program);
|
|
|
|
glDeleteProgram(renderer->shaders.tex_rgbx.program);
|
|
|
|
glDeleteProgram(renderer->shaders.tex_ext.program);
|
2020-07-28 13:58:07 +02:00
|
|
|
pop_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
2021-07-11 20:00:02 +02:00
|
|
|
if (renderer->exts.KHR_debug) {
|
2018-03-20 19:14:33 +01:00
|
|
|
glDisable(GL_DEBUG_OUTPUT_KHR);
|
2020-07-28 14:02:08 +02:00
|
|
|
renderer->procs.glDebugMessageCallbackKHR(NULL, NULL);
|
2018-03-20 19:14:33 +01:00
|
|
|
}
|
|
|
|
|
2020-05-19 11:54:59 +02:00
|
|
|
wlr_egl_unset_current(renderer->egl);
|
2021-01-09 12:00:31 +01:00
|
|
|
wlr_egl_destroy(renderer->egl);
|
2021-01-12 10:45:14 +01:00
|
|
|
|
2020-06-10 14:47:12 +02:00
|
|
|
if (renderer->drm_fd >= 0) {
|
|
|
|
close(renderer->drm_fd);
|
|
|
|
}
|
|
|
|
|
2018-03-20 19:14:33 +01:00
|
|
|
free(renderer);
|
2017-08-11 04:15:37 +02:00
|
|
|
}
|
|
|
|
|
2023-05-28 20:53:26 +02:00
|
|
|
static struct wlr_render_pass *gles2_begin_buffer_pass(struct wlr_renderer *wlr_renderer,
|
2023-07-10 11:31:01 +02:00
|
|
|
struct wlr_buffer *wlr_buffer, const struct wlr_buffer_pass_options *options) {
|
2023-05-28 20:53:26 +02:00
|
|
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
2023-11-30 17:47:11 +01:00
|
|
|
|
|
|
|
struct wlr_egl_context prev_ctx = {0};
|
|
|
|
wlr_egl_save_context(&prev_ctx);
|
2023-05-28 20:53:26 +02:00
|
|
|
if (!wlr_egl_make_current(renderer->egl)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-06-06 08:17:10 +02:00
|
|
|
struct wlr_gles2_render_timer *timer = NULL;
|
|
|
|
if (options->timer) {
|
|
|
|
timer = gles2_get_render_timer(options->timer);
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &timer->cpu_start);
|
|
|
|
}
|
2023-06-02 12:10:35 +02:00
|
|
|
|
2023-06-25 11:36:11 +02:00
|
|
|
struct wlr_gles2_buffer *buffer = gles2_buffer_get_or_create(renderer, wlr_buffer);
|
2023-05-28 20:53:26 +02:00
|
|
|
if (!buffer) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-11-30 17:47:11 +01:00
|
|
|
struct wlr_gles2_render_pass *pass = begin_gles2_buffer_pass(buffer, &prev_ctx, timer);
|
2023-05-28 20:53:26 +02:00
|
|
|
if (!pass) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return &pass->base;
|
|
|
|
}
|
|
|
|
|
2023-06-02 12:10:35 +02:00
|
|
|
static struct wlr_render_timer *gles2_render_timer_create(struct wlr_renderer *wlr_renderer) {
|
|
|
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
|
|
|
if (!renderer->exts.EXT_disjoint_timer_query) {
|
|
|
|
wlr_log(WLR_ERROR, "can't create timer, EXT_disjoint_timer_query not available");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-10-03 07:51:07 +02:00
|
|
|
struct wlr_gles2_render_timer *timer = calloc(1, sizeof(*timer));
|
2023-06-02 12:10:35 +02:00
|
|
|
if (!timer) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
timer->base.impl = &render_timer_impl;
|
|
|
|
timer->renderer = renderer;
|
|
|
|
|
|
|
|
struct wlr_egl_context prev_ctx;
|
|
|
|
wlr_egl_save_context(&prev_ctx);
|
|
|
|
wlr_egl_make_current(renderer->egl);
|
|
|
|
renderer->procs.glGenQueriesEXT(1, &timer->id);
|
|
|
|
wlr_egl_restore_context(&prev_ctx);
|
|
|
|
|
2023-07-11 20:15:45 +02:00
|
|
|
return &timer->base;
|
2023-06-02 12:10:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int gles2_get_render_time(struct wlr_render_timer *wlr_timer) {
|
|
|
|
struct wlr_gles2_render_timer *timer = gles2_get_render_timer(wlr_timer);
|
|
|
|
struct wlr_gles2_renderer *renderer = timer->renderer;
|
|
|
|
|
|
|
|
struct wlr_egl_context prev_ctx;
|
|
|
|
wlr_egl_save_context(&prev_ctx);
|
|
|
|
wlr_egl_make_current(renderer->egl);
|
|
|
|
|
|
|
|
GLint64 disjoint;
|
|
|
|
renderer->procs.glGetInteger64vEXT(GL_GPU_DISJOINT_EXT, &disjoint);
|
|
|
|
if (disjoint) {
|
|
|
|
wlr_log(WLR_ERROR, "a disjoint operation occurred and the render timer is invalid");
|
|
|
|
wlr_egl_restore_context(&prev_ctx);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLint available;
|
|
|
|
renderer->procs.glGetQueryObjectivEXT(timer->id,
|
|
|
|
GL_QUERY_RESULT_AVAILABLE_EXT, &available);
|
|
|
|
if (!available) {
|
|
|
|
wlr_log(WLR_ERROR, "timer was read too early, gpu isn't done!");
|
|
|
|
wlr_egl_restore_context(&prev_ctx);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint64 gl_render_end;
|
|
|
|
renderer->procs.glGetQueryObjectui64vEXT(timer->id, GL_QUERY_RESULT_EXT,
|
|
|
|
&gl_render_end);
|
|
|
|
|
|
|
|
int64_t cpu_nsec_total = timespec_to_nsec(&timer->cpu_end) - timespec_to_nsec(&timer->cpu_start);
|
|
|
|
|
|
|
|
wlr_egl_restore_context(&prev_ctx);
|
|
|
|
return gl_render_end - timer->gl_cpu_end + cpu_nsec_total;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gles2_render_timer_destroy(struct wlr_render_timer *wlr_timer) {
|
2023-07-11 17:54:08 +02:00
|
|
|
struct wlr_gles2_render_timer *timer = wl_container_of(wlr_timer, timer, base);
|
2023-06-02 12:10:35 +02:00
|
|
|
struct wlr_gles2_renderer *renderer = timer->renderer;
|
|
|
|
|
|
|
|
struct wlr_egl_context prev_ctx;
|
|
|
|
wlr_egl_save_context(&prev_ctx);
|
|
|
|
wlr_egl_make_current(renderer->egl);
|
|
|
|
renderer->procs.glDeleteQueriesEXT(1, &timer->id);
|
|
|
|
wlr_egl_restore_context(&prev_ctx);
|
|
|
|
free(timer);
|
|
|
|
}
|
|
|
|
|
2018-03-20 19:14:33 +01:00
|
|
|
static const struct wlr_renderer_impl renderer_impl = {
|
|
|
|
.destroy = gles2_destroy,
|
2020-11-18 14:57:53 +01:00
|
|
|
.get_shm_texture_formats = gles2_get_shm_texture_formats,
|
2020-11-18 14:53:13 +01:00
|
|
|
.get_dmabuf_texture_formats = gles2_get_dmabuf_texture_formats,
|
2021-04-15 16:22:06 +02:00
|
|
|
.get_render_formats = gles2_get_render_formats,
|
2020-06-10 14:47:12 +02:00
|
|
|
.get_drm_fd = gles2_get_drm_fd,
|
2021-04-23 19:51:05 +02:00
|
|
|
.get_render_buffer_caps = gles2_get_render_buffer_caps,
|
2021-04-12 11:58:31 +02:00
|
|
|
.texture_from_buffer = gles2_texture_from_buffer,
|
2023-05-28 20:53:26 +02:00
|
|
|
.begin_buffer_pass = gles2_begin_buffer_pass,
|
2023-06-02 12:10:35 +02:00
|
|
|
.render_timer_create = gles2_render_timer_create,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct wlr_render_timer_impl render_timer_impl = {
|
|
|
|
.get_duration_ns = gles2_get_render_time,
|
|
|
|
.destroy = gles2_render_timer_destroy,
|
2017-06-08 21:52:42 +02:00
|
|
|
};
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
void push_gles2_debug_(struct wlr_gles2_renderer *renderer,
|
|
|
|
const char *file, const char *func) {
|
2020-07-28 14:02:08 +02:00
|
|
|
if (!renderer->procs.glPushDebugGroupKHR) {
|
2018-03-20 19:14:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int len = snprintf(NULL, 0, "%s:%s", file, func) + 1;
|
|
|
|
char str[len];
|
|
|
|
snprintf(str, len, "%s:%s", file, func);
|
2020-07-28 14:02:08 +02:00
|
|
|
renderer->procs.glPushDebugGroupKHR(GL_DEBUG_SOURCE_APPLICATION_KHR, 1, -1, str);
|
2018-03-20 19:14:33 +01:00
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
void pop_gles2_debug(struct wlr_gles2_renderer *renderer) {
|
2020-07-28 14:02:08 +02:00
|
|
|
if (renderer->procs.glPopDebugGroupKHR) {
|
|
|
|
renderer->procs.glPopDebugGroupKHR();
|
2018-03-20 19:14:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 23:49:54 +02:00
|
|
|
static enum wlr_log_importance gles2_log_importance_to_wlr(GLenum type) {
|
2018-03-20 19:14:33 +01:00
|
|
|
switch (type) {
|
2018-07-09 23:49:54 +02:00
|
|
|
case GL_DEBUG_TYPE_ERROR_KHR: return WLR_ERROR;
|
|
|
|
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR: return WLR_DEBUG;
|
|
|
|
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR: return WLR_ERROR;
|
|
|
|
case GL_DEBUG_TYPE_PORTABILITY_KHR: return WLR_DEBUG;
|
|
|
|
case GL_DEBUG_TYPE_PERFORMANCE_KHR: return WLR_DEBUG;
|
|
|
|
case GL_DEBUG_TYPE_OTHER_KHR: return WLR_DEBUG;
|
|
|
|
case GL_DEBUG_TYPE_MARKER_KHR: return WLR_DEBUG;
|
|
|
|
case GL_DEBUG_TYPE_PUSH_GROUP_KHR: return WLR_DEBUG;
|
|
|
|
case GL_DEBUG_TYPE_POP_GROUP_KHR: return WLR_DEBUG;
|
|
|
|
default: return WLR_DEBUG;
|
2018-03-20 19:14:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gles2_log(GLenum src, GLenum type, GLuint id, GLenum severity,
|
|
|
|
GLsizei len, const GLchar *msg, const void *user) {
|
|
|
|
_wlr_log(gles2_log_importance_to_wlr(type), "[GLES2] %s", msg);
|
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
static GLuint compile_shader(struct wlr_gles2_renderer *renderer,
|
2023-02-02 22:42:42 +01:00
|
|
|
GLenum type, const GLchar *src) {
|
2020-07-28 13:58:07 +02:00
|
|
|
push_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
|
|
|
GLuint shader = glCreateShader(type);
|
|
|
|
glShaderSource(shader, 1, &src, NULL);
|
|
|
|
glCompileShader(shader);
|
|
|
|
|
|
|
|
GLint ok;
|
|
|
|
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
|
|
|
|
if (ok == GL_FALSE) {
|
2022-10-26 19:48:18 +02:00
|
|
|
wlr_log(WLR_ERROR, "Failed to compile shader");
|
2018-03-20 19:14:33 +01:00
|
|
|
glDeleteShader(shader);
|
|
|
|
shader = 0;
|
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
pop_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
return shader;
|
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
static GLuint link_program(struct wlr_gles2_renderer *renderer,
|
|
|
|
const GLchar *vert_src, const GLchar *frag_src) {
|
|
|
|
push_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
GLuint vert = compile_shader(renderer, GL_VERTEX_SHADER, vert_src);
|
2018-03-20 19:14:33 +01:00
|
|
|
if (!vert) {
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
GLuint frag = compile_shader(renderer, GL_FRAGMENT_SHADER, frag_src);
|
2018-03-20 19:14:33 +01:00
|
|
|
if (!frag) {
|
|
|
|
glDeleteShader(vert);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint prog = glCreateProgram();
|
|
|
|
glAttachShader(prog, vert);
|
|
|
|
glAttachShader(prog, frag);
|
|
|
|
glLinkProgram(prog);
|
|
|
|
|
|
|
|
glDetachShader(prog, vert);
|
|
|
|
glDetachShader(prog, frag);
|
|
|
|
glDeleteShader(vert);
|
|
|
|
glDeleteShader(frag);
|
|
|
|
|
|
|
|
GLint ok;
|
|
|
|
glGetProgramiv(prog, GL_LINK_STATUS, &ok);
|
|
|
|
if (ok == GL_FALSE) {
|
2022-10-26 19:48:18 +02:00
|
|
|
wlr_log(WLR_ERROR, "Failed to link shader");
|
2018-03-20 19:14:33 +01:00
|
|
|
glDeleteProgram(prog);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
pop_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
return prog;
|
|
|
|
|
|
|
|
error:
|
2020-07-28 13:58:07 +02:00
|
|
|
pop_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-31 17:20:27 +01:00
|
|
|
static bool check_gl_ext(const char *exts, const char *ext) {
|
|
|
|
size_t extlen = strlen(ext);
|
|
|
|
const char *end = exts + strlen(exts);
|
|
|
|
|
|
|
|
while (exts < end) {
|
|
|
|
if (exts[0] == ' ') {
|
|
|
|
exts++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
size_t n = strcspn(exts, " ");
|
|
|
|
if (n == extlen && strncmp(ext, exts, n) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
exts += n;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-11-10 14:31:33 +01:00
|
|
|
static void load_gl_proc(void *proc_ptr, const char *name) {
|
|
|
|
void *proc = (void *)eglGetProcAddress(name);
|
|
|
|
if (proc == NULL) {
|
|
|
|
wlr_log(WLR_ERROR, "eglGetProcAddress(%s) failed", name);
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
*(void **)proc_ptr = proc;
|
|
|
|
}
|
|
|
|
|
2021-04-20 20:48:22 +02:00
|
|
|
struct wlr_renderer *wlr_gles2_renderer_create_with_drm_fd(int drm_fd) {
|
2021-06-24 13:11:21 +02:00
|
|
|
struct wlr_egl *egl = wlr_egl_create_with_drm_fd(drm_fd);
|
2021-04-20 20:48:22 +02:00
|
|
|
if (egl == NULL) {
|
|
|
|
wlr_log(WLR_ERROR, "Could not initialize EGL");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wlr_renderer *renderer = wlr_gles2_renderer_create(egl);
|
|
|
|
if (!renderer) {
|
|
|
|
wlr_log(WLR_ERROR, "Failed to create GLES2 renderer");
|
|
|
|
wlr_egl_destroy(egl);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
2018-04-01 00:49:43 +02:00
|
|
|
struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
|
2021-01-09 12:13:35 +01:00
|
|
|
if (!wlr_egl_make_current(egl)) {
|
2020-06-02 22:13:16 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-11-10 14:31:33 +01:00
|
|
|
const char *exts_str = (const char *)glGetString(GL_EXTENSIONS);
|
|
|
|
if (exts_str == NULL) {
|
|
|
|
wlr_log(WLR_ERROR, "Failed to get GL_EXTENSIONS");
|
2018-04-01 22:07:50 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2023-10-03 07:51:07 +02:00
|
|
|
struct wlr_gles2_renderer *renderer = calloc(1, sizeof(*renderer));
|
2018-03-20 19:14:33 +01:00
|
|
|
if (renderer == NULL) {
|
2017-08-15 07:56:47 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2018-03-20 19:14:33 +01:00
|
|
|
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl);
|
2017-10-21 23:20:26 +02:00
|
|
|
|
2020-07-28 16:56:23 +02:00
|
|
|
wl_list_init(&renderer->buffers);
|
2021-04-21 12:02:16 +02:00
|
|
|
wl_list_init(&renderer->textures);
|
2020-07-28 16:56:23 +02:00
|
|
|
|
2018-04-01 00:49:43 +02:00
|
|
|
renderer->egl = egl;
|
2020-04-21 14:52:47 +02:00
|
|
|
renderer->exts_str = exts_str;
|
2020-06-10 14:47:12 +02:00
|
|
|
renderer->drm_fd = -1;
|
2020-04-21 14:52:47 +02:00
|
|
|
|
2021-04-21 08:28:29 +02:00
|
|
|
wlr_log(WLR_INFO, "Creating GLES2 renderer");
|
2018-07-09 23:49:54 +02:00
|
|
|
wlr_log(WLR_INFO, "Using %s", glGetString(GL_VERSION));
|
|
|
|
wlr_log(WLR_INFO, "GL vendor: %s", glGetString(GL_VENDOR));
|
2019-05-07 18:44:05 +02:00
|
|
|
wlr_log(WLR_INFO, "GL renderer: %s", glGetString(GL_RENDERER));
|
2019-11-10 14:31:33 +01:00
|
|
|
wlr_log(WLR_INFO, "Supported GLES2 extensions: %s", exts_str);
|
2018-03-27 23:02:48 +02:00
|
|
|
|
2021-07-11 19:55:32 +02:00
|
|
|
if (!renderer->egl->exts.EXT_image_dma_buf_import) {
|
2021-04-08 22:21:50 +02:00
|
|
|
wlr_log(WLR_ERROR, "EGL_EXT_image_dma_buf_import not supported");
|
|
|
|
free(renderer);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-11-10 14:31:33 +01:00
|
|
|
if (!check_gl_ext(exts_str, "GL_EXT_texture_format_BGRA8888")) {
|
2018-10-31 17:20:27 +01:00
|
|
|
wlr_log(WLR_ERROR, "BGRA8888 format not supported by GLES2");
|
|
|
|
free(renderer);
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-12-15 14:55:18 +01:00
|
|
|
if (!check_gl_ext(exts_str, "GL_EXT_unpack_subimage")) {
|
|
|
|
wlr_log(WLR_ERROR, "GL_EXT_unpack_subimage not supported");
|
|
|
|
free(renderer);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-10-31 17:20:27 +01:00
|
|
|
|
2021-07-11 20:00:02 +02:00
|
|
|
renderer->exts.EXT_read_format_bgra =
|
2019-11-10 14:31:33 +01:00
|
|
|
check_gl_ext(exts_str, "GL_EXT_read_format_bgra");
|
|
|
|
|
2021-07-30 05:55:57 +02:00
|
|
|
renderer->exts.EXT_texture_type_2_10_10_10_REV =
|
|
|
|
check_gl_ext(exts_str, "GL_EXT_texture_type_2_10_10_10_REV");
|
|
|
|
|
|
|
|
renderer->exts.OES_texture_half_float_linear =
|
|
|
|
check_gl_ext(exts_str, "GL_OES_texture_half_float_linear");
|
|
|
|
|
2022-05-01 04:43:49 +02:00
|
|
|
renderer->exts.EXT_texture_norm16 =
|
|
|
|
check_gl_ext(exts_str, "GL_EXT_texture_norm16");
|
|
|
|
|
2019-11-10 14:31:33 +01:00
|
|
|
if (check_gl_ext(exts_str, "GL_KHR_debug")) {
|
2021-07-11 20:00:02 +02:00
|
|
|
renderer->exts.KHR_debug = true;
|
2020-07-28 14:02:08 +02:00
|
|
|
load_gl_proc(&renderer->procs.glDebugMessageCallbackKHR,
|
2019-11-10 14:31:33 +01:00
|
|
|
"glDebugMessageCallbackKHR");
|
2020-07-28 14:02:08 +02:00
|
|
|
load_gl_proc(&renderer->procs.glDebugMessageControlKHR,
|
2019-11-10 14:31:33 +01:00
|
|
|
"glDebugMessageControlKHR");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (check_gl_ext(exts_str, "GL_OES_EGL_image_external")) {
|
2021-07-11 20:00:02 +02:00
|
|
|
renderer->exts.OES_egl_image_external = true;
|
2020-07-28 14:02:08 +02:00
|
|
|
load_gl_proc(&renderer->procs.glEGLImageTargetTexture2DOES,
|
2019-11-10 14:31:33 +01:00
|
|
|
"glEGLImageTargetTexture2DOES");
|
|
|
|
}
|
2018-10-31 17:20:27 +01:00
|
|
|
|
2020-04-23 01:23:56 +02:00
|
|
|
if (check_gl_ext(exts_str, "GL_OES_EGL_image")) {
|
2021-07-11 20:00:02 +02:00
|
|
|
renderer->exts.OES_egl_image = true;
|
2020-07-28 14:02:08 +02:00
|
|
|
load_gl_proc(&renderer->procs.glEGLImageTargetRenderbufferStorageOES,
|
2020-04-23 01:23:56 +02:00
|
|
|
"glEGLImageTargetRenderbufferStorageOES");
|
|
|
|
}
|
|
|
|
|
2022-01-12 18:56:08 +01:00
|
|
|
if (check_gl_ext(exts_str, "GL_KHR_robustness")) {
|
|
|
|
GLint notif_strategy = 0;
|
|
|
|
glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_KHR, ¬if_strategy);
|
|
|
|
switch (notif_strategy) {
|
|
|
|
case GL_LOSE_CONTEXT_ON_RESET_KHR:
|
|
|
|
wlr_log(WLR_DEBUG, "GPU reset notifications are enabled");
|
|
|
|
load_gl_proc(&renderer->procs.glGetGraphicsResetStatusKHR,
|
|
|
|
"glGetGraphicsResetStatusKHR");
|
|
|
|
break;
|
|
|
|
case GL_NO_RESET_NOTIFICATION_KHR:
|
|
|
|
wlr_log(WLR_DEBUG, "GPU reset notifications are disabled");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-02 12:10:35 +02:00
|
|
|
if (check_gl_ext(exts_str, "GL_EXT_disjoint_timer_query")) {
|
|
|
|
renderer->exts.EXT_disjoint_timer_query = true;
|
|
|
|
load_gl_proc(&renderer->procs.glGenQueriesEXT, "glGenQueriesEXT");
|
|
|
|
load_gl_proc(&renderer->procs.glDeleteQueriesEXT, "glDeleteQueriesEXT");
|
|
|
|
load_gl_proc(&renderer->procs.glQueryCounterEXT, "glQueryCounterEXT");
|
|
|
|
load_gl_proc(&renderer->procs.glGetQueryObjectivEXT, "glGetQueryObjectivEXT");
|
|
|
|
load_gl_proc(&renderer->procs.glGetQueryObjectui64vEXT, "glGetQueryObjectui64vEXT");
|
|
|
|
load_gl_proc(&renderer->procs.glGetInteger64vEXT, "glGetInteger64vEXT");
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:00:02 +02:00
|
|
|
if (renderer->exts.KHR_debug) {
|
2018-03-20 19:14:33 +01:00
|
|
|
glEnable(GL_DEBUG_OUTPUT_KHR);
|
|
|
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR);
|
2020-07-28 14:02:08 +02:00
|
|
|
renderer->procs.glDebugMessageCallbackKHR(gles2_log, NULL);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
|
|
|
// Silence unwanted message types
|
2020-07-28 14:02:08 +02:00
|
|
|
renderer->procs.glDebugMessageControlKHR(GL_DONT_CARE,
|
2019-11-10 14:31:33 +01:00
|
|
|
GL_DEBUG_TYPE_POP_GROUP_KHR, GL_DONT_CARE, 0, NULL, GL_FALSE);
|
2020-07-28 14:02:08 +02:00
|
|
|
renderer->procs.glDebugMessageControlKHR(GL_DONT_CARE,
|
2019-11-10 14:31:33 +01:00
|
|
|
GL_DEBUG_TYPE_PUSH_GROUP_KHR, GL_DONT_CARE, 0, NULL, GL_FALSE);
|
2018-03-20 19:14:33 +01:00
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
push_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
2018-06-03 00:20:09 +02:00
|
|
|
GLuint prog;
|
|
|
|
renderer->shaders.quad.program = prog =
|
2022-10-27 16:05:50 +02:00
|
|
|
link_program(renderer, common_vert_src, quad_frag_src);
|
2018-06-03 00:20:09 +02:00
|
|
|
if (!renderer->shaders.quad.program) {
|
2018-03-20 19:14:33 +01:00
|
|
|
goto error;
|
|
|
|
}
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.quad.proj = glGetUniformLocation(prog, "proj");
|
|
|
|
renderer->shaders.quad.color = glGetUniformLocation(prog, "color");
|
2020-06-08 18:24:19 +02:00
|
|
|
renderer->shaders.quad.pos_attrib = glGetAttribLocation(prog, "pos");
|
2018-06-03 00:20:09 +02:00
|
|
|
|
|
|
|
renderer->shaders.tex_rgba.program = prog =
|
2022-10-27 16:05:50 +02:00
|
|
|
link_program(renderer, common_vert_src, tex_rgba_frag_src);
|
2018-06-03 00:20:09 +02:00
|
|
|
if (!renderer->shaders.tex_rgba.program) {
|
2018-03-20 19:14:33 +01:00
|
|
|
goto error;
|
|
|
|
}
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.tex_rgba.proj = glGetUniformLocation(prog, "proj");
|
2023-05-23 08:16:29 +02:00
|
|
|
renderer->shaders.tex_rgba.tex_proj = glGetUniformLocation(prog, "tex_proj");
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.tex_rgba.tex = glGetUniformLocation(prog, "tex");
|
|
|
|
renderer->shaders.tex_rgba.alpha = glGetUniformLocation(prog, "alpha");
|
2020-06-08 18:24:19 +02:00
|
|
|
renderer->shaders.tex_rgba.pos_attrib = glGetAttribLocation(prog, "pos");
|
2018-06-03 00:20:09 +02:00
|
|
|
|
|
|
|
renderer->shaders.tex_rgbx.program = prog =
|
2022-10-27 16:05:50 +02:00
|
|
|
link_program(renderer, common_vert_src, tex_rgbx_frag_src);
|
2018-06-03 00:20:09 +02:00
|
|
|
if (!renderer->shaders.tex_rgbx.program) {
|
2018-03-20 19:14:33 +01:00
|
|
|
goto error;
|
|
|
|
}
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.tex_rgbx.proj = glGetUniformLocation(prog, "proj");
|
2023-05-23 08:16:29 +02:00
|
|
|
renderer->shaders.tex_rgbx.tex_proj = glGetUniformLocation(prog, "tex_proj");
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.tex_rgbx.tex = glGetUniformLocation(prog, "tex");
|
|
|
|
renderer->shaders.tex_rgbx.alpha = glGetUniformLocation(prog, "alpha");
|
2020-06-08 18:24:19 +02:00
|
|
|
renderer->shaders.tex_rgbx.pos_attrib = glGetAttribLocation(prog, "pos");
|
2018-06-03 00:20:09 +02:00
|
|
|
|
2021-07-11 20:00:02 +02:00
|
|
|
if (renderer->exts.OES_egl_image_external) {
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.tex_ext.program = prog =
|
2022-10-27 16:05:50 +02:00
|
|
|
link_program(renderer, common_vert_src, tex_external_frag_src);
|
2018-06-03 00:20:09 +02:00
|
|
|
if (!renderer->shaders.tex_ext.program) {
|
2018-03-20 19:14:33 +01:00
|
|
|
goto error;
|
|
|
|
}
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.tex_ext.proj = glGetUniformLocation(prog, "proj");
|
2023-05-23 08:16:29 +02:00
|
|
|
renderer->shaders.tex_ext.tex_proj = glGetUniformLocation(prog, "tex_proj");
|
2018-06-03 00:20:09 +02:00
|
|
|
renderer->shaders.tex_ext.tex = glGetUniformLocation(prog, "tex");
|
|
|
|
renderer->shaders.tex_ext.alpha = glGetUniformLocation(prog, "alpha");
|
2020-06-08 18:24:19 +02:00
|
|
|
renderer->shaders.tex_ext.pos_attrib = glGetAttribLocation(prog, "pos");
|
2018-03-20 19:14:33 +01:00
|
|
|
}
|
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
pop_gles2_debug(renderer);
|
2017-10-21 23:20:26 +02:00
|
|
|
|
2020-05-19 11:54:59 +02:00
|
|
|
wlr_egl_unset_current(renderer->egl);
|
|
|
|
|
2017-08-14 14:37:50 +02:00
|
|
|
return &renderer->wlr_renderer;
|
2018-03-20 19:14:33 +01:00
|
|
|
|
|
|
|
error:
|
2018-06-03 00:20:09 +02:00
|
|
|
glDeleteProgram(renderer->shaders.quad.program);
|
|
|
|
glDeleteProgram(renderer->shaders.tex_rgba.program);
|
|
|
|
glDeleteProgram(renderer->shaders.tex_rgbx.program);
|
|
|
|
glDeleteProgram(renderer->shaders.tex_ext.program);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
2020-07-28 13:58:07 +02:00
|
|
|
pop_gles2_debug(renderer);
|
2018-03-20 19:14:33 +01:00
|
|
|
|
2021-07-11 20:00:02 +02:00
|
|
|
if (renderer->exts.KHR_debug) {
|
2018-03-20 19:14:33 +01:00
|
|
|
glDisable(GL_DEBUG_OUTPUT_KHR);
|
2020-07-28 14:02:08 +02:00
|
|
|
renderer->procs.glDebugMessageCallbackKHR(NULL, NULL);
|
2018-03-20 19:14:33 +01:00
|
|
|
}
|
|
|
|
|
2020-05-19 11:54:59 +02:00
|
|
|
wlr_egl_unset_current(renderer->egl);
|
|
|
|
|
2018-03-20 19:14:33 +01:00
|
|
|
free(renderer);
|
|
|
|
return NULL;
|
2017-06-08 21:52:42 +02:00
|
|
|
}
|
2020-04-21 14:52:47 +02:00
|
|
|
|
|
|
|
bool wlr_gles2_renderer_check_ext(struct wlr_renderer *wlr_renderer,
|
|
|
|
const char *ext) {
|
|
|
|
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
|
|
|
|
return check_gl_ext(renderer->exts_str, ext);
|
|
|
|
}
|