2
* Copyright (C) 2014 Rob Clark <robclark@freedesktop.org>
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 FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
* Rob Clark <robclark@freedesktop.org>
27
#ifndef TGSI_LOWERING_H_
28
#define TGSI_LOWERING_H_
30
#include "pipe/p_shader_tokens.h"
31
#include "tgsi/tgsi_scan.h"
33
struct tgsi_lowering_config
35
/* For fragment shaders, generate a shader that emulates two
36
* sided color by inserting a BGCOLOR input for each COLOR
37
* input, and insert a CMP instruction to select the correct
38
* color to use based on the TGSI_SEMANTIC_FACE input.
40
* Note that drivers which use this to emulate two sided color
42
* a) need to generate (on demand) alternate shaders to use
43
* depending on the rasterizer state (ie. whether two
44
* sided shading enabled)
45
* b) expect to see the BGCOLOR semantic name in fragment
46
* shaders. During linkage, the driver should simply
47
* map VS.OUT.BGCOLOR[n] to FS.IN.BGCOLOR[n] (in the
48
* same was as linking other outs/ins).
50
unsigned color_two_side:1;
52
/* TODO support for alpha_to_one as well?? */
54
/* Individual OPC lowerings, if lower_<opc> is TRUE then
55
* enable lowering of TGSI_OPCODE_<opc>
68
unsigned lower_CEIL:1;
69
unsigned lower_TRUNC:1;
71
/* bitmask of (1 << TGSI_TEXTURE_type): */
74
/* To emulate certain texture wrap modes, this can be used
75
* to saturate the specified tex coord to [0.0, 1.0]. The
76
* bits are according to sampler #, ie. if, for example:
78
* (conf->saturate_s & (1 << n))
80
* is true, then the s coord for sampler n is saturated.
82
unsigned saturate_s, saturate_t, saturate_r;
85
const struct tgsi_token *
86
tgsi_transform_lowering(const struct tgsi_lowering_config *config,
87
const struct tgsi_token *tokens,
88
struct tgsi_shader_info *info);
90
#endif /* FREEDRENO_LOWERING_H_ */