2 * Mesa 3-D graphics library
4 * Copyright (C) 2012-2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
31 #include "ilo_common.h"
32 #include "ilo_context.h"
34 /* XXX The interface needs to be reworked */
37 * A shader variant. It consists of non-orthogonal states of the pipe context
38 * affecting the compilation of a shader.
40 struct ilo_shader_variant {
43 bool rasterizer_discard;
48 bool rasterizer_discard;
50 int semantic_names[PIPE_MAX_SHADER_INPUTS];
51 int semantic_indices[PIPE_MAX_SHADER_INPUTS];
61 int num_sampler_views;
67 } sampler_view_swizzles[ILO_MAX_SAMPLER_VIEWS];
69 uint32_t saturate_tex_coords[3];
76 struct ilo_shader_variant variant;
77 /* hash of the shader variant for quicker lookup */
81 int semantic_names[PIPE_MAX_SHADER_INPUTS];
82 int semantic_indices[PIPE_MAX_SHADER_INPUTS];
83 int interp[PIPE_MAX_SHADER_INPUTS];
84 bool centroid[PIPE_MAX_SHADER_INPUTS];
89 bool has_linear_interp;
90 int barycentric_interpolation_mode;
95 int semantic_names[PIPE_MAX_SHADER_OUTPUTS];
96 int semantic_indices[PIPE_MAX_SHADER_OUTPUTS];
107 /* for VS stream output / rasterizer discard */
114 /* what does the push constant buffer consist of? */
119 struct list_head list;
121 uint32_t cache_seqno;
122 uint32_t cache_offset;
126 * Information about a shader state.
128 struct ilo_shader_info {
129 const struct ilo_dev_info *dev;
132 const struct tgsi_token *tokens;
134 struct pipe_stream_output_info stream_output;
136 unsigned req_local_mem;
137 unsigned req_private_mem;
138 unsigned req_input_mem;
141 bool has_color_interp;
145 bool fs_color0_writes_all_cbufs;
150 uint32_t shadow_samplers;
157 struct ilo_shader_state {
158 struct ilo_shader_info info;
160 struct list_head variants;
161 int num_variants, total_size;
163 struct ilo_shader *shader;
166 struct ilo_shader_cache {
167 struct intel_winsys *winsys;
172 /* starting from 1, incremented whenever a new bo is allocated */
177 ilo_shader_variant_init(struct ilo_shader_variant *variant,
178 const struct ilo_shader_info *info,
179 const struct ilo_context *ilo);
181 struct ilo_shader_state *
182 ilo_shader_state_create(const struct ilo_context *ilo,
183 int type, const void *templ);
186 ilo_shader_state_destroy(struct ilo_shader_state *state);
189 ilo_shader_state_add_variant(struct ilo_shader_state *state,
190 const struct ilo_shader_variant *variant);
193 ilo_shader_state_use_variant(struct ilo_shader_state *state,
194 const struct ilo_shader_variant *variant);
196 struct ilo_shader_cache *
197 ilo_shader_cache_create(struct intel_winsys *winsys);
200 ilo_shader_cache_destroy(struct ilo_shader_cache *shc);
203 ilo_shader_cache_set(struct ilo_shader_cache *shc,
204 struct ilo_shader **shaders,
208 ilo_shader_cache_mark_busy(struct ilo_shader_cache *shc)
215 ilo_shader_compile_vs(const struct ilo_shader_state *state,
216 const struct ilo_shader_variant *variant);
219 ilo_shader_compile_gs(const struct ilo_shader_state *state,
220 const struct ilo_shader_variant *variant);
223 ilo_shader_compile_gs_passthrough(const struct ilo_shader_state *vs_state,
224 const struct ilo_shader_variant *vs_variant,
225 const int *so_mapping,
226 struct ilo_shader *vs);
229 ilo_shader_compile_fs(const struct ilo_shader_state *state,
230 const struct ilo_shader_variant *variant);
233 ilo_shader_compile_cs(const struct ilo_shader_state *state,
234 const struct ilo_shader_variant *variant);
237 ilo_shader_destroy(struct ilo_shader *sh)
243 #endif /* ILO_SHADER_H */