]> xenbits.xensource.com Git - qemu-xen-unstable.git/commitdiff
opengl: add shader build infrastructure
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 16 Jan 2015 12:59:17 +0000 (13:59 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 5 May 2015 07:03:32 +0000 (09:03 +0200)
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 <kraxel@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Makefile
scripts/shaderinclude.pl [new file with mode: 0644]

index 93af871dde58975827d5b7b9ac663fa4ac809e16..49e456769c0302a5d7719b5828dc428db64c0f25 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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*
@@ -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
diff --git a/scripts/shaderinclude.pl b/scripts/shaderinclude.pl
new file mode 100644 (file)
index 0000000..81b5146
--- /dev/null
@@ -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;