radeon_mipmap_tree.h revision 63c00c53a3019b801c5eee8a12f7862422f79f10
1e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse/* 2e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * Copyright (C) 2008 Nicolai Haehnle. 3e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * 4e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * All Rights Reserved. 5e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * 6e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * Permission is hereby granted, free of charge, to any person obtaining 7e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * a copy of this software and associated documentation files (the 8e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * "Software"), to deal in the Software without restriction, including 9e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * without limitation the rights to use, copy, modify, merge, publish, 10e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * distribute, sublicense, and/or sell copies of the Software, and to 11e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * permit persons to whom the Software is furnished to do so, subject to 12e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * the following conditions: 13e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * 14e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * The above copyright notice and this permission notice (including the 15e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * next paragraph) shall be included in all copies or substantial 16e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * portions of the Software. 17e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * 18e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 22e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * 26e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse */ 27e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 2833dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlie#ifndef __RADEON_MIPMAP_TREE_H_ 2933dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlie#define __RADEON_MIPMAP_TREE_H_ 30e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 3123d3559bd4ece1fcab5513ebdaa38600d6654374Dave Airlie#include "radeon_common.h" 32e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 3333dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlietypedef struct _radeon_mipmap_tree radeon_mipmap_tree; 3433dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlietypedef struct _radeon_mipmap_level radeon_mipmap_level; 3533dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlietypedef struct _radeon_mipmap_image radeon_mipmap_image; 36e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 3733dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airliestruct _radeon_mipmap_image { 38e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint offset; /** Offset of this image from the start of mipmap tree buffer, in bytes */ 39e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse}; 40e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 4133dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airliestruct _radeon_mipmap_level { 42e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint width; 43e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint height; 44e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint depth; 45e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint size; /** Size of each image, in bytes */ 46e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint rowstride; /** in bytes */ 4763c00c53a3019b801c5eee8a12f7862422f79f10Maciej Cencora GLuint valid; 4833dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlie radeon_mipmap_image faces[6]; 49e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse}; 50e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 51d0fab94842b18dbd4027f5565804ca6884646240Dave Airlie/* store the max possible in the miptree */ 52d0fab94842b18dbd4027f5565804ca6884646240Dave Airlie#define RADEON_MIPTREE_MAX_TEXTURE_LEVELS 13 53e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 54e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse/** 55e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * A mipmap tree contains texture images in the layout that the hardware 56e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * expects. 57e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * 58e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * The meta-data of mipmap trees is immutable, i.e. you cannot change the 59e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * layout on-the-fly; however, the texture contents (i.e. texels) can be 60e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse * changed. 61e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse */ 6233dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airliestruct _radeon_mipmap_tree { 63e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse struct radeon_bo *bo; 64e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint refcount; 65e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 66e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint totalsize; /** total size of the miptree, in bytes */ 67e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 68e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLenum target; /** GL_TEXTURE_xxx */ 6923ec7c457483aae1e0d399e9b570f1860c27c780Maciej Cencora GLenum mesaFormat; /** MESA_FORMAT_xxx */ 70e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse GLuint faces; /** # of faces: 6 for cubemaps, 1 otherwise */ 7123ec7c457483aae1e0d399e9b570f1860c27c780Maciej Cencora GLuint baseLevel; /** gl_texture_object->baseLevel it was created for */ 7223ec7c457483aae1e0d399e9b570f1860c27c780Maciej Cencora GLuint numLevels; /** Number of mip levels stored in this mipmap tree */ 73e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 7463c00c53a3019b801c5eee8a12f7862422f79f10Maciej Cencora GLuint width0; /** Width of baseLevel image */ 7563c00c53a3019b801c5eee8a12f7862422f79f10Maciej Cencora GLuint height0; /** Height of baseLevel image */ 7663c00c53a3019b801c5eee8a12f7862422f79f10Maciej Cencora GLuint depth0; /** Depth of baseLevel image */ 77e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 7833dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlie GLuint tilebits; /** RADEON_TXO_xxx_TILE */ 79e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 80d0fab94842b18dbd4027f5565804ca6884646240Dave Airlie radeon_mipmap_level levels[RADEON_MIPTREE_MAX_TEXTURE_LEVELS]; 81e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse}; 82e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 837628b06ba32e42f57a4fdb322bc32e3b411c1f18Maciej Cencoravoid radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr); 847628b06ba32e42f57a4fdb322bc32e3b411c1f18Maciej Cencoravoid radeon_miptree_unreference(radeon_mipmap_tree **ptr); 85e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse 8633dc14c707734df37fb02b7bcc278ddeb94036f1Dave AirlieGLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt, 87e5d5dab8c03f72097ec3e5b465fe93b6e369bb2dJerome Glisse struct gl_texture_image *texImage, GLuint face, GLuint level); 8823ec7c457483aae1e0d399e9b570f1860c27c780Maciej Cencoravoid radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t); 890968512f8f4abc5bce84c200bd99f8a522d56122Dave AirlieGLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt, 900968512f8f4abc5bce84c200bd99f8a522d56122Dave Airlie GLuint face, GLuint level); 91f577c8e462fc924ea436d129ad64c8a1226b5f9cDave Airlievoid radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level, GLuint *offsets); 9223ec7c457483aae1e0d399e9b570f1860c27c780Maciej Cencora 9323ec7c457483aae1e0d399e9b570f1860c27c780Maciej Cencorauint32_t get_base_teximage_offset(radeonTexObj *texObj); 9433dc14c707734df37fb02b7bcc278ddeb94036f1Dave Airlie#endif /* __RADEON_MIPMAP_TREE_H_ */ 95