1 /**************************************************************************
3 * Copyright 2007 VMware, Inc.
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 VMWARE 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"
36 struct sp_sampler_view
;
39 typedef void (*wrap_nearest_func
)(float s
,
44 typedef void (*wrap_linear_func
)(float s
,
51 typedef float (*compute_lambda_func
)(const struct sp_sampler_view
*sp_sview
,
52 const float s
[TGSI_QUAD_SIZE
],
53 const float t
[TGSI_QUAD_SIZE
],
54 const float p
[TGSI_QUAD_SIZE
]);
56 typedef float (*compute_lambda_from_grad_func
)(const struct sp_sampler_view
*sp_sview
,
57 const float derivs
[3][2][TGSI_QUAD_SIZE
],
60 struct img_filter_args
{
71 typedef void (*img_filter_func
)(const struct sp_sampler_view
*sp_sview
,
72 const struct sp_sampler
*sp_samp
,
73 const struct img_filter_args
*args
,
77 enum tgsi_sampler_control control
;
82 typedef void (*mip_filter_func
)(const struct sp_sampler_view
*sp_sview
,
83 const struct sp_sampler
*sp_samp
,
84 img_filter_func min_filter
,
85 img_filter_func mag_filter
,
86 const float s
[TGSI_QUAD_SIZE
],
87 const float t
[TGSI_QUAD_SIZE
],
88 const float p
[TGSI_QUAD_SIZE
],
90 const float lod
[TGSI_QUAD_SIZE
],
91 const struct filter_args
*args
,
92 float rgba
[TGSI_NUM_CHANNELS
][TGSI_QUAD_SIZE
]);
95 typedef void (*mip_level_func
)(const struct sp_sampler_view
*sp_sview
,
96 const struct sp_sampler
*sp_samp
,
97 const float lod
[TGSI_QUAD_SIZE
],
98 float level
[TGSI_QUAD_SIZE
]);
100 typedef void (*fetch_func
)(struct sp_sampler_view
*sp_sview
,
101 const int i
[TGSI_QUAD_SIZE
],
102 const int j
[TGSI_QUAD_SIZE
], const int k
[TGSI_QUAD_SIZE
],
103 const int lod
[TGSI_QUAD_SIZE
], const int8_t offset
[3],
104 float rgba
[TGSI_NUM_CHANNELS
][TGSI_QUAD_SIZE
]);
107 struct sp_sampler_view
109 struct pipe_sampler_view base
;
111 /* For sp_get_samples_2d_linear_POT:
116 boolean need_swizzle
;
118 boolean need_cube_convert
;
120 /* these are different per shader type */
121 struct softpipe_tex_tile_cache
*cache
;
122 compute_lambda_func compute_lambda
;
123 compute_lambda_from_grad_func compute_lambda_from_grad
;
124 union pipe_color_union border_color
;
127 struct sp_filter_funcs
{
128 mip_level_func relative_level
;
129 mip_filter_func filter
;
133 struct pipe_sampler_state base
;
135 boolean min_mag_equal_repeat_linear
;
136 boolean min_mag_equal
;
137 unsigned min_img_filter
;
139 wrap_nearest_func nearest_texcoord_s
;
140 wrap_nearest_func nearest_texcoord_t
;
141 wrap_nearest_func nearest_texcoord_p
;
143 wrap_linear_func linear_texcoord_s
;
144 wrap_linear_func linear_texcoord_t
;
145 wrap_linear_func linear_texcoord_p
;
147 const struct sp_filter_funcs
*filter_funcs
;
152 * Subclass of tgsi_sampler
154 struct sp_tgsi_sampler
156 struct tgsi_sampler base
; /**< base class */
157 struct sp_sampler
*sp_sampler
[PIPE_MAX_SAMPLERS
];
158 struct sp_sampler_view sp_sview
[PIPE_MAX_SHADER_SAMPLER_VIEWS
];
163 softpipe_get_lambda_func(const struct pipe_sampler_view
*view
,
164 enum pipe_shader_type shader
);
166 compute_lambda_from_grad_func
167 softpipe_get_lambda_from_grad_func(const struct pipe_sampler_view
*view
,
168 enum pipe_shader_type shader
);
171 softpipe_create_sampler_state(struct pipe_context
*pipe
,
172 const struct pipe_sampler_state
*sampler
);
175 struct pipe_sampler_view
*
176 softpipe_create_sampler_view(struct pipe_context
*pipe
,
177 struct pipe_resource
*resource
,
178 const struct pipe_sampler_view
*templ
);
181 struct sp_tgsi_sampler
*
182 sp_create_tgsi_sampler(void);
185 #endif /* SP_TEX_SAMPLE_H */