Mesa: improvements for use with Qt5

Among other changes, this patch makes it possible to let Mesa render into
a user-provided buffer instead of the screen. This can be achieved with
the 'eglCreateWindowSurface()' function, which takes a buffer
description as third argument.

Fixes #974.
This commit is contained in:
Christian Prochaska 2013-11-21 15:53:56 +01:00 committed by Norman Feske
parent 8e30a07b90
commit a2e405f9e9
4 changed files with 69 additions and 13 deletions

View File

@ -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_ */

View File

@ -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:

View File

@ -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;
}

View File

@ -0,0 +1,25 @@
Allow OpenGL precision qualifiers for Qt5
From: Christian Prochaska <christian.prochaska@genode-labs.com>
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);