Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dumped cubemaps in order (perl script)
#!/usr/bin/perl
use strict;
use warnings;
use IPC::System::Simple qw(capture);
my %cubefaces = (
astc10_rgba => ["astc10-rgba.cube1", "astc10-rgba.cube2", "astc10-rgba.cube3", "astc10-rgba.cube4", "astc10-rgba.cube5", "astc10-rgba.cube6"],
astc10_srgba => ["astc10-srgba.cube1", "astc10-srgba.cube2", "astc10-srgba.cube3", "astc10-srgba.cube4", "astc10-srgba.cube5", "astc10-srgba.cube6"],
astc12_rgba => ["astc12-rgba.cube1", "astc12-rgba.cube2", "astc12-rgba.cube3", "astc12-rgba.cube4", "astc12-rgba.cube5", "astc12-rgba.cube6"],
astc12_srgba => ["astc12-srgba.cube1", "astc12-srgba.cube2", "astc12-srgba.cube3", "astc12-srgba.cube4", "astc12-srgba.cube5", "astc12-srgba.cube6"],
astc4_rgba => ["astc4-rgba.cube1", "astc4-rgba.cube2", "astc4-rgba.cube3", "astc4-rgba.cube4", "astc4-rgba.cube5", "astc4-rgba.cube6"],
astc4_srgba => ["astc4-srgba.cube1", "astc4-srgba.cube2", "astc4-srgba.cube3", "astc4-srgba.cube4", "astc4-srgba.cube5", "astc4-srgba.cube6"],
astc5_rgba => ["astc5-rgba.cube1", "astc5-rgba.cube2", "astc5-rgba.cube3", "astc5-rgba.cube4", "astc5-rgba.cube5", "astc5-rgba.cube6"],
astc5_srgba => ["astc5-srgba.cube1", "astc5-srgba.cube2", "astc5-srgba.cube3", "astc5-srgba.cube4", "astc5-srgba.cube5", "astc5-srgba.cube6"],
astc6_rgba => ["astc6-rgba.cube1", "astc6-rgba.cube2", "astc6-rgba.cube3", "astc6-rgba.cube4", "astc6-rgba.cube5", "astc6-rgba.cube6"],
astc6_srgba => ["astc6-srgba.cube1", "astc6-srgba.cube2", "astc6-srgba.cube3", "astc6-srgba.cube4", "astc6-srgba.cube5", "astc6-srgba.cube6"],
astc8_rgba => ["astc8-rgba.cube1", "astc8-rgba.cube2", "astc8-rgba.cube3", "astc8-rgba.cube4", "astc8-rgba.cube5", "astc8-rgba.cube6"],
astc8_srgba => ["astc8-srgba.cube1", "astc8-srgba.cube2", "astc8-srgba.cube3", "astc8-srgba.cube4", "astc8-srgba.cube5", "astc8-srgba.cube6"],
dxt1_rgb => ["dxt1-rgb.cube1", "dxt1-rgb.cube2", "dxt1-rgb.cube3", "dxt1-rgb.cube4", "dxt1-rgb.cube5", "dxt1-rgb.cube6"],
dxt3_rgba => ["dxt3-rgba.cube1", "dxt3-rgba.cube2", "dxt3-rgba.cube3", "dxt3-rgba.cube4", "dxt3-rgba.cube5", "dxt3-rgba.cube6"],
dxt5_rgba => ["dxt5-rgba.cube1", "dxt5-rgba.cube2", "dxt5-rgba.cube3", "dxt5-rgba.cube4", "dxt5-rgba.cube5", "dxt5-rgba.cube6"],
eac_r11 => ["eac-r11.cube1", "eac-r11.cube2", "eac-r11.cube3", "eac-r11.cube4", "eac-r11.cube5", "eac-r11.cube6"],
eac_rg11 => ["eac-rg11.cube1", "eac-rg11.cube2", "eac-rg11.cube3", "eac-rg11.cube4", "eac-rg11.cube5", "eac-rg11.cube6"],
eac_sr11 => ["eac-sr11.cube1", "eac-sr11.cube2", "eac-sr11.cube3", "eac-sr11.cube4", "eac-sr11.cube5", "eac-sr11.cube6"],
eac_srg11 => ["eac-srg11.cube1", "eac-srg11.cube2", "eac-srg11.cube3", "eac-srg11.cube4", "eac-srg11.cube5", "eac-srg11.cube6"],
etc2_rgba1 => ["etc2-rgba1.cube1", "etc2-rgba1.cube2", "etc2-rgba1.cube3", "etc2-rgba1.cube4", "etc2-rgba1.cube5", "etc2-rgba1.cube6"],
etc2_rgba => ["etc2-rgba.cube1", "etc2-rgba.cube2", "etc2-rgba.cube3", "etc2-rgba.cube4", "etc2-rgba.cube5", "etc2-rgba.cube6"],
etc2_rgb => ["etc2-rgb.cube1", "etc2-rgb.cube2", "etc2-rgb.cube3", "etc2-rgb.cube4", "etc2-rgb.cube5", "etc2-rgb.cube6"],
etc2_srgba1 => ["etc2-srgba1.cube1", "etc2-srgba1.cube2", "etc2-srgba1.cube3", "etc2-srgba1.cube4", "etc2-srgba1.cube5", "etc2-srgba1.cube6"],
etc2_srgba => ["etc2-srgba.cube1", "etc2-srgba.cube2", "etc2-srgba.cube3", "etc2-srgba.cube4", "etc2-srgba.cube5", "etc2-srgba.cube6"],
etc2_srgb => ["etc2-srgb.cube1", "etc2-srgb.cube2", "etc2-srgb.cube3", "etc2-srgb.cube4", "etc2-srgb.cube5", "etc2-srgb.cube6"],
);
my $piglit_fname = "cubemap-compressed-data.h";
open (my $fh, '>', $piglit_fname) or die "Could not open $piglit_fname $!\n";
print $fh qq[#ifndef CUBEMAP_COMPRESSED_DATA_H
#define CUBEMAP_COMPRESSED_DATA_H
];
foreach my $format (keys %cubefaces) {
my @fmt_faces = @{$cubefaces{$format}};
my $array_name = $fmt_faces[0];
$array_name =~ s/.cube1//;
my $var_name = $array_name;
$var_name =~ s/-/_/;
print $fh "unsigned char $var_name\[\] \= \{";
my $cubeface = "";
for (my $i=1; $i<7; $i++) {
my $datafile = "$array_name".".cube"."$i";
my $tmpfile = "data";
capture("dd if=$datafile of=$tmpfile bs=1 skip=192");
my $res = capture("dumper $tmpfile");
$res =~ s/unsigned char data\[\] \= \{//;
$res =~ s/\n};$/,\n/;
$res =~ s/\n\n/\n/;
$res =~ s/,\n\n/,\n/;
$cubeface = $cubeface."$res";
}
$cubeface = $cubeface."};\n\n";
$cubeface =~ s/\,\n\}\;/\n\}\;/;
print $fh $cubeface;
}
print $fh qq[#endif /* CUBEMAP_COMPRESSED_DATA_H */
];
close $fh;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.