Ticket #26379: mesa-python3.diff
File mesa-python3.diff, 232.6 KB (added by jmroot (Joshua Root), 14 years ago) |
---|
-
Mesa-7.8.2/src/gallium/auxiliary/indices/u_indices_gen.py
old new 60 60 61 61 62 62 def prolog(): 63 print '''/* File automatically generated by indices.py */'''64 print copyright65 print r'''63 print ('''/* File automatically generated by indices.py */''') 64 print (copyright) 65 print (r''' 66 66 67 67 /** 68 68 * @file … … 101 101 static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; 102 102 103 103 104 ''' 104 ''') 105 105 106 106 def vert( intype, outtype, v0 ): 107 107 if intype == GENERATE: … … 110 110 return '(' + outtype + ')in[' + v0 + ']' 111 111 112 112 def point( intype, outtype, ptr, v0 ): 113 print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'113 print (' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') 114 114 115 115 def line( intype, outtype, ptr, v0, v1 ): 116 print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'117 print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'116 print (' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') 117 print (' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') 118 118 119 119 def tri( intype, outtype, ptr, v0, v1, v2 ): 120 print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'121 print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'122 print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'120 print (' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') 121 print (' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') 122 print (' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';') 123 123 124 124 def do_point( intype, outtype, ptr, v0 ): 125 125 point( intype, outtype, ptr, v0 ) … … 150 150 return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv 151 151 152 152 def preamble(intype, outtype, inpv, outpv, prim): 153 print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '('153 print ('static void ' + name( intype, outtype, inpv, outpv, prim ) + '(') 154 154 if intype != GENERATE: 155 print ' const void * _in,'156 print ' unsigned nr,'157 print ' void *_out )'158 print '{'155 print (' const void * _in,') 156 print (' unsigned nr,') 157 print (' void *_out )') 158 print ('{') 159 159 if intype != GENERATE: 160 print ' const ' + intype + '*in = (const ' + intype + '*)_in;'161 print ' ' + outtype + ' *out = (' + outtype + '*)_out;'162 print ' unsigned i, j;'163 print ' (void)j;'160 print (' const ' + intype + '*in = (const ' + intype + '*)_in;') 161 print (' ' + outtype + ' *out = (' + outtype + '*)_out;') 162 print (' unsigned i, j;') 163 print (' (void)j;') 164 164 165 165 def postamble(): 166 print '}'166 print ('}') 167 167 168 168 169 169 def points(intype, outtype, inpv, outpv): 170 170 preamble(intype, outtype, inpv, outpv, prim='points') 171 print ' for (i = 0; i < nr; i++) { '171 print (' for (i = 0; i < nr; i++) { ') 172 172 do_point( intype, outtype, 'out+i', 'i' ); 173 print ' }'173 print (' }') 174 174 postamble() 175 175 176 176 def lines(intype, outtype, inpv, outpv): 177 177 preamble(intype, outtype, inpv, outpv, prim='lines') 178 print ' for (i = 0; i < nr; i+=2) { '178 print (' for (i = 0; i < nr; i+=2) { ') 179 179 do_line( intype, outtype, 'out+i', 'i', 'i+1', inpv, outpv ); 180 print ' }'180 print (' }') 181 181 postamble() 182 182 183 183 def linestrip(intype, outtype, inpv, outpv): 184 184 preamble(intype, outtype, inpv, outpv, prim='linestrip') 185 print ' for (j = i = 0; j < nr; j+=2, i++) { '185 print (' for (j = i = 0; j < nr; j+=2, i++) { ') 186 186 do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); 187 print ' }'187 print (' }') 188 188 postamble() 189 189 190 190 def lineloop(intype, outtype, inpv, outpv): 191 191 preamble(intype, outtype, inpv, outpv, prim='lineloop') 192 print ' for (j = i = 0; j < nr - 2; j+=2, i++) { '192 print (' for (j = i = 0; j < nr - 2; j+=2, i++) { ') 193 193 do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); 194 print ' }'194 print (' }') 195 195 do_line( intype, outtype, 'out+j', 'i', '0', inpv, outpv ); 196 196 postamble() 197 197 198 198 def tris(intype, outtype, inpv, outpv): 199 199 preamble(intype, outtype, inpv, outpv, prim='tris') 200 print ' for (i = 0; i < nr; i+=3) { '200 print (' for (i = 0; i < nr; i+=3) { ') 201 201 do_tri( intype, outtype, 'out+i', 'i', 'i+1', 'i+2', inpv, outpv ); 202 print ' }'202 print (' }') 203 203 postamble() 204 204 205 205 206 206 def tristrip(intype, outtype, inpv, outpv): 207 207 preamble(intype, outtype, inpv, outpv, prim='tristrip') 208 print ' for (j = i = 0; j < nr; j+=3, i++) { '208 print (' for (j = i = 0; j < nr; j+=3, i++) { ') 209 209 if inpv == FIRST: 210 210 do_tri( intype, outtype, 'out+j', 'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv ); 211 211 else: 212 212 do_tri( intype, outtype, 'out+j', 'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv ); 213 print ' }'213 print (' }') 214 214 postamble() 215 215 216 216 217 217 def trifan(intype, outtype, inpv, outpv): 218 218 preamble(intype, outtype, inpv, outpv, prim='trifan') 219 print ' for (j = i = 0; j < nr; j+=3, i++) { '219 print (' for (j = i = 0; j < nr; j+=3, i++) { ') 220 220 do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv ); 221 print ' }'221 print (' }') 222 222 postamble() 223 223 224 224 225 225 226 226 def polygon(intype, outtype, inpv, outpv): 227 227 preamble(intype, outtype, inpv, outpv, prim='polygon') 228 print ' for (j = i = 0; j < nr; j+=3, i++) { '228 print (' for (j = i = 0; j < nr; j+=3, i++) { ') 229 229 if inpv == FIRST: 230 230 do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2', inpv, outpv ); 231 231 else: 232 232 do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', '0', inpv, outpv ); 233 print ' }'233 print (' }') 234 234 postamble() 235 235 236 236 237 237 def quads(intype, outtype, inpv, outpv): 238 238 preamble(intype, outtype, inpv, outpv, prim='quads') 239 print ' for (j = i = 0; j < nr; j+=6, i+=4) { '239 print (' for (j = i = 0; j < nr; j+=6, i+=4) { ') 240 240 do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv ); 241 print ' }'241 print (' }') 242 242 postamble() 243 243 244 244 245 245 def quadstrip(intype, outtype, inpv, outpv): 246 246 preamble(intype, outtype, inpv, outpv, prim='quadstrip') 247 print ' for (j = i = 0; j < nr; j+=6, i+=2) { '247 print (' for (j = i = 0; j < nr; j+=6, i+=2) { ') 248 248 do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv ); 249 print ' }'249 print (' }') 250 250 postamble() 251 251 252 252 … … 293 293 init(intype, outtype, inpv, outpv, prim) 294 294 295 295 def emit_init(): 296 print 'void u_index_init( void )'297 print '{'298 print ' static int firsttime = 1;'299 print ' if (!firsttime) return;'300 print ' firsttime = 0;'296 print ('void u_index_init( void )') 297 print ('{') 298 print (' static int firsttime = 1;') 299 print (' if (!firsttime) return;') 300 print (' firsttime = 0;') 301 301 emit_all_inits() 302 print '}'302 print ('}') 303 303 304 304 305 305 306 306 307 307 def epilog(): 308 print '#include "indices/u_indices.c"'308 print ('#include "indices/u_indices.c"') 309 309 310 310 311 311 def main(): -
Mesa-7.8.2/src/gallium/auxiliary/indices/u_unfilled_gen.py
old new 50 50 51 51 52 52 def prolog(): 53 print '''/* File automatically generated by u_unfilled_gen.py */'''54 print copyright55 print r'''53 print ('''/* File automatically generated by u_unfilled_gen.py */''') 54 print (copyright) 55 print (r''' 56 56 57 57 /** 58 58 * @file … … 90 90 static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT]; 91 91 static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT]; 92 92 93 ''' 93 ''') 94 94 95 95 def vert( intype, outtype, v0 ): 96 96 if intype == GENERATE: … … 99 99 return '(' + outtype + ')in[' + v0 + ']' 100 100 101 101 def line( intype, outtype, ptr, v0, v1 ): 102 print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'103 print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'102 print (' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') 103 print (' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') 104 104 105 105 # XXX: have the opportunity here to avoid over-drawing shared lines in 106 106 # tristrips, fans, etc, by integrating this into the calling functions … … 124 124 return 'translate_' + prim + '_' + intype + '2' + outtype 125 125 126 126 def preamble(intype, outtype, prim): 127 print 'static void ' + name( intype, outtype, prim ) + '('127 print ('static void ' + name( intype, outtype, prim ) + '(') 128 128 if intype != GENERATE: 129 print ' const void * _in,'130 print ' unsigned nr,'131 print ' void *_out )'132 print '{'129 print (' const void * _in,') 130 print (' unsigned nr,') 131 print (' void *_out )') 132 print ('{') 133 133 if intype != GENERATE: 134 print ' const ' + intype + '*in = (const ' + intype + '*)_in;'135 print ' ' + outtype + ' *out = (' + outtype + '*)_out;'136 print ' unsigned i, j;'137 print ' (void)j;'134 print (' const ' + intype + '*in = (const ' + intype + '*)_in;') 135 print (' ' + outtype + ' *out = (' + outtype + '*)_out;') 136 print (' unsigned i, j;') 137 print (' (void)j;') 138 138 139 139 def postamble(): 140 print '}'140 print ('}') 141 141 142 142 143 143 def tris(intype, outtype): 144 144 preamble(intype, outtype, prim='tris') 145 print ' for (j = i = 0; j < nr; j+=6, i+=3) { '145 print (' for (j = i = 0; j < nr; j+=6, i+=3) { ') 146 146 do_tri( intype, outtype, 'out+j', 'i', 'i+1', 'i+2' ); 147 print ' }'147 print (' }') 148 148 postamble() 149 149 150 150 151 151 def tristrip(intype, outtype): 152 152 preamble(intype, outtype, prim='tristrip') 153 print ' for (j = i = 0; j < nr; j+=6, i++) { '153 print (' for (j = i = 0; j < nr; j+=6, i++) { ') 154 154 do_tri( intype, outtype, 'out+j', 'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' ); 155 print ' }'155 print (' }') 156 156 postamble() 157 157 158 158 159 159 def trifan(intype, outtype): 160 160 preamble(intype, outtype, prim='trifan') 161 print ' for (j = i = 0; j < nr; j+=6, i++) { '161 print (' for (j = i = 0; j < nr; j+=6, i++) { ') 162 162 do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' ); 163 print ' }'163 print (' }') 164 164 postamble() 165 165 166 166 167 167 168 168 def polygon(intype, outtype): 169 169 preamble(intype, outtype, prim='polygon') 170 print ' for (j = i = 0; j < nr; j+=6, i++) { '170 print (' for (j = i = 0; j < nr; j+=6, i++) { ') 171 171 do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' ); 172 print ' }'172 print (' }') 173 173 postamble() 174 174 175 175 176 176 def quads(intype, outtype): 177 177 preamble(intype, outtype, prim='quads') 178 print ' for (j = i = 0; j < nr; j+=8, i+=4) { '178 print (' for (j = i = 0; j < nr; j+=8, i+=4) { ') 179 179 do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' ); 180 print ' }'180 print (' }') 181 181 postamble() 182 182 183 183 184 184 def quadstrip(intype, outtype): 185 185 preamble(intype, outtype, prim='quadstrip') 186 print ' for (j = i = 0; j < nr; j+=8, i+=2) { '186 print (' for (j = i = 0; j < nr; j+=8, i+=2) { ') 187 187 do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' ); 188 print ' }'188 print (' }') 189 189 postamble() 190 190 191 191 … … 220 220 init(intype, outtype, prim) 221 221 222 222 def emit_init(): 223 print 'void u_unfilled_init( void )'224 print '{'225 print ' static int firsttime = 1;'226 print ' if (!firsttime) return;'227 print ' firsttime = 0;'223 print ('void u_unfilled_init( void )') 224 print ('{') 225 print (' static int firsttime = 1;') 226 print (' if (!firsttime) return;') 227 print (' firsttime = 0;') 228 228 emit_all_inits() 229 print '}'229 print ('}') 230 230 231 231 232 232 233 233 234 234 def epilog(): 235 print '#include "indices/u_unfilled_indices.c"'235 print ('#include "indices/u_unfilled_indices.c"') 236 236 237 237 238 238 def main(): -
Mesa-7.8.2/src/gallium/auxiliary/util/u_format_access.py
old new 96 96 97 97 98 98 def generate_srgb_tables(): 99 print 'static ubyte srgb_to_linear[256] = {'99 print ('static ubyte srgb_to_linear[256] = {') 100 100 for i in range(256): 101 print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255))102 print '};'103 print 104 print 'static ubyte linear_to_srgb[256] = {'105 print ' 0,'101 print (' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255))) 102 print ('};') 103 print ('') 104 print ('static ubyte linear_to_srgb[256] = {') 105 print (' 0,') 106 106 for i in range(1, 256): 107 print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255))108 print '};'109 print 107 print (' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255))) 108 print ('};') 109 print ('') 110 110 111 111 112 112 def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): … … 116 116 117 117 src_native_type = native_type(format) 118 118 119 print 'static void'120 print 'util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)121 print '{'122 print ' unsigned x, y;'123 print ' const uint8_t *src_row = src + y0*src_stride;'124 print ' %s *dst_row = dst;' % dst_native_type125 print ' for (y = 0; y < h; ++y) {'126 print ' const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())127 print ' %s *dst_pixel = dst_row;' %dst_native_type128 print ' for (x = 0; x < w; ++x) {'119 print ('static void') 120 print ('util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)) 121 print ('{') 122 print (' unsigned x, y;') 123 print (' const uint8_t *src_row = src + y0*src_stride;') 124 print (' %s *dst_row = dst;' % dst_native_type) 125 print (' for (y = 0; y < h; ++y) {') 126 print (' const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())) 127 print (' %s *dst_pixel = dst_row;' %dst_native_type) 128 print (' for (x = 0; x < w; ++x) {') 129 129 130 130 names = ['']*4 131 131 if format.colorspace == 'rgb': … … 144 144 145 145 if format.layout == PLAIN: 146 146 if not format.is_array(): 147 print ' %s pixel = *src_pixel++;' % src_native_type147 print (' %s pixel = *src_pixel++;' % src_native_type) 148 148 shift = 0; 149 149 for i in range(4): 150 150 src_channel = format.channels[i] … … 157 157 if shift + width < format.block_size(): 158 158 value = '(%s & 0x%x)' % (value, mask) 159 159 value = conversion_expr(src_channel, dst_channel, dst_native_type, value) 160 print ' %s %s = %s;' % (dst_native_type, names[i], value)160 print (' %s %s = %s;' % (dst_native_type, names[i], value)) 161 161 shift += width 162 162 else: 163 163 for i in range(4): … … 165 165 if names[i]: 166 166 value = 'src_pixel[%u]' % i 167 167 value = conversion_expr(src_channel, dst_channel, dst_native_type, value) 168 print ' %s %s = %s;' % (dst_native_type, names[i], value)169 print ' src_pixel += %u;' % (format.nr_channels())168 print (' %s %s = %s;' % (dst_native_type, names[i], value)) 169 print (' src_pixel += %u;' % (format.nr_channels())) 170 170 else: 171 171 assert False 172 172 … … 188 188 value = get_one(dst_channel) 189 189 else: 190 190 assert False 191 print ' *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i])191 print (' *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i])) 192 192 193 print ' }'194 print ' src_row += src_stride;'195 print ' dst_row += dst_stride/sizeof(*dst_row);'196 print ' }'197 print '}'198 print 193 print (' }') 194 print (' src_row += src_stride;') 195 print (' dst_row += dst_stride/sizeof(*dst_row);') 196 print (' }') 197 print ('}') 198 print ('') 199 199 200 200 201 201 def generate_format_write(format, src_channel, src_native_type, src_suffix): … … 205 205 206 206 dst_native_type = native_type(format) 207 207 208 print 'static void'209 print 'util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)210 print '{'211 print ' unsigned x, y;'212 print ' uint8_t *dst_row = dst + y0*dst_stride;'213 print ' const %s *src_row = src;' % src_native_type214 print ' for (y = 0; y < h; ++y) {'215 print ' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())216 print ' const %s *src_pixel = src_row;' %src_native_type217 print ' for (x = 0; x < w; ++x) {'208 print ('static void') 209 print ('util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)) 210 print ('{') 211 print (' unsigned x, y;') 212 print (' uint8_t *dst_row = dst + y0*dst_stride;') 213 print (' const %s *src_row = src;' % src_native_type) 214 print (' for (y = 0; y < h; ++y) {') 215 print (' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())) 216 print (' const %s *src_pixel = src_row;' %src_native_type) 217 print (' for (x = 0; x < w; ++x) {') 218 218 219 219 inv_swizzle = format.inv_swizzles() 220 220 221 221 if format.layout == PLAIN: 222 222 if not format.is_array(): 223 print ' %s pixel = 0;' % dst_native_type223 print (' %s pixel = 0;' % dst_native_type) 224 224 shift = 0; 225 225 for i in range(4): 226 226 dst_channel = format.channels[i] … … 230 230 value = conversion_expr(src_channel, dst_channel, dst_native_type, value) 231 231 if shift: 232 232 value = '(%s << %u)' % (value, shift) 233 print ' pixel |= %s;' % value233 print (' pixel |= %s;' % value) 234 234 shift += width 235 print ' *dst_pixel++ = pixel;'235 print (' *dst_pixel++ = pixel;') 236 236 else: 237 237 for i in range(4): 238 238 dst_channel = format.channels[i] 239 239 if inv_swizzle[i] is not None: 240 240 value = 'src_pixel[%u]' % inv_swizzle[i] 241 241 value = conversion_expr(src_channel, dst_channel, dst_native_type, value) 242 print ' *dst_pixel++ = %s;' % value242 print (' *dst_pixel++ = %s;' % value) 243 243 else: 244 244 assert False 245 print ' src_pixel += 4;'245 print (' src_pixel += 4;') 246 246 247 print ' }'248 print ' dst_row += dst_stride;'249 print ' src_row += src_stride/sizeof(*src_row);'250 print ' }'251 print '}'252 print 247 print (' }') 248 print (' dst_row += dst_stride;') 249 print (' src_row += src_stride/sizeof(*src_row);') 250 print (' }') 251 print ('}') 252 print ('') 253 253 254 254 255 255 def generate_read(formats, dst_channel, dst_native_type, dst_suffix): … … 259 259 if is_format_supported(format): 260 260 generate_format_read(format, dst_channel, dst_native_type, dst_suffix) 261 261 262 print 'void'263 print 'util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)264 print '{'265 print ' void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type266 print ' switch(format) {'262 print ('void') 263 print ('util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)) 264 print ('{') 265 print (' void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type) 266 print (' switch(format) {') 267 267 for format in formats: 268 268 if is_format_supported(format): 269 print ' case %s:' % format.name270 print ' func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix)271 print ' break;'272 print ' default:'273 print ' debug_printf("unsupported format\\n");'274 print ' return;'275 print ' }'276 print ' func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);'277 print '}'278 print 269 print (' case %s:' % format.name) 270 print (' func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix)) 271 print (' break;') 272 print (' default:') 273 print (' debug_printf("unsupported format\\n");') 274 print (' return;') 275 print (' }') 276 print (' func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);') 277 print ('}') 278 print ('') 279 279 280 280 281 281 def generate_write(formats, src_channel, src_native_type, src_suffix): … … 285 285 if is_format_supported(format): 286 286 generate_format_write(format, src_channel, src_native_type, src_suffix) 287 287 288 print 'void'289 print 'util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)288 print ('void') 289 print ('util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)) 290 290 291 print '{'292 print ' void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type293 print ' switch(format) {'291 print ('{') 292 print (' void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type) 293 print (' switch(format) {') 294 294 for format in formats: 295 295 if is_format_supported(format): 296 print ' case %s:' % format.name297 print ' func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix)298 print ' break;'299 print ' default:'300 print ' debug_printf("unsupported format\\n");'301 print ' return;'302 print ' }'303 print ' func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);'304 print '}'305 print 296 print (' case %s:' % format.name) 297 print (' func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix)) 298 print (' break;') 299 print (' default:') 300 print (' debug_printf("unsupported format\\n");') 301 print (' return;') 302 print (' }') 303 print (' func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);') 304 print ('}') 305 print ('') 306 306 307 307 308 308 def main(): … … 310 310 for arg in sys.argv[1:]: 311 311 formats.extend(parse(arg)) 312 312 313 print '/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */'314 print 313 print ('/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */') 314 print ('') 315 315 # This will print the copyright message on the top of this file 316 print __doc__.strip()317 print 318 print '#include "pipe/p_compiler.h"'319 print '#include "u_math.h"'320 print '#include "u_format_pack.h"'321 print 316 print (__doc__.strip()) 317 print ('') 318 print ('#include "pipe/p_compiler.h"') 319 print ('#include "u_math.h"') 320 print ('#include "u_format_pack.h"') 321 print ('') 322 322 323 323 generate_srgb_tables() 324 324 -
Mesa-7.8.2/src/gallium/auxiliary/util/u_format_pack.py
old new 45 45 def generate_format_type(format): 46 46 '''Generate a structure that describes the format.''' 47 47 48 print 'union util_format_%s {' % format.short_name()48 print ('union util_format_%s {' % format.short_name()) 49 49 if format.is_bitmask(): 50 print ' uint%u_t value;' % (format.block_size(),)51 print ' struct {'50 print (' uint%u_t value;' % (format.block_size(),)) 51 print (' struct {') 52 52 for channel in format.channels: 53 53 if format.is_bitmask() and not format.is_array(): 54 54 if channel.type == VOID: 55 55 if channel.size: 56 print ' unsigned %s:%u;' % (channel.name, channel.size)56 print (' unsigned %s:%u;' % (channel.name, channel.size)) 57 57 elif channel.type == UNSIGNED: 58 print ' unsigned %s:%u;' % (channel.name, channel.size)58 print (' unsigned %s:%u;' % (channel.name, channel.size)) 59 59 elif channel.type == SIGNED: 60 print ' int %s:%u;' % (channel.name, channel.size)60 print (' int %s:%u;' % (channel.name, channel.size)) 61 61 else: 62 62 assert 0 63 63 else: 64 64 assert channel.size % 8 == 0 and is_pot(channel.size) 65 65 if channel.type == VOID: 66 66 if channel.size: 67 print ' uint%u_t %s;' % (channel.size, channel.name)67 print (' uint%u_t %s;' % (channel.size, channel.name)) 68 68 elif channel.type == UNSIGNED: 69 print ' uint%u_t %s;' % (channel.size, channel.name)69 print (' uint%u_t %s;' % (channel.size, channel.name)) 70 70 elif channel.type in (SIGNED, FIXED): 71 print ' int%u_t %s;' % (channel.size, channel.name)71 print (' int%u_t %s;' % (channel.size, channel.name)) 72 72 elif channel.type == FLOAT: 73 73 if channel.size == 64: 74 print ' double %s;' % (channel.name)74 print (' double %s;' % (channel.name)) 75 75 elif channel.size == 32: 76 print ' float %s;' % (channel.name)76 print (' float %s;' % (channel.name)) 77 77 elif channel.size == 16: 78 print ' uint16_t %s;' % (channel.name)78 print (' uint16_t %s;' % (channel.name)) 79 79 else: 80 80 assert 0 81 81 else: 82 82 assert 0 83 print ' } chan;'84 print '};'85 print 83 print (' } chan;') 84 print ('};') 85 print ('') 86 86 87 87 88 88 def bswap_format(format): 89 89 '''Generate a structure that describes the format.''' 90 90 91 91 if format.is_bitmask() and not format.is_array(): 92 print '#ifdef PIPE_ARCH_BIG_ENDIAN'93 print ' pixel.value = util_bswap%u(pixel.value);' % format.block_size()94 print '#endif'92 print ('#ifdef PIPE_ARCH_BIG_ENDIAN') 93 print (' pixel.value = util_bswap%u(pixel.value);' % format.block_size()) 94 print ('#endif') 95 95 96 96 97 97 def is_format_supported(format): … … 192 192 ('ui', 'unsigned int'), 193 193 ('si', 'int'), 194 194 ]: 195 print 'static INLINE %s' % native_type196 print 'clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type)197 print '{'198 print ' if(value < lbound)'199 print ' return lbound;'200 print ' if(value > ubound)'201 print ' return ubound;'202 print ' return value;'203 print '}'204 print 195 print ('static INLINE %s' % native_type) 196 print ('clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type)) 197 print ('{') 198 print (' if(value < lbound)') 199 print (' return lbound;') 200 print (' if(value > ubound)') 201 print (' return ubound;') 202 print (' return value;') 203 print ('}') 204 print ('') 205 205 206 206 207 207 def clamp_expr(src_channel, dst_channel, dst_native_type, value): … … 311 311 312 312 src_native_type = native_type(format) 313 313 314 print 'static INLINE void'315 print 'util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type)316 print '{'317 print ' union util_format_%s pixel;' % format.short_name()318 print ' memcpy(&pixel, src, sizeof pixel);'314 print ('static INLINE void') 315 print ('util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type)) 316 print ('{') 317 print (' union util_format_%s pixel;' % format.short_name()) 318 print (' memcpy(&pixel, src, sizeof pixel);') 319 319 bswap_format(format) 320 320 321 321 assert format.layout == PLAIN … … 339 339 value = get_one(dst_channel) 340 340 elif i >= 1: 341 341 value = 'dst[0]' 342 print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])342 print (' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])) 343 343 344 print '}'345 print 344 print ('}') 345 print ('') 346 346 347 347 348 348 def generate_format_pack(format, src_channel, src_native_type, src_suffix): … … 352 352 353 353 dst_native_type = native_type(format) 354 354 355 print 'static INLINE void'356 print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)357 print '{'358 print ' union util_format_%s pixel;' % format.short_name()355 print ('static INLINE void') 356 print ('util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)) 357 print ('{') 358 print (' union util_format_%s pixel;' % format.short_name()) 359 359 360 360 assert format.layout == PLAIN 361 361 … … 373 373 value = get_one(dst_channel) 374 374 elif i >= 1: 375 375 value = '0' 376 print ' pixel.chan.%s = %s;' % (dst_channel.name, value)376 print (' pixel.chan.%s = %s;' % (dst_channel.name, value)) 377 377 378 378 bswap_format(format) 379 print ' memcpy(dst, &pixel, sizeof pixel);'380 print '}'381 print 379 print (' memcpy(dst, &pixel, sizeof pixel);') 380 print ('}') 381 print ('') 382 382 383 383 384 384 def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix): … … 388 388 if is_format_supported(format): 389 389 generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) 390 390 391 print 'static INLINE void'392 print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type)393 print '{'394 print ' void (*func)(%s *dst, const void *src);' % dst_native_type395 print ' switch(format) {'391 print ('static INLINE void') 392 print ('util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type)) 393 print ('{') 394 print (' void (*func)(%s *dst, const void *src);' % dst_native_type) 395 print (' switch(format) {') 396 396 for format in formats: 397 397 if is_format_supported(format): 398 print ' case %s:' % format.name399 print ' func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix)400 print ' break;'401 print ' default:'402 print ' debug_printf("unsupported format\\n");'403 print ' return;'404 print ' }'405 print ' func(dst, src);'406 print '}'407 print 398 print (' case %s:' % format.name) 399 print (' func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix)) 400 print (' break;') 401 print (' default:') 402 print (' debug_printf("unsupported format\\n");') 403 print (' return;') 404 print (' }') 405 print (' func(dst, src);') 406 print ('}') 407 print ('') 408 408 409 409 410 410 def generate_pack(formats, src_channel, src_native_type, src_suffix): … … 414 414 if is_format_supported(format): 415 415 generate_format_pack(format, src_channel, src_native_type, src_suffix) 416 416 417 print 'static INLINE void'418 print 'util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)419 print '{'420 print ' void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type)421 print ' switch(format) {'417 print ('static INLINE void') 418 print ('util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)) 419 print ('{') 420 print (' void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type)) 421 print (' switch(format) {') 422 422 for format in formats: 423 423 if is_format_supported(format): 424 print ' case %s:' % format.name425 print ' func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix)426 print ' break;'427 print ' default:'428 print ' debug_printf("%s: unsupported format\\n", __FUNCTION__);'429 print ' return;'430 print ' }'431 print ' func(dst, r, g, b, a);'432 print '}'433 print 424 print (' case %s:' % format.name) 425 print (' func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix)) 426 print (' break;') 427 print (' default:') 428 print (' debug_printf("%s: unsupported format\\n", __FUNCTION__);') 429 print (' return;') 430 print (' }') 431 print (' func(dst, r, g, b, a);') 432 print ('}') 433 print ('') 434 434 435 435 436 436 def main(): … … 438 438 for arg in sys.argv[1:]: 439 439 formats.extend(parse(arg)) 440 440 441 print '/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */'442 print 441 print ('/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */') 442 print ('') 443 443 # This will print the copyright message on the top of this file 444 print __doc__.strip()444 print (__doc__.strip()) 445 445 446 print 447 print '#ifndef U_FORMAT_PACK_H'448 print '#define U_FORMAT_PACK_H'449 print 450 print '#include "pipe/p_compiler.h"'451 print '#include "u_math.h"'452 print '#include "u_format.h"'453 print 446 print ('') 447 print ('#ifndef U_FORMAT_PACK_H') 448 print ('#define U_FORMAT_PACK_H') 449 print ('') 450 print ('#include "pipe/p_compiler.h"') 451 print ('#include "u_math.h"') 452 print ('#include "u_format.h"') 453 print ('') 454 454 455 455 generate_clamp() 456 456 … … 472 472 generate_unpack(formats, channel, native_type, suffix) 473 473 generate_pack(formats, channel, native_type, suffix) 474 474 475 print 476 print '#ifdef __cplusplus'477 print '}'478 print '#endif'479 print 480 print '#endif /* ! U_FORMAT_PACK_H */'475 print ('') 476 print ('#ifdef __cplusplus') 477 print ('}') 478 print ('#endif') 479 print ('') 480 print ('#endif /* ! U_FORMAT_PACK_H */') 481 481 482 482 483 483 if __name__ == '__main__': -
Mesa-7.8.2/src/gallium/auxiliary/util/u_format_table.py
old new 79 79 80 80 81 81 def write_format_table(formats): 82 print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'83 print 82 print ('/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */') 83 print ('') 84 84 # This will print the copyright message on the top of this file 85 print __doc__.strip()86 print 87 print '#include "u_format.h"'88 print 89 print 'const struct util_format_description'90 print 'util_format_none_description = {'91 print " PIPE_FORMAT_NONE,"92 print " \"PIPE_FORMAT_NONE\","93 print " {0, 0, 0},"94 print " 0,"95 print " 0,"96 print " 0,"97 print " 0,"98 print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"99 print " {0, 0, 0, 0},"100 print " 0"101 print "};"102 print 85 print (__doc__.strip()) 86 print ('') 87 print ('#include "u_format.h"') 88 print ('') 89 print ('const struct util_format_description') 90 print ('util_format_none_description = {') 91 print (" PIPE_FORMAT_NONE,") 92 print (" \"PIPE_FORMAT_NONE\",") 93 print (" {0, 0, 0},") 94 print (" 0,") 95 print (" 0,") 96 print (" 0,") 97 print (" 0,") 98 print (" {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},") 99 print (" {0, 0, 0, 0},") 100 print (" 0") 101 print ("};") 102 print ('') 103 103 for format in formats: 104 print 'const struct util_format_description'105 print 'util_format_%s_description = {' % (format.short_name(),)106 print " %s," % (format.name,)107 print " \"%s\"," % (format.name,)108 print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())109 print " %s," % (layout_map(format.layout),)110 print " %u,\t/* nr_channels */" % (format.nr_channels(),)111 print " %s,\t/* is_array */" % (bool_map(format.is_array()),)112 print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)113 print " {"104 print ('const struct util_format_description') 105 print ('util_format_%s_description = {' % (format.short_name(),)) 106 print (" %s," % (format.name,)) 107 print (" \"%s\"," % (format.name,)) 108 print (" {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())) 109 print (" %s," % (layout_map(format.layout),)) 110 print (" %u,\t/* nr_channels */" % (format.nr_channels(),)) 111 print (" %s,\t/* is_array */" % (bool_map(format.is_array()),)) 112 print (" %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)) 113 print (" {") 114 114 for i in range(4): 115 115 channel = format.channels[i] 116 116 if i < 3: … … 118 118 else: 119 119 sep = "" 120 120 if channel.size: 121 print " {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name)121 print (" {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name)) 122 122 else: 123 print " {0, 0, 0}%s" % (sep,)124 print " },"125 print " {"123 print (" {0, 0, 0}%s" % (sep,)) 124 print (" },") 125 print (" {") 126 126 for i in range(4): 127 127 swizzle = format.swizzles[i] 128 128 if i < 3: … … 133 133 comment = colorspace_channels_map[format.colorspace][i] 134 134 except (KeyError, IndexError): 135 135 comment = 'ignored' 136 print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)137 print " },"138 print " %s," % (colorspace_map(format.colorspace),)139 print "};"140 print 141 print "const struct util_format_description *"142 print "util_format_description(enum pipe_format format)"143 print "{"144 print " if (format >= PIPE_FORMAT_COUNT) {"145 print " return NULL;"146 print " }"147 print 148 print " switch (format) {"149 print " case PIPE_FORMAT_NONE:"150 print " return &util_format_none_description;"136 print (" %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)) 137 print (" },") 138 print (" %s," % (colorspace_map(format.colorspace),)) 139 print ("};") 140 print ('') 141 print ("const struct util_format_description *") 142 print ("util_format_description(enum pipe_format format)") 143 print ("{") 144 print (" if (format >= PIPE_FORMAT_COUNT) {") 145 print (" return NULL;") 146 print (" }") 147 print ('') 148 print (" switch (format) {") 149 print (" case PIPE_FORMAT_NONE:") 150 print (" return &util_format_none_description;") 151 151 for format in formats: 152 print " case %s:" % format.name153 print " return &util_format_%s_description;" % (format.short_name(),)154 print " default:"155 print " assert(0);"156 print " return NULL;"157 print " }"158 print "}"159 print 152 print (" case %s:" % format.name) 153 print (" return &util_format_%s_description;" % (format.short_name(),)) 154 print (" default:") 155 print (" assert(0);") 156 print (" return NULL;") 157 print (" }") 158 print ("}") 159 print ('') 160 160 161 161 162 162 def main(): -
Mesa-7.8.2/src/gallium/drivers/llvmpipe/lp_tile_soa.py
old new 52 52 53 53 src_native_type = native_type(format) 54 54 55 print 'static void'56 print 'lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)57 print '{'58 print ' unsigned x, y;'59 print ' const uint8_t *src_row = src + y0*src_stride;'60 print ' for (y = 0; y < h; ++y) {'61 print ' const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())62 print ' for (x = 0; x < w; ++x) {'55 print ('static void') 56 print ('lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)) 57 print ('{') 58 print (' unsigned x, y;') 59 print (' const uint8_t *src_row = src + y0*src_stride;') 60 print (' for (y = 0; y < h; ++y) {') 61 print (' const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())) 62 print (' for (x = 0; x < w; ++x) {') 63 63 64 64 names = ['']*4 65 65 if format.colorspace == 'rgb': … … 78 78 79 79 if format.layout == PLAIN: 80 80 if not format.is_array(): 81 print ' %s pixel = *src_pixel++;' % src_native_type81 print (' %s pixel = *src_pixel++;' % src_native_type) 82 82 shift = 0; 83 83 for i in range(4): 84 84 src_channel = format.channels[i] … … 91 91 if shift + width < format.block_size(): 92 92 value = '(%s & 0x%x)' % (value, mask) 93 93 value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) 94 print ' %s %s = %s;' % (dst_native_type, names[i], value)94 print (' %s %s = %s;' % (dst_native_type, names[i], value)) 95 95 shift += width 96 96 else: 97 97 for i in range(4): … … 99 99 if names[i]: 100 100 value = '(*src_pixel++)' 101 101 value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) 102 print ' %s %s = %s;' % (dst_native_type, names[i], value)102 print (' %s %s = %s;' % (dst_native_type, names[i], value)) 103 103 else: 104 104 assert False 105 105 … … 121 121 value = get_one(dst_channel) 122 122 else: 123 123 assert False 124 print ' TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i])124 print (' TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i])) 125 125 126 print ' }'127 print ' src_row += src_stride;'128 print ' }'129 print '}'130 print 126 print (' }') 127 print (' src_row += src_stride;') 128 print (' }') 129 print ('}') 130 print ('') 131 131 132 132 133 133 def pack_rgba(format, src_channel, r, g, b, a): … … 171 171 This is considerably faster than the TILE_PIXEL-based code below. 172 172 ''' 173 173 dst_native_type = 'uint%u_t' % format.block_size() 174 print ' const unsigned dstpix_stride = dst_stride / %d;' % format.stride()175 print ' %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type)176 print ' unsigned int qx, qy, i;'177 print 178 print ' for (qy = 0; qy < h; qy += TILE_VECTOR_HEIGHT) {'179 print ' const unsigned py = y0 + qy;'180 print ' for (qx = 0; qx < w; qx += TILE_VECTOR_WIDTH) {'181 print ' const unsigned px = x0 + qx;'182 print ' const uint8_t *r = src + 0 * TILE_C_STRIDE;'183 print ' const uint8_t *g = src + 1 * TILE_C_STRIDE;'184 print ' const uint8_t *b = src + 2 * TILE_C_STRIDE;'185 print ' const uint8_t *a = src + 3 * TILE_C_STRIDE;'186 print ' (void) r; (void) g; (void) b; (void) a; /* silence warnings */'187 print ' for (i = 0; i < TILE_C_STRIDE; i += 2) {'188 print ' const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]")189 print ' const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]")190 print ' const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);'191 print ' dstpix[offset + 0] = pixel0;'192 print ' dstpix[offset + 1] = pixel1;'193 print ' }'194 print ' src += TILE_X_STRIDE;'195 print ' }'196 print ' }'174 print (' const unsigned dstpix_stride = dst_stride / %d;' % format.stride()) 175 print (' %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type)) 176 print (' unsigned int qx, qy, i;') 177 print ('') 178 print (' for (qy = 0; qy < h; qy += TILE_VECTOR_HEIGHT) {') 179 print (' const unsigned py = y0 + qy;') 180 print (' for (qx = 0; qx < w; qx += TILE_VECTOR_WIDTH) {') 181 print (' const unsigned px = x0 + qx;') 182 print (' const uint8_t *r = src + 0 * TILE_C_STRIDE;') 183 print (' const uint8_t *g = src + 1 * TILE_C_STRIDE;') 184 print (' const uint8_t *b = src + 2 * TILE_C_STRIDE;') 185 print (' const uint8_t *a = src + 3 * TILE_C_STRIDE;') 186 print (' (void) r; (void) g; (void) b; (void) a; /* silence warnings */') 187 print (' for (i = 0; i < TILE_C_STRIDE; i += 2) {') 188 print (' const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]")) 189 print (' const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]")) 190 print (' const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);') 191 print (' dstpix[offset + 0] = pixel0;') 192 print (' dstpix[offset + 1] = pixel1;') 193 print (' }') 194 print (' src += TILE_X_STRIDE;') 195 print (' }') 196 print (' }') 197 197 198 198 199 199 def emit_tile_pixel_write_code(format, src_channel): … … 202 202 203 203 inv_swizzle = format.inv_swizzles() 204 204 205 print ' unsigned x, y;'206 print ' uint8_t *dst_row = dst + y0*dst_stride;'207 print ' for (y = 0; y < h; ++y) {'208 print ' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())209 print ' for (x = 0; x < w; ++x) {'205 print (' unsigned x, y;') 206 print (' uint8_t *dst_row = dst + y0*dst_stride;') 207 print (' for (y = 0; y < h; ++y) {') 208 print (' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())) 209 print (' for (x = 0; x < w; ++x) {') 210 210 211 211 if format.layout == PLAIN: 212 212 if not format.is_array(): 213 print ' %s pixel = 0;' % dst_native_type213 print (' %s pixel = 0;' % dst_native_type) 214 214 shift = 0; 215 215 for i in range(4): 216 216 dst_channel = format.channels[i] … … 220 220 value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) 221 221 if shift: 222 222 value = '(%s << %u)' % (value, shift) 223 print ' pixel |= %s;' % value223 print (' pixel |= %s;' % value) 224 224 shift += width 225 print ' *dst_pixel++ = pixel;'225 print (' *dst_pixel++ = pixel;') 226 226 else: 227 227 for i in range(4): 228 228 dst_channel = format.channels[i] 229 229 if inv_swizzle[i] is not None: 230 230 value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] 231 231 value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) 232 print ' *dst_pixel++ = %s;' % value232 print (' *dst_pixel++ = %s;' % value) 233 233 else: 234 234 assert False 235 235 236 print ' }'237 print ' dst_row += dst_stride;'238 print ' }'236 print (' }') 237 print (' dst_row += dst_stride;') 238 print (' }') 239 239 240 240 241 241 def generate_format_write(format, src_channel, src_native_type, src_suffix): … … 243 243 244 244 name = format.short_name() 245 245 246 print 'static void'247 print 'lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)248 print '{'246 print ('static void') 247 print ('lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)) 248 print ('{') 249 249 if format.layout == PLAIN \ 250 250 and format.colorspace == 'rgb' \ 251 251 and format.block_size() <= 32 \ … … 255 255 emit_unrolled_write_code(format, src_channel) 256 256 else: 257 257 emit_tile_pixel_write_code(format, src_channel) 258 print '}'259 print 258 print ('}') 259 print ('') 260 260 261 261 262 262 def generate_read(formats, dst_channel, dst_native_type, dst_suffix): … … 266 266 if is_format_supported(format): 267 267 generate_format_read(format, dst_channel, dst_native_type, dst_suffix) 268 268 269 print 'void'270 print 'lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)271 print '{'272 print ' void (*func)(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type273 print ' switch(format) {'269 print ('void') 270 print ('lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)) 271 print ('{') 272 print (' void (*func)(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type) 273 print (' switch(format) {') 274 274 for format in formats: 275 275 if is_format_supported(format): 276 print ' case %s:' % format.name277 print ' func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix)278 print ' break;'279 print ' default:'280 print ' debug_printf("unsupported format\\n");'281 print ' return;'282 print ' }'283 print ' func(dst, (const uint8_t *)src, src_stride, x, y, w, h);'284 print '}'285 print 276 print (' case %s:' % format.name) 277 print (' func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix)) 278 print (' break;') 279 print (' default:') 280 print (' debug_printf("unsupported format\\n");') 281 print (' return;') 282 print (' }') 283 print (' func(dst, (const uint8_t *)src, src_stride, x, y, w, h);') 284 print ('}') 285 print ('') 286 286 287 287 288 288 def generate_write(formats, src_channel, src_native_type, src_suffix): … … 292 292 if is_format_supported(format): 293 293 generate_format_write(format, src_channel, src_native_type, src_suffix) 294 294 295 print 'void'296 print 'lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)295 print ('void') 296 print ('lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)) 297 297 298 print '{'299 print ' void (*func)(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type300 print ' switch(format) {'298 print ('{') 299 print (' void (*func)(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type) 300 print (' switch(format) {') 301 301 for format in formats: 302 302 if is_format_supported(format): 303 print ' case %s:' % format.name304 print ' func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix)305 print ' break;'306 print ' default:'307 print ' debug_printf("unsupported format\\n");'308 print ' return;'309 print ' }'310 print ' func(src, (uint8_t *)dst, dst_stride, x, y, w, h);'311 print '}'312 print 303 print (' case %s:' % format.name) 304 print (' func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix)) 305 print (' break;') 306 print (' default:') 307 print (' debug_printf("unsupported format\\n");') 308 print (' return;') 309 print (' }') 310 print (' func(src, (uint8_t *)dst, dst_stride, x, y, w, h);') 311 print ('}') 312 print ('') 313 313 314 314 315 315 def main(): … … 317 317 for arg in sys.argv[1:]: 318 318 formats.extend(parse(arg)) 319 319 320 print '/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */'321 print 320 print ('/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */') 321 print ('') 322 322 # This will print the copyright message on the top of this file 323 print __doc__.strip()324 print 325 print '#include "pipe/p_compiler.h"'326 print '#include "util/u_format.h"'327 print '#include "util/u_math.h"'328 print '#include "lp_tile_soa.h"'329 print 330 print 'const unsigned char'331 print 'tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = {'332 print ' { 0, 1, 4, 5},'333 print ' { 2, 3, 6, 7},'334 print ' { 8, 9, 12, 13},'335 print ' { 10, 11, 14, 15}'336 print '};'337 print 338 print '/* Note: these lookup tables could be replaced with some'339 print ' * bit-twiddling code, but this is a little faster.'340 print ' */'341 print 'static unsigned tile_x_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {'342 print ' 0, 1, 0, 1, 2, 3, 2, 3,'343 print ' 0, 1, 0, 1, 2, 3, 2, 3'344 print '};'345 print 346 print 'static unsigned tile_y_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {'347 print ' 0, 0, 1, 1, 0, 0, 1, 1,'348 print ' 2, 2, 3, 3, 2, 2, 3, 3'349 print '};'350 print 323 print (__doc__.strip()) 324 print ('') 325 print ('#include "pipe/p_compiler.h"') 326 print ('#include "util/u_format.h"') 327 print ('#include "util/u_math.h"') 328 print ('#include "lp_tile_soa.h"') 329 print ('') 330 print ('const unsigned char') 331 print ('tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = {') 332 print (' { 0, 1, 4, 5},') 333 print (' { 2, 3, 6, 7},') 334 print (' { 8, 9, 12, 13},') 335 print (' { 10, 11, 14, 15}') 336 print ('};') 337 print ('') 338 print ('/* Note: these lookup tables could be replaced with some') 339 print (' * bit-twiddling code, but this is a little faster.') 340 print (' */') 341 print ('static unsigned tile_x_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {') 342 print (' 0, 1, 0, 1, 2, 3, 2, 3,') 343 print (' 0, 1, 0, 1, 2, 3, 2, 3') 344 print ('};') 345 print ('') 346 print ('static unsigned tile_y_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {') 347 print (' 0, 0, 1, 1, 0, 0, 1, 1,') 348 print (' 2, 2, 3, 3, 2, 2, 3, 3') 349 print ('};') 350 print ('') 351 351 352 352 generate_clamp() 353 353 -
Mesa-7.8.2/src/gallium/drivers/svga/svgadump/svga_dump.py
old new 63 63 64 64 for variable in class_.variables(): 65 65 if variable.name != '': 66 #print 'variable = %r' % variable.name66 #print ('variable = %r' % variable.name) 67 67 dump_type(self._instance + '.' + variable.name, variable.type) 68 68 69 69 def visit_enumeration(self): 70 70 if enums: 71 print ' switch(%s) {' % ("(*cmd)" + self._instance,)71 print (' switch(%s) {' % ("(*cmd)" + self._instance,)) 72 72 for name, value in self.decl.values: 73 print ' case %s:' % (name,)74 print ' _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)75 print ' break;'76 print ' default:'77 print ' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)78 print ' break;'79 print ' }'73 print (' case %s:' % (name,)) 74 print (' _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)) 75 print (' break;') 76 print (' default:') 77 print (' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)) 78 print (' break;') 79 print (' }') 80 80 else: 81 print ' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)81 print (' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)) 82 82 83 83 84 84 def dump_decl(instance, decl): … … 149 149 self.print_instance('%p') 150 150 151 151 def visit_declarated(self): 152 #print 'decl = %r' % self.type.decl_string152 #print ('decl = %r' % self.type.decl_string) 153 153 decl = type_traits.remove_declarated(self.type) 154 154 dump_decl(self.instance, decl) 155 155 156 156 def print_instance(self, format): 157 print ' _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)157 print (' _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)) 158 158 159 159 160 160 def dump_type(instance, type_): … … 164 164 165 165 166 166 def dump_struct(decls, class_): 167 print 'static void'168 print 'dump_%s(const %s *cmd)' % (class_.name, class_.name)169 print '{'167 print ('static void') 168 print ('dump_%s(const %s *cmd)' % (class_.name, class_.name)) 169 print ('{') 170 170 dump_decl('', class_) 171 print '}'172 print ''171 print ('}') 172 print ('') 173 173 174 174 175 175 cmds = [ … … 206 206 ] 207 207 208 208 def dump_cmds(): 209 print r'''209 print (r''' 210 210 void 211 211 svga_dump_command(uint32_t cmd_id, const void *data, uint32_t size) 212 212 { 213 213 const uint8_t *body = (const uint8_t *)data; 214 214 const uint8_t *next = body + size; 215 ''' 216 print ' switch(cmd_id) {'215 ''') 216 print (' switch(cmd_id) {') 217 217 indexes = 'ijklmn' 218 218 for id, header, body, footer in cmds: 219 print ' case %s:' % id220 print ' _debug_printf("\\t%s\\n");' % id221 print ' {'222 print ' const %s *cmd = (const %s *)body;' % (header, header)219 print (' case %s:' % id) 220 print (' _debug_printf("\\t%s\\n");' % id) 221 print (' {') 222 print (' const %s *cmd = (const %s *)body;' % (header, header)) 223 223 if len(body): 224 print ' unsigned ' + ', '.join(indexes[:len(body)]) + ';'225 print ' dump_%s(cmd);' % header226 print ' body = (const uint8_t *)&cmd[1];'224 print (' unsigned ' + ', '.join(indexes[:len(body)]) + ';') 225 print (' dump_%s(cmd);' % header) 226 print (' body = (const uint8_t *)&cmd[1];') 227 227 for i in range(len(body)): 228 228 struct, count = body[i] 229 229 idx = indexes[i] 230 print ' for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx)231 print ' dump_%s((const %s *)body);' % (struct, struct)232 print ' body += sizeof(%s);' % struct233 print ' }'230 print (' for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx)) 231 print (' dump_%s((const %s *)body);' % (struct, struct)) 232 print (' body += sizeof(%s);' % struct) 233 print (' }') 234 234 if footer is not None: 235 print ' while(body + sizeof(%s) <= next) {' % footer236 print ' dump_%s((const %s *)body);' % (footer, footer)237 print ' body += sizeof(%s);' % footer238 print ' }'235 print (' while(body + sizeof(%s) <= next) {' % footer) 236 print (' dump_%s((const %s *)body);' % (footer, footer)) 237 print (' body += sizeof(%s);' % footer) 238 print (' }') 239 239 if id == 'SVGA_3D_CMD_SHADER_DEFINE': 240 print ' svga_shader_dump((const uint32_t *)body,'241 print ' (unsigned)(next - body)/sizeof(uint32_t),'242 print ' FALSE);'243 print ' body = next;'244 print ' }'245 print ' break;'246 print ' default:'247 print ' _debug_printf("\\t0x%08x\\n", cmd_id);'248 print ' break;'249 print ' }'250 print r'''240 print (' svga_shader_dump((const uint32_t *)body,') 241 print (' (unsigned)(next - body)/sizeof(uint32_t),') 242 print (' FALSE);') 243 print (' body = next;') 244 print (' }') 245 print (' break;') 246 print (' default:') 247 print (' _debug_printf("\\t0x%08x\\n", cmd_id);') 248 print (' break;') 249 print (' }') 250 print (r''' 251 251 while(body + sizeof(uint32_t) <= next) { 252 252 _debug_printf("\t\t0x%08x\n", *(const uint32_t *)body); 253 253 body += sizeof(uint32_t); … … 255 255 while(body + sizeof(uint32_t) <= next) 256 256 _debug_printf("\t\t0x%02x\n", *body++); 257 257 } 258 ''' 259 print r'''258 ''') 259 print (r''' 260 260 void 261 261 svga_dump_commands(const void *commands, uint32_t size) 262 262 { … … 289 289 } 290 290 } 291 291 } 292 ''' 292 ''') 293 293 294 294 def main(): 295 print copyright.strip()296 print 297 print '/**'298 print ' * @file'299 print ' * Dump SVGA commands.'300 print ' *'301 print ' * Generated automatically from svga3d_reg.h by svga_dump.py.'302 print ' */'303 print 304 print '#include "svga_types.h"'305 print '#include "svga_shader_dump.h"'306 print '#include "svga3d_reg.h"'307 print 308 print '#include "util/u_debug.h"'309 print '#include "svga_dump.h"'310 print 295 print (copyright.strip()) 296 print ('') 297 print ('/**') 298 print (' * @file') 299 print (' * Dump SVGA commands.') 300 print (' *') 301 print (' * Generated automatically from svga3d_reg.h by svga_dump.py.') 302 print (' */') 303 print ('') 304 print ('#include "svga_types.h"') 305 print ('#include "svga_shader_dump.h"') 306 print ('#include "svga3d_reg.h"') 307 print ('') 308 print ('#include "util/u_debug.h"') 309 print ('#include "svga_dump.h"') 310 print ('') 311 311 312 312 config = parser.config_t( 313 313 include_paths = ['../../../include', '../include'], -
Mesa-7.8.2/src/mesa/es/glapi/gl_compare.py
old new 226 226 227 227 # no child 228 228 if not e.functions: 229 print '%s<enum %s/>' % (spaces(indent), attrs)229 print ('%s<enum %s/>' % (spaces(indent), attrs)) 230 230 return 231 231 232 print '%s<enum %s>' % (spaces(indent), attrs)232 print ('%s<enum %s>' % (spaces(indent), attrs)) 233 233 for key, val in e.functions.iteritems(): 234 234 attrs = 'name="%s"' % key 235 235 if val[0] != e.default_count: … … 237 237 if not val[1]: 238 238 attrs += ' mode="get"' 239 239 240 print '%s<size %s/>' % (spaces(indent * 2), attrs)240 print ('%s<size %s/>' % (spaces(indent * 2), attrs)) 241 241 242 print '%s</enum>' % spaces(indent)242 print ('%s</enum>' % spaces(indent)) 243 243 244 244 def output_type(t, indent=0): 245 245 tab = spaces(16, t.name) … … 249 249 attrs += ' unsigned="true"' 250 250 elif ctype.find("signed") == -1: 251 251 attrs += ' float="true"' 252 print '%s<type %s/>' % (spaces(indent), attrs)252 print ('%s<type %s/>' % (spaces(indent), attrs)) 253 253 254 254 def output_function(f, indent=0): 255 255 attrs = 'name="%s"' % f.name … … 258 258 attrs += ' offset="assign"' 259 259 else: 260 260 attrs += ' offset="%d"' % f.offset 261 print '%s<function %s>' % (spaces(indent), attrs)261 print ('%s<function %s>' % (spaces(indent), attrs)) 262 262 263 263 for p in f.parameters: 264 264 attrs = 'name="%s" type="%s"' \ 265 265 % (p.name, p.type_expr.original_string) 266 print '%s<param %s/>' % (spaces(indent * 2), attrs)266 print ('%s<param %s/>' % (spaces(indent * 2), attrs)) 267 267 if f.return_type != "void": 268 268 attrs = 'type="%s"' % f.return_type 269 print '%s<return %s/>' % (spaces(indent * 2), attrs)269 print ('%s<return %s/>' % (spaces(indent * 2), attrs)) 270 270 271 print '%s</function>' % spaces(indent)271 print ('%s</function>' % spaces(indent)) 272 272 273 273 def output_category(api, indent=0): 274 274 enums = api.enums_by_name.values() … … 281 281 for e in enums: 282 282 output_enum(e, indent) 283 283 if enums and types: 284 print 284 print ('') 285 285 for t in types: 286 286 output_type(t, indent) 287 287 if enums or types: 288 print 288 print ('') 289 289 for f in functions: 290 290 output_function(f, indent) 291 291 if f != functions[-1]: 292 print 292 print ('') 293 293 294 294 def is_api_empty(api): 295 295 return bool(not api.enums_by_name and … … 297 297 not api.functions_by_name) 298 298 299 299 def show_usage(ops): 300 print "Usage: %s [-k elts] <%s> <file1> <file2>" % (sys.argv[0], "|".join(ops))301 print " -k elts A comma separated string of types of elements to"302 print " skip. Possible types are enum, type, and function."300 print ("Usage: %s [-k elts] <%s> <file1> <file2>" % (sys.argv[0], "|".join(ops))) 301 print (" -k elts A comma separated string of types of elements to") 302 print (" skip. Possible types are enum, type, and function.") 303 303 sys.exit(1) 304 304 305 305 def main(): … … 339 339 cat_name = "%s_of_%s_and_%s" \ 340 340 % (op, os.path.basename(file1), os.path.basename(file2)) 341 341 342 print '<?xml version="1.0"?>'343 print '<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI344 print 345 print '<OpenGLAPI>'346 print 347 print '<category name="%s">' % (cat_name)342 print ('<?xml version="1.0"?>') 343 print ('<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI) 344 print ('') 345 print ('<OpenGLAPI>') 346 print ('') 347 print ('<category name="%s">' % (cat_name)) 348 348 output_category(result, 4) 349 print '</category>'350 print 351 print '</OpenGLAPI>'349 print ('</category>') 350 print ('') 351 print ('</OpenGLAPI>') 352 352 353 353 if __name__ == "__main__": 354 354 main() -
Mesa-7.8.2/src/mesa/es/glapi/gl_parse_header.py
old new 106 106 m = self.DEFINE.search(line) 107 107 if not m: 108 108 if self.verbose and line.find("#define") >= 0: 109 print "ignore %s" % (line)109 print ("ignore %s" % (line)) 110 110 return None 111 111 112 112 key = m.group("key").strip() … … 116 116 if ((not (key.startswith("GL_") and key.isupper())) or 117 117 (self.ignore_enum.match(key) and val == "1")): 118 118 if self.verbose: 119 print "ignore enum %s" % (key)119 print ("ignore enum %s" % (key)) 120 120 return None 121 121 122 122 return (key, val) … … 126 126 m = self.TYPEDEF.search(line) 127 127 if not m: 128 128 if self.verbose and line.find("typedef") >= 0: 129 print "ignore %s" % (line)129 print ("ignore %s" % (line)) 130 130 return None 131 131 132 132 f = m.group("from").strip() 133 133 t = m.group("to").strip() 134 134 if not t.startswith("GL"): 135 135 if self.verbose: 136 print "ignore type %s" % (t)136 print ("ignore type %s" % (t)) 137 137 return None 138 138 attrs = self._get_ctype_attrs(f) 139 139 … … 144 144 m = self.GLAPI.search(line) 145 145 if not m: 146 146 if self.verbose and line.find("APIENTRY") >= 0: 147 print "ignore %s" % (line)147 print ("ignore %s" % (line)) 148 148 return None 149 149 150 150 rettype = m.group("return") … … 213 213 lines = fp.readlines() 214 214 fp.close() 215 215 except IOError, e: 216 print "failed to read %s: %s" % (header, e)216 print ("failed to read %s: %s" % (header, e)) 217 217 return lines 218 218 219 219 def _cmp_enum(self, enum1, enum2): … … 287 287 for i in dup: 288 288 e = cat["enums"].pop(i) 289 289 if self.verbose: 290 print "remove duplicate enum %s" % e[0]290 print ("remove duplicate enum %s" % e[0]) 291 291 292 292 cat["types"].sort(self._cmp_type) 293 293 cat["functions"].sort(self._cmp_function) … … 305 305 self._reset() 306 306 307 307 if self.verbose: 308 print "Parsing %s" % (header)308 print ("Parsing %s" % (header)) 309 309 310 310 hdict = {} 311 311 lines = self._read_header(header) … … 347 347 348 348 if self.need_char: 349 349 if self.verbose: 350 print "define GLchar"350 print ("define GLchar") 351 351 elem = self._parse_typedef("typedef char GLchar;") 352 352 cat["types"].append(elem) 353 353 return self._postprocess_dict(hdict) … … 364 364 for i in xrange(len(hlist)): 365 365 cat_name, cat = hlist[i] 366 366 367 print '<category name="%s">' % (cat_name)367 print ('<category name="%s">' % (cat_name)) 368 368 indent = 4 369 369 370 370 for enum in cat["enums"]: … … 372 372 value = enum[1] 373 373 tab = spaces(41, name) 374 374 attrs = 'name="%s"%svalue="%s"' % (name, tab, value) 375 print '%s<enum %s/>' % (spaces(indent), attrs)375 print ('%s<enum %s/>' % (spaces(indent), attrs)) 376 376 377 377 if cat["enums"] and cat["types"]: 378 print 378 print ('') 379 379 380 380 for type in cat["types"]: 381 381 ctype = type[0] … … 388 388 elif not is_signed: 389 389 attrs += ' unsigned="true"' 390 390 391 print '%s<type %s/>' % (spaces(indent), attrs)391 print ('%s<type %s/>' % (spaces(indent), attrs)) 392 392 393 393 for func in cat["functions"]: 394 print 394 print ('') 395 395 ret = func[0] 396 396 name = func[1][2:] 397 397 params = func[2] 398 398 399 399 attrs = 'name="%s" offset="assign"' % name 400 print '%s<function %s>' % (spaces(indent), attrs)400 print ('%s<function %s>' % (spaces(indent), attrs)) 401 401 402 402 for param in params: 403 403 attrs = 'name="%s" type="%s"' % (param[1], param[0]) 404 print '%s<param %s/>' % (spaces(indent * 2), attrs)404 print ('%s<param %s/>' % (spaces(indent * 2), attrs)) 405 405 if ret: 406 406 attrs = 'type="%s"' % ret 407 print '%s<return %s/>' % (spaces(indent * 2), attrs)407 print ('%s<return %s/>' % (spaces(indent * 2), attrs)) 408 408 409 print '%s</function>' % spaces(indent)409 print ('%s</function>' % spaces(indent)) 410 410 411 print '</category>'412 print 411 print ('</category>') 412 print ('') 413 413 414 414 def show_usage(): 415 print "Usage: %s [-v] <header> ..." % sys.argv[0]415 print ("Usage: %s [-v] <header> ..." % sys.argv[0]) 416 416 sys.exit(1) 417 417 418 418 def main(): … … 435 435 hlist = parser.parse(h) 436 436 437 437 if need_xml_header: 438 print '<?xml version="1.0"?>'439 print '<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI438 print ('<?xml version="1.0"?>') 439 print ('<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI) 440 440 need_xml_header = False 441 441 442 print 443 print '<!-- %s -->' % (h)444 print '<OpenGLAPI>'445 print 442 print ('') 443 print ('<!-- %s -->' % (h)) 444 print ('<OpenGLAPI>') 445 print ('') 446 446 output_xml(h, hlist) 447 print '</OpenGLAPI>'447 print ('</OpenGLAPI>') 448 448 449 449 if __name__ == '__main__': 450 450 main() -
Mesa-7.8.2/src/mesa/es/main/APIspec.py
old new 431 431 stmts = [] 432 432 for name in self.switches.iterkeys(): 433 433 c_switch = self._c_switch(name) 434 print "\n".join(c_switch)434 print ("\n".join(c_switch)) 435 435 436 436 437 437 class Description(object): … … 610 610 611 611 doc.freeDoc() 612 612 613 print "%s is successfully parsed" % filename613 print ("%s is successfully parsed" % filename) 614 614 615 615 616 616 if __name__ == "__main__": -
Mesa-7.8.2/src/mesa/es/main/APIspecutil.py
old new 61 61 if not alias: 62 62 # external functions are manually dispatched 63 63 if not func.is_external: 64 print >>sys.stderr, "Error: unable to dispatch %s" % func.name64 sys.stderr.write("Error: unable to dispatch %s\n" % func.name) 65 65 alias = func 66 66 need_conv = False 67 67 … … 119 119 120 120 items = desc.checker.switches.items() 121 121 if len(items) > 1: 122 print >>sys.stderr, "%s: more than one parameter depend on %s" % \123 (func.name, desc.name) 122 sys.stderr.write("%s: more than one parameter depend on %s\n" % \ 123 (func.name, desc.name)) 124 124 dep_name, dep_switch = items[0] 125 125 126 126 for dep_desc in dep_switch: 127 127 if dep_desc.index >= 0 and dep_desc.index != 0: 128 print >>sys.stderr, "%s: not first element of a vector" % func.name128 sys.stderr.write("%s: not first element of a vector\n" % func.name) 129 129 if dep_desc.checker.switches: 130 print >>sys.stderr, "%s: deep nested dependence" % func.name130 sys.stderr.write("%s: deep nested dependence\n" % func.name) 131 131 132 132 convert = None if dep_desc.convert else "noconvert" 133 133 for val in desc.values: … … 188 188 if not size: 189 189 need_conv = __aliases[func.name][1] 190 190 if need_conv: 191 print >>sys.stderr,\192 "Error: unable to dicide the max size of %s in %s " % \193 (param.name, func.name) 191 sys.stderr.write( \ 192 "Error: unable to dicide the max size of %s in %s\n" % \ 193 (param.name, func.name)) 194 194 return size 195 195 196 196 -
Mesa-7.8.2/src/mesa/es/main/es_generator.py
old new 70 70 type-converted if necessary.""" 71 71 72 72 if not Converters.has_key(fromType): 73 print >> sys.stderr, "No base converter for type '%s' found. Ignoring." % fromType73 sys.stderr.write("No base converter for type '%s' found. Ignoring.\n" % fromType) 74 74 return value 75 75 76 76 if not Converters[fromType].has_key(toType): 77 print >> sys.stderr, "No converter found for type '%s' to type '%s'. Ignoring." % (fromType, toType)77 sys.stderr.write("No converter found for type '%s' to type '%s'. Ignoring.\n" % (fromType, toType)) 78 78 return value 79 79 80 80 # This part is simple. Return the proper conversion. … … 175 175 176 176 allSpecials = apiutil.AllSpecials() 177 177 178 print """/* DO NOT EDIT *************************************************178 print ("""/* DO NOT EDIT ************************************************* 179 179 * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT 180 180 * API specification file: %s 181 181 * GLES version: %s 182 182 * date: %s 183 183 */ 184 """ % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")) 184 """ % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S"))) 185 185 186 186 # The headers we choose are version-specific. 187 print """187 print (""" 188 188 #include "%s" 189 189 #include "%s" 190 """ % (versionHeader, versionExtHeader) 190 """ % (versionHeader, versionExtHeader)) 191 191 192 192 # Everyone needs these types. 193 print """193 print (""" 194 194 /* These types are needed for the Mesa veneer, but are not defined in 195 195 * the standard GLES headers. 196 196 */ … … 210 210 #include "main/dispatch.h" 211 211 212 212 typedef void (*_glapi_proc)(void); /* generic function pointer */ 213 """ 213 """) 214 214 215 215 # Finally we get to the all-important functions 216 print """/*************************************************************216 print ("""/************************************************************* 217 217 * Generated functions begin here 218 218 */ 219 """ 219 """) 220 220 for funcName in keys: 221 221 if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName)) 222 222 … … 569 569 # header files. The easiest way to manage declarations 570 570 # is to create them ourselves. 571 571 if funcName in allSpecials: 572 print "/* this function is special and is defined elsewhere */"573 print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)572 print ("/* this function is special and is defined elsewhere */") 573 print ("extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)) 574 574 575 575 # A function may be a core function (i.e. it exists in 576 576 # the core specification), a core addition (extension … … 612 612 # Now the generated function. The text used to mark an API-level 613 613 # function, oddly, is version-specific. 614 614 if extensionName: 615 print "/* Extension %s */" % extensionName615 print ("/* Extension %s */" % extensionName) 616 616 617 617 if (not variables and 618 618 not switchCode and 619 619 not conversionCodeOutgoing and 620 620 not conversionCodeIncoming): 621 621 # pass through directly 622 print "#define %s %s" % (fullFuncName, passthroughFuncName)623 print 622 print ("#define %s %s" % (fullFuncName, passthroughFuncName)) 623 print ('') 624 624 continue 625 625 626 print "static %s %s(%s)" % (returnType, fullFuncName, declarationString)627 print "{"626 print ("static %s %s(%s)" % (returnType, fullFuncName, declarationString)) 627 print ("{") 628 628 629 629 # Start printing our code pieces. Start with any local 630 630 # variables we need. This unusual syntax joins the 631 631 # lines in the variables[] array with the "\n" separator. 632 632 if len(variables) > 0: 633 print "\n".join(variables) + "\n"633 print ("\n".join(variables) + "\n") 634 634 635 635 # If there's any sort of parameter checking or variable 636 636 # array sizing, the switch code will contain it. 637 637 if len(switchCode) > 0: 638 print "\n".join(switchCode) + "\n"638 print ("\n".join(switchCode) + "\n") 639 639 640 640 # In the case of an outgoing conversion (i.e. parameters must 641 641 # be converted before calling the underlying Mesa function), 642 642 # use the appropriate code. 643 643 if "get" not in props and len(conversionCodeOutgoing) > 0: 644 print "\n".join(conversionCodeOutgoing) + "\n"644 print ("\n".join(conversionCodeOutgoing) + "\n") 645 645 646 646 # Call the Mesa function. Note that there are very few functions 647 647 # that return a value (i.e. returnType is not "void"), and that … … 650 650 # even though it's not completely independent. 651 651 652 652 if returnType == "void": 653 print " %s(%s);" % (passthroughFuncName, passthroughCallString)653 print (" %s(%s);" % (passthroughFuncName, passthroughCallString)) 654 654 else: 655 print " return %s(%s);" % (passthroughFuncName, passthroughCallString)655 print (" return %s(%s);" % (passthroughFuncName, passthroughCallString)) 656 656 657 657 # If the function is one that returns values (i.e. "get" in props), 658 658 # it might return values of a different type than we need, that 659 659 # require conversion before passing back to the application. 660 660 if "get" in props and len(conversionCodeIncoming) > 0: 661 print "\n".join(conversionCodeIncoming)661 print ("\n".join(conversionCodeIncoming)) 662 662 663 663 # All done. 664 print "}"665 print 664 print ("}") 665 print ('') 666 666 # end for each category provided for a function 667 667 668 668 # end for each function 669 669 670 print "void"671 print "_mesa_init_exec_table(struct _glapi_table *exec)"672 print "{"670 print ("void") 671 print ("_mesa_init_exec_table(struct _glapi_table *exec)") 672 print ("{") 673 673 for func in keys: 674 674 prefix = "_es_" if func not in allSpecials else "_check_" 675 675 for spec in apiutil.Categories(func): … … 681 681 if ext: 682 682 suffix = ext[0].split("_")[0] 683 683 entry += suffix 684 print " SET_%s(exec, %s%s);" % (entry, prefix, entry)685 print "}"684 print (" SET_%s(exec, %s%s);" % (entry, prefix, entry)) 685 print ("}") -
Mesa-7.8.2/src/mesa/es/main/get_gen.py
old new 585 585 else: 586 586 abort() 587 587 588 print "void GLAPIENTRY"589 print "%s( GLenum pname, %s *params )" % (function, strType)590 print "{"591 print " GET_CURRENT_CONTEXT(ctx);"592 print " ASSERT_OUTSIDE_BEGIN_END(ctx);"593 print ""594 print " if (!params)"595 print " return;"596 print ""597 print " if (ctx->NewState)"598 print " _mesa_update_state(ctx);"599 print ""600 print " switch (pname) {"588 print ("void GLAPIENTRY") 589 print ("%s( GLenum pname, %s *params )" % (function, strType)) 590 print ("{") 591 print (" GET_CURRENT_CONTEXT(ctx);") 592 print (" ASSERT_OUTSIDE_BEGIN_END(ctx);") 593 print ("") 594 print (" if (!params)") 595 print (" return;") 596 print ("") 597 print (" if (ctx->NewState)") 598 print (" _mesa_update_state(ctx);") 599 print ("") 600 print (" switch (pname) {") 601 601 602 602 for (name, varType, state, optionalCode, extensions) in stateVars: 603 print " case " + name + ":"603 print (" case " + name + ":") 604 604 if extensions: 605 605 if len(extensions) == 1: 606 606 print (' CHECK_EXT1(%s, "%s");' % … … 616 616 print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' % 617 617 (extensions[0], extensions[1], extensions[2], extensions[3], function)) 618 618 if optionalCode: 619 print " {"620 print " " + optionalCode619 print (" {") 620 print (" " + optionalCode) 621 621 conversion = ConversionFunc(varType, returnType) 622 622 n = len(state) 623 623 for i in range(n): 624 624 if conversion: 625 print " params[%d] = %s(%s);" % (i, conversion, state[i])625 print (" params[%d] = %s(%s);" % (i, conversion, state[i])) 626 626 else: 627 print " params[%d] = %s;" % (i, state[i])627 print (" params[%d] = %s;" % (i, state[i])) 628 628 if optionalCode: 629 print " }"630 print " break;"629 print (" }") 630 print (" break;") 631 631 632 print " default:"633 print ' _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function634 print " }"635 print "}"636 print ""632 print (" default:") 633 print (' _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function) 634 print (" }") 635 print ("}") 636 print ("") 637 637 return 638 638 639 639 640 640 641 641 def EmitHeader(): 642 642 """Print the get.c file header.""" 643 print """643 print (""" 644 644 /*** 645 645 *** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py 646 646 ***/ … … 776 776 void GLAPIENTRY 777 777 _mesa_GetFixedv( GLenum pname, GLfixed *params ); 778 778 779 """ 779 """) 780 780 return 781 781 782 782 … … 797 797 API = 2 798 798 else: 799 799 API = 1 800 #print "len args = %d API = %d" % (len(args), API)800 #print ("len args = %d API = %d" % (len(args), API)) 801 801 802 802 if API == 1: 803 803 vars = StateVars_common + StateVars_es1 -
Mesa-7.8.2/src/mesa/glapi/gen/extension_helper.py
old new 150 150 151 151 152 152 def printRealHeader(self): 153 print '#include "utils.h"'154 print '#include "main/dispatch.h"'155 print ''153 print ('#include "utils.h"') 154 print ('#include "main/dispatch.h"') 155 print ('') 156 156 return 157 157 158 158 … … 161 161 162 162 category_list = {} 163 163 164 print '#ifndef NULL'165 print '# define NULL 0'166 print '#endif'167 print ''164 print ('#ifndef NULL') 165 print ('# define NULL 0') 166 print ('#endif') 167 print ('') 168 168 169 169 for f in api.functionIterateAll(): 170 170 condition = condition_for_function(f, abi, 0) 171 171 if len(condition): 172 print '#if %s' % (string.join(condition, " || "))173 print 'static const char %s_names[] =' % (f.name)172 print ('#if %s' % (string.join(condition, " || "))) 173 print ('static const char %s_names[] =' % (f.name)) 174 174 175 175 parameter_signature = '' 176 176 for p in f.parameterIterator(): … … 189 189 else: 190 190 parameter_signature += 'd' 191 191 192 print ' "%s\\0" /* Parameter signature */' % (parameter_signature)192 print (' "%s\\0" /* Parameter signature */' % (parameter_signature)) 193 193 194 194 for n in f.entry_points: 195 print ' "gl%s\\0"' % (n)195 print (' "gl%s\\0"' % (n)) 196 196 197 197 [category, num] = api.get_category_for_name( n ) 198 198 if category not in abi: … … 202 202 203 203 category_list[ c ].append( f ) 204 204 205 print ' "";'206 print '#endif'207 print ''205 print (' "";') 206 print ('#endif') 207 print ('') 208 208 209 209 keys = category_list.keys() 210 210 keys.sort() 211 211 212 212 for category in keys: 213 print '#if defined(need_%s)' % (category)214 print 'static const struct dri_extension_function %s_functions[] = {' % (category)213 print ('#if defined(need_%s)' % (category)) 214 print ('static const struct dri_extension_function %s_functions[] = {' % (category)) 215 215 216 216 for f in category_list[ category ]: 217 217 # A function either has an offset that is … … 224 224 index_name = "%s_remap_index" % (f.name) 225 225 offset = -1 226 226 227 print ' { %s_names, %s, %d },' % (f.name, index_name, offset)227 print (' { %s_names, %s, %d },' % (f.name, index_name, offset)) 228 228 229 229 230 print ' { NULL, 0, 0 }'231 print '};'232 print '#endif'233 print ''230 print (' { NULL, 0, 0 }') 231 print ('};') 232 print ('#endif') 233 print ('') 234 234 235 235 return 236 236 … … 258 258 259 259 if condition_string != last_condition_string: 260 260 if last_condition_string: 261 print '#endif /* %s */' % (last_condition_string)261 print ('#endif /* %s */' % (last_condition_string)) 262 262 263 263 if condition_string: 264 print '#if %s' % (condition_string)264 print ('#if %s' % (condition_string)) 265 265 266 266 if vtxfmt_only: 267 print ' disp->%s = vfmt->%s;' % (f.name, f.name)267 print (' disp->%s = vfmt->%s;' % (f.name, f.name)) 268 268 else: 269 print ' disp->%s = _mesa_%s;' % (f.name, f.name)269 print (' disp->%s = _mesa_%s;' % (f.name, f.name)) 270 270 271 271 last_condition_string = condition_string 272 272 273 273 if last_condition_string: 274 print '#endif /* %s */' % (last_condition_string)274 print ('#endif /* %s */' % (last_condition_string)) 275 275 276 276 277 277 278 278 def printBody(self, api): 279 279 abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ] 280 280 281 print 'void driver_init_exec_table(struct _glapi_table *disp)'282 print '{'281 print ('void driver_init_exec_table(struct _glapi_table *disp)') 282 print ('{') 283 283 self.do_function_body(api, abi, 0) 284 print '}'285 print ''286 print 'void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)'287 print '{'284 print ('}') 285 print ('') 286 print ('void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)') 287 print ('{') 288 288 self.do_function_body(api, abi, 1) 289 print '}'289 print ('}') 290 290 291 291 return 292 292 293 293 294 294 def show_usage(): 295 print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]296 print " -m output_mode Output mode can be one of 'extensions' or 'exec_init'."295 print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]) 296 print (" -m output_mode Output mode can be one of 'extensions' or 'exec_init'.") 297 297 sys.exit(1) 298 298 299 299 if __name__ == '__main__': -
Mesa-7.8.2/src/mesa/glapi/gen/gl_apitemp.py
old new 92 92 if (cat.startswith("es") or cat.startswith("GL_OES")): 93 93 need_proto = True 94 94 if need_proto: 95 print '%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name))96 print ''95 print ('%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name))) 96 print ('') 97 97 98 print '%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))99 print '{'98 print ('%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))) 99 print ('{') 100 100 if p_string == "": 101 print ' %s(%s, (), (F, "gl%s();\\n"));' \102 % (dispatch, f.name, name) 101 print (' %s(%s, (), (F, "gl%s();\\n"));' \ 102 % (dispatch, f.name, name)) 103 103 else: 104 print ' %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \105 % (dispatch, f.name, p_string, name, t_string, o_string) 106 print '}'107 print ''104 print (' %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \ 105 % (dispatch, f.name, p_string, name, t_string, o_string)) 106 print ('}') 107 print ('') 108 108 return 109 109 110 110 def printRealHeader(self): 111 print ''111 print ('') 112 112 self.printVisibility( "HIDDEN", "hidden" ) 113 print """113 print (""" 114 114 /* 115 115 * This file is a template which generates the OpenGL API entry point 116 116 * functions. It should be included by a .c file which first defines … … 157 157 #error RETURN_DISPATCH must be defined 158 158 #endif 159 159 160 """ 160 """) 161 161 return 162 162 163 163 164 164 165 165 def printInitDispatch(self, api): 166 print """166 print (""" 167 167 #endif /* defined( NAME ) */ 168 168 169 169 /* … … 180 180 #error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined 181 181 #endif 182 182 183 _glapi_proc DISPATCH_TABLE_NAME[] = {""" 183 _glapi_proc DISPATCH_TABLE_NAME[] = {""") 184 184 for f in api.functionIterateByOffset(): 185 print ' TABLE_ENTRY(%s),' % (f.dispatch_name())185 print (' TABLE_ENTRY(%s),' % (f.dispatch_name())) 186 186 187 print ' /* A whole bunch of no-op functions. These might be called'188 print ' * when someone tries to call a dynamically-registered'189 print ' * extension function without a current rendering context.'190 print ' */'187 print (' /* A whole bunch of no-op functions. These might be called') 188 print (' * when someone tries to call a dynamically-registered') 189 print (' * extension function without a current rendering context.') 190 print (' */') 191 191 for i in range(1, 100): 192 print ' TABLE_ENTRY(Unused),'192 print (' TABLE_ENTRY(Unused),') 193 193 194 print '};'195 print '#endif /* DISPATCH_TABLE_NAME */'196 print ''194 print ('};') 195 print ('#endif /* DISPATCH_TABLE_NAME */') 196 print ('') 197 197 return 198 198 199 199 200 200 def printAliasedTable(self, api): 201 print """201 print (""" 202 202 /* 203 203 * This is just used to silence compiler warnings. 204 204 * We list the functions which are not otherwise used. 205 205 */ 206 206 #ifdef UNUSED_TABLE_NAME 207 _glapi_proc UNUSED_TABLE_NAME[] = {""" 207 _glapi_proc UNUSED_TABLE_NAME[] = {""") 208 208 209 209 normal_entries = [] 210 210 proto_entries = [] … … 223 223 normal_entries.extend(normal_ents) 224 224 proto_entries.extend(proto_ents) 225 225 226 print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'226 print ('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS') 227 227 for ent in normal_entries: 228 print ' TABLE_ENTRY(%s),' % (ent)229 print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'230 print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'228 print (' TABLE_ENTRY(%s),' % (ent)) 229 print ('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */') 230 print ('#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS') 231 231 for ent in proto_entries: 232 print ' TABLE_ENTRY(%s),' % (ent)233 print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'232 print (' TABLE_ENTRY(%s),' % (ent)) 233 print ('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */') 234 234 235 print '};'236 print '#endif /*UNUSED_TABLE_NAME*/'237 print ''235 print ('};') 236 print ('#endif /*UNUSED_TABLE_NAME*/') 237 print ('') 238 238 return 239 239 240 240 … … 271 271 normal_entry_points.append((func, normal_ents)) 272 272 proto_entry_points.append((func, proto_ents)) 273 273 274 print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'275 print ''274 print ('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS') 275 print ('') 276 276 for func, ents in normal_entry_points: 277 277 for ent in ents: 278 278 self.printFunction(func, ent) 279 print ''280 print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'281 print ''282 print '/* these entry points might require different protocols */'283 print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'284 print ''279 print ('') 280 print ('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */') 281 print ('') 282 print ('/* these entry points might require different protocols */') 283 print ('#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS') 284 print ('') 285 285 for func, ents in proto_entry_points: 286 286 for ent in ents: 287 287 self.printFunction(func, ent) 288 print ''289 print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'290 print ''288 print ('') 289 print ('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */') 290 print ('') 291 291 292 292 self.printInitDispatch(api) 293 293 self.printAliasedTable(api) … … 295 295 296 296 297 297 def show_usage(): 298 print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]299 print "-c Enable compatibility with OpenGL ES."298 print ("Usage: %s [-f input_file_name] [-c]" % sys.argv[0]) 299 print ("-c Enable compatibility with OpenGL ES.") 300 300 sys.exit(1) 301 301 302 302 if __name__ == '__main__': -
Mesa-7.8.2/src/mesa/glapi/gen/gl_enums.py
old new 42 42 43 43 44 44 def printRealHeader(self): 45 print '#include "main/glheader.h"'46 print '#include "main/mfeatures.h"'47 print '#include "main/enums.h"'48 print '#include "main/imports.h"'49 print ''50 print 'typedef struct {'51 print ' size_t offset;'52 print ' int n;'53 print '} enum_elt;'54 print ''45 print ('#include "main/glheader.h"') 46 print ('#include "main/mfeatures.h"') 47 print ('#include "main/enums.h"') 48 print ('#include "main/imports.h"') 49 print ('') 50 print ('typedef struct {') 51 print (' size_t offset;') 52 print (' int n;') 53 print ('} enum_elt;') 54 print ('') 55 55 return 56 56 57 57 def print_code(self): 58 print """58 print (""" 59 59 typedef int (*cfunc)(const void *, const void *); 60 60 61 61 /** … … 147 147 return (f != NULL) ? f->n : -1; 148 148 } 149 149 150 """ 150 """) 151 151 return 152 152 153 153 … … 174 174 175 175 string_offsets = {} 176 176 i = 0; 177 print 'LONGSTRING static const char enum_string_table[] = '177 print ('LONGSTRING static const char enum_string_table[] = ') 178 178 for [name, enum] in name_table: 179 print ' "%s\\0"' % (name)179 print (' "%s\\0"' % (name)) 180 180 string_offsets[ name ] = i 181 181 i += len(name) + 1 182 182 183 print ' ;'184 print ''183 print (' ;') 184 print ('') 185 185 186 186 187 print 'static const enum_elt all_enums[%u] =' % (len(name_table))188 print '{'187 print ('static const enum_elt all_enums[%u] =' % (len(name_table))) 188 print ('{') 189 189 for [name, enum] in name_table: 190 print ' { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name)191 print '};'192 print ''190 print (' { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name)) 191 print ('};') 192 print ('') 193 193 194 print 'static const unsigned reduced_enums[%u] =' % (len(keys))195 print '{'194 print ('static const unsigned reduced_enums[%u] =' % (len(keys))) 195 print ('{') 196 196 for enum in keys: 197 197 name = enum_table[ enum ] 198 198 if [name, enum] not in name_table: 199 print ' /* Error! %s, 0x%04x */ 0,' % (name, enum)199 print (' /* Error! %s, 0x%04x */ 0,' % (name, enum)) 200 200 else: 201 201 i = name_table.index( [name, enum] ) 202 202 203 print ' %4u, /* %s */' % (i, name)204 print '};'203 print (' %4u, /* %s */' % (i, name)) 204 print ('};') 205 205 206 206 207 207 self.print_code() … … 222 222 223 223 224 224 def show_usage(): 225 print "Usage: %s [-f input_file_name]" % sys.argv[0]225 print ("Usage: %s [-f input_file_name]" % sys.argv[0]) 226 226 sys.exit(1) 227 227 228 228 if __name__ == '__main__': -
Mesa-7.8.2/src/mesa/glapi/gen/gl_offsets.py
old new 42 42 return 43 43 44 44 def printBody(self, api): 45 print '/* this file should not be included directly in mesa */'46 print ''45 print ('/* this file should not be included directly in mesa */') 46 print ('') 47 47 48 48 functions = [] 49 49 abi_functions = [] … … 62 62 alias_functions.append(f) 63 63 64 64 for f in abi_functions: 65 print '#define _gloffset_%s %d' % (f.name, f.offset)65 print ('#define _gloffset_%s %d' % (f.name, f.offset)) 66 66 last_static = f.offset 67 67 68 print ''69 print '#if !defined(_GLAPI_USE_REMAP_TABLE)'70 print ''68 print ('') 69 print ('#if !defined(_GLAPI_USE_REMAP_TABLE)') 70 print ('') 71 71 72 72 for [f, index] in functions: 73 print '#define _gloffset_%s %d' % (f.name, f.offset)73 print ('#define _gloffset_%s %d' % (f.name, f.offset)) 74 74 75 print '#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset)75 print ('#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset)) 76 76 77 print ''78 print '#else'79 print ''77 print ('') 78 print ('#else') 79 print ('') 80 80 81 81 for [f, index] in functions: 82 print '#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)82 print ('#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)) 83 83 84 print ''85 print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'84 print ('') 85 print ('#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */') 86 86 87 87 if alias_functions: 88 print ''89 print '/* define aliases for compatibility */'88 print ('') 89 print ('/* define aliases for compatibility */') 90 90 for f in alias_functions: 91 91 for name in f.entry_points: 92 92 if name != f.name: 93 print '#define _gloffset_%s _gloffset_%s' % (name, f.name)93 print ('#define _gloffset_%s _gloffset_%s' % (name, f.name)) 94 94 return 95 95 96 96 97 97 def show_usage(): 98 print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]99 print " -c Enable compatibility with OpenGL ES."98 print ("Usage: %s [-f input_file_name] [-c]" % sys.argv[0]) 99 print (" -c Enable compatibility with OpenGL ES.") 100 100 sys.exit(1) 101 101 102 102 if __name__ == '__main__': -
Mesa-7.8.2/src/mesa/glapi/gen/gl_procs.py
old new 42 42 43 43 44 44 def printRealHeader(self): 45 print """45 print (""" 46 46 /* This file is only included by glapi.c and is used for 47 47 * the GetProcAddress() function 48 48 */ … … 65 65 # define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o } 66 66 #endif 67 67 68 """ 68 """) 69 69 return 70 70 71 71 def printRealFooter(self): 72 print ''73 print '#undef NAME_FUNC_OFFSET'72 print ('') 73 print ('#undef NAME_FUNC_OFFSET') 74 74 return 75 75 76 76 def printFunctionString(self, name): 77 77 if self.long_strings: 78 print ' "gl%s\\0"' % (name)78 print (' "gl%s\\0"' % (name)) 79 79 else: 80 print " 'g','l',",80 print (" 'g','l',",) 81 81 for c in name: 82 print "'%s'," % (c),82 print ("'%s'," % (c),) 83 83 84 print "'\\0',"84 print ("'\\0',") 85 85 86 86 87 87 def printBody(self, api): 88 print ''88 print ('') 89 89 if self.long_strings: 90 print 'static const char gl_string_table[] ='90 print ('static const char gl_string_table[] =') 91 91 else: 92 print 'static const char gl_string_table[] = {'92 print ('static const char gl_string_table[] = {') 93 93 94 94 base_offset = 0 95 95 table = [] … … 120 120 121 121 122 122 if self.long_strings: 123 print ' ;'123 print (' ;') 124 124 else: 125 print '};'125 print ('};') 126 126 127 print ''128 print ''129 print "#ifdef USE_MGL_NAMESPACE"127 print ('') 128 print ('') 129 print ("#ifdef USE_MGL_NAMESPACE") 130 130 for func in api.functionIterateByOffset(): 131 131 for n in func.entry_points: 132 132 if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)): 133 print '#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset)133 print ('#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset)) 134 134 break 135 print "#endif /* USE_MGL_NAMESPACE */"136 print ''137 print ''138 print '#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)'135 print ("#endif /* USE_MGL_NAMESPACE */") 136 print ('') 137 print ('') 138 print ('#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)') 139 139 for func in api.functionIterateByOffset(): 140 140 for n in func.entry_points: 141 141 if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)): 142 print '%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string())142 print ('%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string())) 143 143 break 144 144 145 145 if self.es: … … 154 154 % (func.return_type, "gl" + n, func.get_parameter_string(n)) 155 155 categories[cat].append(proto) 156 156 if categories: 157 print ''158 print '/* OpenGL ES specific prototypes */'159 print ''157 print ('') 158 print ('/* OpenGL ES specific prototypes */') 159 print ('') 160 160 keys = categories.keys() 161 161 keys.sort() 162 162 for key in keys: 163 print '/* category %s */' % key164 print "\n".join(categories[key])165 print ''163 print ('/* category %s */' % key) 164 print ("\n".join(categories[key])) 165 print ('') 166 166 167 print '#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */'167 print ('#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */') 168 168 169 print ''170 print 'static const glprocs_table_t static_functions[] = {'169 print ('') 170 print ('static const glprocs_table_t static_functions[] = {') 171 171 172 172 for info in table: 173 print ' NAME_FUNC_OFFSET(%5u, %s, %s, %s, _gloffset_%s),' % info173 print (' NAME_FUNC_OFFSET(%5u, %s, %s, %s, _gloffset_%s),' % info) 174 174 175 print ' NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)'176 print '};'175 print (' NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)') 176 print ('};') 177 177 return 178 178 179 179 180 180 def show_usage(): 181 print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]182 print "-c Enable compatibility with OpenGL ES."183 print "-m mode mode can be one of:"184 print " long - Create code for compilers that can handle very"185 print " long string constants. (default)"186 print " short - Create code for compilers that can only handle"187 print " ANSI C89 string constants."181 print ("Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]) 182 print ("-c Enable compatibility with OpenGL ES.") 183 print ("-m mode mode can be one of:") 184 print (" long - Create code for compilers that can handle very") 185 print (" long string constants. (default)") 186 print (" short - Create code for compilers that can only handle") 187 print (" ANSI C89 string constants.") 188 188 sys.exit(1) 189 189 190 190 if __name__ == '__main__': -
Mesa-7.8.2/src/mesa/glapi/gen/gl_SPARC_asm.py
old new 39 39 40 40 41 41 def printRealHeader(self): 42 print '#include "glapi/glapioffsets.h"'43 print ''44 print '#ifdef __arch64__'45 print '#define GL_OFF(N)\t((N) * 8)'46 print '#define GL_LL\t\tldx'47 print '#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)'48 print '#define GL_STACK_SIZE\t128'49 print '#else'50 print '#define GL_OFF(N)\t((N) * 4)'51 print '#define GL_LL\t\tld'52 print '#define GL_TIE_LD(SYM)\t%tie_ld(SYM)'53 print '#define GL_STACK_SIZE\t64'54 print '#endif'55 print ''56 print '#define GLOBL_FN(x) .globl x ; .type x, @function'57 print '#define HIDDEN(x) .hidden x'58 print ''59 print '\t.register %g2, #scratch'60 print '\t.register %g3, #scratch'61 print ''62 print '\t.text'63 print ''64 print '\tGLOBL_FN(__glapi_sparc_icache_flush)'65 print '\tHIDDEN(__glapi_sparc_icache_flush)'66 print '\t.type\t__glapi_sparc_icache_flush, @function'67 print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'68 print '\tflush\t%o0'69 print '\tretl'70 print '\t nop'71 print ''72 print '\t.align\t32'73 print ''74 print '\t.type\t__glapi_sparc_get_pc, @function'75 print '__glapi_sparc_get_pc:'76 print '\tretl'77 print '\t add\t%o7, %g2, %g2'78 print '\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc'79 print ''80 print '#ifdef GLX_USE_TLS'81 print ''82 print '\tGLOBL_FN(__glapi_sparc_get_dispatch)'83 print '\tHIDDEN(__glapi_sparc_get_dispatch)'84 print '__glapi_sparc_get_dispatch:'85 print '\tmov\t%o7, %g1'86 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'87 print '\tcall\t__glapi_sparc_get_pc'88 print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'89 print '\tmov\t%g1, %o7'90 print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1'91 print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1'92 print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)'93 print '\tretl'94 print '\t mov\t%g2, %o0'95 print ''96 print '\t.data'97 print '\t.align\t32'98 print ''99 print '\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */'100 print '\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */'101 print '\tGLOBL_FN(__glapi_sparc_tls_stub)'102 print '\tHIDDEN(__glapi_sparc_tls_stub)'103 print '__glapi_sparc_tls_stub: /* Call offset in %g3 */'104 print '\tmov\t%o7, %g1'105 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'106 print '\tcall\t__glapi_sparc_get_pc'107 print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'108 print '\tmov\t%g1, %o7'109 print '\tsrl\t%g3, 10, %g3'110 print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1'111 print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1'112 print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)'113 print '\tGL_LL\t[%g7+%g2], %g1'114 print '\tGL_LL\t[%g1 + %g3], %g1'115 print '\tjmp\t%g1'116 print '\t nop'117 print '\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub'118 print ''119 print '#define GL_STUB(fn, off)\t\t\t\t\\'120 print '\tGLOBL_FN(fn);\t\t\t\t\t\\'121 print 'fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\'122 print '\t sethi\tGL_OFF(off), %g3;\t\t\t\\'123 print '\t.size\tfn,.-fn;'124 print ''125 print '#elif defined(PTHREADS)'126 print ''127 print '\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */'128 print '\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */'129 print '\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */'130 print '\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */'131 print '\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */'132 print '\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */'133 print ''134 print '\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */'135 print '\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */'136 print ''137 print '\t.data'138 print '\t.align\t32'139 print ''140 print '\tGLOBL_FN(__glapi_sparc_pthread_stub)'141 print '\tHIDDEN(__glapi_sparc_pthread_stub)'142 print '__glapi_sparc_pthread_stub: /* Call offset in %g3 */'143 print '\tmov\t%o7, %g1'144 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'145 print '\tcall\t__glapi_sparc_get_pc'146 print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'147 print '\tmov\t%g1, %o7'148 print '\tsethi\t%hi(_glapi_Dispatch), %g1'149 print '\tor\t%g1, %lo(_glapi_Dispatch), %g1'150 print '\tsrl\t%g3, 10, %g3'151 print '\tGL_LL\t[%g2+%g1], %g2'152 print '\tGL_LL\t[%g2], %g1'153 print '\tcmp\t%g1, 0'154 print '\tbe\t2f'155 print '\t nop'156 print '1:\tGL_LL\t[%g1 + %g3], %g1'157 print '\tjmp\t%g1'158 print '\t nop'159 print '2:\tsave\t%sp, GL_STACK_SIZE, %sp'160 print '\tmov\t%g3, %l0'161 print '\tcall\t_glapi_get_dispatch'162 print '\t nop'163 print '\tmov\t%o0, %g1'164 print '\tmov\t%l0, %g3'165 print '\tba\t1b'166 print '\t restore %g0, %g0, %g0'167 print '\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub'168 print ''169 print '#define GL_STUB(fn, off)\t\t\t\\'170 print '\tGLOBL_FN(fn);\t\t\t\t\\'171 print 'fn:\tba\t__glapi_sparc_pthread_stub;\t\\'172 print '\t sethi\tGL_OFF(off), %g3;\t\t\\'173 print '\t.size\tfn,.-fn;'174 print ''175 print '#else /* Non-threaded version. */'176 print ''177 print '\t.type __glapi_sparc_nothread_stub, @function'178 print '__glapi_sparc_nothread_stub: /* Call offset in %g3 */'179 print '\tmov\t%o7, %g1'180 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'181 print '\tcall\t__glapi_sparc_get_pc'182 print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'183 print '\tmov\t%g1, %o7'184 print '\tsrl\t%g3, 10, %g3'185 print '\tsethi\t%hi(_glapi_Dispatch), %g1'186 print '\tor\t%g1, %lo(_glapi_Dispatch), %g1'187 print '\tGL_LL\t[%g2+%g1], %g2'188 print '\tGL_LL\t[%g2], %g1'189 print '\tGL_LL\t[%g1 + %g3], %g1'190 print '\tjmp\t%g1'191 print '\t nop'192 print '\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub'193 print ''194 print '#define GL_STUB(fn, off)\t\t\t\\'195 print '\tGLOBL_FN(fn);\t\t\t\t\\'196 print 'fn:\tba\t__glapi_sparc_nothread_stub;\t\\'197 print '\t sethi\tGL_OFF(off), %g3;\t\t\\'198 print '\t.size\tfn,.-fn;'199 print ''200 print '#endif'201 print ''202 print '#define GL_STUB_ALIAS(fn, alias) \\'203 print ' .globl fn; \\'204 print ' .set fn, alias'205 print ''206 print '\t.text'207 print '\t.align\t32'208 print ''209 print '\t.globl\tgl_dispatch_functions_start'210 print '\tHIDDEN(gl_dispatch_functions_start)'211 print 'gl_dispatch_functions_start:'212 print ''42 print ('#include "glapi/glapioffsets.h"') 43 print ('') 44 print ('#ifdef __arch64__') 45 print ('#define GL_OFF(N)\t((N) * 8)') 46 print ('#define GL_LL\t\tldx') 47 print ('#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)') 48 print ('#define GL_STACK_SIZE\t128') 49 print ('#else') 50 print ('#define GL_OFF(N)\t((N) * 4)') 51 print ('#define GL_LL\t\tld') 52 print ('#define GL_TIE_LD(SYM)\t%tie_ld(SYM)') 53 print ('#define GL_STACK_SIZE\t64') 54 print ('#endif') 55 print ('') 56 print ('#define GLOBL_FN(x) .globl x ; .type x, @function') 57 print ('#define HIDDEN(x) .hidden x') 58 print ('') 59 print ('\t.register %g2, #scratch') 60 print ('\t.register %g3, #scratch') 61 print ('') 62 print ('\t.text') 63 print ('') 64 print ('\tGLOBL_FN(__glapi_sparc_icache_flush)') 65 print ('\tHIDDEN(__glapi_sparc_icache_flush)') 66 print ('\t.type\t__glapi_sparc_icache_flush, @function') 67 print ('__glapi_sparc_icache_flush: /* %o0 = insn_addr */') 68 print ('\tflush\t%o0') 69 print ('\tretl') 70 print ('\t nop') 71 print ('') 72 print ('\t.align\t32') 73 print ('') 74 print ('\t.type\t__glapi_sparc_get_pc, @function') 75 print ('__glapi_sparc_get_pc:') 76 print ('\tretl') 77 print ('\t add\t%o7, %g2, %g2') 78 print ('\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc') 79 print ('') 80 print ('#ifdef GLX_USE_TLS') 81 print ('') 82 print ('\tGLOBL_FN(__glapi_sparc_get_dispatch)') 83 print ('\tHIDDEN(__glapi_sparc_get_dispatch)') 84 print ('__glapi_sparc_get_dispatch:') 85 print ('\tmov\t%o7, %g1') 86 print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') 87 print ('\tcall\t__glapi_sparc_get_pc') 88 print ('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') 89 print ('\tmov\t%g1, %o7') 90 print ('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1') 91 print ('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1') 92 print ('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)') 93 print ('\tretl') 94 print ('\t mov\t%g2, %o0') 95 print ('') 96 print ('\t.data') 97 print ('\t.align\t32') 98 print ('') 99 print ('\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */') 100 print ('\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */') 101 print ('\tGLOBL_FN(__glapi_sparc_tls_stub)') 102 print ('\tHIDDEN(__glapi_sparc_tls_stub)') 103 print ('__glapi_sparc_tls_stub: /* Call offset in %g3 */') 104 print ('\tmov\t%o7, %g1') 105 print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') 106 print ('\tcall\t__glapi_sparc_get_pc') 107 print ('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') 108 print ('\tmov\t%g1, %o7') 109 print ('\tsrl\t%g3, 10, %g3') 110 print ('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1') 111 print ('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1') 112 print ('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)') 113 print ('\tGL_LL\t[%g7+%g2], %g1') 114 print ('\tGL_LL\t[%g1 + %g3], %g1') 115 print ('\tjmp\t%g1') 116 print ('\t nop') 117 print ('\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub') 118 print ('') 119 print ('#define GL_STUB(fn, off)\t\t\t\t\\') 120 print ('\tGLOBL_FN(fn);\t\t\t\t\t\\') 121 print ('fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\') 122 print ('\t sethi\tGL_OFF(off), %g3;\t\t\t\\') 123 print ('\t.size\tfn,.-fn;') 124 print ('') 125 print ('#elif defined(PTHREADS)') 126 print ('') 127 print ('\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */') 128 print ('\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */') 129 print ('\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */') 130 print ('\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */') 131 print ('\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */') 132 print ('\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */') 133 print ('') 134 print ('\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */') 135 print ('\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */') 136 print ('') 137 print ('\t.data') 138 print ('\t.align\t32') 139 print ('') 140 print ('\tGLOBL_FN(__glapi_sparc_pthread_stub)') 141 print ('\tHIDDEN(__glapi_sparc_pthread_stub)') 142 print ('__glapi_sparc_pthread_stub: /* Call offset in %g3 */') 143 print ('\tmov\t%o7, %g1') 144 print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') 145 print ('\tcall\t__glapi_sparc_get_pc') 146 print ('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') 147 print ('\tmov\t%g1, %o7') 148 print ('\tsethi\t%hi(_glapi_Dispatch), %g1') 149 print ('\tor\t%g1, %lo(_glapi_Dispatch), %g1') 150 print ('\tsrl\t%g3, 10, %g3') 151 print ('\tGL_LL\t[%g2+%g1], %g2') 152 print ('\tGL_LL\t[%g2], %g1') 153 print ('\tcmp\t%g1, 0') 154 print ('\tbe\t2f') 155 print ('\t nop') 156 print ('1:\tGL_LL\t[%g1 + %g3], %g1') 157 print ('\tjmp\t%g1') 158 print ('\t nop') 159 print ('2:\tsave\t%sp, GL_STACK_SIZE, %sp') 160 print ('\tmov\t%g3, %l0') 161 print ('\tcall\t_glapi_get_dispatch') 162 print ('\t nop') 163 print ('\tmov\t%o0, %g1') 164 print ('\tmov\t%l0, %g3') 165 print ('\tba\t1b') 166 print ('\t restore %g0, %g0, %g0') 167 print ('\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub') 168 print ('') 169 print ('#define GL_STUB(fn, off)\t\t\t\\') 170 print ('\tGLOBL_FN(fn);\t\t\t\t\\') 171 print ('fn:\tba\t__glapi_sparc_pthread_stub;\t\\') 172 print ('\t sethi\tGL_OFF(off), %g3;\t\t\\') 173 print ('\t.size\tfn,.-fn;') 174 print ('') 175 print ('#else /* Non-threaded version. */') 176 print ('') 177 print ('\t.type __glapi_sparc_nothread_stub, @function') 178 print ('__glapi_sparc_nothread_stub: /* Call offset in %g3 */') 179 print ('\tmov\t%o7, %g1') 180 print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') 181 print ('\tcall\t__glapi_sparc_get_pc') 182 print ('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') 183 print ('\tmov\t%g1, %o7') 184 print ('\tsrl\t%g3, 10, %g3') 185 print ('\tsethi\t%hi(_glapi_Dispatch), %g1') 186 print ('\tor\t%g1, %lo(_glapi_Dispatch), %g1') 187 print ('\tGL_LL\t[%g2+%g1], %g2') 188 print ('\tGL_LL\t[%g2], %g1') 189 print ('\tGL_LL\t[%g1 + %g3], %g1') 190 print ('\tjmp\t%g1') 191 print ('\t nop') 192 print ('\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub') 193 print ('') 194 print ('#define GL_STUB(fn, off)\t\t\t\\') 195 print ('\tGLOBL_FN(fn);\t\t\t\t\\') 196 print ('fn:\tba\t__glapi_sparc_nothread_stub;\t\\') 197 print ('\t sethi\tGL_OFF(off), %g3;\t\t\\') 198 print ('\t.size\tfn,.-fn;') 199 print ('') 200 print ('#endif') 201 print ('') 202 print ('#define GL_STUB_ALIAS(fn, alias) \\') 203 print (' .globl fn; \\') 204 print (' .set fn, alias') 205 print ('') 206 print ('\t.text') 207 print ('\t.align\t32') 208 print ('') 209 print ('\t.globl\tgl_dispatch_functions_start') 210 print ('\tHIDDEN(gl_dispatch_functions_start)') 211 print ('gl_dispatch_functions_start:') 212 print ('') 213 213 return 214 214 215 215 def printRealFooter(self): 216 print ''217 print '\t.globl\tgl_dispatch_functions_end'218 print '\tHIDDEN(gl_dispatch_functions_end)'219 print 'gl_dispatch_functions_end:'216 print ('') 217 print ('\t.globl\tgl_dispatch_functions_end') 218 print ('\tHIDDEN(gl_dispatch_functions_end)') 219 print ('gl_dispatch_functions_end:') 220 220 return 221 221 222 222 def printBody(self, api): 223 223 for f in api.functionIterateByOffset(): 224 224 name = f.dispatch_name() 225 225 226 print '\tGL_STUB(gl%s, _gloffset_%s)' % (name, f.name)226 print ('\tGL_STUB(gl%s, _gloffset_%s)' % (name, f.name)) 227 227 228 228 if not f.is_static_entry_point(f.name): 229 print '\tHIDDEN(gl%s)' % (name)229 print ('\tHIDDEN(gl%s)' % (name)) 230 230 231 231 for f in api.functionIterateByOffset(): 232 232 name = f.dispatch_name() … … 237 237 text = '\tGL_STUB_ALIAS(gl%s, gl%s)' % (n, f.name) 238 238 239 239 if f.has_different_protocol(n): 240 print '#ifndef GLX_INDIRECT_RENDERING'241 print text242 print '#endif'240 print ('#ifndef GLX_INDIRECT_RENDERING') 241 print (text) 242 print ('#endif') 243 243 else: 244 print text244 print (text) 245 245 246 246 return 247 247 248 248 249 249 def show_usage(): 250 print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]250 print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]) 251 251 sys.exit(1) 252 252 253 253 if __name__ == '__main__': … … 268 268 if mode == "generic": 269 269 printer = PrintGenericStubs() 270 270 else: 271 print "ERROR: Invalid mode \"%s\" specified." % mode271 print ("ERROR: Invalid mode \"%s\" specified." % mode) 272 272 show_usage() 273 273 274 274 api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) -
Mesa-7.8.2/src/mesa/glapi/gen/gl_table.py
old new 45 45 def printBody(self, api): 46 46 for f in api.functionIterateByOffset(): 47 47 arg_string = f.get_parameter_string() 48 print ' %s (GLAPIENTRYP %s)(%s); /* %d */' % (f.return_type, f.name, arg_string, f.offset)48 print (' %s (GLAPIENTRYP %s)(%s); /* %d */' % (f.return_type, f.name, arg_string, f.offset)) 49 49 50 50 51 51 def printRealHeader(self): 52 print '#ifndef GLAPIENTRYP'53 print '# ifndef GLAPIENTRY'54 print '# define GLAPIENTRY'55 print '# endif'56 print ''57 print '# define GLAPIENTRYP GLAPIENTRY *'58 print '#endif'59 print ''60 print ''61 print 'struct _glapi_table'62 print '{'52 print ('#ifndef GLAPIENTRYP') 53 print ('# ifndef GLAPIENTRY') 54 print ('# define GLAPIENTRY') 55 print ('# endif') 56 print ('') 57 print ('# define GLAPIENTRYP GLAPIENTRY *') 58 print ('#endif') 59 print ('') 60 print ('') 61 print ('struct _glapi_table') 62 print ('{') 63 63 return 64 64 65 65 66 66 def printRealFooter(self): 67 print '};'67 print ('};') 68 68 return 69 69 70 70 … … 80 80 81 81 82 82 def printRealHeader(self): 83 print """83 print (""" 84 84 /* this file should not be included directly in mesa */ 85 85 86 86 /** … … 93 93 * can SET_FuncName, are used to get and set the dispatch pointer for the 94 94 * named function in the specified dispatch table. 95 95 */ 96 """ 96 """) 97 97 98 98 return 99 99 100 100 def printBody(self, api): 101 print '#define CALL_by_offset(disp, cast, offset, parameters) \\'102 print ' (*(cast (GET_by_offset(disp, offset)))) parameters'103 print '#define GET_by_offset(disp, offset) \\'104 print ' (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL'105 print '#define SET_by_offset(disp, offset, fn) \\'106 print ' do { \\'107 print ' if ( (offset) < 0 ) { \\'108 print ' /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\'109 print ' /* __func__, __LINE__, disp, offset, # fn); */ \\'110 print ' /* abort(); */ \\'111 print ' } \\'112 print ' else { \\'113 print ' ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\'114 print ' } \\'115 print ' } while(0)'116 print ''101 print ('#define CALL_by_offset(disp, cast, offset, parameters) \\') 102 print (' (*(cast (GET_by_offset(disp, offset)))) parameters') 103 print ('#define GET_by_offset(disp, offset) \\') 104 print (' (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL') 105 print ('#define SET_by_offset(disp, offset, fn) \\') 106 print (' do { \\') 107 print (' if ( (offset) < 0 ) { \\') 108 print (' /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\') 109 print (' /* __func__, __LINE__, disp, offset, # fn); */ \\') 110 print (' /* abort(); */ \\') 111 print (' } \\') 112 print (' else { \\') 113 print (' ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\') 114 print (' } \\') 115 print (' } while(0)') 116 print ('') 117 117 118 118 functions = [] 119 119 abi_functions = [] … … 133 133 134 134 135 135 for f in abi_functions: 136 print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)137 print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)138 print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)136 print ('#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)) 137 print ('#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)) 138 print ('#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)) 139 139 140 140 141 print ''142 print '#if !defined(_GLAPI_USE_REMAP_TABLE)'143 print ''141 print ('') 142 print ('#if !defined(_GLAPI_USE_REMAP_TABLE)') 143 print ('') 144 144 145 145 for [f, index] in functions: 146 print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)147 print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)148 print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)149 150 print ''151 print '#else'152 print ''153 print '#define driDispatchRemapTable_size %u' % (count)154 print 'extern int driDispatchRemapTable[ driDispatchRemapTable_size ];'155 print ''146 print ('#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)) 147 print ('#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)) 148 print ('#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)) 149 150 print ('') 151 print ('#else') 152 print ('') 153 print ('#define driDispatchRemapTable_size %u' % (count)) 154 print ('extern int driDispatchRemapTable[ driDispatchRemapTable_size ];') 155 print ('') 156 156 157 157 for [f, index] in functions: 158 print '#define %s_remap_index %u' % (f.name, index)158 print ('#define %s_remap_index %u' % (f.name, index)) 159 159 160 print ''160 print ('') 161 161 162 162 for [f, index] in functions: 163 163 arg_string = gl_XML.create_parameter_string( f.parameters, 0 ) 164 164 cast = '%s (GLAPIENTRYP)(%s)' % (f.return_type, arg_string) 165 165 166 print '#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name)167 print '#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name)168 print '#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name)166 print ('#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name)) 167 print ('#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name)) 168 print ('#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name)) 169 169 170 170 171 print ''172 print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'171 print ('') 172 print ('#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */') 173 173 174 174 if alias_functions: 175 print ''176 print '/* define aliases for compatibility */'175 print ('') 176 print ('/* define aliases for compatibility */') 177 177 for f in alias_functions: 178 178 for name in f.entry_points: 179 179 if name != f.name: 180 print '#define CALL_%s(disp, parameters) CALL_%s(disp, parameters)' % (name, f.name)181 print '#define GET_%s(disp) GET_%s(disp)' % (name, f.name)182 print '#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name)183 print ''180 print ('#define CALL_%s(disp, parameters) CALL_%s(disp, parameters)' % (name, f.name)) 181 print ('#define GET_%s(disp) GET_%s(disp)' % (name, f.name)) 182 print ('#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name)) 183 print ('') 184 184 185 print '#if defined(_GLAPI_USE_REMAP_TABLE)'185 print ('#if defined(_GLAPI_USE_REMAP_TABLE)') 186 186 for f in alias_functions: 187 187 for name in f.entry_points: 188 188 if name != f.name: 189 print '#define %s_remap_index %s_remap_index' % (name, f.name)190 print '#endif /* defined(_GLAPI_USE_REMAP_TABLE) */'191 print ''189 print ('#define %s_remap_index %s_remap_index' % (name, f.name)) 190 print ('#endif /* defined(_GLAPI_USE_REMAP_TABLE) */') 191 print ('') 192 192 193 193 return 194 194 195 195 196 196 def show_usage(): 197 print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]198 print " -m mode Mode can be 'table' or 'remap_table'."199 print " -c Enable compatibility with OpenGL ES."197 print ("Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]) 198 print (" -m mode Mode can be 'table' or 'remap_table'.") 199 print (" -c Enable compatibility with OpenGL ES.") 200 200 sys.exit(1) 201 201 202 202 if __name__ == '__main__': -
Mesa-7.8.2/src/mesa/glapi/gen/gl_x86-64_asm.py
old new 53 53 adjust_stack = 0 54 54 if not should_use_push(registers): 55 55 adjust_stack = local_size(registers) 56 print '\tsubq\t$%u, %%rsp' % (adjust_stack)56 print ('\tsubq\t$%u, %%rsp' % (adjust_stack)) 57 57 58 58 for [reg, stack_offset] in registers: 59 59 save_reg( reg, stack_offset, adjust_stack ) … … 71 71 restore_reg(reg, stack_offset, adjust_stack) 72 72 73 73 if adjust_stack: 74 print '\taddq\t$%u, %%rsp' % (adjust_stack)74 print ('\taddq\t$%u, %%rsp' % (adjust_stack)) 75 75 return 76 76 77 77 78 78 def save_reg(reg, offset, use_move): 79 79 if use_move: 80 80 if offset == 0: 81 print '\tmovq\t%s, (%%rsp)' % (reg)81 print ('\tmovq\t%s, (%%rsp)' % (reg)) 82 82 else: 83 print '\tmovq\t%s, %u(%%rsp)' % (reg, offset)83 print ('\tmovq\t%s, %u(%%rsp)' % (reg, offset)) 84 84 else: 85 print '\tpushq\t%s' % (reg)85 print ('\tpushq\t%s' % (reg)) 86 86 87 87 return 88 88 … … 90 90 def restore_reg(reg, offset, use_move): 91 91 if use_move: 92 92 if offset == 0: 93 print '\tmovq\t(%%rsp), %s' % (reg)93 print ('\tmovq\t(%%rsp), %s' % (reg)) 94 94 else: 95 print '\tmovq\t%u(%%rsp), %s' % (offset, reg)95 print ('\tmovq\t%u(%%rsp), %s' % (offset, reg)) 96 96 else: 97 print '\tpopq\t%s' % (reg)97 print ('\tpopq\t%s' % (reg)) 98 98 99 99 return 100 100 … … 118 118 119 119 120 120 def printRealHeader(self): 121 print "/* If we build with gcc's -fvisibility=hidden flag, we'll need to change"122 print " * the symbol visibility mode to 'default'."123 print ' */'124 print ''125 print '#include "x86/assyntax.h"'126 print ''127 print '#ifdef __GNUC__'128 print '# pragma GCC visibility push(default)'129 print '# define HIDDEN(x) .hidden x'130 print '#else'131 print '# define HIDDEN(x)'132 print '#endif'133 print ''134 print '# if defined(USE_MGL_NAMESPACE)'135 print '# define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))'136 print '# define _glapi_Dispatch _mglapi_Dispatch'137 print '# else'138 print '# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'139 print '# endif'140 print ''141 print '#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'142 print '# define THREADS'143 print '#endif'144 print ''145 print '\t.text'146 print ''147 print '#ifdef GLX_USE_TLS'148 print ''149 print '\t.globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)'150 print '_x86_64_get_get_dispatch:'151 print '\tlea\t_x86_64_get_dispatch(%rip), %rax'152 print '\tret'153 print ''154 print '\t.p2align\t4,,15'155 print '_x86_64_get_dispatch:'156 print '\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax'157 print '\tmovq\t%fs:(%rax), %rax'158 print '\tret'159 print '\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch'160 print ''161 print '#elif defined(PTHREADS)'162 print ''163 print '\t.extern\t_glapi_Dispatch'164 print '\t.extern\t_gl_DispatchTSD'165 print '\t.extern\tpthread_getspecific'166 print ''167 print '\t.p2align\t4,,15'168 print '_x86_64_get_dispatch:'169 print '\tmovq\t_gl_DispatchTSD(%rip), %rdi'170 print '\tjmp\tpthread_getspecific@PLT'171 print ''172 print '#elif defined(THREADS)'173 print ''174 print '\t.extern\t_glapi_get_dispatch'175 print ''176 print '#endif'177 print ''121 print ("/* If we build with gcc's -fvisibility=hidden flag, we'll need to change") 122 print (" * the symbol visibility mode to 'default'.") 123 print (' */') 124 print ('') 125 print ('#include "x86/assyntax.h"') 126 print ('') 127 print ('#ifdef __GNUC__') 128 print ('# pragma GCC visibility push(default)') 129 print ('# define HIDDEN(x) .hidden x') 130 print ('#else') 131 print ('# define HIDDEN(x)') 132 print ('#endif') 133 print ('') 134 print ('# if defined(USE_MGL_NAMESPACE)') 135 print ('# define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))') 136 print ('# define _glapi_Dispatch _mglapi_Dispatch') 137 print ('# else') 138 print ('# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))') 139 print ('# endif') 140 print ('') 141 print ('#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)') 142 print ('# define THREADS') 143 print ('#endif') 144 print ('') 145 print ('\t.text') 146 print ('') 147 print ('#ifdef GLX_USE_TLS') 148 print ('') 149 print ('\t.globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)') 150 print ('_x86_64_get_get_dispatch:') 151 print ('\tlea\t_x86_64_get_dispatch(%rip), %rax') 152 print ('\tret') 153 print ('') 154 print ('\t.p2align\t4,,15') 155 print ('_x86_64_get_dispatch:') 156 print ('\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax') 157 print ('\tmovq\t%fs:(%rax), %rax') 158 print ('\tret') 159 print ('\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch') 160 print ('') 161 print ('#elif defined(PTHREADS)') 162 print ('') 163 print ('\t.extern\t_glapi_Dispatch') 164 print ('\t.extern\t_gl_DispatchTSD') 165 print ('\t.extern\tpthread_getspecific') 166 print ('') 167 print ('\t.p2align\t4,,15') 168 print ('_x86_64_get_dispatch:') 169 print ('\tmovq\t_gl_DispatchTSD(%rip), %rdi') 170 print ('\tjmp\tpthread_getspecific@PLT') 171 print ('') 172 print ('#elif defined(THREADS)') 173 print ('') 174 print ('\t.extern\t_glapi_get_dispatch') 175 print ('') 176 print ('#endif') 177 print ('') 178 178 return 179 179 180 180 181 181 def printRealFooter(self): 182 print ''183 print '#if defined(GLX_USE_TLS) && defined(__linux__)'184 print ' .section ".note.ABI-tag", "a"'185 print ' .p2align 2'186 print ' .long 1f - 0f /* name length */'187 print ' .long 3f - 2f /* data length */'188 print ' .long 1 /* note length */'189 print '0: .asciz "GNU" /* vendor name */'190 print '1: .p2align 2'191 print '2: .long 0 /* note data: the ABI tag */'192 print ' .long 2,4,20 /* Minimum kernel version w/TLS */'193 print '3: .p2align 2 /* pad out section */'194 print '#endif /* GLX_USE_TLS */'195 print ''196 print '#if defined (__ELF__) && defined (__linux__)'197 print ' .section .note.GNU-stack,"",%progbits'198 print '#endif'182 print ('') 183 print ('#if defined(GLX_USE_TLS) && defined(__linux__)') 184 print (' .section ".note.ABI-tag", "a"') 185 print (' .p2align 2') 186 print (' .long 1f - 0f /* name length */') 187 print (' .long 3f - 2f /* data length */') 188 print (' .long 1 /* note length */') 189 print ('0: .asciz "GNU" /* vendor name */') 190 print ('1: .p2align 2') 191 print ('2: .long 0 /* note data: the ABI tag */') 192 print (' .long 2,4,20 /* Minimum kernel version w/TLS */') 193 print ('3: .p2align 2 /* pad out section */') 194 print ('#endif /* GLX_USE_TLS */') 195 print ('') 196 print ('#if defined (__ELF__) && defined (__linux__)') 197 print (' .section .note.GNU-stack,"",%progbits') 198 print ('#endif') 199 199 return 200 200 201 201 … … 240 240 241 241 name = f.dispatch_name() 242 242 243 print '\t.p2align\t4,,15'244 print '\t.globl\tGL_PREFIX(%s)' % (name)245 print '\t.type\tGL_PREFIX(%s), @function' % (name)243 print ('\t.p2align\t4,,15') 244 print ('\t.globl\tGL_PREFIX(%s)' % (name)) 245 print ('\t.type\tGL_PREFIX(%s), @function' % (name)) 246 246 if not f.is_static_entry_point(f.name): 247 print '\tHIDDEN(GL_PREFIX(%s))' % (name)248 print 'GL_PREFIX(%s):' % (name)249 print '#if defined(GLX_USE_TLS)'250 print '\tcall\t_x86_64_get_dispatch@PLT'251 print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)252 print '\tjmp\t*%r11'253 print '#elif defined(PTHREADS)'247 print ('\tHIDDEN(GL_PREFIX(%s))' % (name)) 248 print ('GL_PREFIX(%s):' % (name)) 249 print ('#if defined(GLX_USE_TLS)') 250 print ('\tcall\t_x86_64_get_dispatch@PLT') 251 print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) 252 print ('\tjmp\t*%r11') 253 print ('#elif defined(PTHREADS)') 254 254 255 255 save_all_regs(registers) 256 print '\tcall\t_x86_64_get_dispatch@PLT'256 print ('\tcall\t_x86_64_get_dispatch@PLT') 257 257 restore_all_regs(registers) 258 258 259 259 if f.offset == 0: 260 print '\tmovq\t(%rax), %r11'260 print ('\tmovq\t(%rax), %r11') 261 261 else: 262 print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)262 print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) 263 263 264 print '\tjmp\t*%r11'264 print ('\tjmp\t*%r11') 265 265 266 print '#else'267 print '\tmovq\t_glapi_Dispatch(%rip), %rax'268 print '\ttestq\t%rax, %rax'269 print '\tje\t1f'270 print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)271 print '\tjmp\t*%r11'272 print '1:'266 print ('#else') 267 print ('\tmovq\t_glapi_Dispatch(%rip), %rax') 268 print ('\ttestq\t%rax, %rax') 269 print ('\tje\t1f') 270 print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) 271 print ('\tjmp\t*%r11') 272 print ('1:') 273 273 274 274 save_all_regs(registers) 275 print '\tcall\t_glapi_get_dispatch'275 print ('\tcall\t_glapi_get_dispatch') 276 276 restore_all_regs(registers) 277 277 278 print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)279 print '\tjmp\t*%r11'280 print '#endif /* defined(GLX_USE_TLS) */'278 print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) 279 print ('\tjmp\t*%r11') 280 print ('#endif /* defined(GLX_USE_TLS) */') 281 281 282 print '\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name)283 print ''282 print ('\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name)) 283 print ('') 284 284 return 285 285 286 286 … … 297 297 text = '\t.globl GL_PREFIX(%s) ; .set GL_PREFIX(%s), GL_PREFIX(%s)' % (n, n, dispatch) 298 298 299 299 if f.has_different_protocol(n): 300 print '#ifndef GLX_INDIRECT_RENDERING'301 print text302 print '#endif'300 print ('#ifndef GLX_INDIRECT_RENDERING') 301 print (text) 302 print ('#endif') 303 303 else: 304 print text304 print (text) 305 305 306 306 return 307 307 308 308 def show_usage(): 309 print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]309 print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]) 310 310 sys.exit(1) 311 311 312 312 if __name__ == '__main__': … … 327 327 if mode == "generic": 328 328 printer = PrintGenericStubs() 329 329 else: 330 print "ERROR: Invalid mode \"%s\" specified." % mode330 print ("ERROR: Invalid mode \"%s\" specified." % mode) 331 331 show_usage() 332 332 333 333 api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) -
Mesa-7.8.2/src/mesa/glapi/gen/gl_x86_asm.py
old new 53 53 54 54 55 55 def printRealHeader(self): 56 print '#include "x86/assyntax.h"'57 print '#include "glapi/glapioffsets.h"'58 print ''59 print '#if defined(STDCALL_API)'60 print '# if defined(USE_MGL_NAMESPACE)'61 print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))'62 print '# else'63 print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))'64 print '# endif'65 print '#else'66 print '# if defined(USE_MGL_NAMESPACE)'67 print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))'68 print '# define _glapi_Dispatch _mglapi_Dispatch'69 print '# else'70 print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))'71 print '# endif'72 print '#endif'73 print ''74 print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'75 print ''76 print '#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)'77 print '#define GLOBL_FN(x) GLOBL x ; .type x, function'78 print '#else'79 print '#define GLOBL_FN(x) GLOBL x'80 print '#endif'81 print ''82 print '#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'83 print '# define THREADS'84 print '#endif'85 print ''86 print '#ifdef GLX_USE_TLS'87 print ''88 print '#ifdef GLX_X86_READONLY_TEXT'89 print '# define CTX_INSNS MOV_L(GS:(EAX), EAX)'90 print '#else'91 print '# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */'92 print '#endif'93 print ''94 print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'95 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'96 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'97 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'98 print '\tCALL(_x86_get_dispatch) ;\t\t\t\\'99 print '\tCTX_INSNS ; \\'100 print '\tJMP(GL_OFFSET(off))'101 print ''102 print '#elif defined(PTHREADS)'103 print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'104 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'105 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'106 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'107 print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'108 print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'109 print '\tJE(1f) ;\t\t\t\t\t\\'110 print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'111 print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\'112 print '\tJMP(GL_OFFSET(off))'113 print '#elif defined(THREADS)'114 print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'115 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'116 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'117 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'118 print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'119 print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'120 print '\tJE(1f) ;\t\t\t\t\t\\'121 print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'122 print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\'123 print '\tJMP(GL_OFFSET(off))'124 print '#else /* Non-threaded version. */'125 print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'126 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'127 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'128 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'129 print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'130 print '\tJMP(GL_OFFSET(off))'131 print '#endif'132 print ''133 print '#ifdef HAVE_ALIAS'134 print '# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'135 print '\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\'136 print '\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)'137 print '#else'138 print '# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'139 print ' GL_STUB(fn, off, fn_alt)'140 print '#endif'141 print ''142 print 'SEG_TEXT'143 print ''144 print '#ifdef GLX_USE_TLS'145 print ''146 print '\tGLOBL\tGLNAME(_x86_get_dispatch)'147 print '\tHIDDEN(GLNAME(_x86_get_dispatch))'148 print 'ALIGNTEXT16'149 print 'GLNAME(_x86_get_dispatch):'150 print '\tcall 1f'151 print '1:\tpopl %eax'152 print '\taddl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax'153 print '\tmovl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax'154 print '\tret'155 print ''156 print '#elif defined(PTHREADS)'157 print 'EXTERN GLNAME(_glapi_Dispatch)'158 print 'EXTERN GLNAME(_gl_DispatchTSD)'159 print 'EXTERN GLNAME(pthread_getspecific)'160 print ''161 print 'ALIGNTEXT16'162 print 'GLNAME(_x86_get_dispatch):'163 print '\tSUB_L(CONST(24), ESP)'164 print '\tPUSH_L(GLNAME(_gl_DispatchTSD))'165 print '\tCALL(GLNAME(pthread_getspecific))'166 print '\tADD_L(CONST(28), ESP)'167 print '\tRET'168 print '#elif defined(THREADS)'169 print 'EXTERN GLNAME(_glapi_get_dispatch)'170 print '#endif'171 print ''172 173 print '#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )'174 print '\t\t.section\twtext, "awx", @progbits'175 print '#endif /* defined( GLX_USE_TLS ) */'176 177 print ''178 print '\t\tALIGNTEXT16'179 print '\t\tGLOBL GLNAME(gl_dispatch_functions_start)'180 print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))'181 print 'GLNAME(gl_dispatch_functions_start):'182 print ''56 print ('#include "x86/assyntax.h"') 57 print ('#include "glapi/glapioffsets.h"') 58 print ('') 59 print ('#if defined(STDCALL_API)') 60 print ('# if defined(USE_MGL_NAMESPACE)') 61 print ('# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))') 62 print ('# else') 63 print ('# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))') 64 print ('# endif') 65 print ('#else') 66 print ('# if defined(USE_MGL_NAMESPACE)') 67 print ('# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))') 68 print ('# define _glapi_Dispatch _mglapi_Dispatch') 69 print ('# else') 70 print ('# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))') 71 print ('# endif') 72 print ('#endif') 73 print ('') 74 print ('#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))') 75 print ('') 76 print ('#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)') 77 print ('#define GLOBL_FN(x) GLOBL x ; .type x, function') 78 print ('#else') 79 print ('#define GLOBL_FN(x) GLOBL x') 80 print ('#endif') 81 print ('') 82 print ('#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)') 83 print ('# define THREADS') 84 print ('#endif') 85 print ('') 86 print ('#ifdef GLX_USE_TLS') 87 print ('') 88 print ('#ifdef GLX_X86_READONLY_TEXT') 89 print ('# define CTX_INSNS MOV_L(GS:(EAX), EAX)') 90 print ('#else') 91 print ('# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */') 92 print ('#endif') 93 print ('') 94 print ('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') 95 print ('ALIGNTEXT16;\t\t\t\t\t\t\\') 96 print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') 97 print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') 98 print ('\tCALL(_x86_get_dispatch) ;\t\t\t\\') 99 print ('\tCTX_INSNS ; \\') 100 print ('\tJMP(GL_OFFSET(off))') 101 print ('') 102 print ('#elif defined(PTHREADS)') 103 print ('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') 104 print ('ALIGNTEXT16;\t\t\t\t\t\t\\') 105 print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') 106 print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') 107 print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\') 108 print ('\tTEST_L(EAX, EAX) ;\t\t\t\t\\') 109 print ('\tJE(1f) ;\t\t\t\t\t\\') 110 print ('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\') 111 print ('1:\tCALL(_x86_get_dispatch) ;\t\t\t\\') 112 print ('\tJMP(GL_OFFSET(off))') 113 print ('#elif defined(THREADS)') 114 print ('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') 115 print ('ALIGNTEXT16;\t\t\t\t\t\t\\') 116 print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') 117 print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') 118 print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\') 119 print ('\tTEST_L(EAX, EAX) ;\t\t\t\t\\') 120 print ('\tJE(1f) ;\t\t\t\t\t\\') 121 print ('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\') 122 print ('1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\') 123 print ('\tJMP(GL_OFFSET(off))') 124 print ('#else /* Non-threaded version. */') 125 print ('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') 126 print ('ALIGNTEXT16;\t\t\t\t\t\t\\') 127 print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') 128 print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') 129 print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\') 130 print ('\tJMP(GL_OFFSET(off))') 131 print ('#endif') 132 print ('') 133 print ('#ifdef HAVE_ALIAS') 134 print ('# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\') 135 print ('\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\') 136 print ('\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)') 137 print ('#else') 138 print ('# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\') 139 print (' GL_STUB(fn, off, fn_alt)') 140 print ('#endif') 141 print ('') 142 print ('SEG_TEXT') 143 print ('') 144 print ('#ifdef GLX_USE_TLS') 145 print ('') 146 print ('\tGLOBL\tGLNAME(_x86_get_dispatch)') 147 print ('\tHIDDEN(GLNAME(_x86_get_dispatch))') 148 print ('ALIGNTEXT16') 149 print ('GLNAME(_x86_get_dispatch):') 150 print ('\tcall 1f') 151 print ('1:\tpopl %eax') 152 print ('\taddl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax') 153 print ('\tmovl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax') 154 print ('\tret') 155 print ('') 156 print ('#elif defined(PTHREADS)') 157 print ('EXTERN GLNAME(_glapi_Dispatch)') 158 print ('EXTERN GLNAME(_gl_DispatchTSD)') 159 print ('EXTERN GLNAME(pthread_getspecific)') 160 print ('') 161 print ('ALIGNTEXT16') 162 print ('GLNAME(_x86_get_dispatch):') 163 print ('\tSUB_L(CONST(24), ESP)') 164 print ('\tPUSH_L(GLNAME(_gl_DispatchTSD))') 165 print ('\tCALL(GLNAME(pthread_getspecific))') 166 print ('\tADD_L(CONST(28), ESP)') 167 print ('\tRET') 168 print ('#elif defined(THREADS)') 169 print ('EXTERN GLNAME(_glapi_get_dispatch)') 170 print ('#endif') 171 print ('') 172 173 print ('#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )') 174 print ('\t\t.section\twtext, "awx", @progbits') 175 print ('#endif /* defined( GLX_USE_TLS ) */') 176 177 print ('') 178 print ('\t\tALIGNTEXT16') 179 print ('\t\tGLOBL GLNAME(gl_dispatch_functions_start)') 180 print ('\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))') 181 print ('GLNAME(gl_dispatch_functions_start):') 182 print ('') 183 183 return 184 184 185 185 186 186 def printRealFooter(self): 187 print ''188 print '\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)'189 print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))'190 print '\t\tALIGNTEXT16'191 print 'GLNAME(gl_dispatch_functions_end):'192 print ''193 print '#if defined(GLX_USE_TLS) && defined(__linux__)'194 print ' .section ".note.ABI-tag", "a"'195 print ' .p2align 2'196 print ' .long 1f - 0f /* name length */'197 print ' .long 3f - 2f /* data length */'198 print ' .long 1 /* note length */'199 print '0: .asciz "GNU" /* vendor name */'200 print '1: .p2align 2'201 print '2: .long 0 /* note data: the ABI tag */'202 print ' .long 2,4,20 /* Minimum kernel version w/TLS */'203 print '3: .p2align 2 /* pad out section */'204 print '#endif /* GLX_USE_TLS */'205 print ''206 print '#if defined (__ELF__) && defined (__linux__)'207 print ' .section .note.GNU-stack,"",%progbits'208 print '#endif'187 print ('') 188 print ('\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)') 189 print ('\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))') 190 print ('\t\tALIGNTEXT16') 191 print ('GLNAME(gl_dispatch_functions_end):') 192 print ('') 193 print ('#if defined(GLX_USE_TLS) && defined(__linux__)') 194 print (' .section ".note.ABI-tag", "a"') 195 print (' .p2align 2') 196 print (' .long 1f - 0f /* name length */') 197 print (' .long 3f - 2f /* data length */') 198 print (' .long 1 /* note length */') 199 print ('0: .asciz "GNU" /* vendor name */') 200 print ('1: .p2align 2') 201 print ('2: .long 0 /* note data: the ABI tag */') 202 print (' .long 2,4,20 /* Minimum kernel version w/TLS */') 203 print ('3: .p2align 2 /* pad out section */') 204 print ('#endif /* GLX_USE_TLS */') 205 print ('') 206 print ('#if defined (__ELF__) && defined (__linux__)') 207 print (' .section .note.GNU-stack,"",%progbits') 208 print ('#endif') 209 209 return 210 210 211 211 … … 215 215 stack = self.get_stack_size(f) 216 216 alt = "%s@%u" % (name, stack) 217 217 218 print '\tGL_STUB(%s, _gloffset_%s, %s)' % (name, f.name, alt)218 print ('\tGL_STUB(%s, _gloffset_%s, %s)' % (name, f.name, alt)) 219 219 220 220 if not f.is_static_entry_point(f.name): 221 print '\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt)221 print ('\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt)) 222 222 223 223 224 224 for f in api.functionIterateByOffset(): … … 233 233 text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, name, alt) 234 234 235 235 if f.has_different_protocol(n): 236 print '#ifndef GLX_INDIRECT_RENDERING'237 print text238 print '#endif'236 print ('#ifndef GLX_INDIRECT_RENDERING') 237 print (text) 238 print ('#endif') 239 239 else: 240 print text240 print (text) 241 241 242 242 return 243 243 244 244 def show_usage(): 245 print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]245 print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]) 246 246 sys.exit(1) 247 247 248 248 if __name__ == '__main__': … … 263 263 if mode == "generic": 264 264 printer = PrintGenericStubs() 265 265 else: 266 print "ERROR: Invalid mode \"%s\" specified." % mode266 print ("ERROR: Invalid mode \"%s\" specified." % mode) 267 267 show_usage() 268 268 269 269 api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) -
Mesa-7.8.2/src/mesa/glapi/gen/gl_XML.py
old new 127 127 def printHeader(self): 128 128 """Print the header associated with all files and call the printRealHeader method.""" 129 129 130 print '/* DO NOT EDIT - This file generated automatically by %s script */' \130 print ('/* DO NOT EDIT - This file generated automatically by %s script */' \) 131 131 % (self.name) 132 print ''133 print '/*'134 print ' * ' + self.license.replace('\n', '\n * ')135 print ' */'136 print ''132 print ('') 133 print ('/*') 134 print (' * ' + self.license.replace('\n', '\n * ')) 135 print (' */') 136 print ('') 137 137 if self.header_tag: 138 print '#if !defined( %s )' % (self.header_tag)139 print '# define %s' % (self.header_tag)140 print ''138 print ('#if !defined( %s )' % (self.header_tag)) 139 print ('# define %s' % (self.header_tag)) 140 print ('') 141 141 self.printRealHeader(); 142 142 return 143 143 … … 148 148 self.printRealFooter() 149 149 150 150 if self.undef_list: 151 print ''151 print ('') 152 152 for u in self.undef_list: 153 print "# undef %s" % (u)153 print ("# undef %s" % (u)) 154 154 155 155 if self.header_tag: 156 print ''157 print '#endif /* !defined( %s ) */' % (self.header_tag)156 print ('') 157 print ('#endif /* !defined( %s ) */' % (self.header_tag)) 158 158 159 159 160 160 def printRealHeader(self): … … 184 184 The name is also added to the file's undef_list. 185 185 """ 186 186 self.undef_list.append("PURE") 187 print """# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))187 print ("""# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) 188 188 # define PURE __attribute__((pure)) 189 189 # else 190 190 # define PURE … … 204 204 """ 205 205 206 206 self.undef_list.append("FASTCALL") 207 print """# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)207 print ("""# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)) 208 208 # define FASTCALL __attribute__((fastcall)) 209 209 # else 210 210 # define FASTCALL … … 224 224 """ 225 225 226 226 self.undef_list.append(S) 227 print """# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__)227 print ("""# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__)) 228 228 # define %s __attribute__((visibility("%s"))) 229 229 # else 230 230 # define %s … … 244 244 """ 245 245 246 246 self.undef_list.append("NOINLINE") 247 print """# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))247 print ("""# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) 248 248 # define NOINLINE __attribute__((noinline)) 249 249 # else 250 250 # define NOINLINE … … 435 435 elements = 0 436 436 437 437 #if ts == "GLdouble": 438 # print '/* stack size -> %s = %u (before)*/' % (self.name, self.type_expr.get_stack_size())439 # print '/* # elements = %u */' % (elements)438 # print ('/* stack size -> %s = %u (before)*/' % (self.name, self.type_expr.get_stack_size())) 439 # print ('/* # elements = %u */' % (elements)) 440 440 self.type_expr.set_elements( elements ) 441 441 #if ts == "GLdouble": 442 # print '/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size())442 # print ('/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size())) 443 443 444 444 self.is_client_only = is_attr_true( element, 'client_only' ) 445 445 self.is_counter = is_attr_true( element, 'counter' ) … … 963 963 if type_name in self.types_by_name: 964 964 return self.types_by_name[ type_name ].type_expr 965 965 else: 966 print "Unable to find base type matching \"%s\"." % (type_name)966 print ("Unable to find base type matching \"%s\"." % (type_name)) 967 967 return None -
Mesa-7.8.2/src/mesa/glapi/gen/glX_doc.py
old new 128 128 else: 129 129 s = "%u+%s" % (size, size_str) 130 130 131 print ' 2 %-15s rendering command length' % (s)132 print ' 2 %-4u rendering command opcode' % (f.glx_rop)131 print (' 2 %-15s rendering command length' % (s)) 132 print (' 2 %-4u rendering command opcode' % (f.glx_rop)) 133 133 return 134 134 135 135 … … 140 140 if f.glx_vendorpriv != 0: 141 141 size += 1 142 142 143 print ' 1 CARD8 opcode (X assigned)'144 print ' 1 %-4u GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name())143 print (' 1 CARD8 opcode (X assigned)') 144 print (' 1 %-4u GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name())) 145 145 146 146 if size_str == "": 147 147 s = "%u" % (size) … … 150 150 else: 151 151 s = "%u+((%s)/4)" % (size, size_str) 152 152 153 print ' 2 %-15s request length' % (s)153 print (' 2 %-15s request length' % (s)) 154 154 155 155 if f.glx_vendorpriv != 0: 156 print ' 4 %-4u vendor specific opcode' % (f.opcode_value())156 print (' 4 %-4u vendor specific opcode' % (f.opcode_value())) 157 157 158 print ' 4 GLX_CONTEXT_TAG context tag'158 print (' 4 GLX_CONTEXT_TAG context tag') 159 159 160 160 return 161 161 162 162 163 163 def print_reply(self, f): 164 print ' =>'165 print ' 1 1 reply'166 print ' 1 unused'167 print ' 2 CARD16 sequence number'164 print (' =>') 165 print (' 1 1 reply') 166 print (' 1 unused') 167 print (' 2 CARD16 sequence number') 168 168 169 169 if f.output == None: 170 print ' 4 0 reply length'170 print (' 4 0 reply length') 171 171 elif f.reply_always_array: 172 print ' 4 m reply length'172 print (' 4 m reply length') 173 173 else: 174 print ' 4 m reply length, m = (n == 1 ? 0 : n)'174 print (' 4 m reply length, m = (n == 1 ? 0 : n)') 175 175 176 176 177 177 output = None … … 182 182 183 183 unused = 24 184 184 if f.return_type != 'void': 185 print ' 4 %-15s return value' % (f.return_type)185 print (' 4 %-15s return value' % (f.return_type)) 186 186 unused -= 4 187 187 elif output != None: 188 print ' 4 unused'188 print (' 4 unused') 189 189 unused -= 4 190 190 191 191 if output != None: 192 print ' 4 CARD32 n'192 print (' 4 CARD32 n') 193 193 unused -= 4 194 194 195 195 if output != None: 196 196 if not f.reply_always_array: 197 print ''198 print ' if (n = 1) this follows:'199 print ''200 print ' 4 CARD32 %s' % (output.name)201 print ' %-2u unused' % (unused - 4)202 print ''203 print ' otherwise this follows:'204 print ''197 print ('') 198 print (' if (n = 1) this follows:') 199 print ('') 200 print (' 4 CARD32 %s' % (output.name)) 201 print (' %-2u unused' % (unused - 4)) 202 print ('') 203 print (' otherwise this follows:') 204 print ('') 205 205 206 print ' %-2u unused' % (unused)206 print (' %-2u unused' % (unused)) 207 207 208 208 [s, pad] = output.packet_size() 209 print ' %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name)209 print (' %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name)) 210 210 if pad != None: 211 211 try: 212 212 bytes = int(s) 213 213 bytes = 4 - (bytes & 3) 214 print ' %-8u %-15s unused' % (bytes, "")214 print (' %-8u %-15s unused' % (bytes, "")) 215 215 except Exception,e: 216 print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)216 print (' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)) 217 217 else: 218 print ' %-2u unused' % (unused)218 print (' %-2u unused' % (unused)) 219 219 220 220 221 221 def print_body(self, f): 222 222 for p in f.parameterIterateGlxSend(): 223 223 [s, pad] = p.packet_size() 224 print ' %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name)224 print (' %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name)) 225 225 if pad != None: 226 226 try: 227 227 bytes = int(s) 228 228 bytes = 4 - (bytes & 3) 229 print ' %-8u %-15s unused' % (bytes, "")229 print (' %-8u %-15s unused' % (bytes, "")) 230 230 except Exception,e: 231 print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)231 print (' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)) 232 232 233 233 def printBody(self, api): 234 234 self.type_map = {} … … 245 245 246 246 247 247 if f.glx_rop: 248 print ' %s' % (f.name)248 print (' %s' % (f.name)) 249 249 self.print_render_header(f) 250 250 elif f.glx_sop or f.glx_vendorpriv: 251 print ' %s' % (f.name)251 print (' %s' % (f.name)) 252 252 self.print_single_header(f) 253 253 else: 254 254 continue … … 258 258 if f.needs_reply(): 259 259 self.print_reply(f) 260 260 261 print ''261 print ('') 262 262 return 263 263 264 264 -
Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_common.py
old new 84 84 85 85 compsize = self.size_call(f) 86 86 if compsize: 87 print ' const GLuint compsize = %s;' % (compsize)87 print (' const GLuint compsize = %s;' % (compsize)) 88 88 89 89 if bias: 90 print ' const GLuint cmdlen = %s - %u;' % (f.command_length(), bias)90 print (' const GLuint cmdlen = %s - %u;' % (f.command_length(), bias)) 91 91 else: 92 print ' const GLuint cmdlen = %s;' % (f.command_length())92 print (' const GLuint cmdlen = %s;' % (f.command_length())) 93 93 94 #print ''94 #print ('') 95 95 return compsize -
Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_recv.py
old new 42 42 43 43 def printRealHeader(self): 44 44 self.printVisibility( "HIDDEN", "hidden" ) 45 print 'struct __GLXclientStateRec;'46 print ''45 print ('struct __GLXclientStateRec;') 46 print ('') 47 47 return 48 48 49 49 … … 51 51 for func in api.functionIterateAll(): 52 52 if not func.ignore and not func.vectorequiv: 53 53 if func.glx_rop: 54 print 'extern HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name)55 print 'extern HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name)54 print ('extern HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name)) 55 print ('extern HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name)) 56 56 elif func.glx_sop or func.glx_vendorpriv: 57 print 'extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)58 print 'extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)57 print ('extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)) 58 print ('extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)) 59 59 60 60 if func.glx_sop and func.glx_vendorpriv: 61 61 n = func.glx_vendorpriv_names[0] 62 print 'extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)63 print 'extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)62 print ('extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)) 63 print ('extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)) 64 64 65 65 return 66 66 … … 77 77 78 78 79 79 def printRealHeader(self): 80 print '#include <X11/Xmd.h>'81 print '#include <GL/gl.h>'82 print '#include <GL/glxproto.h>'83 84 print '#include <inttypes.h>'85 print '#include "indirect_size.h"'86 print '#include "indirect_size_get.h"'87 print '#include "indirect_dispatch.h"'88 print '#include "glxserver.h"'89 print '#include "glxbyteorder.h"'90 print '#include "indirect_util.h"'91 print '#include "singlesize.h"'92 print '#include "glapi.h"'93 print '#include "glapitable.h"'94 print '#include "glthread.h"'95 print '#include "glapidispatch.h"'96 print ''97 print '#define __GLX_PAD(x) (((x) + 3) & ~3)'98 print ''99 print 'typedef struct {'100 print ' __GLX_PIXEL_3D_HDR;'101 print '} __GLXpixel3DHeader;'102 print ''103 print 'extern GLboolean __glXErrorOccured( void );'104 print 'extern void __glXClearErrorOccured( void );'105 print ''106 print 'static const unsigned dummy_answer[2] = {0, 0};'107 print ''80 print ('#include <X11/Xmd.h>') 81 print ('#include <GL/gl.h>') 82 print ('#include <GL/glxproto.h>') 83 84 print ('#include <inttypes.h>') 85 print ('#include "indirect_size.h"') 86 print ('#include "indirect_size_get.h"') 87 print ('#include "indirect_dispatch.h"') 88 print ('#include "glxserver.h"') 89 print ('#include "glxbyteorder.h"') 90 print ('#include "indirect_util.h"') 91 print ('#include "singlesize.h"') 92 print ('#include "glapi.h"') 93 print ('#include "glapitable.h"') 94 print ('#include "glthread.h"') 95 print ('#include "glapidispatch.h"') 96 print ('') 97 print ('#define __GLX_PAD(x) (((x) + 3) & ~3)') 98 print ('') 99 print ('typedef struct {') 100 print (' __GLX_PIXEL_3D_HDR;') 101 print ('} __GLXpixel3DHeader;') 102 print ('') 103 print ('extern GLboolean __glXErrorOccured( void );') 104 print ('extern void __glXClearErrorOccured( void );') 105 print ('') 106 print ('static const unsigned dummy_answer[2] = {0, 0};') 107 print ('') 108 108 return 109 109 110 110 … … 133 133 base = '__glXDispSwap' 134 134 135 135 if f.glx_rop: 136 print 'void %s_%s(GLbyte * pc)' % (base, name)136 print ('void %s_%s(GLbyte * pc)' % (base, name)) 137 137 else: 138 print 'int %s_%s(__GLXclientState *cl, GLbyte *pc)' % (base, name)138 print ('int %s_%s(__GLXclientState *cl, GLbyte *pc)' % (base, name)) 139 139 140 print '{'140 print ('{') 141 141 142 142 if f.glx_rop or f.vectorequiv: 143 143 self.printRenderFunction(f) … … 145 145 if len(f.get_images()) == 0: 146 146 self.printSingleFunction(f, name) 147 147 else: 148 print "/* Missing GLX protocol for %s. */" % (name)148 print ("/* Missing GLX protocol for %s. */" % (name)) 149 149 150 print '}'151 print ''150 print ('}') 151 print ('') 152 152 return 153 153 154 154 … … 172 172 if t.glx_name not in already_done: 173 173 real_name = self.real_types[t_size] 174 174 175 print 'static %s' % (t_name)176 print 'bswap_%s( const void * src )' % (t.glx_name)177 print '{'178 print ' union { %s dst; %s ret; } x;' % (real_name, t_name)179 print ' x.dst = bswap_%u( *(%s *) src );' % (t_size * 8, real_name)180 print ' return x.ret;'181 print '}'182 print ''175 print ('static %s' % (t_name)) 176 print ('bswap_%s( const void * src )' % (t.glx_name)) 177 print ('{') 178 print (' union { %s dst; %s ret; } x;' % (real_name, t_name)) 179 print (' x.dst = bswap_%u( *(%s *) src );' % (t_size * 8, real_name)) 180 print (' return x.ret;') 181 print ('}') 182 print ('') 183 183 already_done.append( t.glx_name ) 184 184 185 185 for bits in [16, 32, 64]: 186 print 'static void *'187 print 'bswap_%u_array( uint%u_t * src, unsigned count )' % (bits, bits)188 print '{'189 print ' unsigned i;'190 print ''191 print ' for ( i = 0 ; i < count ; i++ ) {'192 print ' uint%u_t temp = bswap_%u( src[i] );' % (bits, bits)193 print ' src[i] = temp;'194 print ' }'195 print ''196 print ' return src;'197 print '}'198 print ''186 print ('static void *') 187 print ('bswap_%u_array( uint%u_t * src, unsigned count )' % (bits, bits)) 188 print ('{') 189 print (' unsigned i;') 190 print ('') 191 print (' for ( i = 0 ; i < count ; i++ ) {') 192 print (' uint%u_t temp = bswap_%u( src[i] );' % (bits, bits)) 193 print (' src[i] = temp;') 194 print (' }') 195 print ('') 196 print (' return src;') 197 print ('}') 198 print ('') 199 199 200 200 201 201 def fetch_param(self, param): … … 237 237 238 238 239 239 if len( list ): 240 print '%s %sCALL_%s( GET_DISPATCH(), (' % (indent, retval_assign, f.name)241 print string.join( list, ",\n")242 print '%s ) );' % (indent)240 print ('%s %sCALL_%s( GET_DISPATCH(), (' % (indent, retval_assign, f.name)) 241 print (string.join( list, ",\n" )) 242 print ('%s ) );' % (indent)) 243 243 else: 244 print '%s %sCALL_%s( GET_DISPATCH(), () );' % (indent, retval_assign, f.name)244 print ('%s %sCALL_%s( GET_DISPATCH(), () );' % (indent, retval_assign, f.name)) 245 245 return 246 246 247 247 … … 266 266 # FIXME or something similar. 267 267 268 268 if param.img_null_flag: 269 print '%s const CARD32 ptr_is_null = *(CARD32 *)(pc + %s);' % (indent, param.offset - 4)269 print ('%s const CARD32 ptr_is_null = *(CARD32 *)(pc + %s);' % (indent, param.offset - 4)) 270 270 cond = '(ptr_is_null != 0) ? NULL : ' 271 271 else: 272 272 cond = "" … … 277 277 if param.is_image(): 278 278 offset = f.offset_of( param.name ) 279 279 280 print '%s %s const %s = (%s) (%s(pc + %s));' % (indent, type_string, param.name, type_string, cond, offset)280 print ('%s %s const %s = (%s) (%s(pc + %s));' % (indent, type_string, param.name, type_string, cond, offset)) 281 281 282 282 if param.depth: 283 print '%s __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);' % (indent)283 print ('%s __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);' % (indent)) 284 284 else: 285 print '%s __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);' % (indent)285 print ('%s __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);' % (indent)) 286 286 287 287 need_blank = 1 288 288 elif param.is_counter or param.name in f.count_parameter_list: 289 289 location = self.fetch_param(param) 290 print '%s const %s %s = %s;' % (indent, type_string, param.name, location)290 print ('%s const %s %s = %s;' % (indent, type_string, param.name, location)) 291 291 need_blank = 1 292 292 elif len(param.count_parameter_list): 293 293 if param.size() == 1 and not self.do_swap: 294 294 location = self.fetch_param(param) 295 print '%s %s %s = %s%s;' % (indent, type_string, param.name, cond, location)295 print ('%s %s %s = %s%s;' % (indent, type_string, param.name, cond, location)) 296 296 else: 297 print '%s %s %s;' % (indent, type_string, param.name)297 print ('%s %s %s;' % (indent, type_string, param.name)) 298 298 need_blank = 1 299 299 300 300 301 301 302 302 if need_blank: 303 print ''303 print ('') 304 304 305 305 if align64: 306 print '#ifdef __GLX_ALIGN64'306 print ('#ifdef __GLX_ALIGN64') 307 307 308 308 if f.has_variable_size_request(): 309 309 self.emit_packet_size_calculation(f, 4) … … 311 311 else: 312 312 s = str((f.command_fixed_length() + 3) & ~3) 313 313 314 print ' if ((unsigned long)(pc) & 7) {'315 print ' (void) memmove(pc-4, pc, %s);' % (s)316 print ' pc -= 4;'317 print ' }'318 print '#endif'319 print ''314 print (' if ((unsigned long)(pc) & 7) {') 315 print (' (void) memmove(pc-4, pc, %s);' % (s)) 316 print (' pc -= 4;') 317 print (' }') 318 print ('#endif') 319 print ('') 320 320 321 321 322 322 need_blank = 0 … … 341 341 x.append( [2, ['SHORT', 'UNSIGNED_SHORT']] ) 342 342 x.append( [4, ['INT', 'UNSIGNED_INT', 'FLOAT']] ) 343 343 344 print ' switch(%s) {' % (param.count_parameter_list[0])344 print (' switch(%s) {' % (param.count_parameter_list[0])) 345 345 for sub in x: 346 346 for t_name in sub[1]: 347 print ' case GL_%s:' % (t_name)347 print (' case GL_%s:' % (t_name)) 348 348 349 349 if sub[0] == 1: 350 print ' %s = (%s) (pc + %s); break;' % (param.name, param.type_string(), o)350 print (' %s = (%s) (pc + %s); break;' % (param.name, param.type_string(), o)) 351 351 else: 352 352 swap_func = self.swap_name(sub[0]) 353 print ' %s = (%s) %s( (%s *) (pc + %s), %s ); break;' % (param.name, param.type_string(), swap_func, self.real_types[sub[0]], o, count_name)354 print ' default:'355 print ' return;'356 print ' }'353 print (' %s = (%s) %s( (%s *) (pc + %s), %s ); break;' % (param.name, param.type_string(), swap_func, self.real_types[sub[0]], o, count_name)) 354 print (' default:') 355 print (' return;') 356 print (' }') 357 357 else: 358 358 swap_func = self.swap_name(type_size) 359 359 compsize = self.size_call(f, 1) 360 print ' %s = (%s) %s( (%s *) (pc + %s), %s );' % (param.name, param.type_string(), swap_func, self.real_types[type_size], o, compsize)360 print (' %s = (%s) %s( (%s *) (pc + %s), %s );' % (param.name, param.type_string(), swap_func, self.real_types[type_size], o, compsize)) 361 361 362 362 need_blank = 1 363 363 364 364 else: 365 365 for param in f.parameterIterateGlxSend(): 366 366 if param.count_parameter_list: 367 print '%s %s = (%s) (pc + %s);' % (indent, param.name, param.type_string(), param.offset)367 print ('%s %s = (%s) (pc + %s);' % (indent, param.name, param.type_string(), param.offset)) 368 368 need_blank = 1 369 369 370 370 371 371 if need_blank: 372 print ''372 print ('') 373 373 374 374 375 375 return … … 377 377 378 378 def printSingleFunction(self, f, name): 379 379 if name not in f.glx_vendorpriv_names: 380 print ' xGLXSingleReq * const req = (xGLXSingleReq *) pc;'380 print (' xGLXSingleReq * const req = (xGLXSingleReq *) pc;') 381 381 else: 382 print ' xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc;'382 print (' xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc;') 383 383 384 print ' int error;'384 print (' int error;') 385 385 386 386 if self.do_swap: 387 print ' __GLXcontext * const cx = __glXForceCurrent(cl, bswap_CARD32( &req->contextTag ), &error);'387 print (' __GLXcontext * const cx = __glXForceCurrent(cl, bswap_CARD32( &req->contextTag ), &error);') 388 388 else: 389 print ' __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, &error);'389 print (' __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, &error);') 390 390 391 print ''391 print ('') 392 392 if name not in f.glx_vendorpriv_names: 393 print ' pc += __GLX_SINGLE_HDR_SIZE;'393 print (' pc += __GLX_SINGLE_HDR_SIZE;') 394 394 else: 395 print ' pc += __GLX_VENDPRIV_HDR_SIZE;'395 print (' pc += __GLX_VENDPRIV_HDR_SIZE;') 396 396 397 print ' if ( cx != NULL ) {'397 print (' if ( cx != NULL ) {') 398 398 self.common_func_print_just_start(f, " ") 399 399 400 400 401 401 if f.return_type != 'void': 402 print ' %s retval;' % (f.return_type)402 print (' %s retval;' % (f.return_type)) 403 403 retval_string = "retval" 404 404 retval_assign = "retval = " 405 405 else: … … 427 427 428 428 429 429 if param.count_parameter_list: 430 print ' const GLuint compsize = %s;' % (self.size_call(f, 1))431 print ' %s answerBuffer[200];' % (answer_type)432 print ' %s %s = __glXGetAnswerBuffer(cl, compsize%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, size_scale, type_size)430 print (' const GLuint compsize = %s;' % (self.size_call(f, 1))) 431 print (' %s answerBuffer[200];' % (answer_type)) 432 print (' %s %s = __glXGetAnswerBuffer(cl, compsize%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, size_scale, type_size )) 433 433 answer_string = param.name 434 434 answer_count = "compsize" 435 435 436 print ''437 print ' if (%s == NULL) return BadAlloc;' % (param.name)438 print ' __glXClearErrorOccured();'439 print ''436 print ('') 437 print (' if (%s == NULL) return BadAlloc;' % (param.name)) 438 print (' __glXClearErrorOccured();') 439 print ('') 440 440 elif param.counter: 441 print ' %s answerBuffer[200];' % (answer_type)442 print ' %s %s = __glXGetAnswerBuffer(cl, %s%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, param.counter, size_scale, type_size)441 print (' %s answerBuffer[200];' % (answer_type)) 442 print (' %s %s = __glXGetAnswerBuffer(cl, %s%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, param.counter, size_scale, type_size)) 443 443 answer_string = param.name 444 444 answer_count = param.counter 445 445 elif c >= 1: 446 print ' %s %s[%u];' % (answer_type, param.name, c)446 print (' %s %s[%u];' % (answer_type, param.name, c)) 447 447 answer_string = param.name 448 448 answer_count = "%u" % (c) 449 449 … … 462 462 463 463 if type_size > 1: 464 464 swap_name = self.swap_name( type_size ) 465 print ' (void) %s( (uint%u_t *) %s, %s );' % (swap_name, 8 * type_size, param.name, answer_count)465 print (' (void) %s( (uint%u_t *) %s, %s );' % (swap_name, 8 * type_size, param.name, answer_count)) 466 466 467 467 468 468 reply_func = '__glXSendReplySwap' 469 469 else: 470 470 reply_func = '__glXSendReply' 471 471 472 print ' %s(cl->client, %s, %s, %u, %s, %s);' % (reply_func, answer_string, answer_count, type_size, is_array_string, retval_string)472 print (' %s(cl->client, %s, %s, %u, %s, %s);' % (reply_func, answer_string, answer_count, type_size, is_array_string, retval_string)) 473 473 #elif f.note_unflushed: 474 # print ' cx->hasUnflushedCommands = GL_TRUE;'474 # print (' cx->hasUnflushedCommands = GL_TRUE;') 475 475 476 print ' error = Success;'477 print ' }'478 print ''479 print ' return error;'476 print (' error = Success;') 477 print (' }') 478 print ('') 479 print (' return error;') 480 480 return 481 481 482 482 … … 505 505 # the must NEVER be byte-swapped. 506 506 507 507 if not (img.img_type == "GL_BITMAP" and img.img_format == "GL_COLOR_INDEX"): 508 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES, hdr->swapBytes) );'508 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES, hdr->swapBytes) );') 509 509 510 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_LSB_FIRST, hdr->lsbFirst) );'510 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_LSB_FIRST, hdr->lsbFirst) );') 511 511 512 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH, (GLint) %shdr->rowLength%s) );' % (pre, post)512 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH, (GLint) %shdr->rowLength%s) );' % (pre, post)) 513 513 if img.depth: 514 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_IMAGE_HEIGHT, (GLint) %shdr->imageHeight%s) );' % (pre, post)515 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, (GLint) %shdr->skipRows%s) );' % (pre, post)514 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_IMAGE_HEIGHT, (GLint) %shdr->imageHeight%s) );' % (pre, post)) 515 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, (GLint) %shdr->skipRows%s) );' % (pre, post)) 516 516 if img.depth: 517 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_IMAGES, (GLint) %shdr->skipImages%s) );' % (pre, post)518 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, (GLint) %shdr->skipPixels%s) );' % (pre, post)519 print ' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ALIGNMENT, (GLint) %shdr->alignment%s) );' % (pre, post)520 print ''517 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_IMAGES, (GLint) %shdr->skipImages%s) );' % (pre, post)) 518 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, (GLint) %shdr->skipPixels%s) );' % (pre, post)) 519 print (' CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ALIGNMENT, (GLint) %shdr->alignment%s) );' % (pre, post)) 520 print ('') 521 521 522 522 523 523 self.emit_function_call(f, "", "") -
Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_send.py
old new 161 161 return 162 162 163 163 def printRealHeader(self): 164 print ''165 print '#include <GL/gl.h>'166 print '#include "indirect.h"'167 print '#include "glxclient.h"'168 print '#include "indirect_size.h"'169 print '#include "glapidispatch.h"'170 print '#include "glapi.h"'171 print '#include "glthread.h"'172 print '#include <GL/glxproto.h>'173 print '#ifdef USE_XCB'174 print '#include <X11/Xlib-xcb.h>'175 print '#include <xcb/xcb.h>'176 print '#include <xcb/glx.h>'177 print '#endif /* USE_XCB */'178 179 print ''180 print '#define __GLX_PAD(n) (((n) + 3) & ~3)'181 print ''164 print ('') 165 print ('#include <GL/gl.h>') 166 print ('#include "indirect.h"') 167 print ('#include "glxclient.h"') 168 print ('#include "indirect_size.h"') 169 print ('#include "glapidispatch.h"') 170 print ('#include "glapi.h"') 171 print ('#include "glthread.h"') 172 print ('#include <GL/glxproto.h>') 173 print ('#ifdef USE_XCB') 174 print ('#include <X11/Xlib-xcb.h>') 175 print ('#include <xcb/xcb.h>') 176 print ('#include <xcb/glx.h>') 177 print ('#endif /* USE_XCB */') 178 179 print ('') 180 print ('#define __GLX_PAD(n) (((n) + 3) & ~3)') 181 print ('') 182 182 self.printFastcall() 183 183 self.printNoinline() 184 print ''185 print '#ifndef __GNUC__'186 print '# define __builtin_expect(x, y) x'187 print '#endif'188 print ''189 print '/* If the size and opcode values are known at compile-time, this will, on'190 print ' * x86 at least, emit them with a single instruction.'191 print ' */'192 print '#define emit_header(dest, op, size) \\'193 print ' do { union { short s[2]; int i; } temp; \\'194 print ' temp.s[0] = (size); temp.s[1] = (op); \\'195 print ' *((int *)(dest)) = temp.i; } while(0)'196 print ''197 print """NOINLINE CARD32184 print ('') 185 print ('#ifndef __GNUC__') 186 print ('# define __builtin_expect(x, y) x') 187 print ('#endif') 188 print ('') 189 print ('/* If the size and opcode values are known at compile-time, this will, on') 190 print (' * x86 at least, emit them with a single instruction.') 191 print (' */') 192 print ('#define emit_header(dest, op, size) \\') 193 print (' do { union { short s[2]; int i; } temp; \\') 194 print (' temp.s[0] = (size); temp.s[1] = (op); \\') 195 print (' *((int *)(dest)) = temp.i; } while(0)') 196 print ('') 197 print ("""NOINLINE CARD32 198 198 __glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array ) 199 199 { 200 200 xGLXSingleReply reply; … … 306 306 #define default_pixel_store_3D_size 36 307 307 #define default_pixel_store_4D (__glXDefaultPixelStore+0) 308 308 #define default_pixel_store_4D_size 36 309 """ 309 """) 310 310 311 311 for size in self.generic_sizes: 312 312 self.print_generic_function(size) … … 357 357 def printFunction(self, func, name): 358 358 footer = '}\n' 359 359 if func.glx_rop == ~0: 360 print 'static %s' % (func.return_type)361 print '%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string())362 print '{'360 print ('static %s' % (func.return_type)) 361 print ('%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string())) 362 print ('{') 363 363 else: 364 364 if func.has_different_protocol(name): 365 365 if func.return_type == "void": … … 368 368 ret_string = "return " 369 369 370 370 func_name = func.static_glx_name(name) 371 print '#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv)372 print '%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string())373 print '{'374 print ' __GLXcontext * const gc = __glXGetCurrentContext();'375 print ''376 print '#ifdef GLX_DIRECT_RENDERING'377 print ' if (gc->driContext) {'378 print ' %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())379 print ' } else'380 print '#endif'381 print ' {'371 print ('#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv)) 372 print ('%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string())) 373 print ('{') 374 print (' __GLXcontext * const gc = __glXGetCurrentContext();') 375 print ('') 376 print ('#ifdef GLX_DIRECT_RENDERING') 377 print (' if (gc->driContext) {') 378 print (' %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())) 379 print (' } else') 380 print ('#endif') 381 print (' {') 382 382 383 383 footer = '}\n}\n' 384 384 else: 385 print '#define %s %d' % (func.opcode_name(), func.opcode_value())385 print ('#define %s %d' % (func.opcode_name(), func.opcode_value())) 386 386 387 print '%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string())388 print '{'387 print ('%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string())) 388 print ('{') 389 389 390 390 391 391 if func.glx_rop != 0 or func.vectorequiv != None: … … 397 397 self.printSingleFunction(func, name) 398 398 pass 399 399 else: 400 print "/* Missing GLX protocol for %s. */" % (name)400 print ("/* Missing GLX protocol for %s. */" % (name)) 401 401 402 print footer402 print (footer) 403 403 return 404 404 405 405 406 406 def print_generic_function(self, n): 407 407 size = (n + 3) & ~3 408 print """static FASTCALL NOINLINE void408 print ("""static FASTCALL NOINLINE void 409 409 generic_%u_byte( GLint rop, const void * ptr ) 410 410 { 411 411 __GLXcontext * const gc = __glXGetCurrentContext(); … … 416 416 gc->pc += cmdlen; 417 417 if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); } 418 418 } 419 """ % (n, size + 4, size) 419 """ % (n, size + 4, size)) 420 420 return 421 421 422 422 … … 427 427 src_ptr = "&" + p.name 428 428 429 429 if p.is_padding: 430 print '(void) memset((void *)(%s + %u), 0, %s);' \431 % (pc, p.offset + adjust, p.size_string() ) 430 print ('(void) memset((void *)(%s + %u), 0, %s);' \ 431 % (pc, p.offset + adjust, p.size_string() )) 432 432 elif not extra_offset: 433 print '(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \434 % (pc, p.offset + adjust, src_ptr, p.size_string() ) 433 print ('(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \ 434 % (pc, p.offset + adjust, src_ptr, p.size_string() )) 435 435 else: 436 print '(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \437 % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() ) 436 print ('(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \ 437 % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() )) 438 438 439 439 def common_emit_args(self, f, pc, adjust, skip_vla): 440 440 extra_offset = None … … 470 470 self.common_emit_one_arg(param, pc, adjust, None) 471 471 472 472 if f.pad_after(param): 473 print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust)473 print ('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust)) 474 474 475 475 else: 476 476 [dim, width, height, depth, extent] = param.get_dimensions() … … 480 480 dim_str = str(dim) 481 481 482 482 if param.is_padding: 483 print '(void) memset((void *)(%s + %u), 0, %s);' \484 % (pc, (param.offset - 4) + adjust, param.size_string() ) 483 print ('(void) memset((void *)(%s + %u), 0, %s);' \ 484 % (pc, (param.offset - 4) + adjust, param.size_string() )) 485 485 486 486 if param.img_null_flag: 487 487 if large: 488 print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust)488 print ('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust)) 489 489 else: 490 print '(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name)490 print ('(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name)) 491 491 492 492 493 493 pixHeaderPtr = "%s + %u" % (pc, adjust) … … 499 499 else: 500 500 condition = 'compsize > 0' 501 501 502 print 'if (%s) {' % (condition)503 print ' (*gc->fillImage)(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)504 print '} else {'505 print ' (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim)506 print '}'502 print ('if (%s) {' % (condition)) 503 print (' (*gc->fillImage)(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)) 504 print ('} else {') 505 print (' (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim)) 506 print ('}') 507 507 else: 508 print '__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)508 print ('__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)) 509 509 510 510 return 511 511 … … 514 514 if not op_name: 515 515 op_name = f.opcode_real_name() 516 516 517 print 'const GLint op = %s;' % (op_name)518 print 'const GLuint cmdlenLarge = cmdlen + 4;'519 print 'GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);'520 print '(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);'521 print '(void) memcpy((void *)(pc + 4), (void *)(&op), 4);'517 print ('const GLint op = %s;' % (op_name)) 518 print ('const GLuint cmdlenLarge = cmdlen + 4;') 519 print ('GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);') 520 print ('(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);') 521 print ('(void) memcpy((void *)(pc + 4), (void *)(&op), 4);') 522 522 return 523 523 524 524 525 525 def common_func_print_just_start(self, f, name): 526 print ' __GLXcontext * const gc = __glXGetCurrentContext();'526 print (' __GLXcontext * const gc = __glXGetCurrentContext();') 527 527 528 528 # The only reason that single and vendor private commands need 529 529 # a variable called 'dpy' is becuase they use the SyncHandle … … 541 541 if not f.glx_rop: 542 542 for p in f.parameterIterateOutputs(): 543 543 if p.is_image() and (p.img_format != "GL_COLOR_INDEX" or p.img_type != "GL_BITMAP"): 544 print ' const __GLXattribute * const state = gc->client_state_private;'544 print (' const __GLXattribute * const state = gc->client_state_private;') 545 545 break 546 546 547 print ' Display * const dpy = gc->currentDpy;'547 print (' Display * const dpy = gc->currentDpy;') 548 548 skip_condition = "dpy != NULL" 549 549 elif f.can_be_large: 550 550 skip_condition = "gc->currentDpy != NULL" … … 553 553 554 554 555 555 if f.return_type != 'void': 556 print ' %s retval = (%s) 0;' % (f.return_type, f.return_type)556 print (' %s retval = (%s) 0;' % (f.return_type, f.return_type)) 557 557 558 558 559 559 if name != None and name not in f.glx_vendorpriv_names: 560 print '#ifndef USE_XCB'560 print ('#ifndef USE_XCB') 561 561 self.emit_packet_size_calculation(f, 0) 562 562 if name != None and name not in f.glx_vendorpriv_names: 563 print '#endif'563 print ('#endif') 564 564 565 565 condition_list = [] 566 566 for p in f.parameterIterateCounters(): 567 567 condition_list.append( "%s >= 0" % (p.name) ) 568 568 # 'counter' parameters cannot be negative 569 print " if (%s < 0) {" % p.name570 print " __glXSetError(gc, GL_INVALID_VALUE);"569 print (" if (%s < 0) {" % p.name) 570 print (" __glXSetError(gc, GL_INVALID_VALUE);") 571 571 if f.return_type != 'void': 572 print " return 0;"572 print (" return 0;") 573 573 else: 574 print " return;"575 print " }"574 print (" return;") 575 print (" }") 576 576 577 577 if skip_condition: 578 578 condition_list.append( skip_condition ) … … 583 583 else: 584 584 skip_condition = "%s" % (condition_list.pop(0)) 585 585 586 print ' if (__builtin_expect(%s, 1)) {' % (skip_condition)586 print (' if (__builtin_expect(%s, 1)) {' % (skip_condition)) 587 587 return 1 588 588 else: 589 589 return 0 … … 593 593 self.common_func_print_just_start(f, name) 594 594 595 595 if self.debug: 596 print ' printf( "Enter %%s...\\n", "gl%s" );' % (f.name)596 print (' printf( "Enter %%s...\\n", "gl%s" );' % (f.name)) 597 597 598 598 if name not in f.glx_vendorpriv_names: 599 599 600 600 # XCB specific: 601 print '#ifdef USE_XCB'601 print ('#ifdef USE_XCB') 602 602 if self.debug: 603 print ' printf("\\tUsing XCB.\\n");'604 print ' xcb_connection_t *c = XGetXCBConnection(dpy);'605 print ' (void) __glXFlushRenderBuffer(gc, gc->pc);'603 print (' printf("\\tUsing XCB.\\n");') 604 print (' xcb_connection_t *c = XGetXCBConnection(dpy);') 605 print (' (void) __glXFlushRenderBuffer(gc, gc->pc);') 606 606 xcb_name = 'xcb_glx%s' % convertStringForXCB(name) 607 607 608 608 iparams=[] … … 629 629 xcb_request = '%s(%s)' % (xcb_name, ", ".join(["c", "gc->currentContextTag"] + iparams + extra_iparams)) 630 630 631 631 if f.needs_reply(): 632 print ' %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request)632 print (' %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request)) 633 633 if output and f.reply_always_array: 634 print ' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())634 print (' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())) 635 635 636 636 elif output and not f.reply_always_array: 637 637 if not output.is_image(): 638 print ' if (%s_data_length(reply) == 0)' % (xcb_name)639 print ' (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)640 print ' else'641 print ' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())638 print (' if (%s_data_length(reply) == 0)' % (xcb_name)) 639 print (' (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)) 640 print (' else') 641 print (' (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())) 642 642 643 643 644 644 if f.return_type != 'void': 645 print ' retval = reply->ret_val;'646 print ' free(reply);'645 print (' retval = reply->ret_val;') 646 print (' free(reply);') 647 647 else: 648 print ' ' + xcb_request + ';'649 print '#else'648 print (' ' + xcb_request + ';') 649 print ('#else') 650 650 # End of XCB specific. 651 651 652 652 … … 656 656 pc_decl = "(void)" 657 657 658 658 if name in f.glx_vendorpriv_names: 659 print ' %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name))659 print (' %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name))) 660 660 else: 661 print ' %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name())661 print (' %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name())) 662 662 663 663 self.common_emit_args(f, "pc", 0, 0) 664 664 … … 667 667 for img in images: 668 668 if img.is_output: 669 669 o = f.command_fixed_length() - 4 670 print ' *(int32_t *)(pc + %u) = 0;' % (o)670 print (' *(int32_t *)(pc + %u) = 0;' % (o)) 671 671 if img.img_format != "GL_COLOR_INDEX" or img.img_type != "GL_BITMAP": 672 print ' * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o)672 print (' * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o)) 673 673 674 674 if f.img_reset: 675 print ' * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset)675 print (' * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset)) 676 676 677 677 678 678 return_name = '' … … 689 689 if p.is_image(): 690 690 [dim, w, h, d, junk] = p.get_dimensions() 691 691 if f.dimensions_in_reply: 692 print " __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name)692 print (" __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name)) 693 693 else: 694 print " __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name)694 print (" __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name)) 695 695 696 696 got_reply = 1 697 697 else: … … 711 711 # non-arrays) gives us this. 712 712 713 713 s = p.size() / p.get_element_count() 714 print " %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa)714 print (" %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa)) 715 715 got_reply = 1 716 716 717 717 … … 719 719 # read a NULL reply to get the return value. 720 720 721 721 if not got_reply: 722 print " %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str)722 print (" %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str)) 723 723 724 724 725 725 elif self.debug: 726 726 # Only emit the extra glFinish call for functions 727 727 # that don't already require a reply from the server. 728 print ' __indirect_glFinish();'728 print (' __indirect_glFinish();') 729 729 730 730 if self.debug: 731 print ' printf( "Exit %%s.\\n", "gl%s" );' % (name)731 print (' printf( "Exit %%s.\\n", "gl%s" );' % (name)) 732 732 733 733 734 print ' UnlockDisplay(dpy); SyncHandle();'734 print (' UnlockDisplay(dpy); SyncHandle();') 735 735 736 736 if name not in f.glx_vendorpriv_names: 737 print '#endif /* USE_XCB */'737 print ('#endif /* USE_XCB */') 738 738 739 print ' }'740 print ' return%s;' % (return_name)739 print (' }') 740 print (' return%s;' % (return_name)) 741 741 return 742 742 743 743 … … 761 761 if f.pad_after(param): 762 762 p_string += ", 1" 763 763 764 print ' %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string)764 print (' %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string)) 765 765 return 766 766 767 767 … … 772 772 773 773 774 774 if f.can_be_large: 775 print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {'776 print ' if ( (gc->pc + cmdlen) > gc->bufEnd ) {'777 print ' (void) __glXFlushRenderBuffer(gc, gc->pc);'778 print ' }'775 print ('if (cmdlen <= gc->maxSmallRenderCommandSize) {') 776 print (' if ( (gc->pc + cmdlen) > gc->bufEnd ) {') 777 print (' (void) __glXFlushRenderBuffer(gc, gc->pc);') 778 print (' }') 779 779 780 780 if f.glx_rop == ~0: 781 781 opcode = "opcode" 782 782 else: 783 783 opcode = f.opcode_real_name() 784 784 785 print 'emit_header(gc->pc, %s, cmdlen);' % (opcode)785 print ('emit_header(gc->pc, %s, cmdlen);' % (opcode)) 786 786 787 787 self.pixel_emit_args( f, "gc->pc", 0 ) 788 print 'gc->pc += cmdlen;'789 print 'if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }'788 print ('gc->pc += cmdlen;') 789 print ('if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }') 790 790 791 791 if f.can_be_large: 792 print '}'793 print 'else {'792 print ('}') 793 print ('else {') 794 794 795 795 self.large_emit_begin(f, opcode) 796 796 self.pixel_emit_args(f, "pc", 1) 797 797 798 print '}'798 print ('}') 799 799 800 if trailer: print trailer800 if trailer: print (trailer) 801 801 return 802 802 803 803 … … 814 814 if p.is_pointer(): 815 815 cmdlen = f.command_fixed_length() 816 816 if cmdlen in self.generic_sizes: 817 print ' generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name)817 print (' generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name)) 818 818 return 819 819 820 820 if self.common_func_print_just_start(f, None): … … 823 823 trailer = None 824 824 825 825 if self.debug: 826 print 'printf( "Enter %%s...\\n", "gl%s" );' % (f.name)826 print ('printf( "Enter %%s...\\n", "gl%s" );' % (f.name)) 827 827 828 828 if f.can_be_large: 829 print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {'830 print ' if ( (gc->pc + cmdlen) > gc->bufEnd ) {'831 print ' (void) __glXFlushRenderBuffer(gc, gc->pc);'832 print ' }'829 print ('if (cmdlen <= gc->maxSmallRenderCommandSize) {') 830 print (' if ( (gc->pc + cmdlen) > gc->bufEnd ) {') 831 print (' (void) __glXFlushRenderBuffer(gc, gc->pc);') 832 print (' }') 833 833 834 print 'emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name())834 print ('emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name())) 835 835 836 836 self.common_emit_args(f, "gc->pc", 4, 0) 837 print 'gc->pc += cmdlen;'838 print 'if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }'837 print ('gc->pc += cmdlen;') 838 print ('if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }') 839 839 840 840 if f.can_be_large: 841 print '}'842 print 'else {'841 print ('}') 842 print ('else {') 843 843 844 844 self.large_emit_begin(f) 845 845 self.common_emit_args(f, "pc", 8, 1) 846 846 847 847 p = f.variable_length_parameter() 848 print ' __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string())849 print '}'848 print (' __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string())) 849 print ('}') 850 850 851 851 if self.debug: 852 print '__indirect_glFinish();'853 print 'printf( "Exit %%s.\\n", "gl%s" );' % (f.name)852 print ('__indirect_glFinish();') 853 print ('printf( "Exit %%s.\\n", "gl%s" );' % (f.name)) 854 854 855 if trailer: print trailer855 if trailer: print (trailer) 856 856 return 857 857 858 858 … … 868 868 869 869 870 870 def printRealHeader(self): 871 print """/**871 print ("""/** 872 872 * \\file indirect_init.c 873 873 * Initialize indirect rendering dispatch table. 874 874 * … … 918 918 print """ 919 919 return glAPI; 920 920 } 921 """ 921 """) 922 922 return 923 923 924 924 … … 931 931 932 932 for func in api.functionIterateByCategory(name): 933 933 if func.client_supported_for_indirect(): 934 print '%s glAPI->%s = __indirect_gl%s;' % (preamble, func.name, func.name)934 print ('%s glAPI->%s = __indirect_gl%s;' % (preamble, func.name, func.name)) 935 935 preamble = '' 936 936 937 937 return … … 952 952 953 953 954 954 def printRealHeader(self): 955 print """/**955 print ("""/** 956 956 * \\file 957 957 * Prototypes for indirect rendering functions. 958 958 * 959 959 * \\author Kevin E. Martin <kevin@precisioninsight.com> 960 960 * \\author Ian Romanick <idr@us.ibm.com> 961 961 */ 962 """ 962 """) 963 963 self.printVisibility( "HIDDEN", "hidden" ) 964 964 self.printFastcall() 965 965 self.printNoinline() 966 966 967 print """967 print (""" 968 968 #include "glxclient.h" 969 969 970 970 extern HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size, … … 980 980 981 981 extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( 982 982 __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen ); 983 """ 983 """) 984 984 985 985 986 986 def printBody(self, api): 987 987 for func in api.functionIterateGlx(): 988 988 params = func.get_parameter_string() 989 989 990 print 'extern HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params)990 print ('extern HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params)) 991 991 992 992 for n in func.entry_points: 993 993 if func.has_different_protocol(n): 994 994 asdf = func.static_glx_name(n) 995 995 if asdf not in func.static_entry_points: 996 print 'extern HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params)996 print ('extern HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params)) 997 997 else: 998 print 'GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params)998 print ('GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params)) 999 999 1000 1000 break 1001 1001 1002 1002 1003 1003 1004 1004 def show_usage(): 1005 print "Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0]1006 print " -m output_mode Output mode can be one of 'proto', 'init_c' or 'init_h'."1007 print " -d Enable extra debug information in the generated code."1005 print ("Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0]) 1006 print (" -m output_mode Output mode can be one of 'proto', 'init_c' or 'init_h'.") 1007 print (" -d Enable extra debug information in the generated code.") 1008 1008 sys.exit(1) 1009 1009 1010 1010 -
Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_size.py
old new 166 166 masked_count[i] = c 167 167 168 168 169 print ' static const GLushort a[%u] = {' % (mask + 1)169 print (' static const GLushort a[%u] = {' % (mask + 1)) 170 170 for e in masked_enums: 171 print ' %s, ' % (masked_enums[e])172 print ' };'171 print (' %s, ' % (masked_enums[e])) 172 print (' };') 173 173 174 print ' static const GLubyte b[%u] = {' % (mask + 1)174 print (' static const GLubyte b[%u] = {' % (mask + 1)) 175 175 for c in masked_count: 176 print ' %u, ' % (masked_count[c])177 print ' };'176 print (' %u, ' % (masked_count[c])) 177 print (' };') 178 178 179 print ' const unsigned idx = (e & 0x%02xU);' % (mask)180 print ''181 print ' return (e == a[idx]) ? (GLint) b[idx] : 0;'179 print (' const unsigned idx = (e & 0x%02xU);' % (mask)) 180 print ('') 181 print (' return (e == a[idx]) ? (GLint) b[idx] : 0;') 182 182 return 1; 183 183 else: 184 184 return 0; … … 188 188 """Emit the body of the __gl*_size function using a 189 189 switch-statement.""" 190 190 191 print ' switch( e ) {'191 print (' switch( e ) {') 192 192 193 193 for c in self.count: 194 194 for e in self.count[c]: … … 210 210 for k in keys: 211 211 j = list[k] 212 212 if first: 213 print ' case GL_%s:' % (j)213 print (' case GL_%s:' % (j)) 214 214 first = 0 215 215 else: 216 print '/* case GL_%s:*/' % (j)216 print ('/* case GL_%s:*/' % (j)) 217 217 218 218 if c == -1: 219 print ' return __gl%s_variable_size( e );' % (name)219 print (' return __gl%s_variable_size( e );' % (name)) 220 220 else: 221 print ' return %u;' % (c)221 print (' return %u;' % (c)) 222 222 223 print ' default: return 0;'224 print ' }'223 print (' default: return 0;') 224 print (' }') 225 225 226 226 227 227 def Print(self, name): 228 print 'INTERNAL PURE FASTCALL GLint'229 print '__gl%s_size( GLenum e )' % (name)230 print '{'228 print ('INTERNAL PURE FASTCALL GLint') 229 print ('__gl%s_size( GLenum e )' % (name)) 230 print ('{') 231 231 232 232 if not self.PrintUsingTable(): 233 233 self.PrintUsingSwitch(name) 234 234 235 print '}'236 print ''235 print ('}') 236 print ('') 237 237 238 238 239 239 class glx_server_enum_function(glx_enum_function): … … 281 281 fixup.append( p.name ) 282 282 283 283 284 print ' GLsizei compsize;'285 print ''284 print (' GLsizei compsize;') 285 print ('') 286 286 287 287 printer.common_emit_fixups(fixup) 288 288 289 print ''290 print ' compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ","))289 print ('') 290 print (' compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ","))) 291 291 p = f.variable_length_parameter() 292 print ' return __GLX_PAD(%s);' % (p.size_string())292 print (' return __GLX_PAD(%s);' % (p.size_string())) 293 293 294 print '}'295 print ''294 print ('}') 295 print ('') 296 296 297 297 298 298 class PrintGlxSizeStubs_common(gl_XML.gl_print_base): … … 312 312 313 313 class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common): 314 314 def printRealHeader(self): 315 print ''316 print '#include <GL/gl.h>'315 print ('') 316 print ('#include <GL/gl.h>') 317 317 if self.emit_get: 318 print '#include "indirect_size_get.h"'319 print '#include "glxserver.h"'320 print '#include "indirect_util.h"'318 print ('#include "indirect_size_get.h"') 319 print ('#include "glxserver.h"') 320 print ('#include "indirect_util.h"') 321 321 322 print '#include "indirect_size.h"'322 print ('#include "indirect_size.h"') 323 323 324 print ''324 print ('') 325 325 self.printPure() 326 print ''326 print ('') 327 327 self.printFastcall() 328 print ''328 print ('') 329 329 self.printVisibility( "INTERNAL", "internal" ) 330 print ''331 print ''332 print '#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)'333 print '# undef HAVE_ALIAS'334 print '#endif'335 print '#ifdef HAVE_ALIAS'336 print '# define ALIAS2(from,to) \\'337 print ' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'338 print ' __attribute__ ((alias( # to )));'339 print '# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )'340 print '#else'341 print '# define ALIAS(from,to) \\'342 print ' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'343 print ' { return __gl ## to ## _size( e ); }'344 print '#endif'345 print ''346 print ''330 print ('') 331 print ('') 332 print ('#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)') 333 print ('# undef HAVE_ALIAS') 334 print ('#endif') 335 print ('#ifdef HAVE_ALIAS') 336 print ('# define ALIAS2(from,to) \\') 337 print (' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\') 338 print (' __attribute__ ((alias( # to )));') 339 print ('# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )') 340 print ('#else') 341 print ('# define ALIAS(from,to) \\') 342 print (' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\') 343 print (' { return __gl ## to ## _size( e ); }') 344 print ('#endif') 345 print ('') 346 print ('') 347 347 348 348 349 349 def printBody(self, api): … … 365 365 366 366 367 367 for [alias_name, real_name] in aliases: 368 print 'ALIAS( %s, %s )' % (alias_name, real_name)368 print ('ALIAS( %s, %s )' % (alias_name, real_name)) 369 369 370 370 371 371 372 372 class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common): 373 373 def printRealHeader(self): 374 print """/**374 print ("""/** 375 375 * \\file 376 376 * Prototypes for functions used to determine the number of data elements in 377 377 * various GLX protocol messages. 378 378 * 379 379 * \\author Ian Romanick <idr@us.ibm.com> 380 380 */ 381 """ 381 """) 382 382 self.printPure(); 383 print ''383 print ('') 384 384 self.printFastcall(); 385 print ''385 print ('') 386 386 self.printVisibility( "INTERNAL", "internal" ); 387 print ''387 print ('') 388 388 389 389 390 390 def printBody(self, api): … … 394 394 continue 395 395 396 396 if (ef.is_set() and self.emit_set) or (not ef.is_set() and self.emit_get): 397 print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name)397 print ('extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name)) 398 398 399 399 400 400 class PrintGlxReqSize_common(gl_XML.gl_print_base): … … 419 419 420 420 def printRealHeader(self): 421 421 self.printVisibility("HIDDEN", "hidden") 422 print ''422 print ('') 423 423 self.printPure() 424 print ''424 print ('') 425 425 426 426 427 427 def printBody(self, api): 428 428 for func in api.functionIterateGlx(): 429 429 if not func.ignore and func.has_variable_size_request(): 430 print 'extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name)430 print ('extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name)) 431 431 432 432 433 433 class PrintGlxReqSize_c(PrintGlxReqSize_common): … … 444 444 445 445 446 446 def printRealHeader(self): 447 print ''448 print '#include <GL/gl.h>'449 print '#include "glxserver.h"'450 print '#include "glxbyteorder.h"'451 print '#include "indirect_size.h"'452 print '#include "indirect_reqsize.h"'453 print ''454 print '#define __GLX_PAD(x) (((x) + 3) & ~3)'455 print ''456 print '#if defined(__CYGWIN__) || defined(__MINGW32__)'457 print '# undef HAVE_ALIAS'458 print '#endif'459 print '#ifdef HAVE_ALIAS'460 print '# define ALIAS2(from,to) \\'461 print ' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'462 print ' __attribute__ ((alias( # to )));'463 print '# define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )'464 print '#else'465 print '# define ALIAS(from,to) \\'466 print ' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'467 print ' { return __glX ## to ## ReqSize( pc, swap ); }'468 print '#endif'469 print ''470 print ''447 print ('') 448 print ('#include <GL/gl.h>') 449 print ('#include "glxserver.h"') 450 print ('#include "glxbyteorder.h"') 451 print ('#include "indirect_size.h"') 452 print ('#include "indirect_reqsize.h"') 453 print ('') 454 print ('#define __GLX_PAD(x) (((x) + 3) & ~3)') 455 print ('') 456 print ('#if defined(__CYGWIN__) || defined(__MINGW32__)') 457 print ('# undef HAVE_ALIAS') 458 print ('#endif') 459 print ('#ifdef HAVE_ALIAS') 460 print ('# define ALIAS2(from,to) \\') 461 print (' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\') 462 print (' __attribute__ ((alias( # to )));') 463 print ('# define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )') 464 print ('#else') 465 print ('# define ALIAS(from,to) \\') 466 print (' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\') 467 print (' { return __glX ## to ## ReqSize( pc, swap ); }') 468 print ('#endif') 469 print ('') 470 print ('') 471 471 472 472 473 473 def printBody(self, api): … … 519 519 520 520 521 521 for [alias_name, real_name] in aliases: 522 print 'ALIAS( %s, %s )' % (alias_name, real_name)522 print ('ALIAS( %s, %s )' % (alias_name, real_name)) 523 523 524 524 return 525 525 … … 528 528 """Utility function to emit conditional byte-swaps.""" 529 529 530 530 if fixup: 531 print ' if (swap) {'531 print (' if (swap) {') 532 532 for name in fixup: 533 print ' %s = bswap_32(%s);' % (name, name)534 print ' }'533 print (' %s = bswap_32(%s);' % (name, name)) 534 print (' }') 535 535 536 536 return 537 537 … … 540 540 offset = p.offset 541 541 dst = p.string() 542 542 src = '(%s *)' % (p.type_string()) 543 print '%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust);543 print ('%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust)) 544 544 return 545 545 546 546 547 547 def common_func_print_just_header(self, f): 548 print 'int'549 print '__glX%sReqSize( const GLbyte * pc, Bool swap )' % (f.name)550 print '{'548 print ('int') 549 print ('__glX%sReqSize( const GLbyte * pc, Bool swap )' % (f.name)) 550 print ('{') 551 551 552 552 553 553 def printPixelFunction(self, f): … … 556 556 f.offset_of( f.parameters[0].name ) 557 557 [dim, w, h, d, junk] = f.get_images()[0].get_dimensions() 558 558 559 print ' GLint row_length = * (GLint *)(pc + 4);'559 print (' GLint row_length = * (GLint *)(pc + 4);') 560 560 561 561 if dim < 3: 562 562 fixup = ['row_length', 'skip_rows', 'alignment'] 563 print ' GLint image_height = 0;'564 print ' GLint skip_images = 0;'565 print ' GLint skip_rows = * (GLint *)(pc + 8);'566 print ' GLint alignment = * (GLint *)(pc + 16);'563 print (' GLint image_height = 0;') 564 print (' GLint skip_images = 0;') 565 print (' GLint skip_rows = * (GLint *)(pc + 8);') 566 print (' GLint alignment = * (GLint *)(pc + 16);') 567 567 else: 568 568 fixup = ['row_length', 'image_height', 'skip_rows', 'skip_images', 'alignment'] 569 print ' GLint image_height = * (GLint *)(pc + 8);'570 print ' GLint skip_rows = * (GLint *)(pc + 16);'571 print ' GLint skip_images = * (GLint *)(pc + 20);'572 print ' GLint alignment = * (GLint *)(pc + 32);'569 print (' GLint image_height = * (GLint *)(pc + 8);') 570 print (' GLint skip_rows = * (GLint *)(pc + 16);') 571 print (' GLint skip_images = * (GLint *)(pc + 20);') 572 print (' GLint alignment = * (GLint *)(pc + 32);') 573 573 574 574 img = f.images[0] 575 575 for p in f.parameterIterateGlxSend(): … … 577 577 self.common_emit_one_arg(p, "pc", 0) 578 578 fixup.append( p.name ) 579 579 580 print ''580 print ('') 581 581 582 582 self.common_emit_fixups(fixup) 583 583 584 584 if img.img_null_flag: 585 print ''586 print ' if (*(CARD32 *) (pc + %s))' % (img.offset - 4)587 print ' return 0;'588 589 print ''590 print ' return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d)591 print ' image_height, row_length, skip_images,'592 print ' skip_rows, alignment);'593 print '}'594 print ''585 print ('') 586 print (' if (*(CARD32 *) (pc + %s))' % (img.offset - 4)) 587 print (' return 0;') 588 589 print ('') 590 print (' return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d )) 591 print (' image_height, row_length, skip_images,') 592 print (' skip_rows, alignment);') 593 print ('}') 594 print ('') 595 595 return 596 596 597 597 … … 640 640 self.common_emit_one_arg(p, "pc", 0) 641 641 642 642 643 print ''643 print ('') 644 644 self.common_emit_fixups(fixup) 645 print ''645 print ('') 646 646 647 print ' return __GLX_PAD(%s);' % (size)648 print '}'649 print ''647 print (' return __GLX_PAD(%s);' % (size)) 648 print ('}') 649 print ('') 650 650 651 651 return alias 652 652 653 653 654 654 def show_usage(): 655 print "Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0]656 print " -m output_mode Output mode can be one of 'size_c' or 'size_h'."657 print " --only-get Only emit 'get'-type functions."658 print " --only-set Only emit 'set'-type functions."659 print ""660 print "By default, both 'get' and 'set'-type functions are emitted."655 print ("Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0]) 656 print (" -m output_mode Output mode can be one of 'size_c' or 'size_h'.") 657 print (" --only-get Only emit 'get'-type functions.") 658 print (" --only-set Only emit 'set'-type functions.") 659 print ("") 660 print ("By default, both 'get' and 'set'-type functions are emitted.") 661 661 sys.exit(1) 662 662 663 663 -
Mesa-7.8.2/src/mesa/glapi/gen/glX_server_table.py
old new 172 172 if children == []: 173 173 return 174 174 175 print ' /* [%u] -> opcode range [%u, %u], node depth %u */' % (base_entry, base_opcode, base_opcode + (1 << remaining_bits), depth)176 print ' %u,' % (M)175 print (' /* [%u] -> opcode range [%u, %u], node depth %u */' % (base_entry, base_opcode, base_opcode + (1 << remaining_bits), depth)) 176 print (' %u,' % (M)) 177 177 178 178 base_entry += (1 << M) + 1 179 179 … … 182 182 for child in children: 183 183 if child[1] == []: 184 184 if self.is_empty_leaf(child_base_opcode, child_M): 185 print ' EMPTY_LEAF,'185 print (' EMPTY_LEAF,') 186 186 else: 187 187 # Emit the index of the next dispatch 188 188 # function. Then add all the … … 190 190 # node to the dispatch function 191 191 # lookup table. 192 192 193 print ' LEAF(%u),' % (len(self.lookup_table))193 print (' LEAF(%u),' % (len(self.lookup_table))) 194 194 195 195 for op in range(child_base_opcode, child_base_opcode + (1 << child_M)): 196 196 if self.functions.has_key(op): … … 218 218 219 219 self.lookup_table.append(temp) 220 220 else: 221 print ' %u,' % (child_index)221 print (' %u,' % (child_index)) 222 222 child_index += child[2] 223 223 224 224 child_base_opcode += 1 << child_M 225 225 226 print ''226 print ('') 227 227 228 228 child_index = base_entry 229 229 for child in children: … … 278 278 279 279 tree = self.divide_group(0, 0) 280 280 281 print '/*****************************************************************/'282 print '/* tree depth = %u */' % (tree[3])283 print 'static const int_fast16_t %s_dispatch_tree[%u] = {' % (self.name_base, tree[2])281 print ('/*****************************************************************/') 282 print ('/* tree depth = %u */' % (tree[3])) 283 print ('static const int_fast16_t %s_dispatch_tree[%u] = {' % (self.name_base, tree[2])) 284 284 self.dump_tree(tree, 0, self.max_bits, 0, 1) 285 print '};\n'285 print ('};\n') 286 286 287 287 # After dumping the tree, dump the function lookup table. 288 288 289 print 'static const void *%s_function_table[%u][2] = {' % (self.name_base, len(self.lookup_table))289 print ('static const void *%s_function_table[%u][2] = {' % (self.name_base, len(self.lookup_table))) 290 290 index = 0 291 291 for func in self.lookup_table: 292 292 opcode = func[0] 293 293 name = func[1] 294 294 name_swap = func[2] 295 295 296 print ' /* [% 3u] = %5u */ {%s, %s},' % (index, opcode, name, name_swap)296 print (' /* [% 3u] = %5u */ {%s, %s},' % (index, opcode, name, name_swap)) 297 297 298 298 index += 1 299 299 300 print '};\n'300 print ('};\n') 301 301 302 302 if self.do_size_check: 303 303 var_table = [] 304 304 305 print 'static const int_fast16_t %s_size_table[%u][2] = {' % (self.name_base, len(self.lookup_table))305 print ('static const int_fast16_t %s_size_table[%u][2] = {' % (self.name_base, len(self.lookup_table))) 306 306 index = 0 307 307 var_table = [] 308 308 for func in self.lookup_table: … … 316 316 else: 317 317 var_offset = "~0" 318 318 319 print ' /* [%3u] = %5u */ {%3u, %s},' % (index, opcode, fixed, var_offset)319 print (' /* [%3u] = %5u */ {%3u, %s},' % (index, opcode, fixed, var_offset)) 320 320 index += 1 321 321 322 322 323 print '};\n'323 print ('};\n') 324 324 325 325 326 print 'static const gl_proto_size_func %s_size_func_table[%u] = {' % (self.name_base, len(var_table))326 print ('static const gl_proto_size_func %s_size_func_table[%u] = {' % (self.name_base, len(var_table))) 327 327 for func in var_table: 328 print ' %s,' % (func)328 print (' %s,' % (func)) 329 329 330 print '};\n'330 print ('};\n') 331 331 332 332 333 print 'const struct __glXDispatchInfo %s_dispatch_info = {' % (self.name_base)334 print ' %u,' % (self.max_bits)335 print ' %s_dispatch_tree,' % (self.name_base)336 print ' %s_function_table,' % (self.name_base)333 print ('const struct __glXDispatchInfo %s_dispatch_info = {' % (self.name_base)) 334 print (' %u,' % (self.max_bits)) 335 print (' %s_dispatch_tree,' % (self.name_base)) 336 print (' %s_function_table,' % (self.name_base)) 337 337 if self.do_size_check: 338 print ' %s_size_table,' % (self.name_base)339 print ' %s_size_func_table' % (self.name_base)338 print (' %s_size_table,' % (self.name_base)) 339 print (' %s_size_func_table' % (self.name_base)) 340 340 else: 341 print ' NULL,'342 print ' NULL'343 print '};\n'341 print (' NULL,') 342 print (' NULL') 343 print ('};\n') 344 344 return 345 345 346 346 … … 357 357 358 358 359 359 def printRealHeader(self): 360 print '#include <inttypes.h>'361 print '#include "glxserver.h"'362 print '#include "glxext.h"'363 print '#include "indirect_dispatch.h"'364 print '#include "indirect_reqsize.h"'365 print '#include "g_disptab.h"'366 print '#include "indirect_table.h"'367 print ''360 print ('#include <inttypes.h>') 361 print ('#include "glxserver.h"') 362 print ('#include "glxext.h"') 363 print ('#include "indirect_dispatch.h"') 364 print ('#include "indirect_reqsize.h"') 365 print ('#include "g_disptab.h"') 366 print ('#include "indirect_table.h"') 367 print ('') 368 368 return 369 369 370 370 -
Mesa-7.8.2/src/mesa/glapi/gen/mesadef.py
old new 40 40 41 41 42 42 def PrintHead(): 43 print '; DO NOT EDIT - This file generated automatically by mesadef.py script'44 print 'DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\''45 print 'VERSION 6.0'46 print ';'47 print '; Module definition file for Mesa (OPENGL32.DLL)'48 print ';'49 print '; Note: The OpenGL functions use the STDCALL'50 print '; function calling convention. Microsoft\'s'51 print '; OPENGL32 uses this convention and so must the'52 print '; Mesa OPENGL32 so that the Mesa DLL can be used'53 print '; as a drop-in replacement.'54 print ';'55 print '; The linker exports STDCALL entry points with'56 print '; \'decorated\' names; e.g., _glBegin@0, where the'57 print '; trailing number is the number of bytes of '58 print '; parameter data pushed onto the stack. The'59 print '; callee is responsible for popping this data'60 print '; off the stack, usually via a RETF n instruction.'61 print ';'62 print '; However, the Microsoft OPENGL32.DLL does not export'63 print '; the decorated names, even though the calling convention'64 print '; is STDCALL. So, this module definition file is'65 print '; needed to force the Mesa OPENGL32.DLL to export the'66 print '; symbols in the same manner as the Microsoft DLL.'67 print '; Were it not for this problem, this file would not'68 print '; be needed (for the gl* functions) since the entry'69 print '; points are compiled with dllexport declspec.'70 print ';'71 print '; However, this file is still needed to export "internal"'72 print '; Mesa symbols for the benefit of the OSMESA32.DLL.'73 print ';'74 print 'EXPORTS'43 print ('; DO NOT EDIT - This file generated automatically by mesadef.py script') 44 print ('DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\'') 45 print ('VERSION 6.0') 46 print (';') 47 print ('; Module definition file for Mesa (OPENGL32.DLL)') 48 print (';') 49 print ('; Note: The OpenGL functions use the STDCALL') 50 print ('; function calling convention. Microsoft\'s') 51 print ('; OPENGL32 uses this convention and so must the') 52 print ('; Mesa OPENGL32 so that the Mesa DLL can be used') 53 print ('; as a drop-in replacement.') 54 print (';') 55 print ('; The linker exports STDCALL entry points with') 56 print ('; \'decorated\' names; e.g., _glBegin@0, where the') 57 print ('; trailing number is the number of bytes of ') 58 print ('; parameter data pushed onto the stack. The') 59 print ('; callee is responsible for popping this data') 60 print ('; off the stack, usually via a RETF n instruction.') 61 print (';') 62 print ('; However, the Microsoft OPENGL32.DLL does not export') 63 print ('; the decorated names, even though the calling convention') 64 print ('; is STDCALL. So, this module definition file is') 65 print ('; needed to force the Mesa OPENGL32.DLL to export the') 66 print ('; symbols in the same manner as the Microsoft DLL.') 67 print ('; Were it not for this problem, this file would not') 68 print ('; be needed (for the gl* functions) since the entry') 69 print ('; points are compiled with dllexport declspec.') 70 print (';') 71 print ('; However, this file is still needed to export "internal"') 72 print ('; Mesa symbols for the benefit of the OSMESA32.DLL.') 73 print (';') 74 print ('EXPORTS') 75 75 return 76 76 #enddef 77 77 78 78 79 79 def PrintTail(): 80 print ';'81 print '; WGL API'82 print '\twglChoosePixelFormat'83 print '\twglCopyContext'84 print '\twglCreateContext'85 print '\twglCreateLayerContext'86 print '\twglDeleteContext'87 print '\twglDescribeLayerPlane'88 print '\twglDescribePixelFormat'89 print '\twglGetCurrentContext'90 print '\twglGetCurrentDC'91 print '\twglGetExtensionsStringARB'92 print '\twglGetLayerPaletteEntries'93 print '\twglGetPixelFormat'94 print '\twglGetProcAddress'95 print '\twglMakeCurrent'96 print '\twglRealizeLayerPalette'97 print '\twglSetLayerPaletteEntries'98 print '\twglSetPixelFormat'99 print '\twglShareLists'100 print '\twglSwapBuffers'101 print '\twglSwapLayerBuffers'102 print '\twglUseFontBitmapsA'103 print '\twglUseFontBitmapsW'104 print '\twglUseFontOutlinesA'105 print '\twglUseFontOutlinesW'106 print ';'107 print '; Mesa internals - mostly for OSMESA'108 print '\t_ac_CreateContext'109 print '\t_ac_DestroyContext'110 print '\t_ac_InvalidateState'111 print '\t_glapi_get_context'112 print '\t_glapi_get_proc_address'113 print '\t_mesa_buffer_data'114 print '\t_mesa_buffer_map'115 print '\t_mesa_buffer_subdata'116 print '\t_mesa_choose_tex_format'117 print '\t_mesa_compressed_texture_size'118 print '\t_mesa_create_framebuffer'119 print '\t_mesa_create_visual'120 print '\t_mesa_delete_buffer_object'121 print '\t_mesa_delete_texture_object'122 print '\t_mesa_destroy_framebuffer'123 print '\t_mesa_destroy_visual'124 print '\t_mesa_enable_1_3_extensions'125 print '\t_mesa_enable_1_4_extensions'126 print '\t_mesa_enable_1_5_extensions'127 print '\t_mesa_enable_sw_extensions'128 print '\t_mesa_error'129 print '\t_mesa_free_context_data'130 print '\t_mesa_get_current_context'131 print '\t_mesa_init_default_imports'132 print '\t_mesa_initialize_context'133 print '\t_mesa_make_current'134 print '\t_mesa_new_buffer_object'135 print '\t_mesa_new_texture_object'136 print '\t_mesa_problem'137 print '\t_mesa_ResizeBuffersMESA'138 print '\t_mesa_store_compressed_teximage1d'139 print '\t_mesa_store_compressed_teximage2d'140 print '\t_mesa_store_compressed_teximage3d'141 print '\t_mesa_store_compressed_texsubimage1d'142 print '\t_mesa_store_compressed_texsubimage2d'143 print '\t_mesa_store_compressed_texsubimage3d'144 print '\t_mesa_store_teximage1d'145 print '\t_mesa_store_teximage2d'146 print '\t_mesa_store_teximage3d'147 print '\t_mesa_store_texsubimage1d'148 print '\t_mesa_store_texsubimage2d'149 print '\t_mesa_store_texsubimage3d'150 print '\t_mesa_test_proxy_teximage'151 print '\t_mesa_Viewport'152 print '\t_mesa_meta_CopyColorSubTable'153 print '\t_mesa_meta_CopyColorTable'154 print '\t_mesa_meta_CopyConvolutionFilter1D'155 print '\t_mesa_meta_CopyConvolutionFilter2D'156 print '\t_mesa_meta_CopyTexImage1D'157 print '\t_mesa_meta_CopyTexImage2D'158 print '\t_mesa_meta_CopyTexSubImage1D'159 print '\t_mesa_meta_CopyTexSubImage2D'160 print '\t_mesa_meta_CopyTexSubImage3D'161 print '\t_swrast_Accum'162 print '\t_swrast_alloc_buffers'163 print '\t_swrast_Bitmap'164 print '\t_swrast_CopyPixels'165 print '\t_swrast_DrawPixels'166 print '\t_swrast_GetDeviceDriverReference'167 print '\t_swrast_Clear'168 print '\t_swrast_choose_line'169 print '\t_swrast_choose_triangle'170 print '\t_swrast_CreateContext'171 print '\t_swrast_DestroyContext'172 print '\t_swrast_InvalidateState'173 print '\t_swrast_ReadPixels'174 print '\t_swrast_zbuffer_address'175 print '\t_swsetup_Wakeup'176 print '\t_swsetup_CreateContext'177 print '\t_swsetup_DestroyContext'178 print '\t_swsetup_InvalidateState'179 print '\t_tnl_CreateContext'180 print '\t_tnl_DestroyContext'181 print '\t_tnl_InvalidateState'182 print '\t_tnl_MakeCurrent'183 print '\t_tnl_run_pipeline'80 print (';') 81 print ('; WGL API') 82 print ('\twglChoosePixelFormat') 83 print ('\twglCopyContext') 84 print ('\twglCreateContext') 85 print ('\twglCreateLayerContext') 86 print ('\twglDeleteContext') 87 print ('\twglDescribeLayerPlane') 88 print ('\twglDescribePixelFormat') 89 print ('\twglGetCurrentContext') 90 print ('\twglGetCurrentDC') 91 print ('\twglGetExtensionsStringARB') 92 print ('\twglGetLayerPaletteEntries') 93 print ('\twglGetPixelFormat') 94 print ('\twglGetProcAddress') 95 print ('\twglMakeCurrent') 96 print ('\twglRealizeLayerPalette') 97 print ('\twglSetLayerPaletteEntries') 98 print ('\twglSetPixelFormat') 99 print ('\twglShareLists') 100 print ('\twglSwapBuffers') 101 print ('\twglSwapLayerBuffers') 102 print ('\twglUseFontBitmapsA') 103 print ('\twglUseFontBitmapsW') 104 print ('\twglUseFontOutlinesA') 105 print ('\twglUseFontOutlinesW') 106 print (';') 107 print ('; Mesa internals - mostly for OSMESA') 108 print ('\t_ac_CreateContext') 109 print ('\t_ac_DestroyContext') 110 print ('\t_ac_InvalidateState') 111 print ('\t_glapi_get_context') 112 print ('\t_glapi_get_proc_address') 113 print ('\t_mesa_buffer_data') 114 print ('\t_mesa_buffer_map') 115 print ('\t_mesa_buffer_subdata') 116 print ('\t_mesa_choose_tex_format') 117 print ('\t_mesa_compressed_texture_size') 118 print ('\t_mesa_create_framebuffer') 119 print ('\t_mesa_create_visual') 120 print ('\t_mesa_delete_buffer_object') 121 print ('\t_mesa_delete_texture_object') 122 print ('\t_mesa_destroy_framebuffer') 123 print ('\t_mesa_destroy_visual') 124 print ('\t_mesa_enable_1_3_extensions') 125 print ('\t_mesa_enable_1_4_extensions') 126 print ('\t_mesa_enable_1_5_extensions') 127 print ('\t_mesa_enable_sw_extensions') 128 print ('\t_mesa_error') 129 print ('\t_mesa_free_context_data') 130 print ('\t_mesa_get_current_context') 131 print ('\t_mesa_init_default_imports') 132 print ('\t_mesa_initialize_context') 133 print ('\t_mesa_make_current') 134 print ('\t_mesa_new_buffer_object') 135 print ('\t_mesa_new_texture_object') 136 print ('\t_mesa_problem') 137 print ('\t_mesa_ResizeBuffersMESA') 138 print ('\t_mesa_store_compressed_teximage1d') 139 print ('\t_mesa_store_compressed_teximage2d') 140 print ('\t_mesa_store_compressed_teximage3d') 141 print ('\t_mesa_store_compressed_texsubimage1d') 142 print ('\t_mesa_store_compressed_texsubimage2d') 143 print ('\t_mesa_store_compressed_texsubimage3d') 144 print ('\t_mesa_store_teximage1d') 145 print ('\t_mesa_store_teximage2d') 146 print ('\t_mesa_store_teximage3d') 147 print ('\t_mesa_store_texsubimage1d') 148 print ('\t_mesa_store_texsubimage2d') 149 print ('\t_mesa_store_texsubimage3d') 150 print ('\t_mesa_test_proxy_teximage') 151 print ('\t_mesa_Viewport') 152 print ('\t_mesa_meta_CopyColorSubTable') 153 print ('\t_mesa_meta_CopyColorTable') 154 print ('\t_mesa_meta_CopyConvolutionFilter1D') 155 print ('\t_mesa_meta_CopyConvolutionFilter2D') 156 print ('\t_mesa_meta_CopyTexImage1D') 157 print ('\t_mesa_meta_CopyTexImage2D') 158 print ('\t_mesa_meta_CopyTexSubImage1D') 159 print ('\t_mesa_meta_CopyTexSubImage2D') 160 print ('\t_mesa_meta_CopyTexSubImage3D') 161 print ('\t_swrast_Accum') 162 print ('\t_swrast_alloc_buffers') 163 print ('\t_swrast_Bitmap') 164 print ('\t_swrast_CopyPixels') 165 print ('\t_swrast_DrawPixels') 166 print ('\t_swrast_GetDeviceDriverReference') 167 print ('\t_swrast_Clear') 168 print ('\t_swrast_choose_line') 169 print ('\t_swrast_choose_triangle') 170 print ('\t_swrast_CreateContext') 171 print ('\t_swrast_DestroyContext') 172 print ('\t_swrast_InvalidateState') 173 print ('\t_swrast_ReadPixels') 174 print ('\t_swrast_zbuffer_address') 175 print ('\t_swsetup_Wakeup') 176 print ('\t_swsetup_CreateContext') 177 print ('\t_swsetup_DestroyContext') 178 print ('\t_swsetup_InvalidateState') 179 print ('\t_tnl_CreateContext') 180 print ('\t_tnl_DestroyContext') 181 print ('\t_tnl_InvalidateState') 182 print ('\t_tnl_MakeCurrent') 183 print ('\t_tnl_run_pipeline') 184 184 #enddef 185 185 186 186 … … 204 204 if offset < 0: 205 205 offset = FindOffset(dispatchName) 206 206 if offset >= 0 and string.find(name, "unused") == -1: 207 print '\tgl%s' % (name)207 print ('\tgl%s' % (name)) 208 208 # save this info in case we need to look up an alias later 209 209 records.append((name, dispatchName, offset)) 210 210 -
Mesa-7.8.2/src/mesa/glapi/gen/remap_helper.py
old new 64 64 65 65 66 66 def printRealHeader(self): 67 print '#include "main/dispatch.h"'68 print ''67 print ('#include "main/dispatch.h"') 68 print ('') 69 69 return 70 70 71 71 72 72 def printBody(self, api): 73 print 'struct gl_function_remap {'74 print ' GLint func_index;'75 print ' GLint dispatch_offset; /* for sanity check */'76 print '};'77 print ''73 print ('struct gl_function_remap {') 74 print (' GLint func_index;') 75 print (' GLint dispatch_offset; /* for sanity check */') 76 print ('};') 77 print ('') 78 78 79 79 pool_indices = {} 80 80 81 print '/* this is internal to remap.c */'82 print '#ifdef need_MESA_remap_table'83 print ''84 print 'static const char _mesa_function_pool[] ='81 print ('/* this is internal to remap.c */') 82 print ('#ifdef need_MESA_remap_table') 83 print ('') 84 print ('static const char _mesa_function_pool[] =') 85 85 86 86 # output string pool 87 87 index = 0; … … 99 99 else: 100 100 comments = "dynamic" 101 101 102 print ' /* _mesa_function_pool[%d]: %s (%s) */' \103 % (index, f.name, comments) 102 print (' /* _mesa_function_pool[%d]: %s (%s) */' \ 103 % (index, f.name, comments)) 104 104 for line in spec: 105 print ' "%s\\0"' % line105 print (' "%s\\0"' % line) 106 106 index += len(line) + 1 107 print ' ;'108 print ''107 print (' ;') 108 print ('') 109 109 110 print '/* these functions need to be remapped */'111 print 'static const struct {'112 print ' GLint pool_index;'113 print ' GLint remap_index;'114 print '} MESA_remap_table_functions[] = {'110 print ('/* these functions need to be remapped */') 111 print ('static const struct {') 112 print (' GLint pool_index;') 113 print (' GLint remap_index;') 114 print ('} MESA_remap_table_functions[] = {') 115 115 # output all functions that need to be remapped 116 116 # iterate by offsets so that they are sorted by remap indices 117 117 for f in api.functionIterateByOffset(): 118 118 if not f.assign_offset: 119 119 continue 120 print ' { %5d, %s_remap_index },' \121 % (pool_indices[f], f.name) 122 print ' { -1, -1 }'123 print '};'124 print ''120 print (' { %5d, %s_remap_index },' \ 121 % (pool_indices[f], f.name)) 122 print (' { -1, -1 }') 123 print ('};') 124 print ('') 125 125 126 126 # collect functions by versions/extensions 127 127 extension_functions = {} … … 147 147 extensions.sort() 148 148 149 149 # output ABI functions that have alternative names (with ext suffix) 150 print '/* these functions are in the ABI, but have alternative names */'151 print 'static const struct gl_function_remap MESA_alt_functions[] = {'150 print ('/* these functions are in the ABI, but have alternative names */') 151 print ('static const struct gl_function_remap MESA_alt_functions[] = {') 152 152 for ext in extensions: 153 153 funcs = [] 154 154 for f in extension_functions[ext]: … … 157 157 funcs.append(f) 158 158 if not funcs: 159 159 continue 160 print ' /* from %s */' % ext160 print (' /* from %s */' % ext) 161 161 for f in funcs: 162 print ' { %5d, _gloffset_%s },' \163 % (pool_indices[f], f.name) 164 print ' { -1, -1 }'165 print '};'166 print ''162 print (' { %5d, _gloffset_%s },' \ 163 % (pool_indices[f], f.name)) 164 print (' { -1, -1 }') 165 print ('};') 166 print ('') 167 167 168 print '#endif /* need_MESA_remap_table */'169 print ''168 print ('#endif /* need_MESA_remap_table */') 169 print ('') 170 170 171 171 # output remap helpers for DRI drivers 172 172 … … 182 182 # abi, or have offset -1 183 183 funcs.append(f) 184 184 185 print '#if defined(need_%s)' % (ext)185 print ('#if defined(need_%s)' % (ext)) 186 186 if remapped: 187 print '/* functions defined in MESA_remap_table_functions are excluded */'187 print ('/* functions defined in MESA_remap_table_functions are excluded */') 188 188 189 189 # output extension functions that need to be mapped 190 print 'static const struct gl_function_remap %s_functions[] = {' % (ext)190 print ('static const struct gl_function_remap %s_functions[] = {' % (ext)) 191 191 for f in funcs: 192 192 if f.offset >= 0: 193 print ' { %5d, _gloffset_%s },' \194 % (pool_indices[f], f.name) 193 print (' { %5d, _gloffset_%s },' \ 194 % (pool_indices[f], f.name)) 195 195 else: 196 print ' { %5d, -1 }, /* %s */' % \197 (pool_indices[f], f.name) 198 print ' { -1, -1 }'199 print '};'196 print (' { %5d, -1 }, /* %s */' % \ 197 (pool_indices[f], f.name)) 198 print (' { -1, -1 }') 199 print ('};') 200 200 201 print '#endif'202 print ''201 print ('#endif') 202 print ('') 203 203 204 204 return 205 205 206 206 207 207 def show_usage(): 208 print "Usage: %s [-f input_file_name]" % sys.argv[0]208 print ("Usage: %s [-f input_file_name]" % sys.argv[0]) 209 209 sys.exit(1) 210 210 211 211 if __name__ == '__main__': -
Mesa-7.8.2/src/mesa/glapi/gen/typeexpr.py
old new 287 287 create_initial_types() 288 288 289 289 for t in types_to_try: 290 print 'Trying "%s"...' % (t)290 print ('Trying "%s"...' % (t)) 291 291 te = type_expression( t ) 292 print 'Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size())292 print ('Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size()))