Device, computer readable medium, and method for selecting compression modes to be applied in a depth buffer (20). The method includes obtaining values corresponding to a tile (30) of the depth buffer (20), selecting a first compression mode (34) from a first plurality of compression modes, compressing the values of the tile (30), writing the compressed values into a first block, based on the first mode (34), and using a preset number of primary bits (34) to store information related to at least one of the first mode (34) and a compression size of the first block, selecting a set of secondary compression modes (32) from a second plurality of compression modes, determining a number of sub-tiles (28), that make up the tile (30), compressing values of the sub-tiles, writing the compressed values into a second block, based on the set of secondary modes (32), and using the same preset number of primary bits (34) to store information related to at least one of the set of secondary modes (32) and a compression size of the second block, comparing the compression size of the tile (30) to the compression size of the sub-tiles (28), choosing the first mode (34) or the set of secondary modes (32) and a corresponding tile size based on a result of the comparing, and storing the selected compressed tile or sub-tiles into the depth buffer (20) and writing into the preset number of primary bits (34) information related to the chosen first mode (34) or set of secondary compression modes (32) or a corresponding size.