1 |
Author: scarabeus |
2 |
Date: 2010-07-30 22:23:59 +0000 (Fri, 30 Jul 2010) |
3 |
New Revision: 774 |
4 |
|
5 |
Added: |
6 |
trunk/extern/modules/mesa.eselect |
7 |
Modified: |
8 |
trunk/extern/modules/opengl.eselect |
9 |
Log: |
10 |
Initial commit of mesa.eselect module. This thing allows us to pick what mesa implementation to use (classic or gallium). |
11 |
|
12 |
Added: trunk/extern/modules/mesa.eselect |
13 |
=================================================================== |
14 |
--- trunk/extern/modules/mesa.eselect (rev 0) |
15 |
+++ trunk/extern/modules/mesa.eselect 2010-07-30 22:23:59 UTC (rev 774) |
16 |
@@ -0,0 +1,178 @@ |
17 |
+# Copyright 1999-2010 Gentoo Foundation |
18 |
+# Distributed under the terms of the GNU General Public License v2 |
19 |
+# $Id: $ |
20 |
+ |
21 |
+DESCRIPTION="Manage the OpenGL driver architecture used by media-libs/mesa" |
22 |
+MAINTAINER="x11@g.o" |
23 |
+SVN_DATE='$Date: $' |
24 |
+VERSION=$(svn_date_to_version "${SVN_DATE}" ) |
25 |
+EBUILD_VERSION="0.0.4" |
26 |
+ |
27 |
+# Known mesa classic/gallium implementations |
28 |
+MESA_IMPLEMENTATIONS="i915 i965 r300 r600 sw" |
29 |
+declare -A MESA_DRIVERS || die "MESA_DRIVERS already in environment and not associative." |
30 |
+ |
31 |
+MESA_DRIVERS[i915,description]="i915 (Intel 915, 945)" |
32 |
+MESA_DRIVERS[i915,classicdriver]="i915_dri.so" |
33 |
+MESA_DRIVERS[i915,galliumdriver]="i915g_dri.so" |
34 |
+ |
35 |
+MESA_DRIVERS[i965,description]="i965 (Intel 965, G/Q3x, G/Q4x)" |
36 |
+MESA_DRIVERS[i965,classicdriver]="i965_dri.so" |
37 |
+MESA_DRIVERS[i965,galliumdriver]="i965g_dri.so" |
38 |
+ |
39 |
+MESA_DRIVERS[r300,description]="r300 (Radeon R300-R500)" |
40 |
+MESA_DRIVERS[r300,classicdriver]="r300_dri.so" |
41 |
+MESA_DRIVERS[r300,galliumdriver]="radeong_dri.so" |
42 |
+ |
43 |
+MESA_DRIVERS[r600,description]="r600 (Radeon R600-R700)" |
44 |
+MESA_DRIVERS[r600,classicdriver]="r600_dri.so" |
45 |
+MESA_DRIVERS[r600,galliumdriver]="r600g_dri.so" |
46 |
+ |
47 |
+MESA_DRIVERS[sw,description]="sw (Software renderer)" |
48 |
+MESA_DRIVERS[sw,classicdriver]="swrast_dri.so" |
49 |
+MESA_DRIVERS[sw,galliumdriver]="swrastg_dri.so" |
50 |
+ |
51 |
+MESA_DIR="${EROOT}/usr/lib/mesa" |
52 |
+DRI_DIR="${EROOT}/usr/lib/dri" |
53 |
+ |
54 |
+# receives a filename of the driver as argument, outputs the architecture (classic or gallium) |
55 |
+drivername_to_architecture() { |
56 |
+ local drivername=$1 |
57 |
+ local x |
58 |
+ local y |
59 |
+ local z |
60 |
+ for x in ${MESA_IMPLEMENTATIONS}; do |
61 |
+ for y in classic gallium; do |
62 |
+ z=$(get_drivername ${x} ${y}) |
63 |
+ if [[ ${drivername} == ${z} ]]; then |
64 |
+ echo ${y} |
65 |
+ exit 0 |
66 |
+ fi |
67 |
+ done |
68 |
+ done |
69 |
+} |
70 |
+ |
71 |
+# receives chipset family and driver architecture as argument, outputs the driver's filename |
72 |
+get_drivername() { |
73 |
+ local family=$1 |
74 |
+ local architecture=$2 |
75 |
+ echo ${MESA_DRIVERS[${family},${architecture}driver]} |
76 |
+} |
77 |
+ |
78 |
+# receives the chipset family as argument, outputs the currently selected architecture for that family |
79 |
+get_current_implementation() { |
80 |
+ local family=$1 |
81 |
+ local y |
82 |
+ local z |
83 |
+ local current=$(get_drivername ${family} classic) |
84 |
+ |
85 |
+ if [[ -L ${DRI_DIR}/${current} ]]; then |
86 |
+ for y in classic gallium; do |
87 |
+ z=$(get_drivername ${family} ${y}) |
88 |
+ if [[ $(readlink ${DRI_DIR}/${current}) == "../mesa/${z}" && -f "${MESA_DIR}/${z}" ]]; then |
89 |
+ echo $(drivername_to_architecture ${z}) |
90 |
+ fi |
91 |
+ done |
92 |
+ elif [[ -f ${DRI_DIR}/${current} ]]; then |
93 |
+ echo "classic" |
94 |
+ fi |
95 |
+} |
96 |
+ |
97 |
+# receives a family as argument, outputs all installed driver filenames |
98 |
+get_implementations() { |
99 |
+ local ret |
100 |
+ local family=$1 |
101 |
+ local y |
102 |
+ local z |
103 |
+ for y in classic gallium; do |
104 |
+ z=$(get_drivername ${family} ${y}) |
105 |
+ [ -f ${MESA_DIR}/${z} -o -L ${MESA_DIR}/${z} ] && ret+="${y} " |
106 |
+ done |
107 |
+ echo ${ret} |
108 |
+} |
109 |
+ |
110 |
+### show action ### |
111 |
+describe_show() { |
112 |
+ echo "Print the current OpenGL driver." |
113 |
+} |
114 |
+ |
115 |
+do_show() { |
116 |
+ local current |
117 |
+ local x |
118 |
+ local y |
119 |
+ for x in ${MESA_IMPLEMENTATIONS}; do |
120 |
+ current=$(get_current_implementation ${x}) |
121 |
+ if [[ -n ${current} ]]; then |
122 |
+ echo -n "${x} " |
123 |
+ echo ${current} |
124 |
+ fi |
125 |
+ done |
126 |
+ return 0 |
127 |
+} |
128 |
+ |
129 |
+### list action ### |
130 |
+describe_list() { |
131 |
+ echo "List the available OpenGL drivers." |
132 |
+} |
133 |
+ |
134 |
+do_list() { |
135 |
+ local x |
136 |
+ local y |
137 |
+ local z |
138 |
+ local available |
139 |
+ |
140 |
+ for x in ${MESA_IMPLEMENTATIONS}; do |
141 |
+ write_list_start ${MESA_DRIVERS[${x},description]} |
142 |
+ available=( $(get_implementations ${x}) ) |
143 |
+ for (( i = 0 ; i < ${#available[@]} ; i = i + 1 )); do |
144 |
+ if [[ ${available[${i}]} == $(get_current_implementation ${x}) ]]; then |
145 |
+ available[${i}]=$(highlight_marker "${available[${i}]}") |
146 |
+ fi |
147 |
+ write_kv_list_entry "${available[${i}]}" |
148 |
+ done |
149 |
+ done |
150 |
+} |
151 |
+ |
152 |
+### set action ### |
153 |
+describe_set() { |
154 |
+ echo "Select the OpenGL driver." |
155 |
+} |
156 |
+ |
157 |
+describe_set_parameters() { |
158 |
+ echo "[--auto|<family> <architecture>]" |
159 |
+} |
160 |
+ |
161 |
+describe_set_options() { |
162 |
+ echo "--auto : Sets all drivers which are not already set" |
163 |
+ echo "<family> : The chipset family, or sw for software renderer" |
164 |
+ echo "<architecture> : The driver architecture" |
165 |
+} |
166 |
+ |
167 |
+do_set() { |
168 |
+ if [[ "$1" == --auto ]]; then |
169 |
+ local x |
170 |
+ for x in ${MESA_IMPLEMENTATIONS}; do |
171 |
+ local y=( $(get_implementations ${x}) ) |
172 |
+ if [[ -n ${y} && ! -n $(get_current_implementation ${x}) ]]; then |
173 |
+ do_set ${x} ${y} |
174 |
+ fi |
175 |
+ done |
176 |
+ exit 0 |
177 |
+ elif [[ ${#} != 2 ]] ; then |
178 |
+ die -q "Usage: set [--auto|<family> <architecture>]" |
179 |
+ fi |
180 |
+ |
181 |
+ local family=$(echo $1 | tr '[:upper:]' '[:lower:]') |
182 |
+ local architecture=$(echo $2 | tr '[:upper:]' '[:lower:]') |
183 |
+ local symlink=$(get_drivername ${family} classic) |
184 |
+ local target=$(get_drivername ${family} ${architecture}) |
185 |
+ |
186 |
+ if [[ ! -n ${symlink} || ! -n ${target} ]]; then |
187 |
+ die -q "Invalid family or architecture." |
188 |
+ elif [[ -e ${DRI_DIR}/${symlink} && ! -L ${DRI_DIR}/${symlink} ]]; then |
189 |
+ die -q "Unable to update ${DRI_DIR}/${symlink} - not a symlink" |
190 |
+ elif [[ -f ${MESA_DIR}/${target} ]]; then |
191 |
+ echo "Switching $1 to $2" |
192 |
+ ln -s -f ../mesa/${target} ${DRI_DIR}/${symlink} |
193 |
+ fi |
194 |
+} |
195 |
|
196 |
Modified: trunk/extern/modules/opengl.eselect |
197 |
=================================================================== |
198 |
--- trunk/extern/modules/opengl.eselect 2010-07-27 14:25:05 UTC (rev 773) |
199 |
+++ trunk/extern/modules/opengl.eselect 2010-07-30 22:23:59 UTC (rev 774) |
200 |
@@ -156,6 +156,7 @@ |
201 |
local avail_implems=$(get_implementations) |
202 |
local libdir |
203 |
local moduledir |
204 |
+ local gl_dir |
205 |
local gl_local |
206 |
|
207 |
# Set a sane umask... bug #83115 |