diff --git a/libports/include/EGL/eglplatform.h b/libports/include/EGL/eglplatform.h index 8eb135a5a..0fda5cb5b 100644 --- a/libports/include/EGL/eglplatform.h +++ b/libports/include/EGL/eglplatform.h @@ -26,9 +26,17 @@ #define EGLAPIENTRYP EGLAPIENTRY* typedef int EGLNativeDisplayType; -typedef void *EGLNativeWindowType; typedef void *EGLNativePixmapType; +struct Genode_egl_window +{ + int width; + int height; + unsigned char *addr; +}; + +typedef struct Genode_egl_window *EGLNativeWindowType; + typedef khronos_int32_t EGLint; #endif /* __eglplatform_h_ */ diff --git a/libports/ports/mesa.mk b/libports/ports/mesa.mk index d5e35252e..30b438c36 100644 --- a/libports/ports/mesa.mk +++ b/libports/ports/mesa.mk @@ -27,6 +27,7 @@ $(DOWNLOAD_DIR)/$(MESA_TGZ): $(CONTRIB_DIR)/$(MESA_DIR): $(DOWNLOAD_DIR)/$(MESA_TGZ) $(VERBOSE)tar xfz $< -C $(CONTRIB_DIR) $(VERBOSE)patch -N -p0 -d $(CONTRIB_DIR)/$(MESA_DIR) < src/lib/gallium/p_state_config.patch + $(VERBOSE)patch -N -p1 -d $(CONTRIB_DIR)/$(MESA_DIR) < src/lib/egl/opengl_precision.patch $(VERBOSE)touch $@ tool/mesa/glsl: diff --git a/libports/src/lib/egl/driver.cc b/libports/src/lib/egl/driver.cc index 34fcf2af4..06c5e5931 100644 --- a/libports/src/lib/egl/driver.cc +++ b/libports/src/lib/egl/driver.cc @@ -165,7 +165,7 @@ class Winsys : public pipe_winsys struct pipe_surface *surf, void *context_private) { - PDBG("not implemented"); + genode_framebuffer()->flush(); } static struct pipe_buffer * @@ -182,7 +182,10 @@ class Winsys : public pipe_winsys void *ptr, unsigned bytes) { - PDBG("not implemented"); return 0; + Pipe_buffer *buf = + new (Genode::env()->heap()) Pipe_buffer(64, 0, bytes); + Genode::memcpy(buf->data(), ptr, bytes); + return buf; } /* @@ -294,7 +297,7 @@ class Surface : public native_surface { public: - enum Surface_type { TYPE_SCANOUT }; + enum Surface_type { TYPE_SCANOUT, TYPE_WINDOW }; private: @@ -303,6 +306,7 @@ class Surface : public native_surface Surface_type _type; const native_config *_config; int _width, _height; + unsigned char *_addr; /* only used for TYPE_WINDOW */ struct pipe_texture *_textures[NUM_NATIVE_ATTACHMENTS]; unsigned int _sequence_number; @@ -390,10 +394,11 @@ class Surface : public native_surface public: Surface(native_display *display, Surface_type t, const native_config *config, - int width, int height) + int width, int height, unsigned char *addr = 0) : _color_format(config->color_format), _display(display), _type(t), - _config(config), _width(width), _height(height), _sequence_number(0) + _config(config), _width(width), _height(height), _addr(addr), + _sequence_number(0) { for (int i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) _textures[i] = 0; @@ -528,7 +533,7 @@ class Display : public native_display configs[0] = &display->_native_config; struct native_config *config = &display->_native_config; - config->mode.drawableType = GLX_PBUFFER_BIT; + config->mode.drawableType = GLX_PBUFFER_BIT | GLX_WINDOW_BIT; int r = 5, g = 6, b = 5, a = 0; config->mode.swapMethod = GLX_SWAP_EXCHANGE_OML; @@ -591,7 +596,11 @@ class Display : public native_display EGLNativeWindowType win, const struct native_config *nconf) { - PDBG("not implemented"); return 0; + return new (Genode::env()->heap()) + Surface(ndpy, + Surface::TYPE_WINDOW, nconf, + win->width, win->height, win->addr); + } static struct native_surface * @@ -623,8 +632,15 @@ class Display : public native_display /* setup mode list */ _mode.desc = "Mode-genode"; - _mode.width = genode_framebuffer()->width(); - _mode.height = genode_framebuffer()->height(); + try { + _mode.width = genode_framebuffer()->width(); + _mode.height = genode_framebuffer()->height(); + } catch (Genode::Parent::Service_denied) { + PWRN("EGL driver: could not create a Framebuffer session. " + "Screen surfaces cannot be used."); + _mode.width = 1; + _mode.height = 1; + } _mode.refresh_rate = 100; _mode_list[0] = &_mode; @@ -707,15 +723,21 @@ boolean Surface::_swap_buffers(struct native_surface *nsurf) } #endif - blit(data, transfer->stride, genode_framebuffer()->local_addr(), - transfer->stride, transfer->stride, transfer->height); + if (this_surface->_type == TYPE_SCANOUT) + blit(data, transfer->stride, genode_framebuffer()->local_addr(), + transfer->stride, transfer->stride, transfer->height); + else if (this_surface->_type == TYPE_WINDOW) + blit(data, transfer->stride, this_surface->_addr, + transfer->stride, transfer->stride, transfer->height); screen->transfer_unmap(screen, transfer); screen->tex_transfer_destroy(transfer); this_surface->_sequence_number++; - genode_framebuffer()->flush(); + if (this_surface->_type == TYPE_SCANOUT) + genode_framebuffer()->flush(); + return TRUE; } diff --git a/libports/src/lib/egl/opengl_precision.patch b/libports/src/lib/egl/opengl_precision.patch new file mode 100644 index 000000000..c5c673fa5 --- /dev/null +++ b/libports/src/lib/egl/opengl_precision.patch @@ -0,0 +1,25 @@ +Allow OpenGL precision qualifiers for Qt5 + +From: Christian Prochaska + +Qt5 creates shader programs which use precision qualifiers. When these +programs get compiled for desktop OpenGL, a compile error occurs, because +a version number is too low. Lowering the version requirement avoids +the compile errors and didn't seem to cause any problems so far. +--- + src/mesa/shader/slang/slang_compile.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c +index ad86676..101623d 100644 +--- a/src/mesa/shader/slang/slang_compile.c ++++ b/src/mesa/shader/slang/slang_compile.c +@@ -2571,7 +2571,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit, + #if FEATURE_es2_glsl + o.allow_precision = GL_TRUE; + #else +- o.allow_precision = (C->version >= 120) ? GL_TRUE : GL_FALSE; ++ o.allow_precision = (C->version >= 110) ? GL_TRUE : GL_FALSE; + #endif + init_default_precision(&o, unit->type); +