Skip to content

Commit

Permalink
opengl: add shader build infrastructure
Browse files Browse the repository at this point in the history
perl script to transform shader programs into c include files with
static string constands containing the shader programs, so we can
easily embed them into qemu.  Also some Makefile logic for them.

Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
  • Loading branch information
kraxel committed May 5, 2015
1 parent 5bccbb0 commit d98bc0b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ clean:
rm -f fsdev/*.pod
rm -rf .libs */.libs
rm -f qemu-img-cmds.h
rm -f ui/shader/*-vert.h ui/shader/*-frag.h
@# May not be present in GENERATED_HEADERS
rm -f trace/generated-tracers-dtrace.dtrace*
rm -f trace/generated-tracers-dtrace.h*
Expand Down Expand Up @@ -441,6 +442,19 @@ cscope:
find "$(SRC_PATH)" -name "*.[chsS]" -print | sed 's,^\./,,' > ./cscope.files
cscope -b

# opengl shader programs
ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
@mkdir -p $(dir $@)
$(call quiet-command,\
perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
" VERT $@")

ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
@mkdir -p $(dir $@)
$(call quiet-command,\
perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
" FRAG $@")

# documentation
MAKEINFO=makeinfo
MAKEINFOFLAGS=--no-headers --no-split --number-sections
Expand Down
16 changes: 16 additions & 0 deletions scripts/shaderinclude.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/perl
use strict;
use warnings;

my $file = shift;
open FILE, "<", $file or die "open $file: $!";
my $name = $file;
$name =~ s|.*/||;
$name =~ s/[-.]/_/g;
print "static GLchar ${name}_src[] =\n";
while (<FILE>) {
chomp;
printf " \"%s\\n\"\n", $_;
}
print " \"\\n\";\n";
close FILE;

0 comments on commit d98bc0b

Please sign in to comment.