@ -51,6 +51,8 @@ struct vtest_program
int out_fd ;
int out_fd ;
struct vtest_input input ;
struct vtest_input input ;
const char * render_device ;
bool do_fork ;
bool do_fork ;
bool loop ;
bool loop ;
@ -68,6 +70,7 @@ struct vtest_program prog = {
. in_fd = - 1 ,
. in_fd = - 1 ,
. out_fd = - 1 ,
. out_fd = - 1 ,
. input = { { - 1 } , NULL } ,
. input = { { - 1 } , NULL } ,
. render_device = 0 ,
. do_fork = true ,
. do_fork = true ,
. loop = true ,
. loop = true ,
} ;
} ;
@ -78,8 +81,8 @@ static void vtest_main_set_signal_child(void);
static void vtest_main_set_signal_segv ( void ) ;
static void vtest_main_set_signal_segv ( void ) ;
static void vtest_main_open_read_file ( void ) ;
static void vtest_main_open_read_file ( void ) ;
static void vtest_main_open_socket ( void ) ;
static void vtest_main_open_socket ( void ) ;
static void vtest_main_run_renderer ( int in_fd , int out_fd ,
static void vtest_main_run_renderer ( int in_fd , int out_fd , struct vtest_input * input ,
struct vtest_input * input , int ctx_flags ) ;
int ctx_flags , const char * render_device ) ;
static void vtest_main_wait_for_socket_accept ( void ) ;
static void vtest_main_wait_for_socket_accept ( void ) ;
static void vtest_main_tidy_fds ( void ) ;
static void vtest_main_tidy_fds ( void ) ;
static void vtest_main_close_socket ( void ) ;
static void vtest_main_close_socket ( void ) ;
@ -126,12 +129,14 @@ start:
/* fork a renderer process */
/* fork a renderer process */
if ( fork ( ) = = 0 ) {
if ( fork ( ) = = 0 ) {
vtest_main_set_signal_segv ( ) ;
vtest_main_set_signal_segv ( ) ;
vtest_main_run_renderer ( prog . in_fd , prog . out_fd , & prog . input , ctx_flags ) ;
vtest_main_run_renderer ( prog . in_fd , prog . out_fd , & prog . input ,
ctx_flags , prog . render_device ) ;
exit ( 0 ) ;
exit ( 0 ) ;
}
}
} else {
} else {
vtest_main_set_signal_segv ( ) ;
vtest_main_set_signal_segv ( ) ;
vtest_main_run_renderer ( prog . in_fd , prog . out_fd , & prog . input , ctx_flags ) ;
vtest_main_run_renderer ( prog . in_fd , prog . out_fd , & prog . input ,
ctx_flags , prog . render_device ) ;
}
}
vtest_main_tidy_fds ( ) ;
vtest_main_tidy_fds ( ) ;
@ -152,6 +157,7 @@ start:
# define OPT_USE_GLX 'x'
# define OPT_USE_GLX 'x'
# define OPT_USE_EGL_SURFACELESS 's'
# define OPT_USE_EGL_SURFACELESS 's'
# define OPT_USE_GLES 'e'
# define OPT_USE_GLES 'e'
# define OPT_RENDERNODE 'r'
static void vtest_main_parse_args ( int argc , char * * argv )
static void vtest_main_parse_args ( int argc , char * * argv )
{
{
@ -163,6 +169,7 @@ static void vtest_main_parse_args(int argc, char **argv)
{ " use-glx " , no_argument , NULL , OPT_USE_GLX } ,
{ " use-glx " , no_argument , NULL , OPT_USE_GLX } ,
{ " use-egl-surfaceless " , no_argument , NULL , OPT_USE_EGL_SURFACELESS } ,
{ " use-egl-surfaceless " , no_argument , NULL , OPT_USE_EGL_SURFACELESS } ,
{ " use-gles " , no_argument , NULL , OPT_USE_GLES } ,
{ " use-gles " , no_argument , NULL , OPT_USE_GLES } ,
{ " rendernode " , required_argument , NULL , OPT_RENDERNODE } ,
{ 0 , 0 , 0 , 0 }
{ 0 , 0 , 0 , 0 }
} ;
} ;
@ -191,9 +198,13 @@ static void vtest_main_parse_args(int argc, char **argv)
case OPT_USE_GLES :
case OPT_USE_GLES :
prog . use_gles = true ;
prog . use_gles = true ;
break ;
break ;
case OPT_RENDERNODE :
prog . render_device = optarg ;
break ;
default :
default :
printf ( " Usage: %s [--no-fork] [--no-loop-or-fork] [--use-glx] "
printf ( " Usage: %s [--no-fork] [--no-loop-or-fork] [--use-glx] "
" [--use-egl-surfaceless] [--use-gles] [file] \n " , argv [ 0 ] ) ;
" [--use-egl-surfaceless] [--use-gles] [--rendernode <dev>] "
" [file] \n " , argv [ 0 ] ) ;
exit ( EXIT_FAILURE ) ;
exit ( EXIT_FAILURE ) ;
break ;
break ;
}
}
@ -212,6 +223,7 @@ static void vtest_main_getenv(void)
prog . use_glx = getenv ( " VTEST_USE_GLX " ) ! = NULL ;
prog . use_glx = getenv ( " VTEST_USE_GLX " ) ! = NULL ;
prog . use_egl_surfaceless = getenv ( " VTEST_USE_EGL_SURFACELESS " ) ! = NULL ;
prog . use_egl_surfaceless = getenv ( " VTEST_USE_EGL_SURFACELESS " ) ! = NULL ;
prog . use_gles = getenv ( " VTEST_USE_GLES " ) ! = NULL ;
prog . use_gles = getenv ( " VTEST_USE_GLES " ) ! = NULL ;
prog . render_device = getenv ( " VTEST_RENDERNODE " ) ;
}
}
static void handler ( int sig , siginfo_t * si , void * unused )
static void handler ( int sig , siginfo_t * si , void * unused )
@ -360,7 +372,8 @@ static const vtest_cmd_fptr_t vtest_commands[] = {
} ;
} ;
static void vtest_main_run_renderer ( int in_fd , int out_fd ,
static void vtest_main_run_renderer ( int in_fd , int out_fd ,
struct vtest_input * input , int ctx_flags )
struct vtest_input * input , int ctx_flags ,
const char * render_device )
{
{
int err , ret ;
int err , ret ;
uint32_t header [ VTEST_HDR_SIZE ] ;
uint32_t header [ VTEST_HDR_SIZE ] ;
@ -386,7 +399,7 @@ static void vtest_main_run_renderer(int in_fd, int out_fd,
break ;
break ;
}
}
ret = vtest_create_renderer ( input , out_fd , header [ 0 ] , ctx_flags ) ;
ret = vtest_create_renderer ( input , out_fd , header [ 0 ] , ctx_flags , render_device ) ;
if ( ret < 0 ) {
if ( ret < 0 ) {
err = 4 ;
err = 4 ;
break ;
break ;