1b8e80941Smrg/* 2b8e80941Smrg * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org> 3b8e80941Smrg * 4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5b8e80941Smrg * copy of this software and associated documentation files (the "Software"), 6b8e80941Smrg * to deal in the Software without restriction, including without limitation 7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the 9b8e80941Smrg * Software is furnished to do so, subject to the following conditions: 10b8e80941Smrg * 11b8e80941Smrg * The above copyright notice and this permission notice (including the next 12b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the 13b8e80941Smrg * Software. 14b8e80941Smrg * 15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20b8e80941Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21b8e80941Smrg * SOFTWARE. 22b8e80941Smrg * 23b8e80941Smrg * Authors: 24b8e80941Smrg * Rob Clark <robclark@freedesktop.org> 25b8e80941Smrg */ 26b8e80941Smrg 27b8e80941Smrg#ifndef IR3_COMPILER_H_ 28b8e80941Smrg#define IR3_COMPILER_H_ 29b8e80941Smrg 30b8e80941Smrg#include "ir3_shader.h" 31b8e80941Smrg 32b8e80941Smrgstruct ir3_ra_reg_set; 33b8e80941Smrg 34b8e80941Smrgstruct ir3_compiler { 35b8e80941Smrg struct fd_device *dev; 36b8e80941Smrg uint32_t gpu_id; 37b8e80941Smrg struct ir3_ra_reg_set *set; 38b8e80941Smrg uint32_t shader_count; 39b8e80941Smrg 40b8e80941Smrg /* 41b8e80941Smrg * Configuration options for things that are handled differently on 42b8e80941Smrg * different generations: 43b8e80941Smrg */ 44b8e80941Smrg 45b8e80941Smrg /* a4xx (and later) drops SP_FS_FLAT_SHAD_MODE_REG_* for flat-interpolate 46b8e80941Smrg * so we need to use ldlv.u32 to load the varying directly: 47b8e80941Smrg */ 48b8e80941Smrg bool flat_bypass; 49b8e80941Smrg 50b8e80941Smrg /* on a3xx, we need to add one to # of array levels: 51b8e80941Smrg */ 52b8e80941Smrg bool levels_add_one; 53b8e80941Smrg 54b8e80941Smrg /* on a3xx, we need to scale up integer coords for isaml based 55b8e80941Smrg * on LoD: 56b8e80941Smrg */ 57b8e80941Smrg bool unminify_coords; 58b8e80941Smrg 59b8e80941Smrg /* on a3xx do txf_ms w/ isaml and scaled coords: */ 60b8e80941Smrg bool txf_ms_with_isaml; 61b8e80941Smrg 62b8e80941Smrg /* on a4xx, for array textures we need to add 0.5 to the array 63b8e80941Smrg * index coordinate: 64b8e80941Smrg */ 65b8e80941Smrg bool array_index_add_half; 66b8e80941Smrg 67b8e80941Smrg /* on a6xx, rewrite samgp to sequence of samgq0-3 in vertex shaders: 68b8e80941Smrg */ 69b8e80941Smrg bool samgq_workaround; 70b8e80941Smrg}; 71b8e80941Smrg 72b8e80941Smrgstruct ir3_compiler * ir3_compiler_create(struct fd_device *dev, uint32_t gpu_id); 73b8e80941Smrg 74b8e80941Smrgint ir3_compile_shader_nir(struct ir3_compiler *compiler, 75b8e80941Smrg struct ir3_shader_variant *so); 76b8e80941Smrg 77b8e80941Smrgenum ir3_shader_debug { 78b8e80941Smrg IR3_DBG_SHADER_VS = 0x01, 79b8e80941Smrg IR3_DBG_SHADER_FS = 0x02, 80b8e80941Smrg IR3_DBG_SHADER_CS = 0x04, 81b8e80941Smrg IR3_DBG_DISASM = 0x08, 82b8e80941Smrg IR3_DBG_OPTMSGS = 0x10, 83b8e80941Smrg IR3_DBG_FORCES2EN = 0x20, 84b8e80941Smrg IR3_DBG_NOUBOOPT = 0x40, 85b8e80941Smrg}; 86b8e80941Smrg 87b8e80941Smrgextern enum ir3_shader_debug ir3_shader_debug; 88b8e80941Smrg 89b8e80941Smrgstatic inline bool 90b8e80941Smrgshader_debug_enabled(gl_shader_stage type) 91b8e80941Smrg{ 92b8e80941Smrg switch (type) { 93b8e80941Smrg case MESA_SHADER_VERTEX: return !!(ir3_shader_debug & IR3_DBG_SHADER_VS); 94b8e80941Smrg case MESA_SHADER_FRAGMENT: return !!(ir3_shader_debug & IR3_DBG_SHADER_FS); 95b8e80941Smrg case MESA_SHADER_COMPUTE: return !!(ir3_shader_debug & IR3_DBG_SHADER_CS); 96b8e80941Smrg default: 97b8e80941Smrg debug_assert(0); 98b8e80941Smrg return false; 99b8e80941Smrg } 100b8e80941Smrg} 101b8e80941Smrg 102b8e80941Smrg#endif /* IR3_COMPILER_H_ */ 103