blob: 450c4b1cefc23f6c37bd2bdbe08fbbadad2ec2ed [file] [log] [blame]
Brianc14773b2008-01-21 20:16:13 -07001/**************************************************************************
2 *
José Fonseca87712852014-01-17 16:27:50 +00003 * Copyright 2007 VMware, Inc.
Brianc14773b2008-01-21 20:16:13 -07004 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
José Fonseca87712852014-01-17 16:27:50 +000021 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
Brianc14773b2008-01-21 20:16:13 -070022 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
Michel Dänzer753db0d2007-11-30 20:48:03 +010028#ifndef SP_TEXTURE_H
29#define SP_TEXTURE_H
30
31
Brian4f36cf52008-02-27 09:47:46 -070032#include "pipe/p_state.h"
Brian Paulaf4f75c2010-12-02 10:08:33 -070033#include "sp_limits.h"
Brian Paul44eec282010-03-08 13:56:44 -070034
35
Michel Dänzer753db0d2007-11-30 20:48:03 +010036struct pipe_context;
Brian4f36cf52008-02-27 09:47:46 -070037struct pipe_screen;
38struct softpipe_context;
Michel Dänzer753db0d2007-11-30 20:48:03 +010039
40
Brian Paule960dd72010-04-16 09:21:12 -060041/**
42 * Subclass of pipe_resource.
43 */
Keith Whitwell287c94e2010-04-10 16:05:54 +010044struct softpipe_resource
Brian4c90dc72007-12-07 10:21:56 -070045{
Keith Whitwell287c94e2010-04-10 16:05:54 +010046 struct pipe_resource base;
Brian4c90dc72007-12-07 10:21:56 -070047
Brian Paul44eec282010-03-08 13:56:44 -070048 unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS];
49 unsigned stride[SP_MAX_TEXTURE_2D_LEVELS];
Roland Scheidegger3d29e752014-08-28 05:13:35 +020050 unsigned img_stride[SP_MAX_TEXTURE_2D_LEVELS];
Brian4c90dc72007-12-07 10:21:56 -070051
Keith Whitwell94ce4eb2010-03-04 16:09:33 +000052 /**
Keith Whitwell287c94e2010-04-10 16:05:54 +010053 * Display target, only valid for PIPE_TEXTURE_2D with the
54 * PIPE_BIND_DISPLAY_TARGET usage.
Brian4c90dc72007-12-07 10:21:56 -070055 */
Keith Whitwell94ce4eb2010-03-04 16:09:33 +000056 struct sw_displaytarget *dt;
57
58 /**
Keith Whitwell287c94e2010-04-10 16:05:54 +010059 * Malloc'ed data for regular buffers and textures, or a mapping to dt above.
Keith Whitwell94ce4eb2010-03-04 16:09:33 +000060 */
61 void *data;
Brian Paulf38bb102008-06-20 15:58:19 -060062
Keith Whitwell4fc7d032009-08-21 17:13:11 +010063 /* True if texture images are power-of-two in all dimensions:
64 */
65 boolean pot;
Keith Whitwell287c94e2010-04-10 16:05:54 +010066 boolean userBuffer;
Keith Whitwell4fc7d032009-08-21 17:13:11 +010067
Keith Whitwellb5d583e2009-07-17 10:44:22 +010068 unsigned timestamp;
Brian4c90dc72007-12-07 10:21:56 -070069};
70
Brian Paule960dd72010-04-16 09:21:12 -060071
72/**
73 * Subclass of pipe_transfer.
74 */
Michel Dänzer46179812009-02-05 19:41:18 +010075struct softpipe_transfer
76{
77 struct pipe_transfer base;
Brian4c90dc72007-12-07 10:21:56 -070078
Michel Dänzer46179812009-02-05 19:41:18 +010079 unsigned long offset;
80};
81
82
83/** cast wrappers */
Ilia Mirkina2a1a582015-07-20 19:58:43 -040084static inline struct softpipe_resource *
Keith Whitwell287c94e2010-04-10 16:05:54 +010085softpipe_resource(struct pipe_resource *pt)
Brian4c90dc72007-12-07 10:21:56 -070086{
Keith Whitwell287c94e2010-04-10 16:05:54 +010087 return (struct softpipe_resource *) pt;
Brian4c90dc72007-12-07 10:21:56 -070088}
89
Ilia Mirkina2a1a582015-07-20 19:58:43 -040090static inline struct softpipe_transfer *
Michel Dänzer46179812009-02-05 19:41:18 +010091softpipe_transfer(struct pipe_transfer *pt)
92{
93 return (struct softpipe_transfer *) pt;
94}
95
Brian4c90dc72007-12-07 10:21:56 -070096
Brian Paul365f38f2013-07-25 09:27:09 -060097/**
98 * Return pointer to a resource's actual data.
99 * This is a short-cut instead of using map()/unmap(), which should
100 * probably be fixed.
101 */
Ilia Mirkina2a1a582015-07-20 19:58:43 -0400102static inline void *
Brian Paul365f38f2013-07-25 09:27:09 -0600103softpipe_resource_data(struct pipe_resource *pt)
104{
105 if (!pt)
106 return NULL;
107
108 assert(softpipe_resource(pt)->dt == NULL);
109 return softpipe_resource(pt)->data;
110}
111
112
Michel Dänzer753db0d2007-11-30 20:48:03 +0100113extern void
Brian4f36cf52008-02-27 09:47:46 -0700114softpipe_init_screen_texture_funcs(struct pipe_screen *screen);
115
Brian Paule960dd72010-04-16 09:21:12 -0600116extern void
Keith Whitwellb43c1822010-03-11 15:23:16 +0000117softpipe_init_texture_funcs(struct pipe_context *pipe);
118
Dave Airlieeb9ad9f2016-03-22 07:59:35 +1000119unsigned
120softpipe_get_tex_image_offset(const struct softpipe_resource *spr,
121 unsigned level, unsigned layer);
Michel Dänzer753db0d2007-11-30 20:48:03 +0100122#endif /* SP_TEXTURE */