eglCreateContext fails with every EGLConfig that
nvidia blob 334.16 provides causing NULL pointer
dereference in gl_renderer_destroy when destroying
fragment and fan bindings.
https://bugs.freedesktop.org/show_bug.cgi?id=74699
Signed-off-by: Mariusz Ceier <mceier+wayland@gmail.com>
This has a couple of additional implications for the internal weston API:
1) weston_view_configure no longer exists. Use weston_view_set_position
instead.
2) The weston_surface.configure callback no longer takes a width and
height. If you need these, surface.width/height are set before
configure is called. If you need to know when the width/height
changes, you must track that yourself.
Gather the variables affecting the coordinate transformations between
buffer and local coordinates into a new struct weston_buffer_viewport.
This will be more useful later, when the crop & scale extension is
implemented.
When a renderer switch happens, it is possible that when the surface
state is created, a buffer for the given surface is already available.
In that case, run the attach routine so that the pixel contents are
properly set. Otherwise, it would only be set when a new attach request
is made for that surface.
Also, change the drm backend so that it keeps the buffer reference in
the weston_surface when running with the pixman renderer. The pixman
renderer keeps a reference to it anyway, so it is never released
early.
This makes the renderer transition seamless, without leaving a black
screen as before.
When running with the pixman renderer, the debug binding 'W'
(mod-shift-space W) will cause the compositor to load gl-renderer.so
and start using it instead of the pixman renderer.
This wraps all accesses to an SHM buffer between wl_shm_buffer_begin
and end so that wayland-shm can install a handler for SIGBUS and catch
attempts to pass the compositor a buffer that is too small.
The only user for this was the wayland backend with the GL renderer. It is
not needed in the Pixman renderer because you can easily create subimages.
All of the fancy output matrix calculations can be replaced by a single
glViewport call. Also, it didn't work with outputs located anywhere but
(0, 0) and I'm pretty sure output transformed outputs would break it too.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
The first advantage of this new API is that it is per-output instead of
global to the gl_renderer instance. This means that different windows can
have different titles, different button states, etc. The new api also uses
four textures (one for each side) instead of one. This allows you to draw
real borders with text and buttons in them instead of a simple image that
gets streached.
Images will be scaled as needed, so the right and left can be one pixel
tall if desired.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Previously the renderers destroy function assumed they are only called
when the compositor is shutting down and that the compositor had
already destroyed all the surfaces. However, if a runtime renderer
switch would be done, the surface state would be leaked.
This patch adds a destroy_signal to the pixman and gl renderers. The
surface state objects will listen for that signal and destroy
themselves if needed.
This is a step towards runtime switchable renderers.
Remove create_surface() and destroy_surface() from the renderer
interface and change the renderers to create surface state on demand
and destroy it using the weston_surface's destroy signal.
Also make sure the surfaces' renderer state is reset to NULL on
destruction.
This is a step towards runtime switchable renderers.
(rpi-renderer changes are only compile-tested)
Also make sure backends destroy the renderers before shutting down the
compositor to avoid a double call to weston_binding_destroy().
This is a step towards making renderers switchable during runtime.
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
The time spent loading EGL and GLES libraries from disk can be a
considerable hit in some embedded use cases. If Weston is compiled
with EGL support, the binary will depend on those libraries, even if
a software renderer is in use.
This patch splits the GL renderer into a separate loadable module,
and moves the dependency on EGL and GLES to it. The backends still
need the EGL headers for the native types and EGLint. The function
load_module() is renamed to weston_load_module() and exported, so
that it can be used by the backends.
The gl renderer interface is changed so that there is only one symbol
that needs to be dlsym()'d. This symbol contains pointers to all the
functions and data necessary to interact with the renderer. As a side
effect, this change simplifies gl-renderer.h a great deal.
We'll add the GBM format code as the native visual ID for EGLConfigs
when running on GBM. This patch lets the drm backend pass in the
format code it's using with KMS and make sure we get a confing that
matches. In the future, mesa will add support for 10 bpc configs
which will match the "at least 8 color bits" requirement. By also
matching the native visual ID, we avoid rendering XRGB2101010 into a
XRGB8888 KMS framebuffer.
GL_UNSIGNED_INT is only supported when GL_OES_element_index_uint is
available (mesa implements that extension). We don't need 32-bit
indices, so just use GL_UNSIGNED_SHORT.
If weston is compiled against a gl2ext.h that doesn't have the subimage
extension, but then run against a gles2 library that does provide it,
we end up disabling the glTexImage2D falback without having the subimage
code paths compiled in.
It is defined by the mesa #include, which is just a copy of the official
Khronos header. It's just defined in a different section than the
extension tokens. In the mean time, the extension tokens were renamed
to add a _EXT suffix (eg GL_UNPACK_ROW_LENGTH -> GL_UNPACK_ROW_LENGTH_EXT)
and we silently failed to used the subimage extension.
The fix to not call glTexImage2D() on every attach does not properly
set the texture damage region appropriately when the surface has a
buffer transform with 90 or 270 degrees rotation, since it would simply
multiply the buffer dimensions by the buffer scale, but in this case
width and height are inverted.
A possible fix for this would be to add the properly transformed region
to the texture damage region. However, there is a conversion back to
buffer coordinates when doing the actual upload and the entire buffer
needs to be uploaded anyway. So we just set a flag signalling that and
handle that special case in gl_renderer_flush_damage().
Checking for gs->num_images for determining the previous buffer type
when attaching is not reliable. The number of images is never cleared
in the SHM path, so after a switch from an EGL buffer to SHM, every
following attach of an SHM buffer will happen with gs->num_images > 0,
and the code will assume the previous buffer was an EGL one.
Fix this by adding a buffer_type field to gl_surface_state.
This commit adds a weston_buffer structure to replace wl_buffer. This way
we can hold onto buffers by just their resource. In order to do this, the
every renderer.attach function has to fill in the weston_buffer.width and
weston_buffer.height fields.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
v4:
Incorporated krh and anderco's comments. Now adding newly allocated
buffer's dimensions to texture_damage
v3:
* Removed unnecessary parentheses
* Added check for switching from EGL image to SHM buffer
* Moved shader assignment out of IF condition
v2:
Fixed the wrong comparison
v1:
Depending on specific DRI driver implementation, glTexImage2D() with data
set to NULL may or may not re-allocate the texture buffer each time it is
called. Unintended consequences happen if later glTexSubImage2D() is called
to only update a sub-region of the texture buffer.
I've explored moving glTexImage2D() from gl_renderer_attach() and simply
mark the texture dirty, but the current implemention seems cleaner because
I won't have to worry about calling ensure_textures() and re-assigning
gs->shader unnecessarily.
AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system. This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.
Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries. This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
[pq: rebased and converted more files]
We changed the protocol to always list modes in physical pixel
units (not scaled). And we removed the scaled mode flag. This
just updates the DRM and X11 compositors and the gl and pixman renderers
to handle this.
Both GL and pixman renderer (pixman probably only because GL did?)
return the screen capture image as y-flipped, therefore Weston y-flips
it again. However, the future rpi-renderer can produce only right-way-up
(non-flipped) screen captures, and does not need an y-flip.
Add a capability flag for y-flip, which the rpi-renderer will not set,
to get screen captures the right way up.
The wcap recording code needs yet another temporary buffer for the
non-flipped case, since the WCAP format is flipped, and the code
normally overwrites the input image as it compresses it. This becomes
difficult, if the compressor is supposed to flip while processing.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The upcoming rpi-renderer cannot handle arbitrary rotations. Introduce
Weston capability bits, and add a bit for arbitrary rotation. GL and
Pixman renderers support it.
Shell or any other module must not produce surface transformations with
rotation, if the capability bit is not set. Do not register the surface
rotation binding in desktop shell, if arbitary rotation is not
supported.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
If you specify e.g. scale=2 in weston.ini an output section for the
X11 backend we automatically upscale all normal surfaces by this
amount. Additionally we respect a buffer_scale set on the buffer to
mean that the buffer is already in a scaled form.
This works with both the gl and the pixman renderer. The non-X
backends compile and work, but don't support changing the output
scale (they do downscale as needed due to buffer_scale though).
This also sends the new "scale" and "done" events on wl_output,
making clients aware of the scale.
Now that we have EXT_buffer_age in mesa, we should stop assuming double
buffering and use the buffer age instead.
Note: this will cause system without the extension to repaint the whole
screen every frame.
The core uses this region to clear from the primary plane damage the
area that was repainted. If we add the old buffer damage to that, it
may end up clearing more damage from the primary plane than it was
intended.
weston_compositor::read_format is in Pixman values now, so comparing to
a GL value does not work. Compare to the right value.
This fix affects only the log output of the GL renderer.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Instead of relying on the compositor core to keep the wl_buffer around
and unreleased, take a new reference to it in gl-renderer. This makes
sure in the future, that the gl-renderer always has the buffer at hand,
client misbehaviour excluded.
The reference is taken in the attach callback, and released in the
flush_damage callback after copy to texture, or when the next attach
callback with a different buffer occurs.
If the surface is not on the primary plane, the buffer is not released
in flush_damage. This ensures, that the buffer stays valid in case the
surface migrates to the primary plane later.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
The wl_buffer reference counting API has been inconsistent. You would
manually increment the refcount and register a destroy listener, as
opposed to calling weston_buffer_post_release(), which internally
decremented the refcount, and then removing a list item.
Replace both cases with a single function:
weston_buffer_reference(weston_buffer_reference *ref, wl_buffer *buffer)
Buffer is assigned to ref->buffer, while taking care of all the refcounting
and release posting. You take a reference by passing a non-NULL buffer, and
release a reference by passing NULL as buffer. The function uses an
internal wl_buffer destroy listener, so the pointer gets reset on
destruction automatically.
This is inspired by the pipe_resource_reference() of Mesa, and modified
by krh's suggestion to add struct weston_buffer_reference.
Additionally, when a surface gets destroyed, the associated wl_buffer
will send a release event. Often the buffer is already destroyed on
client side, so the event will be discarded by libwayland-client.
Compositor-drm.c is converted to use weston_buffer_reference.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>