1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
5 * Copyright 2010 VMware, Inc. All rights reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #ifndef SP_TEX_SAMPLE_H
30 #define SP_TEX_SAMPLE_H
33 #include "tgsi/tgsi_exec.h"
35 struct sp_sampler_variant
;
37 typedef void (*wrap_nearest_func
)(float s
,
41 typedef void (*wrap_linear_func
)(float s
,
47 typedef float (*compute_lambda_func
)(const struct sp_sampler_variant
*sampler
,
48 const float s
[TGSI_QUAD_SIZE
],
49 const float t
[TGSI_QUAD_SIZE
],
50 const float p
[TGSI_QUAD_SIZE
]);
52 typedef void (*img_filter_func
)(struct tgsi_sampler
*tgsi_sampler
,
58 enum tgsi_sampler_control control
,
61 typedef void (*filter_func
)(struct tgsi_sampler
*tgsi_sampler
,
62 const float s
[TGSI_QUAD_SIZE
],
63 const float t
[TGSI_QUAD_SIZE
],
64 const float p
[TGSI_QUAD_SIZE
],
65 const float c0
[TGSI_QUAD_SIZE
],
66 const float c1
[TGSI_QUAD_SIZE
],
67 enum tgsi_sampler_control control
,
68 float rgba
[TGSI_NUM_CHANNELS
][TGSI_QUAD_SIZE
]);
71 union sp_sampler_key
{
87 * Subclass of tgsi_sampler
89 struct sp_sampler_variant
91 struct tgsi_sampler base
; /**< base class */
93 union sp_sampler_key key
;
95 /* The owner of this struct:
97 const struct pipe_sampler_state
*sampler
;
100 /* Currently bound texture:
102 const struct pipe_sampler_view
*view
;
103 struct softpipe_tex_tile_cache
*cache
;
107 /* For sp_get_samples_2d_linear_POT:
112 unsigned faces
[TGSI_QUAD_SIZE
];
114 wrap_nearest_func nearest_texcoord_s
;
115 wrap_nearest_func nearest_texcoord_t
;
116 wrap_nearest_func nearest_texcoord_p
;
118 wrap_linear_func linear_texcoord_s
;
119 wrap_linear_func linear_texcoord_t
;
120 wrap_linear_func linear_texcoord_p
;
122 img_filter_func min_img_filter
;
123 img_filter_func mag_img_filter
;
125 compute_lambda_func compute_lambda
;
127 filter_func mip_filter
;
129 filter_func sample_target
;
133 struct sp_sampler_variant
*next
;
138 /* Create a sampler variant for a given set of non-orthogonal state. Currently the
140 struct sp_sampler_variant
*
141 sp_create_sampler_variant( const struct pipe_sampler_state
*sampler
,
142 const union sp_sampler_key key
);
144 void sp_sampler_variant_bind_view( struct sp_sampler_variant
*variant
,
145 struct softpipe_tex_tile_cache
*tex_cache
,
146 const struct pipe_sampler_view
*view
);
148 void sp_sampler_variant_destroy( struct sp_sampler_variant
* );
152 static INLINE
struct sp_sampler_variant
*
153 sp_sampler_variant(const struct tgsi_sampler
*sampler
)
155 return (struct sp_sampler_variant
*) sampler
;
159 sp_get_samples(struct tgsi_sampler
*tgsi_sampler
,
160 const float s
[TGSI_QUAD_SIZE
],
161 const float t
[TGSI_QUAD_SIZE
],
162 const float p
[TGSI_QUAD_SIZE
],
164 float rgba
[TGSI_NUM_CHANNELS
][TGSI_QUAD_SIZE
]);
167 #endif /* SP_TEX_SAMPLE_H */