diff options
author | Mathieu Bridon <[email protected]> | 2018-07-05 15:17:32 +0200 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-07-06 10:04:22 -0700 |
commit | 0f7b18fa0d353aab0a44082b1aca8d8c00df71a7 (patch) | |
tree | e511fe8f70b48ad5203e3a0e52d0dc1b086bfd91 /src/gallium | |
parent | b3a42fa0667caeeebabd9e6aeb46a9534810c2f3 (diff) |
python: Use the print function
In Python 2, `print` was a statement, but it became a function in
Python 3.
Using print functions everywhere makes the script compatible with Python
versions >= 2.6, including Python 3.
Signed-off-by: Mathieu Bridon <[email protected]>
Acked-by: Eric Engestrom <[email protected]>
Acked-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/indices/u_indices_gen.py | 296 | ||||
-rw-r--r-- | src/gallium/auxiliary/indices/u_unfilled_gen.py | 94 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format_pack.py | 168 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format_table.py | 181 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py | 8 | ||||
-rw-r--r-- | src/gallium/drivers/r600/egd_tables.py | 51 |
6 files changed, 404 insertions, 394 deletions
diff --git a/src/gallium/auxiliary/indices/u_indices_gen.py b/src/gallium/auxiliary/indices/u_indices_gen.py index 376348d5f8e..2d9297854c5 100644 --- a/src/gallium/auxiliary/indices/u_indices_gen.py +++ b/src/gallium/auxiliary/indices/u_indices_gen.py @@ -1,3 +1,5 @@ +from __future__ import print_function + copyright = ''' /* * Copyright 2009 VMware, Inc. @@ -69,9 +71,9 @@ pv_idx = dict(first='PV_FIRST', last='PV_LAST') pr_idx = dict(prdisable='PR_DISABLE', prenable='PR_ENABLE') def prolog(): - print '''/* File automatically generated by u_indices_gen.py */''' - print copyright - print r''' + print('''/* File automatically generated by u_indices_gen.py */''') + print(copyright) + print(r''' /** * @file @@ -107,7 +109,7 @@ static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PR_CO static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; -''' +''') def vert( intype, outtype, v0 ): if intype == GENERATE: @@ -116,30 +118,30 @@ def vert( intype, outtype, v0 ): return '(' + outtype + ')in[' + v0 + ']' def point( intype, outtype, ptr, v0 ): - print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';' + print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') def line( intype, outtype, ptr, v0, v1 ): - print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';' - print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';' + print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') + print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') def tri( intype, outtype, ptr, v0, v1, v2 ): - print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';' - print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';' - print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';' + print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') + print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') + print(' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';') def lineadj( intype, outtype, ptr, v0, v1, v2, v3 ): - print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';' - print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';' - print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';' - print ' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';' + print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') + print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') + print(' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';') + print(' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';') def triadj( intype, outtype, ptr, v0, v1, v2, v3, v4, v5 ): - print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';' - print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';' - print ' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';' - print ' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';' - print ' (' + ptr + ')[4] = ' + vert( intype, outtype, v4 ) + ';' - print ' (' + ptr + ')[5] = ' + vert( intype, outtype, v5 ) + ';' + print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') + print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') + print(' (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';') + print(' (' + ptr + ')[3] = ' + vert( intype, outtype, v3 ) + ';') + print(' (' + ptr + ')[4] = ' + vert( intype, outtype, v4 ) + ';') + print(' (' + ptr + ')[5] = ' + vert( intype, outtype, v5 ) + ';') def do_point( intype, outtype, ptr, v0 ): point( intype, outtype, ptr, v0 ) @@ -186,231 +188,231 @@ def name(intype, outtype, inpv, outpv, pr, prim): return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv + '_' + pr def preamble(intype, outtype, inpv, outpv, pr, prim): - print 'static void ' + name( intype, outtype, inpv, outpv, pr, prim ) + '(' + print('static void ' + name( intype, outtype, inpv, outpv, pr, prim ) + '(') if intype != GENERATE: - print ' const void * _in,' - print ' unsigned start,' + print(' const void * _in,') + print(' unsigned start,') if intype != GENERATE: - print ' unsigned in_nr,' - print ' unsigned out_nr,' + print(' unsigned in_nr,') + print(' unsigned out_nr,') if intype != GENERATE: - print ' unsigned restart_index,' - print ' void *_out )' - print '{' + print(' unsigned restart_index,') + print(' void *_out )') + print('{') if intype != GENERATE: - print ' const ' + intype + '*in = (const ' + intype + '*)_in;' - print ' ' + outtype + ' *out = (' + outtype + '*)_out;' - print ' unsigned i, j;' - print ' (void)j;' + print(' const ' + intype + '*in = (const ' + intype + '*)_in;') + print(' ' + outtype + ' *out = (' + outtype + '*)_out;') + print(' unsigned i, j;') + print(' (void)j;') def postamble(): - print '}' + print('}') def points(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='points') - print ' for (i = start; i < (out_nr+start); i++) { ' + print(' for (i = start; i < (out_nr+start); i++) { ') do_point( intype, outtype, 'out+i', 'i' ); - print ' }' + print(' }') postamble() def lines(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='lines') - print ' for (i = start; i < (out_nr+start); i+=2) { ' + print(' for (i = start; i < (out_nr+start); i+=2) { ') do_line( intype, outtype, 'out+i', 'i', 'i+1', inpv, outpv ); - print ' }' + print(' }') postamble() def linestrip(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='linestrip') - print ' for (i = start, j = 0; j < out_nr; j+=2, i++) { ' + print(' for (i = start, j = 0; j < out_nr; j+=2, i++) { ') do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); - print ' }' + print(' }') postamble() def lineloop(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='lineloop') - print ' for (i = start, j = 0; j < out_nr - 2; j+=2, i++) { ' + print(' for (i = start, j = 0; j < out_nr - 2; j+=2, i++) { ') do_line( intype, outtype, 'out+j', 'i', 'i+1', inpv, outpv ); - print ' }' + print(' }') do_line( intype, outtype, 'out+j', 'i', 'start', inpv, outpv ); postamble() def tris(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='tris') - print ' for (i = start; i < (out_nr+start); i+=3) { ' + print(' for (i = start; i < (out_nr+start); i+=3) { ') do_tri( intype, outtype, 'out+i', 'i', 'i+1', 'i+2', inpv, outpv ); - print ' }' + print(' }') postamble() def tristrip(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='tristrip') - print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { ' + print(' for (i = start, j = 0; j < out_nr; j+=3, i++) { ') if inpv == FIRST: do_tri( intype, outtype, 'out+j', 'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv ); else: do_tri( intype, outtype, 'out+j', 'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv ); - print ' }' + print(' }') postamble() def trifan(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='trifan') - print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { ' + print(' for (i = start, j = 0; j < out_nr; j+=3, i++) { ') do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); - print ' }' + print(' }') postamble() def polygon(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='polygon') - print ' for (i = start, j = 0; j < out_nr; j+=3, i++) { ' + print(' for (i = start, j = 0; j < out_nr; j+=3, i++) { ') if pr == PRENABLE: - print 'restart:' - print ' if (i + 3 > in_nr) {' - print ' (out+j+0)[0] = restart_index;' - print ' (out+j+0)[1] = restart_index;' - print ' (out+j+0)[2] = restart_index;' - print ' continue;' - print ' }' - print ' if (in[i + 0] == restart_index) {' - print ' i += 1;' - print ' start = i;' - print ' goto restart;' - print ' }' - print ' if (in[i + 1] == restart_index) {' - print ' i += 2;' - print ' start = i;' - print ' goto restart;' - print ' }' - print ' if (in[i + 2] == restart_index) {' - print ' i += 3;' - print ' start = i;' - print ' goto restart;' - print ' }' + print('restart:') + print(' if (i + 3 > in_nr) {') + print(' (out+j+0)[0] = restart_index;') + print(' (out+j+0)[1] = restart_index;') + print(' (out+j+0)[2] = restart_index;') + print(' continue;') + print(' }') + print(' if (in[i + 0] == restart_index) {') + print(' i += 1;') + print(' start = i;') + print(' goto restart;') + print(' }') + print(' if (in[i + 1] == restart_index) {') + print(' i += 2;') + print(' start = i;') + print(' goto restart;') + print(' }') + print(' if (in[i + 2] == restart_index) {') + print(' i += 3;') + print(' start = i;') + print(' goto restart;') + print(' }') if inpv == FIRST: do_tri( intype, outtype, 'out+j', 'start', 'i+1', 'i+2', inpv, outpv ); else: do_tri( intype, outtype, 'out+j', 'i+1', 'i+2', 'start', inpv, outpv ); - print ' }' + print(' }') postamble() def quads(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='quads') - print ' for (i = start, j = 0; j < out_nr; j+=6, i+=4) { ' + print(' for (i = start, j = 0; j < out_nr; j+=6, i+=4) { ') if pr == PRENABLE: - print 'restart:' - print ' if (i + 4 > in_nr) {' - print ' (out+j+0)[0] = restart_index;' - print ' (out+j+0)[1] = restart_index;' - print ' (out+j+0)[2] = restart_index;' - print ' (out+j+3)[0] = restart_index;' - print ' (out+j+3)[1] = restart_index;' - print ' (out+j+3)[2] = restart_index;' - print ' continue;' - print ' }' - print ' if (in[i + 0] == restart_index) {' - print ' i += 1;' - print ' goto restart;' - print ' }' - print ' if (in[i + 1] == restart_index) {' - print ' i += 2;' - print ' goto restart;' - print ' }' - print ' if (in[i + 2] == restart_index) {' - print ' i += 3;' - print ' goto restart;' - print ' }' - print ' if (in[i + 3] == restart_index) {' - print ' i += 4;' - print ' goto restart;' - print ' }' + print('restart:') + print(' if (i + 4 > in_nr) {') + print(' (out+j+0)[0] = restart_index;') + print(' (out+j+0)[1] = restart_index;') + print(' (out+j+0)[2] = restart_index;') + print(' (out+j+3)[0] = restart_index;') + print(' (out+j+3)[1] = restart_index;') + print(' (out+j+3)[2] = restart_index;') + print(' continue;') + print(' }') + print(' if (in[i + 0] == restart_index) {') + print(' i += 1;') + print(' goto restart;') + print(' }') + print(' if (in[i + 1] == restart_index) {') + print(' i += 2;') + print(' goto restart;') + print(' }') + print(' if (in[i + 2] == restart_index) {') + print(' i += 3;') + print(' goto restart;') + print(' }') + print(' if (in[i + 3] == restart_index) {') + print(' i += 4;') + print(' goto restart;') + print(' }') do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv ); - print ' }' + print(' }') postamble() def quadstrip(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='quadstrip') - print ' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ' + print(' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ') if pr == PRENABLE: - print 'restart:' - print ' if (i + 4 > in_nr) {' - print ' (out+j+0)[0] = restart_index;' - print ' (out+j+0)[1] = restart_index;' - print ' (out+j+0)[2] = restart_index;' - print ' (out+j+3)[0] = restart_index;' - print ' (out+j+3)[1] = restart_index;' - print ' (out+j+3)[2] = restart_index;' - print ' continue;' - print ' }' - print ' if (in[i + 0] == restart_index) {' - print ' i += 1;' - print ' goto restart;' - print ' }' - print ' if (in[i + 1] == restart_index) {' - print ' i += 2;' - print ' goto restart;' - print ' }' - print ' if (in[i + 2] == restart_index) {' - print ' i += 3;' - print ' goto restart;' - print ' }' - print ' if (in[i + 3] == restart_index) {' - print ' i += 4;' - print ' goto restart;' - print ' }' + print('restart:') + print(' if (i + 4 > in_nr) {') + print(' (out+j+0)[0] = restart_index;') + print(' (out+j+0)[1] = restart_index;') + print(' (out+j+0)[2] = restart_index;') + print(' (out+j+3)[0] = restart_index;') + print(' (out+j+3)[1] = restart_index;') + print(' (out+j+3)[2] = restart_index;') + print(' continue;') + print(' }') + print(' if (in[i + 0] == restart_index) {') + print(' i += 1;') + print(' goto restart;') + print(' }') + print(' if (in[i + 1] == restart_index) {') + print(' i += 2;') + print(' goto restart;') + print(' }') + print(' if (in[i + 2] == restart_index) {') + print(' i += 3;') + print(' goto restart;') + print(' }') + print(' if (in[i + 3] == restart_index) {') + print(' i += 4;') + print(' goto restart;') + print(' }') if inpv == LAST: do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv ); else: do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+3', 'i+2', inpv, outpv ); - print ' }' + print(' }') postamble() def linesadj(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='linesadj') - print ' for (i = start; i < (out_nr+start); i+=4) { ' + print(' for (i = start; i < (out_nr+start); i+=4) { ') do_lineadj( intype, outtype, 'out+i', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv ) - print ' }' + print(' }') postamble() def linestripadj(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='linestripadj') - print ' for (i = start, j = 0; j < out_nr; j+=4, i++) {' + print(' for (i = start, j = 0; j < out_nr; j+=4, i++) {') do_lineadj( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv ) - print ' }' + print(' }') postamble() def trisadj(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='trisadj') - print ' for (i = start; i < (out_nr+start); i+=6) { ' + print(' for (i = start; i < (out_nr+start); i+=6) { ') do_triadj( intype, outtype, 'out+i', 'i+0', 'i+1', 'i+2', 'i+3', 'i+4', 'i+5', inpv, outpv ) - print ' }' + print(' }') postamble() def tristripadj(intype, outtype, inpv, outpv, pr): preamble(intype, outtype, inpv, outpv, pr, prim='tristripadj') - print ' for (i = start, j = 0; j < out_nr; i+=2, j+=6) { ' - print ' if (i % 4 == 0) {' - print ' /* even triangle */' + print(' for (i = start, j = 0; j < out_nr; i+=2, j+=6) { ') + print(' if (i % 4 == 0) {') + print(' /* even triangle */') do_triadj( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', 'i+4', 'i+5', inpv, outpv ) - print ' } else {' - print ' /* odd triangle */' + print(' } else {') + print(' /* odd triangle */') do_triadj( intype, outtype, 'out+j', 'i+2', 'i-2', 'i+0', 'i+3', 'i+4', 'i+6', inpv, outpv ) - print ' }' - print ' }' + print(' }') + print(' }') postamble() @@ -466,19 +468,19 @@ def emit_all_inits(): init(intype, outtype, inpv, outpv, pr, prim) def emit_init(): - print 'void u_index_init( void )' - print '{' - print ' static int firsttime = 1;' - print ' if (!firsttime) return;' - print ' firsttime = 0;' + print('void u_index_init( void )') + print('{') + print(' static int firsttime = 1;') + print(' if (!firsttime) return;') + print(' firsttime = 0;') emit_all_inits() - print '}' + print('}') def epilog(): - print '#include "indices/u_indices.c"' + print('#include "indices/u_indices.c"') def main(): diff --git a/src/gallium/auxiliary/indices/u_unfilled_gen.py b/src/gallium/auxiliary/indices/u_unfilled_gen.py index 4780d98383a..4c7d7c61e91 100644 --- a/src/gallium/auxiliary/indices/u_unfilled_gen.py +++ b/src/gallium/auxiliary/indices/u_unfilled_gen.py @@ -1,3 +1,5 @@ +from __future__ import print_function + copyright = ''' /* * Copyright 2009 VMware, Inc. @@ -53,9 +55,9 @@ outtype_idx = dict(ushort='OUT_USHORT', uint='OUT_UINT') def prolog(): - print '''/* File automatically generated by u_unfilled_gen.py */''' - print copyright - print r''' + print('''/* File automatically generated by u_unfilled_gen.py */''') + print(copyright) + print(r''' /** * @file @@ -93,7 +95,7 @@ static unsigned in_size_idx( unsigned index_size ) static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT]; static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT]; -''' +''') def vert( intype, outtype, v0 ): if intype == GENERATE: @@ -102,8 +104,8 @@ def vert( intype, outtype, v0 ): return '(' + outtype + ')in[' + v0 + ']' def line( intype, outtype, ptr, v0, v1 ): - print ' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';' - print ' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';' + print(' (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';') + print(' (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';') # XXX: have the opportunity here to avoid over-drawing shared lines in # tristrips, fans, etc, by integrating this into the calling functions @@ -127,89 +129,89 @@ def name(intype, outtype, prim): return 'translate_' + prim + '_' + intype + '2' + outtype def preamble(intype, outtype, prim): - print 'static void ' + name( intype, outtype, prim ) + '(' + print('static void ' + name( intype, outtype, prim ) + '(') if intype != GENERATE: - print ' const void * _in,' - print ' unsigned start,' + print(' const void * _in,') + print(' unsigned start,') if intype != GENERATE: - print ' unsigned in_nr,' - print ' unsigned out_nr,' + print(' unsigned in_nr,') + print(' unsigned out_nr,') if intype != GENERATE: - print ' unsigned restart_index,' - print ' void *_out )' - print '{' + print(' unsigned restart_index,') + print(' void *_out )') + print('{') if intype != GENERATE: - print ' const ' + intype + '*in = (const ' + intype + '*)_in;' - print ' ' + outtype + ' *out = (' + outtype + '*)_out;' - print ' unsigned i, j;' - print ' (void)j;' + print(' const ' + intype + '*in = (const ' + intype + '*)_in;') + print(' ' + outtype + ' *out = (' + outtype + '*)_out;') + print(' unsigned i, j;') + print(' (void)j;') def postamble(): - print '}' + print('}') def tris(intype, outtype): preamble(intype, outtype, prim='tris') - print ' for (i = start, j = 0; j < out_nr; j+=6, i+=3) { ' + print(' for (i = start, j = 0; j < out_nr; j+=6, i+=3) { ') do_tri( intype, outtype, 'out+j', 'i', 'i+1', 'i+2' ); - print ' }' + print(' }') postamble() def tristrip(intype, outtype): preamble(intype, outtype, prim='tristrip') - print ' for (i = start, j = 0; j < out_nr; j+=6, i++) { ' + print(' for (i = start, j = 0; j < out_nr; j+=6, i++) { ') do_tri( intype, outtype, 'out+j', 'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' ); - print ' }' + print(' }') postamble() def trifan(intype, outtype): preamble(intype, outtype, prim='trifan') - print ' for (i = start, j = 0; j < out_nr; j+=6, i++) { ' + print(' for (i = start, j = 0; j < out_nr; j+=6, i++) { ') do_tri( intype, outtype, 'out+j', '0', 'i+1', 'i+2' ); - print ' }' + print(' }') postamble() def polygon(intype, outtype): preamble(intype, outtype, prim='polygon') - print ' for (i = start, j = 0; j < out_nr; j+=2, i++) { ' + print(' for (i = start, j = 0; j < out_nr; j+=2, i++) { ') line( intype, outtype, 'out+j', 'i', '(i+1)%(out_nr/2)' ) - print ' }' + print(' }') postamble() def quads(intype, outtype): preamble(intype, outtype, prim='quads') - print ' for (i = start, j = 0; j < out_nr; j+=8, i+=4) { ' + print(' for (i = start, j = 0; j < out_nr; j+=8, i+=4) { ') do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' ); - print ' }' + print(' }') postamble() def quadstrip(intype, outtype): preamble(intype, outtype, prim='quadstrip') - print ' for (i = start, j = 0; j < out_nr; j+=8, i+=2) { ' + print(' for (i = start, j = 0; j < out_nr; j+=8, i+=2) { ') do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' ); - print ' }' + print(' }') postamble() def trisadj(intype, outtype): preamble(intype, outtype, prim='trisadj') - print ' for (i = start, j = 0; j < out_nr; j+=6, i+=6) { ' + print(' for (i = start, j = 0; j < out_nr; j+=6, i+=6) { ') do_tri( intype, outtype, 'out+j', 'i', 'i+2', 'i+4' ); - print ' }' + print(' }') postamble() def tristripadj(intype, outtype): preamble(intype, outtype, prim='tristripadj') - print ' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ' + print(' for (i = start, j = 0; j < out_nr; j+=6, i+=2) { ') do_tri( intype, outtype, 'out+j', 'i', 'i+2', 'i+4' ); - print ' }' + print(' }') postamble() @@ -227,16 +229,16 @@ def emit_funcs(): def init(intype, outtype, prim): if intype == GENERATE: - print ('generate_line[' + + print(('generate_line[' + outtype_idx[outtype] + '][' + longprim[prim] + - '] = ' + name( intype, outtype, prim ) + ';') + '] = ' + name( intype, outtype, prim ) + ';')) else: - print ('translate_line[' + + print(('translate_line[' + intype_idx[intype] + '][' + outtype_idx[outtype] + '][' + longprim[prim] + - '] = ' + name( intype, outtype, prim ) + ';') + '] = ' + name( intype, outtype, prim ) + ';')) def emit_all_inits(): @@ -246,19 +248,19 @@ def emit_all_inits(): init(intype, outtype, prim) def emit_init(): - print 'void u_unfilled_init( void )' - print '{' - print ' static int firsttime = 1;' - print ' if (!firsttime) return;' - print ' firsttime = 0;' + print('void u_unfilled_init( void )') + print('{') + print(' static int firsttime = 1;') + print(' if (!firsttime) return;') + print(' firsttime = 0;') emit_all_inits() - print '}' + print('}') def epilog(): - print '#include "indices/u_unfilled_indices.c"' + print('#include "indices/u_unfilled_indices.c"') def main(): diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index c9b8cd7abc0..7a952a48b30 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -36,6 +36,8 @@ ''' +from __future__ import print_function + from u_format_parse import * @@ -53,11 +55,11 @@ def print_channels(format, func): if format.nr_channels() <= 1: func(format.le_channels, format.le_swizzles) else: - print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print('#ifdef PIPE_ARCH_BIG_ENDIAN') func(format.be_channels, format.be_swizzles) - print '#else' + print('#else') func(format.le_channels, format.le_swizzles) - print '#endif' + print('#endif') def generate_format_type(format): '''Generate a structure that describes the format.''' @@ -68,18 +70,18 @@ def generate_format_type(format): for channel in channels: if channel.type == VOID: if channel.size: - print ' unsigned %s:%u;' % (channel.name, channel.size) + print(' unsigned %s:%u;' % (channel.name, channel.size)) elif channel.type == UNSIGNED: - print ' unsigned %s:%u;' % (channel.name, channel.size) + print(' unsigned %s:%u;' % (channel.name, channel.size)) elif channel.type in (SIGNED, FIXED): - print ' int %s:%u;' % (channel.name, channel.size) + print(' int %s:%u;' % (channel.name, channel.size)) elif channel.type == FLOAT: if channel.size == 64: - print ' double %s;' % (channel.name) + print(' double %s;' % (channel.name)) elif channel.size == 32: - print ' float %s;' % (channel.name) + print(' float %s;' % (channel.name)) else: - print ' unsigned %s:%u;' % (channel.name, channel.size) + print(' unsigned %s:%u;' % (channel.name, channel.size)) else: assert 0 @@ -88,41 +90,41 @@ def generate_format_type(format): assert channel.size % 8 == 0 and is_pot(channel.size) if channel.type == VOID: if channel.size: - print ' uint%u_t %s;' % (channel.size, channel.name) + print(' uint%u_t %s;' % (channel.size, channel.name)) elif channel.type == UNSIGNED: - print ' uint%u_t %s;' % (channel.size, channel.name) + print(' uint%u_t %s;' % (channel.size, channel.name)) elif channel.type in (SIGNED, FIXED): - print ' int%u_t %s;' % (channel.size, channel.name) + print(' int%u_t %s;' % (channel.size, channel.name)) elif channel.type == FLOAT: if channel.size == 64: - print ' double %s;' % (channel.name) + print(' double %s;' % (channel.name)) elif channel.size == 32: - print ' float %s;' % (channel.name) + print(' float %s;' % (channel.name)) elif channel.size == 16: - print ' uint16_t %s;' % (channel.name) + print(' uint16_t %s;' % (channel.name)) else: assert 0 else: assert 0 - print 'union util_format_%s {' % format.short_name() + print('union util_format_%s {' % format.short_name()) if format.block_size() in (8, 16, 32, 64): - print ' uint%u_t value;' % (format.block_size(),) + print(' uint%u_t value;' % (format.block_size(),)) use_bitfields = False for channel in format.le_channels: if channel.size % 8 or not is_pot(channel.size): use_bitfields = True - print ' struct {' + print(' struct {') if use_bitfields: print_channels(format, generate_bitfields) else: print_channels(format, generate_full_fields) - print ' } chan;' - print '};' - print + print(' } chan;') + print('};') + print() def is_format_supported(format): @@ -444,15 +446,15 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): def unpack_from_bitmask(channels, swizzles): depth = format.block_size() - print ' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth) + print(' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth)) # Declare the intermediate variables for i in range(format.nr_channels()): src_channel = channels[i] if src_channel.type == UNSIGNED: - print ' uint%u_t %s;' % (depth, src_channel.name) + print(' uint%u_t %s;' % (depth, src_channel.name)) elif src_channel.type == SIGNED: - print ' int%u_t %s;' % (depth, src_channel.name) + print(' int%u_t %s;' % (depth, src_channel.name)) # Compute the intermediate unshifted values for i in range(format.nr_channels()): @@ -479,7 +481,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): value = None if value is not None: - print ' %s = %s;' % (src_channel.name, value) + print(' %s = %s;' % (src_channel.name, value)) # Convert, swizzle, and store final values for i in range(4): @@ -503,11 +505,11 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): value = '0' else: assert False - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + print(' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])) def unpack_from_union(channels, swizzles): - print ' union util_format_%s pixel;' % format.short_name() - print ' memcpy(&pixel, src, sizeof pixel);' + print(' union util_format_%s pixel;' % format.short_name()) + print(' memcpy(&pixel, src, sizeof pixel);') for i in range(4): swizzle = swizzles[i] @@ -530,7 +532,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type): value = '0' else: assert False - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + print(' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])) if format.is_bitmask(): print_channels(format, unpack_from_bitmask) @@ -551,7 +553,7 @@ def generate_pack_kernel(format, src_channel, src_native_type): inv_swizzle = inv_swizzles(swizzles) depth = format.block_size() - print ' uint%u_t value = 0;' % depth + print(' uint%u_t value = 0;' % depth) for i in range(4): dst_channel = channels[i] @@ -577,14 +579,14 @@ def generate_pack_kernel(format, src_channel, src_native_type): else: value = None if value is not None: - print ' value |= %s;' % (value) + print(' value |= %s;' % (value)) - print ' *(uint%u_t *)dst = value;' % depth + print(' *(uint%u_t *)dst = value;' % depth) def pack_into_union(channels, swizzles): inv_swizzle = inv_swizzles(swizzles) - print ' union util_format_%s pixel;' % format.short_name() + print(' union util_format_%s pixel;' % format.short_name()) for i in range(4): dst_channel = channels[i] @@ -600,9 +602,9 @@ def generate_pack_kernel(format, src_channel, src_native_type): dst_channel, dst_native_type, value, dst_colorspace = dst_colorspace) - print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + print(' pixel.chan.%s = %s;' % (dst_channel.name, value)) - print ' memcpy(dst, &pixel, sizeof pixel);' + print(' memcpy(dst, &pixel, sizeof pixel);') if format.is_bitmask(): print_channels(format, pack_into_bitmask) @@ -615,28 +617,28 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): name = format.short_name() - print 'static inline void' - print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type) - print '{' + print('static inline void') + print('util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type)) + print('{') if is_format_supported(format): - print ' unsigned x, y;' - print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) - print ' %s *dst = dst_row;' % (dst_native_type) - print ' const uint8_t *src = src_row;' - print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) + print(' unsigned x, y;') + print(' for(y = 0; y < height; y += %u) {' % (format.block_height,)) + print(' %s *dst = dst_row;' % (dst_native_type)) + print(' const uint8_t *src = src_row;') + print(' for(x = 0; x < width; x += %u) {' % (format.block_width,)) generate_unpack_kernel(format, dst_channel, dst_native_type) - print ' src += %u;' % (format.block_size() / 8,) - print ' dst += 4;' - print ' }' - print ' src_row += src_stride;' - print ' dst_row += dst_stride/sizeof(*dst_row);' - print ' }' - - print '}' - print + print(' src += %u;' % (format.block_size() / 8,)) + print(' dst += 4;') + print(' }') + print(' src_row += src_stride;') + print(' dst_row += dst_stride/sizeof(*dst_row);') + print(' }') + + print('}') + print() def generate_format_pack(format, src_channel, src_native_type, src_suffix): @@ -644,28 +646,28 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): name = format.short_name() - print 'static inline void' - print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type) - print '{' + print('static inline void') + print('util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type)) + print('{') if is_format_supported(format): - print ' unsigned x, y;' - print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) - print ' const %s *src = src_row;' % (src_native_type) - print ' uint8_t *dst = dst_row;' - print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) + print(' unsigned x, y;') + print(' for(y = 0; y < height; y += %u) {' % (format.block_height,)) + print(' const %s *src = src_row;' % (src_native_type)) + print(' uint8_t *dst = dst_row;') + print(' for(x = 0; x < width; x += %u) {' % (format.block_width,)) generate_pack_kernel(format, src_channel, src_native_type) - print ' src += 4;' - print ' dst += %u;' % (format.block_size() / 8,) - print ' }' - print ' dst_row += dst_stride;' - print ' src_row += src_stride/sizeof(*src_row);' - print ' }' + print(' src += 4;') + print(' dst += %u;' % (format.block_size() / 8,)) + print(' }') + print(' dst_row += dst_stride;') + print(' src_row += src_stride/sizeof(*src_row);') + print(' }') - print '}' - print + print('}') + print() def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix): @@ -673,15 +675,15 @@ def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix): name = format.short_name() - print 'static inline void' - print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, UNUSED unsigned i, UNUSED unsigned j)' % (name, dst_suffix, dst_native_type) - print '{' + print('static inline void') + print('util_format_%s_fetch_%s(%s *dst, const uint8_t *src, UNUSED unsigned i, UNUSED unsigned j)' % (name, dst_suffix, dst_native_type)) + print('{') if is_format_supported(format): generate_unpack_kernel(format, dst_channel, dst_native_type) - print '}' - print + print('}') + print() def is_format_hand_written(format): @@ -689,16 +691,16 @@ def is_format_hand_written(format): def generate(formats): - print - print '#include "pipe/p_compiler.h"' - print '#include "u_math.h"' - print '#include "u_half.h"' - print '#include "u_format.h"' - print '#include "u_format_other.h"' - print '#include "util/format_srgb.h"' - print '#include "u_format_yuv.h"' - print '#include "u_format_zs.h"' - print + print() + print('#include "pipe/p_compiler.h"') + print('#include "u_math.h"') + print('#include "u_half.h"') + print('#include "u_format.h"') + print('#include "u_format_other.h"') + print('#include "util/format_srgb.h"') + print('#include "u_format_yuv.h"') + print('#include "u_format_zs.h"') + print() for format in formats: if not is_format_hand_written(format): diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index a9df9849947..1a966c52bc7 100644 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -1,3 +1,4 @@ +from __future__ import print_function CopyRight = ''' /************************************************************************** @@ -79,23 +80,23 @@ swizzle_map = { def write_format_table(formats): - print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */' - print + print('/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */') + print() # This will print the copyright message on the top of this file - print CopyRight.strip() - print - print '#include "u_format.h"' - print '#include "u_format_bptc.h"' - print '#include "u_format_s3tc.h"' - print '#include "u_format_rgtc.h"' - print '#include "u_format_latc.h"' - print '#include "u_format_etc.h"' - print + print(CopyRight.strip()) + print() + print('#include "u_format.h"') + print('#include "u_format_bptc.h"') + print('#include "u_format_s3tc.h"') + print('#include "u_format_rgtc.h"') + print('#include "u_format_latc.h"') + print('#include "u_format_etc.h"') + print() u_format_pack.generate(formats) def do_channel_array(channels, swizzles): - print " {" + print(" {") for i in range(4): channel = channels[i] if i < 3: @@ -103,13 +104,13 @@ def write_format_table(formats): else: sep = "" if channel.size: - print " {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name) + print(" {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name)) else: - print " {0, 0, 0, 0, 0}%s" % (sep,) - print " }," + print(" {0, 0, 0, 0, 0}%s" % (sep,)) + print(" },") def do_swizzle_array(channels, swizzles): - print " {" + print(" {") for i in range(4): swizzle = swizzles[i] if i < 3: @@ -120,102 +121,102 @@ def write_format_table(formats): comment = colorspace_channels_map[format.colorspace][i] except (KeyError, IndexError): comment = 'ignored' - print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) - print " }," + print(" %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)) + print(" },") for format in formats: - print 'const struct util_format_description' - print 'util_format_%s_description = {' % (format.short_name(),) - print " %s," % (format.name,) - print " \"%s\"," % (format.name,) - print " \"%s\"," % (format.short_name(),) - print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) - print " %s," % (layout_map(format.layout),) - print " %u,\t/* nr_channels */" % (format.nr_channels(),) - print " %s,\t/* is_array */" % (bool_map(format.is_array()),) - print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),) - print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) + print('const struct util_format_description') + print('util_format_%s_description = {' % (format.short_name(),)) + print(" %s," % (format.name,)) + print(" \"%s\"," % (format.name,)) + print(" \"%s\"," % (format.short_name(),)) + print(" {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())) + print(" %s," % (layout_map(format.layout),)) + print(" %u,\t/* nr_channels */" % (format.nr_channels(),)) + print(" %s,\t/* is_array */" % (bool_map(format.is_array()),)) + print(" %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)) + print(" %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)) u_format_pack.print_channels(format, do_channel_array) u_format_pack.print_channels(format, do_swizzle_array) - print " %s," % (colorspace_map(format.colorspace),) + print(" %s," % (colorspace_map(format.colorspace),)) access = True if format.layout == 'astc': access = False if format.layout == 'etc' and format.short_name() != 'etc1_rgb8': access = False if format.colorspace != ZS and not format.is_pure_color() and access: - print " &util_format_%s_unpack_rgba_8unorm," % format.short_name() - print " &util_format_%s_pack_rgba_8unorm," % format.short_name() + print(" &util_format_%s_unpack_rgba_8unorm," % format.short_name()) + print(" &util_format_%s_pack_rgba_8unorm," % format.short_name()) if format.layout == 's3tc' or format.layout == 'rgtc': - print " &util_format_%s_fetch_rgba_8unorm," % format.short_name() + print(" &util_format_%s_fetch_rgba_8unorm," % format.short_name()) else: - print " NULL, /* fetch_rgba_8unorm */" - print " &util_format_%s_unpack_rgba_float," % format.short_name() - print " &util_format_%s_pack_rgba_float," % format.short_name() - print " &util_format_%s_fetch_rgba_float," % format.short_name() + print(" NULL, /* fetch_rgba_8unorm */") + print(" &util_format_%s_unpack_rgba_float," % format.short_name()) + print(" &util_format_%s_pack_rgba_float," % format.short_name()) + print(" &util_format_%s_fetch_rgba_float," % format.short_name()) else: - print " NULL, /* unpack_rgba_8unorm */" - print " NULL, /* pack_rgba_8unorm */" - print " NULL, /* fetch_rgba_8unorm */" - print " NULL, /* unpack_rgba_float */" - print " NULL, /* pack_rgba_float */" - print " NULL, /* fetch_rgba_float */" + print(" NULL, /* unpack_rgba_8unorm */") + print(" NULL, /* pack_rgba_8unorm */") + print(" NULL, /* fetch_rgba_8unorm */") + print(" NULL, /* unpack_rgba_float */") + print(" NULL, /* pack_rgba_float */") + print(" NULL, /* fetch_rgba_float */") if format.has_depth(): - print " &util_format_%s_unpack_z_32unorm," % format.short_name() - print " &util_format_%s_pack_z_32unorm," % format.short_name() - print " &util_format_%s_unpack_z_float," % format.short_name() - print " &util_format_%s_pack_z_float," % format.short_name() + print(" &util_format_%s_unpack_z_32unorm," % format.short_name()) + print(" &util_format_%s_pack_z_32unorm," % format.short_name()) + print(" &util_format_%s_unpack_z_float," % format.short_name()) + print(" &util_format_%s_pack_z_float," % format.short_name()) else: - print " NULL, /* unpack_z_32unorm */" - print " NULL, /* pack_z_32unorm */" - print " NULL, /* unpack_z_float */" - print " NULL, /* pack_z_float */" + print(" NULL, /* unpack_z_32unorm */") + print(" NULL, /* pack_z_32unorm */") + print(" NULL, /* unpack_z_float */") + print(" NULL, /* pack_z_float */") if format.has_stencil(): - print " &util_format_%s_unpack_s_8uint," % format.short_name() - print " &util_format_%s_pack_s_8uint," % format.short_name() + print(" &util_format_%s_unpack_s_8uint," % format.short_name()) + print(" &util_format_%s_pack_s_8uint," % format.short_name()) else: - print " NULL, /* unpack_s_8uint */" - print " NULL, /* pack_s_8uint */" + print(" NULL, /* unpack_s_8uint */") + print(" NULL, /* pack_s_8uint */") if format.is_pure_unsigned(): - print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name() - print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name() - print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name() - print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name() - print " &util_format_%s_fetch_unsigned, /* fetch_rgba_uint */" % format.short_name() - print " NULL /* fetch_rgba_sint */" + print(" &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()) + print(" &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()) + print(" &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()) + print(" &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()) + print(" &util_format_%s_fetch_unsigned, /* fetch_rgba_uint */" % format.short_name()) + print(" NULL /* fetch_rgba_sint */") elif format.is_pure_signed(): - print " &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name() - print " &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name() - print " &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name() - print " &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name() - print " NULL, /* fetch_rgba_uint */" - print " &util_format_%s_fetch_signed /* fetch_rgba_sint */" % format.short_name() + print(" &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()) + print(" &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()) + print(" &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()) + print(" &util_format_%s_pack_signed, /* pack_rgba_sint */" % format.short_name()) + print(" NULL, /* fetch_rgba_uint */") + print(" &util_format_%s_fetch_signed /* fetch_rgba_sint */" % format.short_name()) else: - print " NULL, /* unpack_rgba_uint */" - print " NULL, /* pack_rgba_uint */" - print " NULL, /* unpack_rgba_sint */" - print " NULL, /* pack_rgba_sint */" - print " NULL, /* fetch_rgba_uint */" - print " NULL /* fetch_rgba_sint */" - print "};" - print + print(" NULL, /* unpack_rgba_uint */") + print(" NULL, /* pack_rgba_uint */") + print(" NULL, /* unpack_rgba_sint */") + print(" NULL, /* pack_rgba_sint */") + print(" NULL, /* fetch_rgba_uint */") + print(" NULL /* fetch_rgba_sint */") + print("};") + print() - print "const struct util_format_description *" - print "util_format_description(enum pipe_format format)" - print "{" - print " if (format >= PIPE_FORMAT_COUNT) {" - print " return NULL;" - print " }" - print - print " switch (format) {" + print("const struct util_format_description *") + print("util_format_description(enum pipe_format format)") + print("{") + print(" if (format >= PIPE_FORMAT_COUNT) {") + print(" return NULL;") + print(" }") + print() + print(" switch (format) {") for format in formats: - print " case %s:" % format.name - print " return &util_format_%s_description;" % (format.short_name(),) - print " default:" - print " return NULL;" - print " }" - print "}" - print + print(" case %s:" % format.name) + print(" return &util_format_%s_description;" % (format.short_name(),)) + print(" default:") + print(" return NULL;") + print(" }") + print("}") + print() def main(): diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py index a0ab9d01903..3968aea543c 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py +++ b/src/gallium/drivers/freedreno/ir3/ir3_nir_trig.py @@ -20,6 +20,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import print_function + import argparse import sys @@ -40,9 +42,9 @@ def main(): def run(): import nir_algebraic # pylint: disable=import-error - print '#include "ir3_nir.h"' - print nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds", - trig_workarounds).render() + print('#include "ir3_nir.h"') + print(nir_algebraic.AlgebraicPass("ir3_nir_apply_trig_workarounds", + trig_workarounds).render()) if __name__ == '__main__': diff --git a/src/gallium/drivers/r600/egd_tables.py b/src/gallium/drivers/r600/egd_tables.py index d7b78c7fb16..7489649ec72 100644 --- a/src/gallium/drivers/r600/egd_tables.py +++ b/src/gallium/drivers/r600/egd_tables.py @@ -1,3 +1,4 @@ +from __future__ import print_function CopyRight = ''' /* @@ -217,10 +218,10 @@ def write_tables(regs, packets): strings = StringTable() strings_offsets = IntTable("int") - print '/* This file is autogenerated by egd_tables.py from evergreend.h. Do not edit directly. */' - print - print CopyRight.strip() - print ''' + print('/* This file is autogenerated by egd_tables.py from evergreend.h. Do not edit directly. */') + print() + print(CopyRight.strip()) + print(''' #ifndef EG_TABLES_H #define EG_TABLES_H @@ -242,20 +243,20 @@ struct eg_packet3 { unsigned name_offset; unsigned op; }; -''' +''') - print 'static const struct eg_packet3 packet3_table[] = {' + print('static const struct eg_packet3 packet3_table[] = {') for pkt in packets: - print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt) - print '};' - print + print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt)) + print('};') + print() - print 'static const struct eg_field egd_fields_table[] = {' + print('static const struct eg_field egd_fields_table[] = {') fields_idx = 0 for reg in regs: if len(reg.fields) and reg.own_fields: - print '\t/* %s */' % (fields_idx) + print('\t/* %s */' % (fields_idx)) reg.fields_idx = fields_idx @@ -266,34 +267,34 @@ struct eg_packet3 { while value[1] >= len(values_offsets): values_offsets.append(-1) values_offsets[value[1]] = strings.add(strip_prefix(value[0])) - print '\t{%s, %s(~0u), %s, %s},' % ( + print('\t{%s, %s(~0u), %s, %s},' % ( strings.add(field.name), field.s_name, - len(values_offsets), strings_offsets.add(values_offsets)) + len(values_offsets), strings_offsets.add(values_offsets))) else: - print '\t{%s, %s(~0u)},' % (strings.add(field.name), field.s_name) + print('\t{%s, %s(~0u)},' % (strings.add(field.name), field.s_name)) fields_idx += 1 - print '};' - print + print('};') + print() - print 'static const struct eg_reg egd_reg_table[] = {' + print('static const struct eg_reg egd_reg_table[] = {') for reg in regs: if len(reg.fields): - print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name, - len(reg.fields), reg.fields_idx if reg.own_fields else reg.fields_owner.fields_idx) + print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name, + len(reg.fields), reg.fields_idx if reg.own_fields else reg.fields_owner.fields_idx)) else: - print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name) - print '};' - print + print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name)) + print('};') + print() strings.emit(sys.stdout, "egd_strings") - print + print() strings_offsets.emit(sys.stdout, "egd_strings_offsets") - print - print '#endif' + print() + print('#endif') def main(): |