• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 unsigned swr_so_adjust_attrib(unsigned in_attrib,
34                               swr_vertex_shader *swr_vs);
35 
36 PFN_VERTEX_FUNC
37 swr_compile_vs(struct swr_context *ctx, swr_jit_vs_key &key);
38 
39 PFN_PIXEL_KERNEL
40 swr_compile_fs(struct swr_context *ctx, swr_jit_fs_key &key);
41 
42 PFN_GS_FUNC
43 swr_compile_gs(struct swr_context *ctx, swr_jit_gs_key &key);
44 
45 void swr_generate_fs_key(struct swr_jit_fs_key &key,
46                          struct swr_context *ctx,
47                          swr_fragment_shader *swr_fs);
48 
49 void swr_generate_vs_key(struct swr_jit_vs_key &key,
50                          struct swr_context *ctx,
51                          swr_vertex_shader *swr_vs);
52 
53 void swr_generate_fetch_key(struct swr_jit_fetch_key &key,
54                             struct swr_vertex_element_state *velems);
55 
56 void swr_generate_gs_key(struct swr_jit_gs_key &key,
57                          struct swr_context *ctx,
58                          swr_geometry_shader *swr_gs);
59 
60 struct swr_jit_sampler_key {
61    unsigned nr_samplers;
62    unsigned nr_sampler_views;
63    struct swr_sampler_static_state sampler[PIPE_MAX_SHADER_SAMPLER_VIEWS];
64 };
65 
66 struct swr_jit_fs_key : swr_jit_sampler_key {
67    unsigned nr_cbufs;
68    unsigned light_twoside;
69    unsigned sprite_coord_enable;
70    ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
71    ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];
72    bool poly_stipple_enable;
73 };
74 
75 struct swr_jit_vs_key : swr_jit_sampler_key {
76    unsigned clip_plane_mask; // from rasterizer state & vs_info
77 };
78 
79 struct swr_jit_fetch_key {
80    FETCH_COMPILE_STATE fsState;
81 };
82 
83 struct swr_jit_gs_key : swr_jit_sampler_key {
84    ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
85    ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];
86 };
87 
88 namespace std
89 {
90 template <> struct hash<swr_jit_fs_key> {
91    std::size_t operator()(const swr_jit_fs_key &k) const
92    {
93       return util_hash_crc32(&k, sizeof(k));
94    }
95 };
96 
97 template <> struct hash<swr_jit_vs_key> {
98    std::size_t operator()(const swr_jit_vs_key &k) const
99    {
100       return util_hash_crc32(&k, sizeof(k));
101    }
102 };
103 
104 template <> struct hash<swr_jit_fetch_key> {
105    std::size_t operator()(const swr_jit_fetch_key &k) const
106    {
107       return util_hash_crc32(&k, sizeof(k));
108    }
109 };
110 
111 template <> struct hash<swr_jit_gs_key> {
112    std::size_t operator()(const swr_jit_gs_key &k) const
113    {
114       return util_hash_crc32(&k, sizeof(k));
115    }
116 };
117 };
118 
119 bool operator==(const swr_jit_fs_key &lhs, const swr_jit_fs_key &rhs);
120 bool operator==(const swr_jit_vs_key &lhs, const swr_jit_vs_key &rhs);
121 bool operator==(const swr_jit_fetch_key &lhs, const swr_jit_fetch_key &rhs);
122 bool operator==(const swr_jit_gs_key &lhs, const swr_jit_gs_key &rhs);
123