1 |
169 |
diegovalve |
#!/usr/bin/perl
|
2 |
|
|
################################################################
|
3 |
|
|
#Theia, Ray Cast Programable graphic Processing Unit.
|
4 |
|
|
#Copyright (C) 2010 Diego Valverde (diego.valverde.g@gmail.com)
|
5 |
|
|
#
|
6 |
|
|
#This program is free software; you can redistribute it and/or
|
7 |
|
|
#modify it under the terms of the GNU General Public License
|
8 |
|
|
#as published by the Free Software Foundation; either version 2
|
9 |
|
|
#of the License, or (at your option) any later version.
|
10 |
|
|
#
|
11 |
|
|
#This program is distributed in the hope that it will be useful,
|
12 |
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
|
#GNU General Public License for more details.
|
15 |
|
|
#
|
16 |
|
|
#You should have received a copy of the GNU General Public #License
|
17 |
|
|
#along with this program; if not, write to the Free Software
|
18 |
|
|
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #02110-1301, USA.
|
19 |
|
|
################################################################
|
20 |
|
|
|
21 |
|
|
use Tie::File;
|
22 |
|
|
$NumberOfCores = $ARGV[0];
|
23 |
|
|
$Widht = $ARGV[1];
|
24 |
|
|
$Height = $ARGV[2];
|
25 |
|
|
|
26 |
|
|
die "\nusage:\nconfigure_gpu.pl number_of_cores [width height]\n\n" if (not defined $NumberOfCores);
|
27 |
|
|
$ParamsFile = "Params.mem";
|
28 |
|
|
$index=$NumberOfCores-1;
|
29 |
|
|
|
30 |
|
|
$Scale = 17;
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
#------------------------------------------------------------------
|
35 |
|
|
tie my @array, 'Tie::File', $ParamsFile or die "Can't open $ParamsFile: $!";
|
36 |
|
|
$size = @array;
|
37 |
|
|
|
38 |
|
|
for ($i = 7; $i < $size; $i++) {$array[$i] = "";}
|
39 |
|
|
if (not defined $Widht and not defined $Height)
|
40 |
|
|
{
|
41 |
|
|
print $array[5];
|
42 |
|
|
$array[5] =~ m/(\w+)\s+(\w+).*/g;
|
43 |
|
|
$Widht = hex($1) / (2 ** $Scale);
|
44 |
|
|
$Height = hex($2) / (2 ** $Scale)
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
print
|
48 |
|
|
"
|
49 |
|
|
Scene resolution: $Widht x $Height
|
50 |
|
|
";
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
$ScaledWidht = sprintf('%X', $Widht * (2 ** $Scale));
|
54 |
|
|
$ScaledHeight = sprintf('%X', $Height *(2 ** $Scale));
|
55 |
|
|
$Delta = $Height / $NumberOfCores;
|
56 |
|
|
print "Separating proyection plane into $NumberOfCores blocks of $Delta rows\n";
|
57 |
|
|
$array[0] = sprintf('%X',3*(6+$NumberOfCores*2));
|
58 |
|
|
$array[5] = "$ScaledWidht $ScaledHeight 0\t//<Width>, <Height>,<NULL>";
|
59 |
|
|
for ($i = 0,$k = 0; $i < $NumberOfCores; $i++,$k+=2)
|
60 |
|
|
{
|
61 |
|
|
$InitialRow = sprintf('%X', $i*$Delta *(2 ** $Scale));
|
62 |
|
|
$FinalRow = sprintf('%X', ($i+1)*$Delta *(2 ** $Scale));
|
63 |
|
|
$array[7+$k] = "0 $InitialRow 0\t\t //Core $i Start";
|
64 |
|
|
$array[7+$k+1] = "$ScaledWidht $FinalRow 0\t\t //Core $i End";
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
untie @array;
|