rpi: add a Dispmanx renderer

Dispmanx is the prorietary display API on the Raspberry Pi, which
provides hardware compositing. Every visible surface is assigned a
Dispmanx element, and the hardware or firmware will do all compositing
onto screen. The API supports translation, scaling, flips, discrete
rotations in 90-degree steps, alpha channel on the surfaces, and
full-surface alpha on top.

Previously, Dispmanx capabilities were used via the weston_plane
mechanism, where surfaces were assigned to planes when possible, and
otherwise transparently falling back to GLESv2 compositing. Because we
have no way to use the same memory buffer as a GL texture and a Dispmanx
resource, we had to prepare for both. In the worst case, that means one GL
texture, and two (double-buffered case) Dispmanx resources, all the size
of a whole surface, for all surfaces. This was eating memory fast. To
make things worse (and less slow), the wl_shm buffer was kept around,
since it was copied to either a texture or a resource as needed. This
caused all clients to need two buffers. In a Dispmanx-only renderer, we
can drop the GL texture, and we can release wl_shm buffer immediately
after the first copy, so clients become effectively single-buffered. So
from the worst case of 5 buffers per surface, we go down to 3 or just
2 (single-buffered Dispmanx element, one wl_shm buffer in the client)
buffers per surface.

As this will replace the GL renderer on rpi, we cannot fall back to the
GLESv2 compositing anymore. We lose arbitrary surface rotation, but we
lose also the GL fallback, which caused glitches.

This patch depends on new RaspberryPi firmware. Older firmware may not
render ARGB surfaces correctly, solid color surfaces maybe cause a
performance hit, and the output may completely fail in case the firmware
does not fall back internal off-line compositing properly as needed.

This new rpi-renderer support surface translation and scaling, but not
rotation or transpose (not even in 90-deg steps). In theory, 90-deg step
surface rotation is possible to support. Output transformations are
supported, but flipped variants do not seem to work right.

As a detail, menus and other surfaces that are simply translated with
respect to another surface caused falling back to the GL renderer. The
rpi-renderer handles them directly.

This patch only adds the new renderer, but does not hook it up into use.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Pekka Paalanen 12 years ago committed by Kristian Høgsberg
parent 4fc5dd0099
commit d7265bc4ac
  1. 2
      src/Makefile.am
  2. 39
      src/rpi-bcm-stubs.h
  3. 1370
      src/rpi-renderer.c
  4. 48
      src/rpi-renderer.h

@ -180,6 +180,8 @@ rpi_backend_la_CFLAGS = \
$(RPI_BCM_HOST_CFLAGS)
rpi_backend_la_SOURCES = \
compositor-rpi.c \
rpi-renderer.c \
rpi-renderer.h \
rpi-bcm-stubs.h \
tty.c \
evdev.c \

@ -43,6 +43,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static inline void bcm_host_init(void) {}
static inline void bcm_host_deinit(void) {}
/* from /opt/vc/include/interface/vmcs_host/vc_dispservice_defs.h */
#define TRANSFORM_HFLIP (1<<0)
#define TRANSFORM_VFLIP (1<<1)
#define TRANSFORM_TRANSPOSE (1<<2)
/* from /opt/vc/include/interface/vctypes/vc_display_types.h */
typedef enum
@ -61,6 +69,14 @@ typedef struct tag_VC_RECT_T {
typedef enum {
VC_IMAGE_ROT0,
/* these are not the right values: */
VC_IMAGE_ROT90,
VC_IMAGE_ROT180,
VC_IMAGE_ROT270,
VC_IMAGE_MIRROR_ROT0,
VC_IMAGE_MIRROR_ROT90,
VC_IMAGE_MIRROR_ROT180,
VC_IMAGE_MIRROR_ROT270,
} VC_IMAGE_TRANSFORM_T;
typedef enum
@ -109,6 +125,12 @@ typedef struct {
typedef enum {
DISPMANX_NO_ROTATE = 0,
DISPMANX_ROTATE_90 = 1,
DISPMANX_ROTATE_180 = 2,
DISPMANX_ROTATE_270 = 3,
DISPMANX_FLIP_HRIZ = 1 << 16,
DISPMANX_FLIP_VERT = 1 << 17
} DISPMANX_TRANSFORM_T;
typedef struct {
@ -160,6 +182,15 @@ vc_dispmanx_resource_write_data_rect(DISPMANX_RESOURCE_HANDLE_T handle,
return -1;
}
static inline int
vc_dispmanx_resource_read_data(DISPMANX_RESOURCE_HANDLE_T handle,
const VC_RECT_T *p_rect,
void *dst_address,
uint32_t dst_pitch)
{
return -1;
}
static inline int
vc_dispmanx_resource_delete(DISPMANX_RESOURCE_HANDLE_T res)
{
@ -256,6 +287,14 @@ vc_dispmanx_element_change_attributes(DISPMANX_UPDATE_HANDLE_T update,
return -1;
}
static inline int
vc_dispmanx_snapshot(DISPMANX_DISPLAY_HANDLE_T display,
DISPMANX_RESOURCE_HANDLE_T snapshot_resource,
VC_IMAGE_TRANSFORM_T transform)
{
return -1;
}
/* from /opt/vc/include/EGL/eglplatform.h */
typedef struct {

File diff suppressed because it is too large Load Diff

@ -0,0 +1,48 @@
/*
* Copyright © 2013 Raspberry Pi Foundation
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef RPI_RENDERER_H
#define RPI_RENDERER_H
struct rpi_renderer_parameters {
int single_buffer;
};
int
rpi_renderer_create(struct weston_compositor *compositor,
const struct rpi_renderer_parameters *params);
int
rpi_renderer_output_create(struct weston_output *base,
DISPMANX_DISPLAY_HANDLE_T display);
void
rpi_renderer_output_destroy(struct weston_output *base);
void
rpi_renderer_set_update_handle(struct weston_output *base,
DISPMANX_UPDATE_HANDLE_T handle);
void
rpi_renderer_finish_frame(struct weston_output *base);
#endif /* RPI_RENDERER_H */
Loading…
Cancel
Save