1287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell/************************************************************************** 2287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 3287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. 4287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * All Rights Reserved. 5287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 6287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 7287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * copy of this software and associated documentation files (the 8287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * "Software"), to deal in the Software without restriction, including 9287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 10287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 11287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * permit persons to whom the Software is furnished to do so, subject to 12287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * the following conditions: 13287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 14287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * The above copyright notice and this permission notice (including the 15287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * next paragraph) shall be included in all copies or substantial portions 16287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * of the Software. 17287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 18287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 26287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell **************************************************************************/ 27287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 28287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#ifndef I915_RESOURCE_H 29287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#define I915_RESOURCE_H 30287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 31287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct i915_screen; 32287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 33287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "util/u_transfer.h" 34287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "util/u_debug.h" 35aba728eb255380ac3c73ba7c9a5ff40bd68705bfDaniel Vetter#include "i915_winsys.h" 36287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 37287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 38287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct i915_context; 39287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct i915_screen; 40287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 41287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 42287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct i915_buffer { 43287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct u_resource b; 44287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell uint8_t *data; 45287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell boolean free_on_destroy; 46287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}; 47287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 481a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin 491a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin/* Texture transfer. */ 501a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesinstruct i915_transfer { 511a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin /* Base class. */ 521a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin struct pipe_transfer b; 531a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin struct pipe_resource *staging_texture; 541a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin}; 551a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin 561a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin 571697dac64294aab73052541dab6763d660d088dcJakob Bornecrantz#define I915_MAX_TEXTURE_2D_LEVELS 12 /* max 2048x2048 */ 581697dac64294aab73052541dab6763d660d088dcJakob Bornecrantz#define I915_MAX_TEXTURE_3D_LEVELS 9 /* max 256x256x256 */ 59287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 60287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 616ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetterstruct offset_pair { 626ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetter unsigned short nblocksx; 636ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetter unsigned short nblocksy; 646ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetter}; 65287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 66287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct i915_texture { 67287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct u_resource b; 68287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 69aba728eb255380ac3c73ba7c9a5ff40bd68705bfDaniel Vetter /* tiling flags */ 70aba728eb255380ac3c73ba7c9a5ff40bd68705bfDaniel Vetter enum i915_winsys_buffer_tile tiling; 71287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned stride; 72287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned depth_stride; /* per-image on i945? */ 73287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned total_nblocksy; 74287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 75287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned nr_images[I915_MAX_TEXTURE_2D_LEVELS]; 76287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 77287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell /* Explicitly store the offset of each image for each cube face or 78287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * depth value. 796ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetter * 806ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetter * Array [depth] off offsets. 81287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell */ 826ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetter struct offset_pair *image_offset[I915_MAX_TEXTURE_2D_LEVELS]; 83287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 84287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell /* The data is held here: 85287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell */ 86287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct i915_winsys_buffer *buffer; 87287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}; 88287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 896ae6e0c6feacd89a7e3db4db5c4ea800cbe40397Daniel Vetterunsigned i915_texture_offset(struct i915_texture *tex, 904c7001462607e6e99e474d6271dd481d3f8f201cRoland Scheidegger unsigned level, unsigned layer); 91287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid i915_init_screen_resource_functions(struct i915_screen *is); 924e20781bac9d2c39ce8aa168950e2081014f1774Jakob Bornecrantzvoid i915_init_resource_functions(struct i915_context *i915); 93287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 94287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellextern struct u_resource_vtbl i915_buffer_vtbl; 95287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellextern struct u_resource_vtbl i915_texture_vtbl; 96287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 974e20781bac9d2c39ce8aa168950e2081014f1774Jakob Bornecrantzstatic INLINE struct i915_texture *i915_texture(struct pipe_resource *resource) 98287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 99287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct i915_texture *tex = (struct i915_texture *)resource; 100287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell assert(tex->b.vtbl == &i915_texture_vtbl); 101287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell return tex; 102287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 103287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 1044e20781bac9d2c39ce8aa168950e2081014f1774Jakob Bornecrantzstatic INLINE struct i915_buffer *i915_buffer(struct pipe_resource *resource) 105287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 106287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct i915_buffer *tex = (struct i915_buffer *)resource; 107287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell assert(tex->b.vtbl == &i915_buffer_vtbl); 108287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell return tex; 109287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 110287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 111287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct pipe_resource * 112287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_texture_create(struct pipe_screen *screen, 1131a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin const struct pipe_resource *template, 1141a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin boolean force_untiled); 115287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 116287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct pipe_resource * 117287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_texture_from_handle(struct pipe_screen * screen, 118287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell const struct pipe_resource *template, 119287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct winsys_handle *whandle); 120287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 121287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 122287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct pipe_resource * 123287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_user_buffer_create(struct pipe_screen *screen, 124287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell void *ptr, 125287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned bytes, 126287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned usage); 127287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 128287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct pipe_resource * 129287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_buffer_create(struct pipe_screen *screen, 130287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell const struct pipe_resource *template); 131287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 132287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#endif /* I915_RESOURCE_H */ 133