1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef SP_TEX_SAMPLE_H
29 #define SP_TEX_SAMPLE_H
32 #include "tgsi/tgsi_exec.h"
34 struct sp_sampler_varient
;
36 typedef void (*wrap_nearest_func
)(const float s
[4],
40 typedef void (*wrap_linear_func
)(const float s
[4],
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
],
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
],
57 float rgba
[NUM_CHANNELS
][QUAD_SIZE
]);
60 union sp_sampler_key
{
72 * Subclass of tgsi_sampler
74 struct sp_sampler_varient
76 struct tgsi_sampler base
; /**< base class */
78 union sp_sampler_key key
;
80 /* The owner of this struct:
82 const struct pipe_sampler_state
*sampler
;
85 /* Currently bound texture:
87 const struct pipe_texture
*texture
;
88 struct softpipe_tex_tile_cache
*cache
;
92 /* For sp_get_samples_2d_linear_POT:
100 wrap_nearest_func nearest_texcoord_s
;
101 wrap_nearest_func nearest_texcoord_t
;
102 wrap_nearest_func nearest_texcoord_p
;
104 wrap_linear_func linear_texcoord_s
;
105 wrap_linear_func linear_texcoord_t
;
106 wrap_linear_func linear_texcoord_p
;
108 filter_func min_img_filter
;
109 filter_func mag_img_filter
;
111 compute_lambda_func compute_lambda
;
113 filter_func mip_filter
;
118 struct sp_sampler_varient
*next
;
123 /* Create a sampler varient for a given set of non-orthogonal state. Currently the
125 struct sp_sampler_varient
*
126 sp_create_sampler_varient( const struct pipe_sampler_state
*sampler
,
127 const union sp_sampler_key key
);
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
);
133 void sp_sampler_varient_destroy( struct sp_sampler_varient
* );
137 static INLINE
struct sp_sampler_varient
*
138 sp_sampler_varient(const struct tgsi_sampler
*sampler
)
140 return (struct sp_sampler_varient
*) sampler
;
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
],
149 float rgba
[NUM_CHANNELS
][QUAD_SIZE
]);
152 #endif /* SP_TEX_SAMPLE_H */