swr/rast: make simd16 logicops avx512f safe
[mesa.git] / src / gallium / drivers / swr / swr_shader.h
1 /****************************************************************************
2 * Copyright (C) 2015 Intel Corporation. All Rights Reserved.
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 ***************************************************************************/
23
24 #pragma once
25
26 struct swr_vertex_shader;
27 struct swr_fragment_shader;
28 struct swr_geometry_shader;
29 struct swr_jit_fs_key;
30 struct swr_jit_vs_key;
31 struct swr_jit_gs_key;
32
33 PFN_VERTEX_FUNC
34 swr_compile_vs(struct swr_context *ctx, swr_jit_vs_key &key);
35
36 PFN_PIXEL_KERNEL
37 swr_compile_fs(struct swr_context *ctx, swr_jit_fs_key &key);
38
39 PFN_GS_FUNC
40 swr_compile_gs(struct swr_context *ctx, swr_jit_gs_key &key);
41
42 void swr_generate_fs_key(struct swr_jit_fs_key &key,
43 struct swr_context *ctx,
44 swr_fragment_shader *swr_fs);
45
46 void swr_generate_vs_key(struct swr_jit_vs_key &key,
47 struct swr_context *ctx,
48 swr_vertex_shader *swr_vs);
49
50 void swr_generate_fetch_key(struct swr_jit_fetch_key &key,
51 struct swr_vertex_element_state *velems);
52
53 void swr_generate_gs_key(struct swr_jit_gs_key &key,
54 struct swr_context *ctx,
55 swr_geometry_shader *swr_gs);
56
57 struct swr_jit_sampler_key {
58 unsigned nr_samplers;
59 unsigned nr_sampler_views;
60 struct swr_sampler_static_state sampler[PIPE_MAX_SHADER_SAMPLER_VIEWS];
61 };
62
63 struct swr_jit_fs_key : swr_jit_sampler_key {
64 unsigned nr_cbufs;
65 unsigned light_twoside;
66 unsigned sprite_coord_enable;
67 ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
68 ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];
69 bool poly_stipple_enable;
70 };
71
72 struct swr_jit_vs_key : swr_jit_sampler_key {
73 unsigned clip_plane_mask; // from rasterizer state & vs_info
74 };
75
76 struct swr_jit_fetch_key {
77 FETCH_COMPILE_STATE fsState;
78 };
79
80 struct swr_jit_gs_key : swr_jit_sampler_key {
81 ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
82 ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];
83 };
84
85 namespace std
86 {
87 template <> struct hash<swr_jit_fs_key> {
88 std::size_t operator()(const swr_jit_fs_key &k) const
89 {
90 return util_hash_crc32(&k, sizeof(k));
91 }
92 };
93
94 template <> struct hash<swr_jit_vs_key> {
95 std::size_t operator()(const swr_jit_vs_key &k) const
96 {
97 return util_hash_crc32(&k, sizeof(k));
98 }
99 };
100
101 template <> struct hash<swr_jit_fetch_key> {
102 std::size_t operator()(const swr_jit_fetch_key &k) const
103 {
104 return util_hash_crc32(&k, sizeof(k));
105 }
106 };
107
108 template <> struct hash<swr_jit_gs_key> {
109 std::size_t operator()(const swr_jit_gs_key &k) const
110 {
111 return util_hash_crc32(&k, sizeof(k));
112 }
113 };
114 };
115
116 bool operator==(const swr_jit_fs_key &lhs, const swr_jit_fs_key &rhs);
117 bool operator==(const swr_jit_vs_key &lhs, const swr_jit_vs_key &rhs);
118 bool operator==(const swr_jit_fetch_key &lhs, const swr_jit_fetch_key &rhs);
119 bool operator==(const swr_jit_gs_key &lhs, const swr_jit_gs_key &rhs);