]> git.sesse.net Git - nageru/blob - flags.cpp
Add an option to not flush PBOs explicitly; causes apitrace not to store the data...
[nageru] / flags.cpp
1 #include "flags.h"
2
3 #include <getopt.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 Flags global_flags;
8
9 void usage()
10 {
11         fprintf(stderr, "Usage: nageru [OPTION]...\n");
12         fprintf(stderr, "\n");
13         fprintf(stderr, "  -h, --help                      print usage information\n");
14         fprintf(stderr, "  -c, --num-cards                 set number of input cards (default 2)\n");
15         fprintf(stderr, "  -t, --theme=FILE                choose theme (default theme.lua)\n");
16         fprintf(stderr, "  -v, --va-display=SPEC           VA-API device for H.264 encoding\n");
17         fprintf(stderr, "                                    ($DISPLAY spec or /dev/dri/render* path)\n");
18         fprintf(stderr, "      --http-uncompressed-video   send uncompressed NV12 video to HTTP clients\n");
19         fprintf(stderr, "      --flat-audio                start with most audio processing turned off\n");
20         fprintf(stderr, "      --no-flush-pbos             do not explicitly signal texture data uploads\n");
21         fprintf(stderr, "                                    (will give display corruption, but makes it\n");
22         fprintf(stderr, "                                    possible to run with apitrace in real time)\n");
23 }
24
25 void parse_flags(int argc, char * const argv[])
26 {
27         static const option long_options[] = {
28                 { "help", no_argument, 0, 'h' },
29                 { "num-cards", required_argument, 0, 'c' },
30                 { "theme", required_argument, 0, 't' },
31                 { "va-display", required_argument, 0, 1000 },
32                 { "http-uncompressed-video", no_argument, 0, 1001 },
33                 { "flat-audio", no_argument, 0, 1002 },
34                 { "no-flush-pbos", no_argument, 0, 1003 },
35                 { 0, 0, 0, 0 }
36         };
37         for ( ;; ) {
38                 int option_index = 0;
39                 int c = getopt_long(argc, argv, "c:t:", long_options, &option_index);
40
41                 if (c == -1) {
42                         break;
43                 }
44                 switch (c) {
45                 case 'c':
46                         global_flags.num_cards = atoi(optarg);
47                         break;
48                 case 't':
49                         global_flags.theme_filename = optarg;
50                         break;
51                 case 1000:
52                         global_flags.va_display = optarg;
53                         break;
54                 case 1001:
55                         global_flags.uncompressed_video_to_http = true;
56                         break;
57                 case 1002:
58                         global_flags.flat_audio = true;
59                         break;
60                 case 1003:
61                         global_flags.flush_pbos = false;
62                         break;
63                 case 'h':
64                         usage();
65                         exit(0);
66                 default:
67                         fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
68                         fprintf(stderr, "\n");
69                         usage();
70                         exit(1);
71                 }
72         }
73 }