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
;
79 int semantic_names
[PIPE_MAX_SHADER_INPUTS
];
80 int semantic_indices
[PIPE_MAX_SHADER_INPUTS
];
81 int interp
[PIPE_MAX_SHADER_INPUTS
];
82 bool centroid
[PIPE_MAX_SHADER_INPUTS
];
87 bool has_linear_interp
;
88 int barycentric_interpolation_mode
;
93 int register_indices
[PIPE_MAX_SHADER_OUTPUTS
];
94 int semantic_names
[PIPE_MAX_SHADER_OUTPUTS
];
95 int semantic_indices
[PIPE_MAX_SHADER_OUTPUTS
];
106 /* for VS stream output / rasterizer discard */
113 /* what does the push constant buffer consist of? */
118 struct list_head list
;
120 uint32_t cache_seqno
;
121 uint32_t cache_offset
;
125 * Information about a shader state.
127 struct ilo_shader_info
{
128 const struct ilo_dev_info
*dev
;
131 const struct tgsi_token
*tokens
;
133 struct pipe_stream_output_info stream_output
;
135 unsigned req_local_mem
;
136 unsigned req_private_mem
;
137 unsigned req_input_mem
;
140 bool has_color_interp
;
144 bool fs_color0_writes_all_cbufs
;
149 uint32_t shadow_samplers
;
156 struct ilo_shader_state
{
157 struct ilo_shader_info info
;
159 struct list_head variants
;
160 int num_variants
, total_size
;
162 struct ilo_shader
*shader
;
165 struct ilo_shader_cache
{
166 struct intel_winsys
*winsys
;
171 /* starting from 1, incremented whenever a new bo is allocated */
176 ilo_shader_variant_init(struct ilo_shader_variant
*variant
,
177 const struct ilo_shader_info
*info
,
178 const struct ilo_context
*ilo
);
180 struct ilo_shader_state
*
181 ilo_shader_state_create(const struct ilo_context
*ilo
,
182 int type
, const void *templ
);
185 ilo_shader_state_destroy(struct ilo_shader_state
*state
);
188 ilo_shader_state_add_variant(struct ilo_shader_state
*state
,
189 const struct ilo_shader_variant
*variant
);
192 ilo_shader_state_use_variant(struct ilo_shader_state
*state
,
193 const struct ilo_shader_variant
*variant
);
195 struct ilo_shader_cache
*
196 ilo_shader_cache_create(struct intel_winsys
*winsys
);
199 ilo_shader_cache_destroy(struct ilo_shader_cache
*shc
);
202 ilo_shader_cache_set(struct ilo_shader_cache
*shc
,
203 struct ilo_shader
**shaders
,
207 ilo_shader_cache_mark_busy(struct ilo_shader_cache
*shc
)
214 ilo_shader_compile_vs(const struct ilo_shader_state
*state
,
215 const struct ilo_shader_variant
*variant
);
218 ilo_shader_compile_gs(const struct ilo_shader_state
*state
,
219 const struct ilo_shader_variant
*variant
);
222 ilo_shader_compile_gs_passthrough(const struct ilo_shader_state
*vs_state
,
223 const struct ilo_shader_variant
*vs_variant
,
224 const int *so_mapping
,
225 struct ilo_shader
*vs
);
228 ilo_shader_compile_fs(const struct ilo_shader_state
*state
,
229 const struct ilo_shader_variant
*variant
);
232 ilo_shader_compile_cs(const struct ilo_shader_state
*state
,
233 const struct ilo_shader_variant
*variant
);
236 ilo_shader_destroy(struct ilo_shader
*sh
)
242 #endif /* ILO_SHADER_H */