update u_format_parse from mesa to handle python3

macos/master
Dave Airlie 6 years ago
parent 402c228861
commit 9b91cc380f
  1. 16
      src/gallium/auxiliary/util/u_format_parse.py

@ -1,4 +1,3 @@
#!/usr/bin/env python
''' '''
/************************************************************************** /**************************************************************************
@ -30,6 +29,9 @@
''' '''
from __future__ import division
VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5) VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7) SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7)
@ -70,14 +72,20 @@ class Channel:
return s return s
def __eq__(self, other): def __eq__(self, other):
if other is None:
return False
return self.type == other.type and self.norm == other.norm and self.pure == other.pure and self.size == other.size return self.type == other.type and self.norm == other.norm and self.pure == other.pure and self.size == other.size
def __ne__(self, other):
return not self == other
def max(self): def max(self):
'''Maximum representable number.''' '''Maximum representable number.'''
if self.type == FLOAT: if self.type == FLOAT:
return VERY_LARGE return VERY_LARGE
if self.type == FIXED: if self.type == FIXED:
return (1 << (self.size/2)) - 1 return (1 << (self.size // 2)) - 1
if self.norm: if self.norm:
return 1 return 1
if self.type == UNSIGNED: if self.type == UNSIGNED:
@ -91,7 +99,7 @@ class Channel:
if self.type == FLOAT: if self.type == FLOAT:
return -VERY_LARGE return -VERY_LARGE
if self.type == FIXED: if self.type == FIXED:
return -(1 << (self.size/2)) return -(1 << (self.size // 2))
if self.type == UNSIGNED: if self.type == UNSIGNED:
return 0 return 0
if self.norm: if self.norm:
@ -313,7 +321,7 @@ def _parse_channels(fields, layout, colorspace, swizzles):
return channels return channels
def parse(filename): def parse(filename):
'''Parse the format descrition in CSV format in terms of the '''Parse the format description in CSV format in terms of the
Channel and Format classes above.''' Channel and Format classes above.'''
stream = open(filename) stream = open(filename)

Loading…
Cancel
Save