1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2017 Advanced Micro Devices, Inc. 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 * on the rights to use, copy, modify, merge, publish, distribute, sub 8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 9bf215546Sopenharmony_ci * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef TGSI_FROM_MESA_H 25bf215546Sopenharmony_ci#define TGSI_FROM_MESA_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <stdbool.h> 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "pipe/p_compiler.h" 30bf215546Sopenharmony_ci#include "pipe/p_defines.h" 31bf215546Sopenharmony_ci#include "pipe/p_shader_tokens.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#include "compiler/shader_enums.h" 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#ifdef __cplusplus 36bf215546Sopenharmony_ciextern "C" { 37bf215546Sopenharmony_ci#endif 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_civoid 41bf215546Sopenharmony_citgsi_get_gl_varying_semantic(gl_varying_slot attr, 42bf215546Sopenharmony_ci bool needs_texcoord_semantic, 43bf215546Sopenharmony_ci unsigned *semantic_name, 44bf215546Sopenharmony_ci unsigned *semantic_index); 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ciunsigned 47bf215546Sopenharmony_citgsi_get_generic_gl_varying_index(gl_varying_slot attr, 48bf215546Sopenharmony_ci bool needs_texcoord_semantic); 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_civoid 51bf215546Sopenharmony_citgsi_get_gl_frag_result_semantic(gl_frag_result frag_result, 52bf215546Sopenharmony_ci unsigned *semantic_name, 53bf215546Sopenharmony_ci unsigned *semantic_index); 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_cienum tgsi_semantic 56bf215546Sopenharmony_citgsi_get_sysval_semantic(unsigned sysval); 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cienum tgsi_interpolate_mode 59bf215546Sopenharmony_citgsi_get_interp_mode(enum glsl_interp_mode mode, bool color); 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_cistatic inline enum pipe_shader_type 62bf215546Sopenharmony_cipipe_shader_type_from_mesa(gl_shader_stage stage) 63bf215546Sopenharmony_ci{ 64bf215546Sopenharmony_ci switch (stage) { 65bf215546Sopenharmony_ci case MESA_SHADER_VERTEX: 66bf215546Sopenharmony_ci return PIPE_SHADER_VERTEX; 67bf215546Sopenharmony_ci case MESA_SHADER_TESS_CTRL: 68bf215546Sopenharmony_ci return PIPE_SHADER_TESS_CTRL; 69bf215546Sopenharmony_ci case MESA_SHADER_TESS_EVAL: 70bf215546Sopenharmony_ci return PIPE_SHADER_TESS_EVAL; 71bf215546Sopenharmony_ci case MESA_SHADER_GEOMETRY: 72bf215546Sopenharmony_ci return PIPE_SHADER_GEOMETRY; 73bf215546Sopenharmony_ci case MESA_SHADER_FRAGMENT: 74bf215546Sopenharmony_ci return PIPE_SHADER_FRAGMENT; 75bf215546Sopenharmony_ci case MESA_SHADER_COMPUTE: 76bf215546Sopenharmony_ci case MESA_SHADER_KERNEL: 77bf215546Sopenharmony_ci return PIPE_SHADER_COMPUTE; 78bf215546Sopenharmony_ci default: 79bf215546Sopenharmony_ci unreachable("bad shader stage"); 80bf215546Sopenharmony_ci } 81bf215546Sopenharmony_ci} 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_cistatic inline gl_shader_stage 84bf215546Sopenharmony_citgsi_processor_to_shader_stage(unsigned processor) 85bf215546Sopenharmony_ci{ 86bf215546Sopenharmony_ci switch (processor) { 87bf215546Sopenharmony_ci case PIPE_SHADER_FRAGMENT: return MESA_SHADER_FRAGMENT; 88bf215546Sopenharmony_ci case PIPE_SHADER_VERTEX: return MESA_SHADER_VERTEX; 89bf215546Sopenharmony_ci case PIPE_SHADER_GEOMETRY: return MESA_SHADER_GEOMETRY; 90bf215546Sopenharmony_ci case PIPE_SHADER_TESS_CTRL: return MESA_SHADER_TESS_CTRL; 91bf215546Sopenharmony_ci case PIPE_SHADER_TESS_EVAL: return MESA_SHADER_TESS_EVAL; 92bf215546Sopenharmony_ci case PIPE_SHADER_COMPUTE: return MESA_SHADER_COMPUTE; 93bf215546Sopenharmony_ci default: 94bf215546Sopenharmony_ci unreachable("invalid TGSI processor"); 95bf215546Sopenharmony_ci } 96bf215546Sopenharmony_ci} 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci#ifdef __cplusplus 99bf215546Sopenharmony_ci} 100bf215546Sopenharmony_ci#endif 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_ci#endif /* TGSI_FROM_MESA_H */ 103