1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2014 Rob Clark <robclark@freedesktop.org> 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci * 23bf215546Sopenharmony_ci * Authors: 24bf215546Sopenharmony_ci * Rob Clark <robclark@freedesktop.org> 25bf215546Sopenharmony_ci */ 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#ifndef TGSI_LOWERING_H_ 28bf215546Sopenharmony_ci#define TGSI_LOWERING_H_ 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "pipe/p_shader_tokens.h" 31bf215546Sopenharmony_ci#include "tgsi/tgsi_scan.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_cistruct tgsi_lowering_config 34bf215546Sopenharmony_ci{ 35bf215546Sopenharmony_ci /* For fragment shaders, generate a shader that emulates two 36bf215546Sopenharmony_ci * sided color by inserting a BGCOLOR input for each COLOR 37bf215546Sopenharmony_ci * input, and insert a CMP instruction to select the correct 38bf215546Sopenharmony_ci * color to use based on the TGSI_SEMANTIC_FACE input. 39bf215546Sopenharmony_ci * 40bf215546Sopenharmony_ci * Note that drivers which use this to emulate two sided color 41bf215546Sopenharmony_ci * will: 42bf215546Sopenharmony_ci * a) need to generate (on demand) alternate shaders to use 43bf215546Sopenharmony_ci * depending on the rasterizer state (ie. whether two 44bf215546Sopenharmony_ci * sided shading enabled) 45bf215546Sopenharmony_ci * b) expect to see the BGCOLOR semantic name in fragment 46bf215546Sopenharmony_ci * shaders. During linkage, the driver should simply 47bf215546Sopenharmony_ci * map VS.OUT.BGCOLOR[n] to FS.IN.BGCOLOR[n] (in the 48bf215546Sopenharmony_ci * same was as linking other outs/ins). 49bf215546Sopenharmony_ci */ 50bf215546Sopenharmony_ci unsigned color_two_side:1; 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci /* TODO support for alpha_to_one as well?? */ 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci /* Individual OPC lowerings, if lower_<opc> is TRUE then 55bf215546Sopenharmony_ci * enable lowering of TGSI_OPCODE_<opc> 56bf215546Sopenharmony_ci */ 57bf215546Sopenharmony_ci unsigned lower_DST:1; 58bf215546Sopenharmony_ci unsigned lower_LRP:1; 59bf215546Sopenharmony_ci unsigned lower_FRC:1; 60bf215546Sopenharmony_ci unsigned lower_POW:1; 61bf215546Sopenharmony_ci unsigned lower_LIT:1; 62bf215546Sopenharmony_ci unsigned lower_EXP:1; 63bf215546Sopenharmony_ci unsigned lower_LOG:1; 64bf215546Sopenharmony_ci unsigned lower_DP4:1; 65bf215546Sopenharmony_ci unsigned lower_DP3:1; 66bf215546Sopenharmony_ci unsigned lower_DP2:1; 67bf215546Sopenharmony_ci unsigned lower_FLR:1; 68bf215546Sopenharmony_ci unsigned lower_CEIL:1; 69bf215546Sopenharmony_ci unsigned lower_TRUNC:1; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /* bitmask of (1 << TGSI_TEXTURE_type): */ 72bf215546Sopenharmony_ci unsigned lower_TXP; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci /* To emulate certain texture wrap modes, this can be used 75bf215546Sopenharmony_ci * to saturate the specified tex coord to [0.0, 1.0]. The 76bf215546Sopenharmony_ci * bits are according to sampler #, ie. if, for example: 77bf215546Sopenharmony_ci * 78bf215546Sopenharmony_ci * (conf->saturate_s & (1 << n)) 79bf215546Sopenharmony_ci * 80bf215546Sopenharmony_ci * is true, then the s coord for sampler n is saturated. 81bf215546Sopenharmony_ci */ 82bf215546Sopenharmony_ci unsigned saturate_s, saturate_t, saturate_r; 83bf215546Sopenharmony_ci}; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ciconst struct tgsi_token * 86bf215546Sopenharmony_citgsi_transform_lowering(const struct tgsi_lowering_config *config, 87bf215546Sopenharmony_ci const struct tgsi_token *tokens, 88bf215546Sopenharmony_ci struct tgsi_shader_info *info); 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci#endif /* FREEDRENO_LOWERING_H_ */ 91