@ -66,7 +66,6 @@
# define OPT_MANDELBROT (1 << 2) /* render mandelbrot */
# define OPT_DIRECT_DISPLAY (1 << 3) /* direct-display */
# define BUFFER_FORMAT DRM_FORMAT_XRGB8888
# define MAX_BUFFER_PLANES 4
struct display {
@ -78,6 +77,7 @@ struct display {
struct zwp_linux_dmabuf_v1 * dmabuf ;
struct weston_direct_display_v1 * direct_display ;
struct zwp_linux_explicit_synchronization_v1 * explicit_sync ;
uint32_t format ;
uint64_t * modifiers ;
int modifiers_count ;
int req_dmabuf_immediate ;
@ -337,7 +337,7 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer,
buffer - > display = display ;
buffer - > width = width ;
buffer - > height = height ;
buffer - > format = BUFFER_FORMAT ;
buffer - > format = display - > format ;
buffer - > release_fence_fd = - 1 ;
# ifdef HAVE_GBM_MODIFIERS
@ -998,16 +998,12 @@ dmabuf_modifiers(void *data, struct zwp_linux_dmabuf_v1 *zwp_linux_dmabuf,
{
struct display * d = data ;
switch ( format ) {
case BUFFER_FORMAT :
if ( format = = d - > format ) {
+ + d - > modifiers_count ;
d - > modifiers = realloc ( d - > modifiers ,
d - > modifiers_count * sizeof ( * d - > modifiers ) ) ;
d - > modifiers [ d - > modifiers_count - 1 ] =
( ( uint64_t ) modifier_hi < < 32 ) | modifier_lo ;
break ;
default :
break ;
}
}
@ -1270,7 +1266,7 @@ display_update_supported_modifiers_for_egl(struct display *d)
if ( try_modifiers ) {
ret = d - > egl . query_dma_buf_modifiers ( d - > egl . display ,
BUFFER_FORMAT ,
d - > format ,
0 , /* max_modifiers */
NULL , /* modifiers */
NULL , /* external_only */
@ -1295,7 +1291,7 @@ display_update_supported_modifiers_for_egl(struct display *d)
egl_modifiers = zalloc ( num_egl_modifiers * sizeof ( * egl_modifiers ) ) ;
ret = d - > egl . query_dma_buf_modifiers ( d - > egl . display ,
BUFFER_FORMAT ,
d - > format ,
num_egl_modifiers ,
egl_modifiers ,
NULL , /* external_only */
@ -1355,7 +1351,7 @@ display_set_up_gbm(struct display *display, char const* drm_render_node)
}
static struct display *
create_display ( char const * drm_render_node , int opts )
create_display ( char const * drm_render_node , uint32_t format , int opts )
{
struct display * display = NULL ;
@ -1370,6 +1366,7 @@ create_display(char const *drm_render_node, int opts)
display - > display = wl_display_connect ( NULL ) ;
assert ( display - > display ) ;
display - > format = format ;
display - > req_dmabuf_immediate = opts & OPT_IMMEDIATE ;
display - > registry = wl_display_get_registry ( display - > display ) ;
@ -1384,7 +1381,8 @@ create_display(char const *drm_render_node, int opts)
wl_display_roundtrip ( display - > display ) ;
if ( ! display - > modifiers_count ) {
fprintf ( stderr , " format XRGB8888 is not available \n " ) ;
fprintf ( stderr , " format 0x% " PRIX32 " is not available \n " ,
display - > format ) ;
goto error ;
}
@ -1450,6 +1448,8 @@ print_usage_and_exit(void)
" \t '-e,--explicit-sync=<>' "
" \n \t \t 0 to disable explicit sync, "
" \n \t \t 1 to enable explicit sync (default: 1) \n "
" \t '-f,--format=0x<>' "
" \n \t \t the DRM format code to use \n "
" \t '-m,--mandelbrot' "
" \n \t \t render a mandelbrot set with multiple draw calls \n "
" \t '-g,--direct-display' "
@ -1479,6 +1479,7 @@ main(int argc, char **argv)
struct sigaction sigint ;
struct display * display ;
struct window * window ;
uint32_t format = DRM_FORMAT_XRGB8888 ;
int opts = 0 ;
char const * drm_render_node = " /dev/dri/renderD128 " ;
int c , option_index , ret = 0 ;
@ -1489,13 +1490,14 @@ main(int argc, char **argv)
{ " drm-render-node " , required_argument , 0 , ' d ' } ,
{ " size " , required_argument , 0 , ' s ' } ,
{ " explicit-sync " , required_argument , 0 , ' e ' } ,
{ " format " , required_argument , 0 , ' f ' } ,
{ " mandelbrot " , no_argument , 0 , ' m ' } ,
{ " direct-display " , no_argument , 0 , ' g ' } ,
{ " help " , no_argument , 0 , ' h ' } ,
{ 0 , 0 , 0 , 0 }
} ;
while ( ( c = getopt_long ( argc , argv , " hi:d:s:e:mg " ,
while ( ( c = getopt_long ( argc , argv , " hi:d:s:e:f: mg " ,
long_options , & option_index ) ) ! = - 1 ) {
switch ( c ) {
case ' i ' :
@ -1518,12 +1520,15 @@ main(int argc, char **argv)
case ' g ' :
opts | = OPT_DIRECT_DISPLAY ;
break ;
case ' f ' :
format = strtoul ( optarg , NULL , 0 ) ;
break ;
default :
print_usage_and_exit ( ) ;
}
}
display = create_display ( drm_render_node , opts ) ;
display = create_display ( drm_render_node , format , opts ) ;
if ( ! display )
return 1 ;
window = create_window ( display , window_size , window_size , opts ) ;