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 "pipe/p_format.h"
41 #include "gallivm/lp_bld.h"
44 struct pipe_sampler_view
;
45 struct pipe_sampler_state
;
46 struct util_format_description
;
48 struct lp_build_context
;
52 * Sampler static state.
54 * These are the bits of state from pipe_resource and pipe_sampler_state that
55 * are embedded in the generated code.
57 struct lp_sampler_static_state
59 /* pipe_sampler_view's state */
60 enum pipe_format format
;
61 unsigned swizzle_r
:3; /**< PIPE_SWIZZLE_* */
66 /* pipe_texture's state */
67 unsigned target
:3; /**< PIPE_TEXTURE_* */
68 unsigned pot_width
:1; /**< is the width a power of two? */
69 unsigned pot_height
:1;
72 /* pipe_sampler_state's state */
76 unsigned min_img_filter
:2;
77 unsigned min_mip_filter
:2;
78 unsigned mag_img_filter
:2;
79 unsigned compare_mode
:1;
80 unsigned compare_func
:3;
81 unsigned normalized_coords
:1;
82 float lod_bias
, min_lod
, max_lod
;
83 float border_color
[4];
88 * Sampler dynamic state.
90 * These are the bits of state from pipe_resource and pipe_sampler_state that
91 * are computed in runtime.
93 * There are obtained through callbacks, as we don't want to tie the texture
94 * sampling code generation logic to any particular texture layout or pipe
97 struct lp_sampler_dynamic_state
100 /** Obtain the base texture width. */
102 (*width
)( const struct lp_sampler_dynamic_state
*state
,
103 LLVMBuilderRef builder
,
106 /** Obtain the base texture height. */
108 (*height
)( const struct lp_sampler_dynamic_state
*state
,
109 LLVMBuilderRef builder
,
112 /** Obtain the base texture depth. */
114 (*depth
)( const struct lp_sampler_dynamic_state
*state
,
115 LLVMBuilderRef builder
,
118 /** Obtain the number of mipmap levels (minus one). */
120 (*last_level
)( const struct lp_sampler_dynamic_state
*state
,
121 LLVMBuilderRef builder
,
125 (*row_stride
)( const struct lp_sampler_dynamic_state
*state
,
126 LLVMBuilderRef builder
,
130 (*img_stride
)( const struct lp_sampler_dynamic_state
*state
,
131 LLVMBuilderRef builder
,
135 (*data_ptr
)( const struct lp_sampler_dynamic_state
*state
,
136 LLVMBuilderRef builder
,
143 * Derive the sampler static state.
146 lp_sampler_static_state(struct lp_sampler_static_state
*state
,
147 const struct pipe_sampler_view
*view
,
148 const struct pipe_sampler_state
*sampler
);
152 lp_build_sample_offset(struct lp_build_context
*bld
,
153 const struct util_format_description
*format_desc
,
157 LLVMValueRef y_stride
,
158 LLVMValueRef z_stride
,
159 LLVMValueRef
*out_offset
,
161 LLVMValueRef
*out_j
);
165 lp_build_sample_soa(LLVMBuilderRef builder
,
166 const struct lp_sampler_static_state
*static_state
,
167 struct lp_sampler_dynamic_state
*dynamic_state
,
168 struct lp_type fp_type
,
171 const LLVMValueRef
*coords
,
172 const LLVMValueRef
*ddx
,
173 const LLVMValueRef
*ddy
,
174 LLVMValueRef lod_bias
,
175 LLVMValueRef explicit_lod
,
176 LLVMValueRef texel_out
[4]);
180 #endif /* LP_BLD_SAMPLE_H */