14a49301eSmrg/************************************************************************** 24a49301eSmrg * 3af69d88dSmrg * Copyright 2007 VMware, Inc. 44a49301eSmrg * All Rights Reserved. 54a49301eSmrg * 64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 74a49301eSmrg * copy of this software and associated documentation files (the 84a49301eSmrg * "Software"), to deal in the Software without restriction, including 94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish, 104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to 114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to 124a49301eSmrg * the following conditions: 134a49301eSmrg * 144a49301eSmrg * The above copyright notice and this permission notice (including the 154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions 164a49301eSmrg * of the Software. 174a49301eSmrg * 184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 254a49301eSmrg * 264a49301eSmrg **************************************************************************/ 274a49301eSmrg 284a49301eSmrg#ifndef SP_TEXTURE_H 294a49301eSmrg#define SP_TEXTURE_H 304a49301eSmrg 314a49301eSmrg 324a49301eSmrg#include "pipe/p_state.h" 333464ebd5Sriastradh#include "sp_limits.h" 344a49301eSmrg 354a49301eSmrg 364a49301eSmrgstruct pipe_context; 374a49301eSmrgstruct pipe_screen; 384a49301eSmrgstruct softpipe_context; 394a49301eSmrg 404a49301eSmrg 413464ebd5Sriastradh/** 423464ebd5Sriastradh * Subclass of pipe_resource. 433464ebd5Sriastradh */ 443464ebd5Sriastradhstruct softpipe_resource 454a49301eSmrg{ 463464ebd5Sriastradh struct pipe_resource base; 474a49301eSmrg 483464ebd5Sriastradh unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS]; 493464ebd5Sriastradh unsigned stride[SP_MAX_TEXTURE_2D_LEVELS]; 5001e04c3fSmrg unsigned img_stride[SP_MAX_TEXTURE_2D_LEVELS]; 514a49301eSmrg 523464ebd5Sriastradh /** 533464ebd5Sriastradh * Display target, only valid for PIPE_TEXTURE_2D with the 543464ebd5Sriastradh * PIPE_BIND_DISPLAY_TARGET usage. 554a49301eSmrg */ 563464ebd5Sriastradh struct sw_displaytarget *dt; 573464ebd5Sriastradh 583464ebd5Sriastradh /** 593464ebd5Sriastradh * Malloc'ed data for regular buffers and textures, or a mapping to dt above. 603464ebd5Sriastradh */ 613464ebd5Sriastradh void *data; 624a49301eSmrg 634a49301eSmrg /* True if texture images are power-of-two in all dimensions: 644a49301eSmrg */ 654a49301eSmrg boolean pot; 663464ebd5Sriastradh boolean userBuffer; 674a49301eSmrg 684a49301eSmrg unsigned timestamp; 694a49301eSmrg}; 704a49301eSmrg 713464ebd5Sriastradh 723464ebd5Sriastradh/** 733464ebd5Sriastradh * Subclass of pipe_transfer. 743464ebd5Sriastradh */ 754a49301eSmrgstruct softpipe_transfer 764a49301eSmrg{ 774a49301eSmrg struct pipe_transfer base; 784a49301eSmrg 794a49301eSmrg unsigned long offset; 804a49301eSmrg}; 814a49301eSmrg 824a49301eSmrg 834a49301eSmrg/** cast wrappers */ 8401e04c3fSmrgstatic inline struct softpipe_resource * 853464ebd5Sriastradhsoftpipe_resource(struct pipe_resource *pt) 864a49301eSmrg{ 873464ebd5Sriastradh return (struct softpipe_resource *) pt; 884a49301eSmrg} 894a49301eSmrg 9001e04c3fSmrgstatic inline struct softpipe_transfer * 914a49301eSmrgsoftpipe_transfer(struct pipe_transfer *pt) 924a49301eSmrg{ 934a49301eSmrg return (struct softpipe_transfer *) pt; 944a49301eSmrg} 954a49301eSmrg 964a49301eSmrg 97af69d88dSmrg/** 98af69d88dSmrg * Return pointer to a resource's actual data. 99af69d88dSmrg * This is a short-cut instead of using map()/unmap(), which should 100af69d88dSmrg * probably be fixed. 101af69d88dSmrg */ 10201e04c3fSmrgstatic inline void * 103af69d88dSmrgsoftpipe_resource_data(struct pipe_resource *pt) 104af69d88dSmrg{ 105af69d88dSmrg if (!pt) 106af69d88dSmrg return NULL; 107af69d88dSmrg 108af69d88dSmrg assert(softpipe_resource(pt)->dt == NULL); 109af69d88dSmrg return softpipe_resource(pt)->data; 110af69d88dSmrg} 111af69d88dSmrg 112af69d88dSmrg 1134a49301eSmrgextern void 1144a49301eSmrgsoftpipe_init_screen_texture_funcs(struct pipe_screen *screen); 1154a49301eSmrg 1163464ebd5Sriastradhextern void 1173464ebd5Sriastradhsoftpipe_init_texture_funcs(struct pipe_context *pipe); 1183464ebd5Sriastradh 11901e04c3fSmrgunsigned 12001e04c3fSmrgsoftpipe_get_tex_image_offset(const struct softpipe_resource *spr, 12101e04c3fSmrg unsigned level, unsigned layer); 1224a49301eSmrg#endif /* SP_TEXTURE */ 123