wolfhece.opengl.tile_packer
Module Contents
- class wolfhece.opengl.tile_packer.TilePackingMode(*args, **kwds)[source]
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- class wolfhece.opengl.tile_packer.TilePacker(nap: numpy.ndarray, tile_size: int, mode: TilePackingMode = TilePackingMode.REGULAR)[source]
A class that packs an array in tiles and provides an indirection map
- After the initialization phase based on the “NAP” array, the class provides two methods:
shuffle_and_pack_array
unpack_and_deshuffle_array
- mode() TilePackingMode [source]
- packed_size()[source]
Size of the arrays after padding them and packing them in tiles, expressed in meshes. Size is a (width, height) tuple.
Note that this size can be very different than the actual computation domain size.
- packed_size_in_tiles()[source]
Size of the arrays after padding them and packing them in tiles, expressed in tiles. Size is a (width, height) tuple.
Note that this size can be very different than the actual computation domain size.
- size_in_tiles()[source]
Size of the (original, non packed, non tiled) computation domain, in tiles. Not that we count full tiles. So if one dimension of the domain is not a multiple of the tile size, then we round one tile up.
Size is a (width, height) tuple.
- unpack_and_deshuffle_array(a: numpy.ndarray) numpy.ndarray [source]
De-shuffle and un-pad an array that was shuffled and padded.
- _pad_array_to_tiles(a: numpy.ndarray) numpy.ndarray [source]
Make an array fit in a given number of tiles (on x and y axis). After this, the array’s dimensions are multiple of the tile_size.
- shuffle_and_pack_array(a: numpy.ndarray, neutral_values=None) numpy.ndarray [source]
Reorganize an array by moving tiles around to follow the ordering given by self._tile_indirection_map The array is resized in order to be just as large as needed to hold the active tiles plus the “empty” tile.
neutral_values: value to fill the empty tile with.