1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright (C) 2008 Nicolai Haehnle. 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved. 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a copy of this software and associated documentation files (the 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish, 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sublicense, and/or sell copies of the Software, and to 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions: 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * portions of the Software. 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef __RADEON_MIPMAP_TREE_H_ 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define __RADEON_MIPMAP_TREE_H_ 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "radeon_common.h" 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef struct _radeon_mipmap_tree radeon_mipmap_tree; 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef struct _radeon_mipmap_level radeon_mipmap_level; 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef struct _radeon_mipmap_image radeon_mipmap_image; 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct _radeon_mipmap_image { 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint offset; /** Offset of this image from the start of mipmap tree buffer, in bytes */ 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct _radeon_mipmap_level { 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint width; 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint height; 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint depth; 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint size; /** Size of each image, in bytes */ 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint rowstride; /** in bytes */ 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint valid; 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org radeon_mipmap_image faces[6]; 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* store the max possible in the miptree */ 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define RADEON_MIPTREE_MAX_TEXTURE_LEVELS 15 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * A mipmap tree contains texture images in the layout that the hardware 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * expects. 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The meta-data of mipmap trees is immutable, i.e. you cannot change the 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * layout on-the-fly; however, the texture contents (i.e. texels) can be 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * changed. 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct _radeon_mipmap_tree { 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct radeon_bo *bo; 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint refcount; 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint totalsize; /** total size of the miptree, in bytes */ 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum target; /** GL_TEXTURE_xxx */ 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum mesaFormat; /** MESA_FORMAT_xxx */ 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint faces; /** # of faces: 6 for cubemaps, 1 otherwise */ 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint baseLevel; /** gl_texture_object->baseLevel it was created for */ 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint numLevels; /** Number of mip levels stored in this mipmap tree */ 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint width0; /** Width of baseLevel image */ 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint height0; /** Height of baseLevel image */ 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint depth0; /** Depth of baseLevel image */ 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint tilebits; /** RADEON_TXO_xxx_TILE */ 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org radeon_mipmap_level levels[RADEON_MIPTREE_MAX_TEXTURE_LEVELS]; 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr); 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid radeon_miptree_unreference(radeon_mipmap_tree **ptr); 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt, 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_texture_image *texImage); 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t); 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt, 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint face, GLuint level); 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orguint32_t get_base_teximage_offset(radeonTexObj *texObj); 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width, unsigned tiling, unsigned target); 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgunsigned get_texture_image_size( 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org gl_format format, 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned rowStride, 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned height, 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned depth, 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned tiling); 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgradeon_mipmap_tree *radeon_miptree_create(radeonContextPtr rmesa, 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum target, gl_format mesaFormat, GLuint baseLevel, GLuint numLevels, 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint width0, GLuint height0, GLuint depth0, GLuint tilebits); 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* __RADEON_MIPMAP_TREE_H_ */ 107