wolfhece.opengl.tile_packer

Module Contents

class wolfhece.opengl.tile_packer.TilePackingMode[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.opengl.tile_packer.TilePackingMode

Generic enumeration.

Derive from this class to define new enumerations.

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