softpipe: fix polygon stipple
[mesa.git] / src / gallium / drivers / softpipe / sp_tex_sample.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
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
28 #ifndef SP_TEX_SAMPLE_H
29 #define SP_TEX_SAMPLE_H
30
31
32 #include "tgsi/tgsi_exec.h"
33
34 struct sp_sampler_varient;
35
36 typedef void (*wrap_nearest_func)(const float s[4],
37 unsigned size,
38 int icoord[4]);
39
40 typedef void (*wrap_linear_func)(const float s[4],
41 unsigned size,
42 int icoord0[4],
43 int icoord1[4],
44 float w[4]);
45
46 typedef float (*compute_lambda_func)(const struct sp_sampler_varient *sampler,
47 const float s[QUAD_SIZE],
48 const float t[QUAD_SIZE],
49 const float p[QUAD_SIZE],
50 float lodbias);
51
52 typedef void (*filter_func)(struct tgsi_sampler *tgsi_sampler,
53 const float s[QUAD_SIZE],
54 const float t[QUAD_SIZE],
55 const float p[QUAD_SIZE],
56 float lodbias,
57 float rgba[NUM_CHANNELS][QUAD_SIZE]);
58
59
60 union sp_sampler_key {
61 struct {
62 unsigned target:3;
63 unsigned is_pot:1;
64 unsigned processor:2;
65 unsigned unit:4;
66 unsigned pad:22;
67 } bits;
68 unsigned value;
69 };
70
71 /**
72 * Subclass of tgsi_sampler
73 */
74 struct sp_sampler_varient
75 {
76 struct tgsi_sampler base; /**< base class */
77
78 union sp_sampler_key key;
79
80 /* The owner of this struct:
81 */
82 const struct pipe_sampler_state *sampler;
83
84
85 /* Currently bound texture:
86 */
87 const struct pipe_texture *texture;
88 struct softpipe_tex_tile_cache *cache;
89
90 unsigned processor;
91
92 /* For sp_get_samples_2d_linear_POT:
93 */
94 unsigned xpot;
95 unsigned ypot;
96 unsigned level;
97
98 unsigned faces[4];
99
100 wrap_nearest_func nearest_texcoord_s;
101 wrap_nearest_func nearest_texcoord_t;
102 wrap_nearest_func nearest_texcoord_p;
103
104 wrap_linear_func linear_texcoord_s;
105 wrap_linear_func linear_texcoord_t;
106 wrap_linear_func linear_texcoord_p;
107
108 filter_func min_img_filter;
109 filter_func mag_img_filter;
110
111 compute_lambda_func compute_lambda;
112
113 filter_func mip_filter;
114 filter_func compare;
115
116 /* Linked list:
117 */
118 struct sp_sampler_varient *next;
119 };
120
121 struct sp_sampler;
122
123 /* Create a sampler varient for a given set of non-orthogonal state. Currently the
124 */
125 struct sp_sampler_varient *
126 sp_create_sampler_varient( const struct pipe_sampler_state *sampler,
127 const union sp_sampler_key key );
128
129 void sp_sampler_varient_bind_texture( struct sp_sampler_varient *varient,
130 struct softpipe_tex_tile_cache *tex_cache,
131 const struct pipe_texture *tex );
132
133 void sp_sampler_varient_destroy( struct sp_sampler_varient * );
134
135
136
137 static INLINE struct sp_sampler_varient *
138 sp_sampler_varient(const struct tgsi_sampler *sampler)
139 {
140 return (struct sp_sampler_varient *) sampler;
141 }
142
143 extern void
144 sp_get_samples(struct tgsi_sampler *tgsi_sampler,
145 const float s[QUAD_SIZE],
146 const float t[QUAD_SIZE],
147 const float p[QUAD_SIZE],
148 float lodbias,
149 float rgba[NUM_CHANNELS][QUAD_SIZE]);
150
151
152 #endif /* SP_TEX_SAMPLE_H */