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 struct ilo_shader_cache
;
36 /* XXX The interface needs to be reworked */
39 * A shader variant. It consists of non-orthogonal states of the pipe context
40 * affecting the compilation of a shader.
42 struct ilo_shader_variant
{
45 bool rasterizer_discard
;
50 bool rasterizer_discard
;
52 int semantic_names
[PIPE_MAX_SHADER_INPUTS
];
53 int semantic_indices
[PIPE_MAX_SHADER_INPUTS
];
63 int num_sampler_views
;
69 } sampler_view_swizzles
[ILO_MAX_SAMPLER_VIEWS
];
71 uint32_t saturate_tex_coords
[3];
78 struct ilo_shader_variant variant
;
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 register_indices
[PIPE_MAX_SHADER_OUTPUTS
];
96 int semantic_names
[PIPE_MAX_SHADER_OUTPUTS
];
97 int semantic_indices
[PIPE_MAX_SHADER_OUTPUTS
];
108 /* for VS stream output / rasterizer discard */
115 /* what does the push constant buffer consist of? */
120 struct list_head list
;
122 /* managed by shader cache */
123 uint32_t cache_seqno
;
124 uint32_t cache_offset
;
128 * Information about a shader state.
130 struct ilo_shader_info
{
131 const struct ilo_dev_info
*dev
;
134 const struct tgsi_token
*tokens
;
136 struct pipe_stream_output_info stream_output
;
138 unsigned req_local_mem
;
139 unsigned req_private_mem
;
140 unsigned req_input_mem
;
143 bool has_color_interp
;
147 bool fs_color0_writes_all_cbufs
;
152 uint32_t shadow_samplers
;
159 struct ilo_shader_state
{
160 struct ilo_shader_info info
;
162 struct list_head variants
;
163 int num_variants
, total_size
;
165 struct ilo_shader
*shader
;
167 /* managed by shader cache */
168 struct ilo_shader_cache
*cache
;
169 struct list_head list
;
172 struct ilo_shader_cache
*
173 ilo_shader_cache_create(void);
176 ilo_shader_cache_destroy(struct ilo_shader_cache
*shc
);
179 ilo_shader_cache_add(struct ilo_shader_cache
*shc
,
180 struct ilo_shader_state
*shader
);
183 ilo_shader_cache_remove(struct ilo_shader_cache
*shc
,
184 struct ilo_shader_state
*shader
);
187 ilo_shader_cache_upload(struct ilo_shader_cache
*shc
,
188 struct intel_bo
*bo
, unsigned offset
,
192 ilo_shader_variant_init(struct ilo_shader_variant
*variant
,
193 const struct ilo_shader_info
*info
,
194 const struct ilo_context
*ilo
);
196 struct ilo_shader_state
*
197 ilo_shader_state_create(const struct ilo_context
*ilo
,
198 int type
, const void *templ
);
201 ilo_shader_state_destroy(struct ilo_shader_state
*state
);
204 ilo_shader_state_add_variant(struct ilo_shader_state
*state
,
205 const struct ilo_shader_variant
*variant
);
208 ilo_shader_state_use_variant(struct ilo_shader_state
*state
,
209 const struct ilo_shader_variant
*variant
);
212 ilo_shader_compile_vs(const struct ilo_shader_state
*state
,
213 const struct ilo_shader_variant
*variant
);
216 ilo_shader_compile_gs(const struct ilo_shader_state
*state
,
217 const struct ilo_shader_variant
*variant
);
220 ilo_shader_compile_gs_passthrough(const struct ilo_shader_state
*vs_state
,
221 const struct ilo_shader_variant
*vs_variant
,
222 const int *so_mapping
,
223 struct ilo_shader
*vs
);
226 ilo_shader_compile_fs(const struct ilo_shader_state
*state
,
227 const struct ilo_shader_variant
*variant
);
230 ilo_shader_compile_cs(const struct ilo_shader_state
*state
,
231 const struct ilo_shader_variant
*variant
);
234 ilo_shader_destroy(struct ilo_shader
*sh
)
240 #endif /* ILO_SHADER_H */