mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-22 06:57:51 +00:00
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:
parent
8e30a07b90
commit
a2e405f9e9
@ -26,9 +26,17 @@
|
|||||||
#define EGLAPIENTRYP EGLAPIENTRY*
|
#define EGLAPIENTRYP EGLAPIENTRY*
|
||||||
|
|
||||||
typedef int EGLNativeDisplayType;
|
typedef int EGLNativeDisplayType;
|
||||||
typedef void *EGLNativeWindowType;
|
|
||||||
typedef void *EGLNativePixmapType;
|
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;
|
typedef khronos_int32_t EGLint;
|
||||||
|
|
||||||
#endif /* __eglplatform_h_ */
|
#endif /* __eglplatform_h_ */
|
||||||
|
@ -27,6 +27,7 @@ $(DOWNLOAD_DIR)/$(MESA_TGZ):
|
|||||||
$(CONTRIB_DIR)/$(MESA_DIR): $(DOWNLOAD_DIR)/$(MESA_TGZ)
|
$(CONTRIB_DIR)/$(MESA_DIR): $(DOWNLOAD_DIR)/$(MESA_TGZ)
|
||||||
$(VERBOSE)tar xfz $< -C $(CONTRIB_DIR)
|
$(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 -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 $@
|
$(VERBOSE)touch $@
|
||||||
|
|
||||||
tool/mesa/glsl:
|
tool/mesa/glsl:
|
||||||
|
@ -165,7 +165,7 @@ class Winsys : public pipe_winsys
|
|||||||
struct pipe_surface *surf,
|
struct pipe_surface *surf,
|
||||||
void *context_private)
|
void *context_private)
|
||||||
{
|
{
|
||||||
PDBG("not implemented");
|
genode_framebuffer()->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pipe_buffer *
|
static struct pipe_buffer *
|
||||||
@ -182,7 +182,10 @@ class Winsys : public pipe_winsys
|
|||||||
void *ptr,
|
void *ptr,
|
||||||
unsigned bytes)
|
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:
|
public:
|
||||||
|
|
||||||
enum Surface_type { TYPE_SCANOUT };
|
enum Surface_type { TYPE_SCANOUT, TYPE_WINDOW };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -303,6 +306,7 @@ class Surface : public native_surface
|
|||||||
Surface_type _type;
|
Surface_type _type;
|
||||||
const native_config *_config;
|
const native_config *_config;
|
||||||
int _width, _height;
|
int _width, _height;
|
||||||
|
unsigned char *_addr; /* only used for TYPE_WINDOW */
|
||||||
struct pipe_texture *_textures[NUM_NATIVE_ATTACHMENTS];
|
struct pipe_texture *_textures[NUM_NATIVE_ATTACHMENTS];
|
||||||
unsigned int _sequence_number;
|
unsigned int _sequence_number;
|
||||||
|
|
||||||
@ -390,10 +394,11 @@ class Surface : public native_surface
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Surface(native_display *display, Surface_type t, const native_config *config,
|
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),
|
_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++)
|
for (int i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
|
||||||
_textures[i] = 0;
|
_textures[i] = 0;
|
||||||
@ -528,7 +533,7 @@ class Display : public native_display
|
|||||||
configs[0] = &display->_native_config;
|
configs[0] = &display->_native_config;
|
||||||
|
|
||||||
struct native_config *config = &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;
|
int r = 5, g = 6, b = 5, a = 0;
|
||||||
config->mode.swapMethod = GLX_SWAP_EXCHANGE_OML;
|
config->mode.swapMethod = GLX_SWAP_EXCHANGE_OML;
|
||||||
@ -591,7 +596,11 @@ class Display : public native_display
|
|||||||
EGLNativeWindowType win,
|
EGLNativeWindowType win,
|
||||||
const struct native_config *nconf)
|
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 *
|
static struct native_surface *
|
||||||
@ -623,8 +632,15 @@ class Display : public native_display
|
|||||||
|
|
||||||
/* setup mode list */
|
/* setup mode list */
|
||||||
_mode.desc = "Mode-genode";
|
_mode.desc = "Mode-genode";
|
||||||
_mode.width = genode_framebuffer()->width();
|
try {
|
||||||
_mode.height = genode_framebuffer()->height();
|
_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.refresh_rate = 100;
|
||||||
_mode_list[0] = &_mode;
|
_mode_list[0] = &_mode;
|
||||||
|
|
||||||
@ -707,15 +723,21 @@ boolean Surface::_swap_buffers(struct native_surface *nsurf)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
blit(data, transfer->stride, genode_framebuffer()->local_addr(),
|
if (this_surface->_type == TYPE_SCANOUT)
|
||||||
transfer->stride, transfer->stride, transfer->height);
|
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->transfer_unmap(screen, transfer);
|
||||||
screen->tex_transfer_destroy(transfer);
|
screen->tex_transfer_destroy(transfer);
|
||||||
|
|
||||||
this_surface->_sequence_number++;
|
this_surface->_sequence_number++;
|
||||||
|
|
||||||
genode_framebuffer()->flush();
|
if (this_surface->_type == TYPE_SCANOUT)
|
||||||
|
genode_framebuffer()->flush();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
25
libports/src/lib/egl/opengl_precision.patch
Normal file
25
libports/src/lib/egl/opengl_precision.patch
Normal 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);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user