wolfhece.opengl.tile_packer

Module Contents

class wolfhece.opengl.tile_packer.TilePackingMode(*args, **kwds)[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.opengl.tile_packer.TilePackingMode

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.

REGULAR = 1[source]
TRANSPARENT = 3[source]
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

_tile_size[source]
_mode[source]
_original_nap[source]
_active_tiles_ndx[source]
_nb_active_tiles[source]
_packed_nb_tiles_x[source]
_packed_nb_tiles_y[source]
_tile_indirection_map[source]
tile_indirection_map()[source]
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.

tile_size() int[source]

The tile size. Note that tiles are squared.

active_tiles_ndx()[source]
unpack_and_deshuffle_array(a: numpy.ndarray) numpy.ndarray[source]

De-shuffle and un-pad an array that was shuffled and padded.

_unpad_array(a: numpy.ndarray) numpy.ndarray[source]

Undo _pad_array_to_tiles.

_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.