1b8e80941Smrg/* 2b8e80941Smrg * Copyright (C) 2015 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#include "util/ralloc.h" 28b8e80941Smrg 29b8e80941Smrg#include "ir3_compiler.h" 30b8e80941Smrg 31b8e80941Smrgstatic const struct debug_named_value shader_debug_options[] = { 32b8e80941Smrg {"vs", IR3_DBG_SHADER_VS, "Print shader disasm for vertex shaders"}, 33b8e80941Smrg {"fs", IR3_DBG_SHADER_FS, "Print shader disasm for fragment shaders"}, 34b8e80941Smrg {"cs", IR3_DBG_SHADER_CS, "Print shader disasm for compute shaders"}, 35b8e80941Smrg {"disasm", IR3_DBG_DISASM, "Dump NIR and adreno shader disassembly"}, 36b8e80941Smrg {"optmsgs", IR3_DBG_OPTMSGS, "Enable optimizer debug messages"}, 37b8e80941Smrg {"forces2en", IR3_DBG_FORCES2EN, "Force s2en mode for tex sampler instructions"}, 38b8e80941Smrg {"nouboopt", IR3_DBG_NOUBOOPT, "Disable lowering UBO to uniform"}, 39b8e80941Smrg DEBUG_NAMED_VALUE_END 40b8e80941Smrg}; 41b8e80941Smrg 42b8e80941SmrgDEBUG_GET_ONCE_FLAGS_OPTION(ir3_shader_debug, "IR3_SHADER_DEBUG", shader_debug_options, 0) 43b8e80941Smrg 44b8e80941Smrgenum ir3_shader_debug ir3_shader_debug = 0; 45b8e80941Smrg 46b8e80941Smrgstruct ir3_compiler * ir3_compiler_create(struct fd_device *dev, uint32_t gpu_id) 47b8e80941Smrg{ 48b8e80941Smrg struct ir3_compiler *compiler = rzalloc(NULL, struct ir3_compiler); 49b8e80941Smrg 50b8e80941Smrg ir3_shader_debug = debug_get_option_ir3_shader_debug(); 51b8e80941Smrg 52b8e80941Smrg compiler->dev = dev; 53b8e80941Smrg compiler->gpu_id = gpu_id; 54b8e80941Smrg compiler->set = ir3_ra_alloc_reg_set(compiler); 55b8e80941Smrg 56b8e80941Smrg if (compiler->gpu_id >= 600) { 57b8e80941Smrg compiler->samgq_workaround = true; 58b8e80941Smrg } 59b8e80941Smrg 60b8e80941Smrg if (compiler->gpu_id >= 400) { 61b8e80941Smrg /* need special handling for "flat" */ 62b8e80941Smrg compiler->flat_bypass = true; 63b8e80941Smrg compiler->levels_add_one = false; 64b8e80941Smrg compiler->unminify_coords = false; 65b8e80941Smrg compiler->txf_ms_with_isaml = false; 66b8e80941Smrg compiler->array_index_add_half = true; 67b8e80941Smrg } else { 68b8e80941Smrg /* no special handling for "flat" */ 69b8e80941Smrg compiler->flat_bypass = false; 70b8e80941Smrg compiler->levels_add_one = true; 71b8e80941Smrg compiler->unminify_coords = true; 72b8e80941Smrg compiler->txf_ms_with_isaml = true; 73b8e80941Smrg compiler->array_index_add_half = false; 74b8e80941Smrg } 75b8e80941Smrg 76b8e80941Smrg return compiler; 77b8e80941Smrg} 78