1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
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 VMWARE 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 **************************************************************************/
32 * @author Jose Fonseca <jfonseca@vmware.com>
35 #ifndef LP_BLD_SAMPLE_H
36 #define LP_BLD_SAMPLE_H
39 #include "gallivm/lp_bld.h"
42 struct pipe_sampler_view
;
43 struct pipe_sampler_state
;
44 struct util_format_description
;
46 struct lp_build_context
;
50 * Sampler static state.
52 * These are the bits of state from pipe_resource and pipe_sampler_state that
53 * are embedded in the generated code.
55 struct lp_sampler_static_state
57 /* pipe_texture's state */
58 enum pipe_format format
;
61 unsigned pot_height
:1;
64 /* pipe_sampler_state's state */
68 unsigned min_img_filter
:2;
69 unsigned min_mip_filter
:2;
70 unsigned mag_img_filter
:2;
71 unsigned compare_mode
:1;
72 unsigned compare_func
:3;
73 unsigned normalized_coords
:1;
74 float lod_bias
, min_lod
, max_lod
;
75 float border_color
[4];
80 * Sampler dynamic state.
82 * These are the bits of state from pipe_resource and pipe_sampler_state that
83 * are computed in runtime.
85 * There are obtained through callbacks, as we don't want to tie the texture
86 * sampling code generation logic to any particular texture layout or pipe
89 struct lp_sampler_dynamic_state
92 /** Obtain the base texture width. */
94 (*width
)( struct lp_sampler_dynamic_state
*state
,
95 LLVMBuilderRef builder
,
98 /** Obtain the base texture height. */
100 (*height
)( struct lp_sampler_dynamic_state
*state
,
101 LLVMBuilderRef builder
,
104 /** Obtain the base texture depth. */
106 (*depth
)( struct lp_sampler_dynamic_state
*state
,
107 LLVMBuilderRef builder
,
110 /** Obtain the number of mipmap levels (minus one). */
112 (*last_level
)( struct lp_sampler_dynamic_state
*state
,
113 LLVMBuilderRef builder
,
117 (*row_stride
)( struct lp_sampler_dynamic_state
*state
,
118 LLVMBuilderRef builder
,
122 (*img_stride
)( struct lp_sampler_dynamic_state
*state
,
123 LLVMBuilderRef builder
,
127 (*data_ptr
)( struct lp_sampler_dynamic_state
*state
,
128 LLVMBuilderRef builder
,
135 * Derive the sampler static state.
138 lp_sampler_static_state(struct lp_sampler_static_state
*state
,
139 const struct pipe_sampler_view
*view
,
140 const struct pipe_sampler_state
*sampler
);
144 lp_build_gather(LLVMBuilderRef builder
,
148 LLVMValueRef base_ptr
,
149 LLVMValueRef offsets
);
153 lp_build_sample_offset(struct lp_build_context
*bld
,
154 const struct util_format_description
*format_desc
,
158 LLVMValueRef y_stride
,
159 LLVMValueRef z_stride
);
163 lp_build_sample_soa(LLVMBuilderRef builder
,
164 const struct lp_sampler_static_state
*static_state
,
165 struct lp_sampler_dynamic_state
*dynamic_state
,
166 struct lp_type fp_type
,
169 const LLVMValueRef
*coords
,
170 LLVMValueRef lodbias
,
171 LLVMValueRef
*texel
);
175 #endif /* LP_BLD_SAMPLE_H */