1 /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
4 * Copyright (C) 2014 Rob Clark <robclark@freedesktop.org>
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 (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Rob Clark <robclark@freedesktop.org>
29 #ifndef FREEDRENO_LOWERING_H_
30 #define FREEDRENO_LOWERING_H_
32 #include "pipe/p_shader_tokens.h"
33 #include "tgsi/tgsi_scan.h"
35 struct fd_lowering_config
{
36 /* For fragment shaders, generate a shader that emulates two
37 * sided color by inserting a BGCOLOR input for each COLOR
38 * input, and insert a CMP instruction to select the correct
39 * color to use based on the TGSI_SEMANTIC_FACE input.
41 * Note that drivers which use this to emulate two sided color
43 * a) need to generate (on demand) alternate shaders to use
44 * depending on the rasterizer state (ie. whether two
45 * sided shading enabled)
46 * b) expect to see the BGCOLOR semantic name in fragment
47 * shaders. During linkage, the driver should simply
48 * map VS.OUT.BGCOLOR[n] to FS.IN.BGCOLOR[n] (in the
49 * same was as linking other outs/ins).
51 unsigned color_two_side
: 1;
53 /* TODO support for alpha_to_one as well?? */
55 /* Individual OPC lowerings, if lower_<opc> is TRUE then
56 * enable lowering of TGSI_OPCODE_<opc>
58 unsigned lower_DST
: 1;
59 unsigned lower_XPD
: 1;
60 unsigned lower_SCS
: 1;
61 unsigned lower_LRP
: 1;
62 unsigned lower_FRC
: 1;
63 unsigned lower_POW
: 1;
64 unsigned lower_LIT
: 1;
65 unsigned lower_EXP
: 1;
66 unsigned lower_LOG
: 1;
67 unsigned lower_DP4
: 1;
68 unsigned lower_DP3
: 1;
69 unsigned lower_DPH
: 1;
70 unsigned lower_DP2
: 1;
71 unsigned lower_DP2A
: 1;
74 const struct tgsi_token
* fd_transform_lowering(
75 const struct fd_lowering_config
*config
,
76 const struct tgsi_token
*tokens
,
77 struct tgsi_shader_info
*info
);
79 #endif /* FREEDRENO_LOWERING_H_ */