1bf215546Sopenharmony_ci/** 2bf215546Sopenharmony_ci * \file teximage.h 3bf215546Sopenharmony_ci * Texture images manipulation functions. 4bf215546Sopenharmony_ci */ 5bf215546Sopenharmony_ci 6bf215546Sopenharmony_ci/* 7bf215546Sopenharmony_ci * Mesa 3-D graphics library 8bf215546Sopenharmony_ci * 9bf215546Sopenharmony_ci * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 12bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 13bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 14bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 16bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included 19bf215546Sopenharmony_ci * in all copies or substantial portions of the Software. 20bf215546Sopenharmony_ci * 21bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 28bf215546Sopenharmony_ci */ 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#ifndef TEXIMAGE_H 32bf215546Sopenharmony_ci#define TEXIMAGE_H 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include "mtypes.h" 36bf215546Sopenharmony_ci#include "formats.h" 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#ifdef __cplusplus 39bf215546Sopenharmony_ciextern "C" { 40bf215546Sopenharmony_ci#endif 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_ci/** Is the given value one of the 6 cube faces? */ 43bf215546Sopenharmony_cistatic inline GLboolean 44bf215546Sopenharmony_ci_mesa_is_cube_face(GLenum target) 45bf215546Sopenharmony_ci{ 46bf215546Sopenharmony_ci return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && 47bf215546Sopenharmony_ci target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); 48bf215546Sopenharmony_ci} 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci/** 52bf215546Sopenharmony_ci * Return number of faces for a texture target. This will be 6 for 53bf215546Sopenharmony_ci * cube maps and 1 otherwise. 54bf215546Sopenharmony_ci * NOTE: this function is not used for cube map arrays which operate 55bf215546Sopenharmony_ci * more like 2D arrays than cube maps. 56bf215546Sopenharmony_ci */ 57bf215546Sopenharmony_cistatic inline GLuint 58bf215546Sopenharmony_ci_mesa_num_tex_faces(GLenum target) 59bf215546Sopenharmony_ci{ 60bf215546Sopenharmony_ci switch (target) { 61bf215546Sopenharmony_ci case GL_TEXTURE_CUBE_MAP: 62bf215546Sopenharmony_ci case GL_PROXY_TEXTURE_CUBE_MAP: 63bf215546Sopenharmony_ci return 6; 64bf215546Sopenharmony_ci default: 65bf215546Sopenharmony_ci return 1; 66bf215546Sopenharmony_ci } 67bf215546Sopenharmony_ci} 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci/** 71bf215546Sopenharmony_ci * If the target is GL_TEXTURE_CUBE_MAP, return one of the 72bf215546Sopenharmony_ci * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z targets corresponding to 73bf215546Sopenharmony_ci * the face parameter. 74bf215546Sopenharmony_ci * Else, return target as-is. 75bf215546Sopenharmony_ci */ 76bf215546Sopenharmony_cistatic inline GLenum 77bf215546Sopenharmony_ci_mesa_cube_face_target(GLenum target, unsigned face) 78bf215546Sopenharmony_ci{ 79bf215546Sopenharmony_ci if (target == GL_TEXTURE_CUBE_MAP) { 80bf215546Sopenharmony_ci assert(face < 6); 81bf215546Sopenharmony_ci return GL_TEXTURE_CUBE_MAP_POSITIVE_X + face; 82bf215546Sopenharmony_ci } 83bf215546Sopenharmony_ci else { 84bf215546Sopenharmony_ci return target; 85bf215546Sopenharmony_ci } 86bf215546Sopenharmony_ci} 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci/** 90bf215546Sopenharmony_ci * For cube map faces, return a face index in [0,5]. 91bf215546Sopenharmony_ci * For other targets return 0; 92bf215546Sopenharmony_ci */ 93bf215546Sopenharmony_cistatic inline GLuint 94bf215546Sopenharmony_ci_mesa_tex_target_to_face(GLenum target) 95bf215546Sopenharmony_ci{ 96bf215546Sopenharmony_ci if (_mesa_is_cube_face(target)) 97bf215546Sopenharmony_ci return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; 98bf215546Sopenharmony_ci else 99bf215546Sopenharmony_ci return 0; 100bf215546Sopenharmony_ci} 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci/** Are any of the dimensions of given texture equal to zero? */ 104bf215546Sopenharmony_cistatic inline GLboolean 105bf215546Sopenharmony_ci_mesa_is_zero_size_texture(const struct gl_texture_image *texImage) 106bf215546Sopenharmony_ci{ 107bf215546Sopenharmony_ci return (texImage->Width == 0 || 108bf215546Sopenharmony_ci texImage->Height == 0 || 109bf215546Sopenharmony_ci texImage->Depth == 0); 110bf215546Sopenharmony_ci} 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci/** \name Internal functions */ 113bf215546Sopenharmony_ci/*@{*/ 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ciextern GLboolean 116bf215546Sopenharmony_ci_mesa_is_proxy_texture(GLenum target); 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_ciextern bool 119bf215546Sopenharmony_ci_mesa_is_array_texture(GLenum target); 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_ciextern void 123bf215546Sopenharmony_ci_mesa_delete_texture_image( struct gl_context *ctx, 124bf215546Sopenharmony_ci struct gl_texture_image *teximage ); 125bf215546Sopenharmony_ci 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ciextern void 128bf215546Sopenharmony_ci_mesa_init_teximage_fields(struct gl_context *ctx, 129bf215546Sopenharmony_ci struct gl_texture_image *img, 130bf215546Sopenharmony_ci GLsizei width, GLsizei height, GLsizei depth, 131bf215546Sopenharmony_ci GLint border, GLenum internalFormat, 132bf215546Sopenharmony_ci mesa_format format); 133bf215546Sopenharmony_ciextern void 134bf215546Sopenharmony_ci_mesa_init_teximage_fields_ms(struct gl_context *ctx, 135bf215546Sopenharmony_ci struct gl_texture_image *img, 136bf215546Sopenharmony_ci GLsizei width, GLsizei height, GLsizei depth, 137bf215546Sopenharmony_ci GLint border, GLenum internalFormat, 138bf215546Sopenharmony_ci mesa_format format, 139bf215546Sopenharmony_ci GLuint numSamples, 140bf215546Sopenharmony_ci GLboolean fixedSampleLocations); 141bf215546Sopenharmony_ci 142bf215546Sopenharmony_ci 143bf215546Sopenharmony_ciextern mesa_format 144bf215546Sopenharmony_ci_mesa_choose_texture_format(struct gl_context *ctx, 145bf215546Sopenharmony_ci struct gl_texture_object *texObj, 146bf215546Sopenharmony_ci GLenum target, GLint level, 147bf215546Sopenharmony_ci GLenum internalFormat, GLenum format, GLenum type); 148bf215546Sopenharmony_ci 149bf215546Sopenharmony_ciextern void 150bf215546Sopenharmony_ci_mesa_update_fbo_texture(struct gl_context *ctx, 151bf215546Sopenharmony_ci struct gl_texture_object *texObj, 152bf215546Sopenharmony_ci GLuint face, GLuint level); 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_ciextern void 155bf215546Sopenharmony_ci_mesa_clear_texture_image(struct gl_context *ctx, 156bf215546Sopenharmony_ci struct gl_texture_image *texImage); 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_ciextern struct gl_texture_image * 160bf215546Sopenharmony_ci_mesa_select_tex_image(const struct gl_texture_object *texObj, 161bf215546Sopenharmony_ci GLenum target, GLint level); 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_ci 164bf215546Sopenharmony_ciextern struct gl_texture_image * 165bf215546Sopenharmony_ci_mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj, 166bf215546Sopenharmony_ci GLenum target, GLint level); 167bf215546Sopenharmony_ci 168bf215546Sopenharmony_cimesa_format 169bf215546Sopenharmony_ci_mesa_get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat); 170bf215546Sopenharmony_ci 171bf215546Sopenharmony_ci/** 172bf215546Sopenharmony_ci * Return the base-level texture image for the given texture object. 173bf215546Sopenharmony_ci */ 174bf215546Sopenharmony_cistatic inline const struct gl_texture_image * 175bf215546Sopenharmony_ci_mesa_base_tex_image(const struct gl_texture_object *texObj) 176bf215546Sopenharmony_ci{ 177bf215546Sopenharmony_ci return texObj->Image[0][texObj->Attrib.BaseLevel]; 178bf215546Sopenharmony_ci} 179bf215546Sopenharmony_ci 180bf215546Sopenharmony_ci 181bf215546Sopenharmony_ciextern GLint 182bf215546Sopenharmony_ci_mesa_max_texture_levels(const struct gl_context *ctx, GLenum target); 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_ciextern GLboolean 186bf215546Sopenharmony_ci_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, 187bf215546Sopenharmony_ci GLuint numLevels, GLint level, 188bf215546Sopenharmony_ci mesa_format format, GLuint numSamples, 189bf215546Sopenharmony_ci GLint width, GLint height, GLint depth); 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ciextern GLboolean 192bf215546Sopenharmony_ci_mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, 193bf215546Sopenharmony_ci GLenum intFormat, GLenum *error); 194bf215546Sopenharmony_ci 195bf215546Sopenharmony_ciextern GLint 196bf215546Sopenharmony_ci_mesa_get_texture_dimensions(GLenum target); 197bf215546Sopenharmony_ci 198bf215546Sopenharmony_ciextern GLboolean 199bf215546Sopenharmony_ci_mesa_tex_target_is_layered(GLenum target); 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ciextern GLuint 202bf215546Sopenharmony_ci_mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level); 203bf215546Sopenharmony_ci 204bf215546Sopenharmony_ciextern GLsizei 205bf215546Sopenharmony_ci_mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height, 206bf215546Sopenharmony_ci GLsizei depth); 207bf215546Sopenharmony_ci 208bf215546Sopenharmony_ciextern GLboolean 209bf215546Sopenharmony_ci_mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, 210bf215546Sopenharmony_ci GLint level, GLint width, GLint height, 211bf215546Sopenharmony_ci GLint depth, GLint border); 212bf215546Sopenharmony_ci 213bf215546Sopenharmony_ciextern mesa_format 214bf215546Sopenharmony_ci_mesa_validate_texbuffer_format(const struct gl_context *ctx, 215bf215546Sopenharmony_ci GLenum internalFormat); 216bf215546Sopenharmony_ci 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_cibool 219bf215546Sopenharmony_ci_mesa_legal_texture_base_format_for_target(struct gl_context *ctx, 220bf215546Sopenharmony_ci GLenum target, 221bf215546Sopenharmony_ci GLenum internalFormat); 222bf215546Sopenharmony_ci 223bf215546Sopenharmony_cibool 224bf215546Sopenharmony_ci_mesa_format_no_online_compression(GLenum format); 225bf215546Sopenharmony_ci 226bf215546Sopenharmony_ciGLboolean 227bf215546Sopenharmony_ci_mesa_is_renderable_texture_format(const struct gl_context *ctx, 228bf215546Sopenharmony_ci GLenum internalformat); 229bf215546Sopenharmony_ci 230bf215546Sopenharmony_ciextern void 231bf215546Sopenharmony_ci_mesa_texture_sub_image(struct gl_context *ctx, GLuint dims, 232bf215546Sopenharmony_ci struct gl_texture_object *texObj, 233bf215546Sopenharmony_ci struct gl_texture_image *texImage, 234bf215546Sopenharmony_ci GLenum target, GLint level, 235bf215546Sopenharmony_ci GLint xoffset, GLint yoffset, GLint zoffset, 236bf215546Sopenharmony_ci GLsizei width, GLsizei height, GLsizei depth, 237bf215546Sopenharmony_ci GLenum format, GLenum type, const GLvoid *pixels, 238bf215546Sopenharmony_ci bool dsa); 239bf215546Sopenharmony_ci 240bf215546Sopenharmony_ciextern void 241bf215546Sopenharmony_ci_mesa_texture_storage_ms_memory(struct gl_context *ctx, GLuint dims, 242bf215546Sopenharmony_ci struct gl_texture_object *texObj, 243bf215546Sopenharmony_ci struct gl_memory_object *memObj, 244bf215546Sopenharmony_ci GLenum target, GLsizei samples, 245bf215546Sopenharmony_ci GLenum internalFormat, GLsizei width, 246bf215546Sopenharmony_ci GLsizei height, GLsizei depth, 247bf215546Sopenharmony_ci GLboolean fixedSampleLocations, 248bf215546Sopenharmony_ci GLuint64 offset, const char* func); 249bf215546Sopenharmony_ci 250bf215546Sopenharmony_cibool 251bf215546Sopenharmony_ci_mesa_is_cube_map_texture(GLenum target); 252bf215546Sopenharmony_ci 253bf215546Sopenharmony_ciGLboolean 254bf215546Sopenharmony_ci_mesa_sparse_texture_error_check(struct gl_context *ctx, GLuint dims, 255bf215546Sopenharmony_ci struct gl_texture_object *texObj, 256bf215546Sopenharmony_ci mesa_format format, GLenum target, GLsizei levels, 257bf215546Sopenharmony_ci GLsizei width, GLsizei height, GLsizei depth, 258bf215546Sopenharmony_ci const char *func); 259bf215546Sopenharmony_ci 260bf215546Sopenharmony_ci/*@}*/ 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_ci#ifdef __cplusplus 263bf215546Sopenharmony_ci} 264bf215546Sopenharmony_ci#endif 265bf215546Sopenharmony_ci 266bf215546Sopenharmony_ci#endif 267