Merge branch 'mesa_7_6_branch'
[mesa.git] / src / gallium / drivers / llvmpipe / lp_bld_sample.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 /**
29 * @file
30 * Texture sampling.
31 *
32 * @author Jose Fonseca <jfonseca@vmware.com>
33 */
34
35 #ifndef LP_BLD_SAMPLE_H
36 #define LP_BLD_SAMPLE_H
37
38
39 #include <llvm-c/Core.h>
40
41 struct pipe_texture;
42 struct pipe_sampler_state;
43 struct lp_type;
44
45
46 /**
47 * Sampler static state.
48 *
49 * These are the bits of state from pipe_texture and pipe_sampler_state that
50 * are embedded in the generated code.
51 */
52 struct lp_sampler_static_state
53 {
54 /* pipe_texture's state */
55 enum pipe_format format;
56 unsigned target:2;
57 unsigned pot_width:1;
58 unsigned pot_height:1;
59 unsigned pot_depth:1;
60
61 /* pipe_sampler_state's state */
62 unsigned wrap_s:3;
63 unsigned wrap_t:3;
64 unsigned wrap_r:3;
65 unsigned min_img_filter:2;
66 unsigned min_mip_filter:2;
67 unsigned mag_img_filter:2;
68 unsigned compare_mode:1;
69 unsigned compare_func:3;
70 unsigned normalized_coords:1;
71 unsigned prefilter:4;
72 };
73
74
75 /**
76 * Sampler dynamic state.
77 *
78 * These are the bits of state from pipe_texture and pipe_sampler_state that
79 * are computed in runtime.
80 *
81 * There are obtained through callbacks, as we don't want to tie the texture
82 * sampling code generation logic to any particular texture layout or pipe
83 * driver.
84 */
85 struct lp_sampler_dynamic_state
86 {
87
88 /** Obtain the base texture width. */
89 LLVMValueRef
90 (*width)( struct lp_sampler_dynamic_state *state,
91 LLVMBuilderRef builder,
92 unsigned unit);
93
94 /** Obtain the base texture height. */
95 LLVMValueRef
96 (*height)( struct lp_sampler_dynamic_state *state,
97 LLVMBuilderRef builder,
98 unsigned unit);
99
100 LLVMValueRef
101 (*stride)( struct lp_sampler_dynamic_state *state,
102 LLVMBuilderRef builder,
103 unsigned unit);
104
105 LLVMValueRef
106 (*data_ptr)( struct lp_sampler_dynamic_state *state,
107 LLVMBuilderRef builder,
108 unsigned unit);
109
110 };
111
112
113 /**
114 * Derive the sampler static state.
115 */
116 void
117 lp_sampler_static_state(struct lp_sampler_static_state *state,
118 const struct pipe_texture *texture,
119 const struct pipe_sampler_state *sampler);
120
121
122 void
123 lp_build_sample_soa(LLVMBuilderRef builder,
124 const struct lp_sampler_static_state *static_state,
125 struct lp_sampler_dynamic_state *dynamic_state,
126 struct lp_type fp_type,
127 unsigned unit,
128 unsigned num_coords,
129 const LLVMValueRef *coords,
130 LLVMValueRef lodbias,
131 LLVMValueRef *texel);
132
133
134
135 #endif /* LP_BLD_SAMPLE_H */