gallium/swr: add OpenSWR driver
[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 class swr_vertex_shader;
27 class swr_fragment_shader;
28 class swr_jit_key;
29
30 PFN_VERTEX_FUNC
31 swr_compile_vs(struct pipe_context *ctx, swr_vertex_shader *swr_vs);
32
33 PFN_PIXEL_KERNEL
34 swr_compile_fs(struct swr_context *ctx, swr_jit_key &key);
35
36 void swr_generate_fs_key(struct swr_jit_key &key,
37 struct swr_context *ctx,
38 swr_fragment_shader *swr_fs);
39
40 struct swr_jit_key {
41 unsigned nr_cbufs;
42 unsigned light_twoside;
43 ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
44 ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];
45 unsigned nr_samplers;
46 unsigned nr_sampler_views;
47 struct swr_sampler_static_state sampler[PIPE_MAX_SHADER_SAMPLER_VIEWS];
48 };
49
50 namespace std
51 {
52 template <> struct hash<swr_jit_key> {
53 std::size_t operator()(const swr_jit_key &k) const
54 {
55 return util_hash_crc32(&k, sizeof(k));
56 }
57 };
58 };
59
60 bool operator==(const swr_jit_key &lhs, const swr_jit_key &rhs);