The open source OpenXR runtime
at main 70 lines 1.2 kB view raw
1// Copyright 2019, Collabora, Ltd. 2// SPDX-License-Identifier: BSL-1.0 3/*! 4 * @file 5 * @brief Format helpers and block code. 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 * @ingroup aux_util 8 */ 9 10#pragma once 11 12#include "xrt/xrt_defines.h" 13 14#ifdef __cplusplus 15extern "C" { 16#endif 17 18 19/*! 20 * Return string for this format. 21 * 22 * @ingroup aux_util 23 */ 24const char * 25u_format_str(enum xrt_format f); 26 27/*! 28 * Is this format block based, also returns true for formats that 1x1 blocks. 29 * 30 * @ingroup aux_util 31 */ 32bool 33u_format_is_blocks(enum xrt_format f); 34 35/*! 36 * Returns the width of the block for the given format. 37 * 38 * @ingroup aux_util 39 */ 40uint32_t 41u_format_block_width(enum xrt_format f); 42 43/*! 44 * Returns the height of the block for the given format. 45 * 46 * @ingroup aux_util 47 */ 48uint32_t 49u_format_block_height(enum xrt_format f); 50 51/*! 52 * Returns the size of the block for the given format. 53 * 54 * @ingroup aux_util 55 */ 56size_t 57u_format_block_size(enum xrt_format f); 58 59/*! 60 * Calculate stride and size for the format and given width and height. 61 * 62 * @ingroup aux_util 63 */ 64void 65u_format_size_for_dimensions(enum xrt_format f, uint32_t width, uint32_t height, size_t *out_stride, size_t *out_size); 66 67 68#ifdef __cplusplus 69} 70#endif