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 "core/ilo_state_shader.h"
33 #include "ilo_common.h"
35 enum ilo_kernel_param
{
36 ILO_KERNEL_INPUT_COUNT
,
37 ILO_KERNEL_OUTPUT_COUNT
,
38 ILO_KERNEL_SAMPLER_COUNT
,
39 ILO_KERNEL_SKIP_CBUF0_UPLOAD
,
40 ILO_KERNEL_PCB_CBUF0_SIZE
,
42 ILO_KERNEL_SURFACE_TOTAL_COUNT
,
43 ILO_KERNEL_SURFACE_TEX_BASE
,
44 ILO_KERNEL_SURFACE_TEX_COUNT
,
45 ILO_KERNEL_SURFACE_CONST_BASE
,
46 ILO_KERNEL_SURFACE_CONST_COUNT
,
47 ILO_KERNEL_SURFACE_RES_BASE
,
48 ILO_KERNEL_SURFACE_RES_COUNT
,
50 ILO_KERNEL_VS_INPUT_INSTANCEID
,
51 ILO_KERNEL_VS_INPUT_VERTEXID
,
52 ILO_KERNEL_VS_INPUT_EDGEFLAG
,
53 ILO_KERNEL_VS_PCB_UCP_SIZE
,
54 ILO_KERNEL_VS_GEN6_SO
,
55 ILO_KERNEL_VS_GEN6_SO_POINT_OFFSET
,
56 ILO_KERNEL_VS_GEN6_SO_LINE_OFFSET
,
57 ILO_KERNEL_VS_GEN6_SO_TRI_OFFSET
,
58 ILO_KERNEL_VS_GEN6_SO_SURFACE_COUNT
,
60 ILO_KERNEL_GS_DISCARD_ADJACENCY
,
61 ILO_KERNEL_GS_GEN6_SVBI_POST_INC
,
62 ILO_KERNEL_GS_GEN6_SURFACE_SO_BASE
,
63 ILO_KERNEL_GS_GEN6_SURFACE_SO_COUNT
,
65 ILO_KERNEL_FS_BARYCENTRIC_INTERPOLATIONS
,
66 ILO_KERNEL_FS_DISPATCH_16_OFFSET
,
67 ILO_KERNEL_FS_SURFACE_RT_BASE
,
68 ILO_KERNEL_FS_SURFACE_RT_COUNT
,
70 ILO_KERNEL_CS_LOCAL_SIZE
,
71 ILO_KERNEL_CS_PRIVATE_SIZE
,
72 ILO_KERNEL_CS_INPUT_SIZE
,
73 ILO_KERNEL_CS_SIMD_SIZE
,
74 ILO_KERNEL_CS_SURFACE_GLOBAL_BASE
,
75 ILO_KERNEL_CS_SURFACE_GLOBAL_COUNT
,
77 ILO_KERNEL_PARAM_COUNT
,
82 struct ilo_rasterizer_state
;
83 struct ilo_shader_cache
;
84 struct ilo_shader_state
;
87 struct ilo_state_vector
;
89 union ilo_shader_cso
{
90 struct ilo_state_vs vs
;
91 struct ilo_state_hs hs
;
92 struct ilo_state_ds ds
;
93 struct ilo_state_gs gs
;
94 struct ilo_state_ps ps
;
97 struct ilo_state_vs vs
;
98 struct ilo_state_gs sol
;
102 struct ilo_shader_cache
*
103 ilo_shader_cache_create(void);
106 ilo_shader_cache_destroy(struct ilo_shader_cache
*shc
);
109 ilo_shader_cache_add(struct ilo_shader_cache
*shc
,
110 struct ilo_shader_state
*shader
);
113 ilo_shader_cache_remove(struct ilo_shader_cache
*shc
,
114 struct ilo_shader_state
*shader
);
117 ilo_shader_cache_upload(struct ilo_shader_cache
*shc
,
118 struct ilo_builder
*builder
);
121 ilo_shader_cache_invalidate(struct ilo_shader_cache
*shc
);
124 ilo_shader_cache_get_max_scratch_sizes(const struct ilo_shader_cache
*shc
,
125 int *vs_scratch_size
,
126 int *gs_scratch_size
,
127 int *fs_scratch_size
);
129 struct ilo_shader_state
*
130 ilo_shader_create_vs(const struct ilo_dev
*dev
,
131 const struct pipe_shader_state
*state
,
132 const struct ilo_state_vector
*precompile
);
134 struct ilo_shader_state
*
135 ilo_shader_create_gs(const struct ilo_dev
*dev
,
136 const struct pipe_shader_state
*state
,
137 const struct ilo_state_vector
*precompile
);
139 struct ilo_shader_state
*
140 ilo_shader_create_fs(const struct ilo_dev
*dev
,
141 const struct pipe_shader_state
*state
,
142 const struct ilo_state_vector
*precompile
);
144 struct ilo_shader_state
*
145 ilo_shader_create_cs(const struct ilo_dev
*dev
,
146 const struct pipe_compute_state
*state
,
147 const struct ilo_state_vector
*precompile
);
150 ilo_shader_destroy(struct ilo_shader_state
*shader
);
153 ilo_shader_select_kernel(struct ilo_shader_state
*shader
,
154 const struct ilo_state_vector
*vec
,
158 ilo_shader_select_kernel_sbe(struct ilo_shader_state
*shader
,
159 const struct ilo_shader_state
*source
,
160 const struct ilo_rasterizer_state
*rasterizer
);
163 ilo_shader_get_kernel_offset(const struct ilo_shader_state
*shader
);
166 ilo_shader_get_kernel_param(const struct ilo_shader_state
*shader
,
167 enum ilo_kernel_param param
);
169 const union ilo_shader_cso
*
170 ilo_shader_get_kernel_cso(const struct ilo_shader_state
*shader
);
172 const struct pipe_stream_output_info
*
173 ilo_shader_get_kernel_so_info(const struct ilo_shader_state
*shader
);
175 const struct ilo_state_sol
*
176 ilo_shader_get_kernel_sol(const struct ilo_shader_state
*shader
);
178 const struct ilo_state_sbe
*
179 ilo_shader_get_kernel_sbe(const struct ilo_shader_state
*shader
);
181 #endif /* ILO_SHADER_H */