1 /* 2 * Mesa 3-D graphics library 3 * 4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 5 * Copyright (c) 2008-2009 VMware, Inc. 6 * Copyright (c) 2012 Intel Corporation 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the "Software"), 10 * to deal in the Software without restriction, including without limitation 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 * and/or sell copies of the Software, and to permit persons to whom the 13 * Software is furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included 16 * in all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 * OTHER DEALINGS IN THE SOFTWARE. 25 */ 26 27 #ifndef GLFORMATS_H 28 #define GLFORMATS_H 29 30 31 #include <stdbool.h> 32 #include <stdint.h> 33 #include <GL/gl.h> 34 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 struct gl_context; 41 42 extern void 43 _mesa_compute_component_mapping(GLenum inFormat, GLenum outFormat, GLubyte *map); 44 45 extern GLboolean 46 _mesa_type_is_packed(GLenum type); 47 48 extern GLint 49 _mesa_sizeof_type( GLenum type ); 50 51 extern GLint 52 _mesa_sizeof_packed_type( GLenum type ); 53 54 extern GLint 55 _mesa_components_in_format( GLenum format ); 56 57 extern GLint 58 _mesa_bytes_per_pixel( GLenum format, GLenum type ); 59 60 extern GLint 61 _mesa_bytes_per_vertex_attrib(GLint comps, GLenum type); 62 63 extern GLboolean 64 _mesa_is_astc_format(GLenum internalFormat); 65 66 extern GLboolean 67 _mesa_is_etc2_format(GLenum internalFormat); 68 69 extern GLboolean 70 _mesa_is_type_unsigned(GLenum type); 71 72 extern GLboolean 73 _mesa_is_enum_format_unsized(GLenum format); 74 75 extern GLboolean 76 _mesa_is_enum_format_unorm(GLenum format); 77 78 extern GLboolean 79 _mesa_is_enum_format_snorm(GLenum format); 80 81 extern GLboolean 82 _mesa_is_enum_format_integer(GLenum format); 83 84 extern GLboolean 85 _mesa_is_enum_format_unsigned_int(GLenum format); 86 87 extern GLboolean 88 _mesa_is_enum_format_signed_int(GLenum format); 89 90 extern GLboolean 91 _mesa_is_color_format(GLenum format); 92 93 extern GLboolean 94 _mesa_is_depth_format(GLenum format); 95 96 extern GLboolean 97 _mesa_is_stencil_format(GLenum format); 98 99 extern GLboolean 100 _mesa_is_ycbcr_format(GLenum format); 101 102 extern GLboolean 103 _mesa_is_depthstencil_format(GLenum format); 104 105 extern GLboolean 106 _mesa_is_depth_or_stencil_format(GLenum format); 107 108 extern GLboolean 109 _mesa_has_depth_float_channel(GLenum internalFormat); 110 111 extern GLboolean 112 _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format); 113 114 extern GLboolean 115 _mesa_is_srgb_format(GLenum format); 116 117 extern GLenum 118 _mesa_base_format_to_integer_format(GLenum format); 119 120 extern GLenum 121 _mesa_unpack_format_to_base_format(GLenum format); 122 123 extern GLboolean 124 _mesa_base_format_has_channel(GLenum base_format, GLenum pname); 125 126 extern GLenum 127 _mesa_generic_compressed_format_to_uncompressed_format(GLenum format); 128 129 extern GLenum 130 _mesa_get_nongeneric_internalformat(GLenum format); 131 132 extern GLenum 133 _mesa_get_linear_internalformat(GLenum format); 134 135 extern GLenum 136 _mesa_error_check_format_and_type(const struct gl_context *ctx, 137 GLenum format, GLenum type); 138 139 extern GLenum 140 _mesa_es_error_check_format_and_type(const struct gl_context *ctx, 141 GLenum format, GLenum type, 142 unsigned dimensions); 143 144 extern GLenum 145 _mesa_gles_error_check_format_and_type(const struct gl_context *ctx, 146 GLenum format, GLenum type, 147 GLenum internalFormat); 148 extern GLint 149 _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat ); 150 151 extern uint32_t 152 _mesa_format_from_format_and_type(GLenum format, GLenum type); 153 154 bool 155 _mesa_swap_bytes_in_type_enum(GLenum *type); 156 157 extern uint32_t 158 _mesa_tex_format_from_format_and_type(const struct gl_context *ctx, 159 GLenum gl_format, GLenum type); 160 161 extern bool 162 _mesa_is_es3_color_renderable(const struct gl_context *ctx, 163 GLenum internal_format); 164 165 extern bool 166 _mesa_is_es3_texture_filterable(const struct gl_context *ctx, 167 GLenum internal_format); 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif /* GLFORMATS_H */ 174