1 /****************************************************************************
2 * Copyright (C) 2015 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 ***************************************************************************/
26 struct swr_vertex_shader
;
27 struct swr_fragment_shader
;
28 struct swr_geometry_shader
;
29 struct swr_tess_control_shader
;
30 struct swr_tess_evaluation_shader
;
32 struct swr_jit_fs_key
;
33 struct swr_jit_vs_key
;
34 struct swr_jit_gs_key
;
35 struct swr_jit_tcs_key
;
36 struct swr_jit_tes_key
;
38 using PFN_TCS_FUNC
= PFN_HS_FUNC
;
39 using PFN_TES_FUNC
= PFN_DS_FUNC
;
41 unsigned swr_so_adjust_attrib(unsigned in_attrib
,
42 swr_vertex_shader
*swr_vs
);
45 swr_compile_vs(struct swr_context
*ctx
, swr_jit_vs_key
&key
);
48 swr_compile_fs(struct swr_context
*ctx
, swr_jit_fs_key
&key
);
51 swr_compile_gs(struct swr_context
*ctx
, swr_jit_gs_key
&key
);
54 swr_compile_tcs(struct swr_context
*ctx
, swr_jit_tcs_key
&key
);
57 swr_compile_tes(struct swr_context
*ctx
, swr_jit_tes_key
&key
);
59 void swr_generate_fs_key(struct swr_jit_fs_key
&key
,
60 struct swr_context
*ctx
,
61 swr_fragment_shader
*swr_fs
);
63 void swr_generate_vs_key(struct swr_jit_vs_key
&key
,
64 struct swr_context
*ctx
,
65 swr_vertex_shader
*swr_vs
);
67 void swr_generate_fetch_key(struct swr_jit_fetch_key
&key
,
68 struct swr_vertex_element_state
*velems
);
70 void swr_generate_gs_key(struct swr_jit_gs_key
&key
,
71 struct swr_context
*ctx
,
72 swr_geometry_shader
*swr_gs
);
74 void swr_generate_tcs_key(struct swr_jit_tcs_key
&key
,
75 struct swr_context
*ctx
,
76 swr_tess_control_shader
*swr_tcs
);
78 void swr_generate_tes_key(struct swr_jit_tes_key
&key
,
79 struct swr_context
*ctx
,
80 swr_tess_evaluation_shader
*swr_tes
);
82 struct swr_jit_sampler_key
{
84 unsigned nr_sampler_views
;
85 struct swr_sampler_static_state sampler
[PIPE_MAX_SHADER_SAMPLER_VIEWS
];
88 struct swr_jit_fs_key
: swr_jit_sampler_key
{
90 unsigned light_twoside
;
91 unsigned sprite_coord_enable
;
92 ubyte vs_output_semantic_name
[PIPE_MAX_SHADER_OUTPUTS
];
93 ubyte vs_output_semantic_idx
[PIPE_MAX_SHADER_OUTPUTS
];
94 bool poly_stipple_enable
;
97 struct swr_jit_vs_key
: swr_jit_sampler_key
{
98 unsigned clip_plane_mask
; // from rasterizer state & vs_info
101 struct swr_jit_fetch_key
{
102 FETCH_COMPILE_STATE fsState
;
105 struct swr_jit_gs_key
: swr_jit_sampler_key
{
106 ubyte vs_output_semantic_name
[PIPE_MAX_SHADER_OUTPUTS
];
107 ubyte vs_output_semantic_idx
[PIPE_MAX_SHADER_OUTPUTS
];
110 // TESS_TODO: revisit this - we probably need to use
111 // primitive modes, number of vertices emitted, etc.
112 struct swr_jit_tcs_key
: swr_jit_sampler_key
{
113 ubyte vs_output_semantic_name
[PIPE_MAX_SHADER_OUTPUTS
];
114 ubyte vs_output_semantic_idx
[PIPE_MAX_SHADER_OUTPUTS
];
115 unsigned clip_plane_mask
; // from rasterizer state & tcs_info
118 // TESS_TODO: revisit this
119 struct swr_jit_tes_key
: swr_jit_sampler_key
{
120 ubyte prev_output_semantic_name
[PIPE_MAX_SHADER_OUTPUTS
];
121 ubyte prev_output_semantic_idx
[PIPE_MAX_SHADER_OUTPUTS
];
122 unsigned clip_plane_mask
; // from rasterizer state & tes_info
127 template <> struct hash
<swr_jit_fs_key
> {
128 std::size_t operator()(const swr_jit_fs_key
&k
) const
130 return util_hash_crc32(&k
, sizeof(k
));
134 template <> struct hash
<swr_jit_vs_key
> {
135 std::size_t operator()(const swr_jit_vs_key
&k
) const
137 return util_hash_crc32(&k
, sizeof(k
));
141 template <> struct hash
<swr_jit_fetch_key
> {
142 std::size_t operator()(const swr_jit_fetch_key
&k
) const
144 return util_hash_crc32(&k
, sizeof(k
));
148 template <> struct hash
<swr_jit_gs_key
> {
149 std::size_t operator()(const swr_jit_gs_key
&k
) const
151 return util_hash_crc32(&k
, sizeof(k
));
155 template <> struct hash
<swr_jit_tcs_key
> {
156 std::size_t operator()(const swr_jit_tcs_key
&k
) const
158 return util_hash_crc32(&k
, sizeof(k
));
162 template <> struct hash
<swr_jit_tes_key
> {
163 std::size_t operator()(const swr_jit_tes_key
&k
) const
165 return util_hash_crc32(&k
, sizeof(k
));
170 bool operator==(const swr_jit_fs_key
&lhs
, const swr_jit_fs_key
&rhs
);
171 bool operator==(const swr_jit_vs_key
&lhs
, const swr_jit_vs_key
&rhs
);
172 bool operator==(const swr_jit_fetch_key
&lhs
, const swr_jit_fetch_key
&rhs
);
173 bool operator==(const swr_jit_gs_key
&lhs
, const swr_jit_gs_key
&rhs
);
174 bool operator==(const swr_jit_tcs_key
&lhs
, const swr_jit_tcs_key
&rhs
);
175 bool operator==(const swr_jit_tes_key
&lhs
, const swr_jit_tes_key
&rhs
);