Skip to content

Commit

Permalink
more software rendering work
Browse files Browse the repository at this point in the history
  • Loading branch information
ardera committed Jun 7, 2024
1 parent 4de70e0 commit d06e855
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 47 deletions.
32 changes: 3 additions & 29 deletions src/gl_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,7 @@ struct gl_renderer *gl_renderer_new_from_gbm_device(
return NULL;
}

struct gl_renderer *gl_renderer_new_surfaceless(
struct tracer *tracer,
bool has_forced_pixel_format,
enum pixfmt pixel_format
) {
struct gl_renderer *gl_renderer_new_surfaceless(struct tracer *tracer, bool has_forced_pixel_format, enum pixfmt pixel_format) {
struct gl_renderer *renderer;
const char *egl_client_exts, *egl_display_exts;
const char *gl_renderer, *gl_exts;
Expand Down Expand Up @@ -492,7 +488,6 @@ struct gl_renderer *gl_renderer_new_surfaceless(
// are defined by EGL_EXT_platform_base.
#ifdef EGL_EXT_platform_base
PFNEGLGETPLATFORMDISPLAYEXTPROC egl_get_platform_display_ext;
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC egl_create_platform_window_surface_ext;
#endif

if (supports_egl_ext_platform_base) {
Expand All @@ -507,26 +502,6 @@ struct gl_renderer *gl_renderer_new_surfaceless(
#endif
}

if (supports_egl_ext_platform_base) {
#ifdef EGL_EXT_platform_base
egl_create_platform_window_surface_ext = try_get_proc_address("eglCreatePlatformWindowSurfaceEXT");
if (egl_create_platform_window_surface_ext == NULL) {
LOG_ERROR(
"Couldn't resolve \"eglCreatePlatformWindowSurfaceEXT\" even though \"EGL_EXT_platform_base\" was listed as supported.\n"
);
egl_get_platform_display_ext = NULL;
supports_egl_ext_platform_base = false;
}
#else
UNREACHABLE();
#endif
}

// EGL_PLATFORM_GBM_KHR is defined by EGL_KHR_platform_gbm.
#ifndef EGL_KHR_platform_gbm
#error "EGL extension EGL_KHR_platform_gbm is required."
#endif

egl_display = EGL_NO_DISPLAY;
bool failed_before = false;

Expand Down Expand Up @@ -574,7 +549,7 @@ struct gl_renderer *gl_renderer_new_surfaceless(

egl_ok = eglInitialize(egl_display, &major, &minor);
if (egl_ok != EGL_TRUE) {
LOG_EGL_ERROR(eglGetError(), "Failed to initialize EGL! eglInitialize:");
LOG_EGL_ERROR(eglGetError(), "Failed to initialize EGL! eglInitialize");
goto fail_free_renderer;
}

Expand Down Expand Up @@ -722,7 +697,7 @@ struct gl_renderer *gl_renderer_new_surfaceless(
renderer->supports_egl_ext_platform_base = supports_egl_ext_platform_base;
#ifdef EGL_EXT_platform_base
renderer->egl_get_platform_display_ext = egl_get_platform_display_ext;
renderer->egl_create_platform_window_surface_ext = egl_create_platform_window_surface_ext;
renderer->egl_create_platform_window_surface_ext = NULL;
#endif
#ifdef EGL_VERSION_1_5
renderer->egl_get_platform_display = egl_get_platform_display;
Expand Down Expand Up @@ -755,7 +730,6 @@ struct gl_renderer *gl_renderer_new_surfaceless(
return NULL;
}


void gl_renderer_destroy(struct gl_renderer *renderer) {
ASSERT_NOT_NULL(renderer);
tracer_unref(renderer->tracer);
Expand Down
52 changes: 34 additions & 18 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#ifdef HAVE_EGL_GLES2
#include "egl_gbm_render_surface.h"
#include "egl_offscreen_render_surface.h"
#include "gl_renderer.h"
#endif

Expand Down Expand Up @@ -943,9 +944,8 @@ MUST_CHECK struct window *kms_window_new(
has_dimensions = true;
width_mm = selected_connector->variable_state.width_mm;
height_mm = selected_connector->variable_state.height_mm;
} else if (selected_connector->type == DRM_MODE_CONNECTOR_DSI
&& selected_connector->variable_state.width_mm == 0
&& selected_connector->variable_state.height_mm == 0) {
} else if (selected_connector->type == DRM_MODE_CONNECTOR_DSI && selected_connector->variable_state.width_mm == 0 &&
selected_connector->variable_state.height_mm == 0) {
// assume this is the official Raspberry Pi DSI display.
has_dimensions = true;
width_mm = 155;
Expand Down Expand Up @@ -1693,22 +1693,38 @@ static struct render_surface *dummy_window_get_render_surface_internal(struct wi
#ifndef EGL_KHR_no_config_context
#error "EGL header definitions for extension EGL_KHR_no_config_context are required."
#endif

struct egl_gbm_render_surface *egl_surface = egl_gbm_render_surface_new_with_egl_config(
window->tracer,
size,
gl_renderer_get_gbm_device(window->gl_renderer),
window->gl_renderer,
window->has_forced_pixel_format ? window->forced_pixel_format : PIXFMT_ARGB8888,
EGL_NO_CONFIG_KHR,
NULL,
0
);
if (egl_surface == NULL) {
LOG_ERROR("Couldn't create EGL GBM rendering surface.\n");
render_surface = NULL;
struct gbm_device *gbm_device = gl_renderer_get_gbm_device(window->gl_renderer);

if (gbm_device != NULL) {
struct egl_gbm_render_surface *egl_surface = egl_gbm_render_surface_new_with_egl_config(
window->tracer,
size,
gl_renderer_get_gbm_device(window->gl_renderer),
window->gl_renderer,
window->has_forced_pixel_format ? window->forced_pixel_format : PIXFMT_ARGB8888,
EGL_NO_CONFIG_KHR,
NULL,
0
);
if (egl_surface == NULL) {
LOG_ERROR("Couldn't create EGL GBM rendering surface.\n");
render_surface = NULL;
} else {
render_surface = CAST_RENDER_SURFACE(egl_surface);
}
} else {
render_surface = CAST_RENDER_SURFACE(egl_surface);
struct egl_offscreen_render_surface *egl_surface = egl_offscreen_render_surface_new(
window->tracer,
size,
window->gl_renderer,
window->has_forced_pixel_format ? window->forced_pixel_format : PIXFMT_ARGB8888
);
if (egl_surface == NULL) {
LOG_ERROR("Couldn't create EGL offscreen rendering surface.\n");
render_surface = NULL;
} else {
render_surface = CAST_RENDER_SURFACE(egl_surface);
}
}

#else
Expand Down

0 comments on commit d06e855

Please sign in to comment.