Brian | c14773b | 2008-01-21 20:16:13 -0700 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
José Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 3 | * Copyright 2007 VMware, Inc. |
Brian | c14773b | 2008-01-21 20:16:13 -0700 | [diff] [blame] | 4 | * 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é Fonseca | 8771285 | 2014-01-17 16:27:50 +0000 | [diff] [blame] | 21 | * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR |
Brian | c14773b | 2008-01-21 20:16:13 -0700 | [diff] [blame] | 22 | * 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änzer | 753db0d | 2007-11-30 20:48:03 +0100 | [diff] [blame] | 28 | #ifndef SP_TEXTURE_H |
| 29 | #define SP_TEXTURE_H |
| 30 | |
| 31 | |
Brian | 4f36cf5 | 2008-02-27 09:47:46 -0700 | [diff] [blame] | 32 | #include "pipe/p_state.h" |
Brian Paul | af4f75c | 2010-12-02 10:08:33 -0700 | [diff] [blame] | 33 | #include "sp_limits.h" |
Brian Paul | 44eec28 | 2010-03-08 13:56:44 -0700 | [diff] [blame] | 34 | |
| 35 | |
Michel Dänzer | 753db0d | 2007-11-30 20:48:03 +0100 | [diff] [blame] | 36 | struct pipe_context; |
Brian | 4f36cf5 | 2008-02-27 09:47:46 -0700 | [diff] [blame] | 37 | struct pipe_screen; |
| 38 | struct softpipe_context; |
Michel Dänzer | 753db0d | 2007-11-30 20:48:03 +0100 | [diff] [blame] | 39 | |
| 40 | |
Brian Paul | e960dd7 | 2010-04-16 09:21:12 -0600 | [diff] [blame] | 41 | /** |
| 42 | * Subclass of pipe_resource. |
| 43 | */ |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 44 | struct softpipe_resource |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 45 | { |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 46 | struct pipe_resource base; |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 47 | |
Brian Paul | 44eec28 | 2010-03-08 13:56:44 -0700 | [diff] [blame] | 48 | unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS]; |
| 49 | unsigned stride[SP_MAX_TEXTURE_2D_LEVELS]; |
Roland Scheidegger | 3d29e75 | 2014-08-28 05:13:35 +0200 | [diff] [blame] | 50 | unsigned img_stride[SP_MAX_TEXTURE_2D_LEVELS]; |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 51 | |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 52 | /** |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 53 | * Display target, only valid for PIPE_TEXTURE_2D with the |
| 54 | * PIPE_BIND_DISPLAY_TARGET usage. |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 55 | */ |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 56 | struct sw_displaytarget *dt; |
| 57 | |
| 58 | /** |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 59 | * Malloc'ed data for regular buffers and textures, or a mapping to dt above. |
Keith Whitwell | 94ce4eb | 2010-03-04 16:09:33 +0000 | [diff] [blame] | 60 | */ |
| 61 | void *data; |
Brian Paul | f38bb10 | 2008-06-20 15:58:19 -0600 | [diff] [blame] | 62 | |
Keith Whitwell | 4fc7d03 | 2009-08-21 17:13:11 +0100 | [diff] [blame] | 63 | /* True if texture images are power-of-two in all dimensions: |
| 64 | */ |
| 65 | boolean pot; |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 66 | boolean userBuffer; |
Keith Whitwell | 4fc7d03 | 2009-08-21 17:13:11 +0100 | [diff] [blame] | 67 | |
Keith Whitwell | b5d583e | 2009-07-17 10:44:22 +0100 | [diff] [blame] | 68 | unsigned timestamp; |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
Brian Paul | e960dd7 | 2010-04-16 09:21:12 -0600 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Subclass of pipe_transfer. |
| 74 | */ |
Michel Dänzer | 4617981 | 2009-02-05 19:41:18 +0100 | [diff] [blame] | 75 | struct softpipe_transfer |
| 76 | { |
| 77 | struct pipe_transfer base; |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 78 | |
Michel Dänzer | 4617981 | 2009-02-05 19:41:18 +0100 | [diff] [blame] | 79 | unsigned long offset; |
| 80 | }; |
| 81 | |
| 82 | |
| 83 | /** cast wrappers */ |
Ilia Mirkin | a2a1a58 | 2015-07-20 19:58:43 -0400 | [diff] [blame] | 84 | static inline struct softpipe_resource * |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 85 | softpipe_resource(struct pipe_resource *pt) |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 86 | { |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 87 | return (struct softpipe_resource *) pt; |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Ilia Mirkin | a2a1a58 | 2015-07-20 19:58:43 -0400 | [diff] [blame] | 90 | static inline struct softpipe_transfer * |
Michel Dänzer | 4617981 | 2009-02-05 19:41:18 +0100 | [diff] [blame] | 91 | softpipe_transfer(struct pipe_transfer *pt) |
| 92 | { |
| 93 | return (struct softpipe_transfer *) pt; |
| 94 | } |
| 95 | |
Brian | 4c90dc7 | 2007-12-07 10:21:56 -0700 | [diff] [blame] | 96 | |
Brian Paul | 365f38f | 2013-07-25 09:27:09 -0600 | [diff] [blame] | 97 | /** |
| 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 Mirkin | a2a1a58 | 2015-07-20 19:58:43 -0400 | [diff] [blame] | 102 | static inline void * |
Brian Paul | 365f38f | 2013-07-25 09:27:09 -0600 | [diff] [blame] | 103 | softpipe_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änzer | 753db0d | 2007-11-30 20:48:03 +0100 | [diff] [blame] | 113 | extern void |
Brian | 4f36cf5 | 2008-02-27 09:47:46 -0700 | [diff] [blame] | 114 | softpipe_init_screen_texture_funcs(struct pipe_screen *screen); |
| 115 | |
Brian Paul | e960dd7 | 2010-04-16 09:21:12 -0600 | [diff] [blame] | 116 | extern void |
Keith Whitwell | b43c182 | 2010-03-11 15:23:16 +0000 | [diff] [blame] | 117 | softpipe_init_texture_funcs(struct pipe_context *pipe); |
| 118 | |
Dave Airlie | eb9ad9f | 2016-03-22 07:59:35 +1000 | [diff] [blame^] | 119 | unsigned |
| 120 | softpipe_get_tex_image_offset(const struct softpipe_resource *spr, |
| 121 | unsigned level, unsigned layer); |
Michel Dänzer | 753db0d | 2007-11-30 20:48:03 +0100 | [diff] [blame] | 122 | #endif /* SP_TEXTURE */ |