diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 9fc29ba97f6..575aba155eb 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -838,6 +838,23 @@ bool brw_should_print_shader(const nir_shader *shader, uint64_t debug_flag) return INTEL_DEBUG(debug_flag) && (!shader->info.internal || NIR_DEBUG(PRINT_INTERNAL)); } +static unsigned +brw_allocate_vgrf_number(fs_visitor &s, unsigned size_in_REGSIZE_units) +{ + assert(size_in_REGSIZE_units > 0); + + if (s.alloc.capacity <= s.alloc.count) { + unsigned new_cap = MAX2(16, s.alloc.capacity * 2); + s.alloc.sizes = rerzalloc(s.mem_ctx, s.alloc.sizes, unsigned, + s.alloc.capacity, new_cap); + s.alloc.capacity = new_cap; + } + + s.alloc.sizes[s.alloc.count] = size_in_REGSIZE_units; + + return s.alloc.count++; +} + brw_reg brw_allocate_vgrf(fs_visitor &s, brw_reg_type type, unsigned count) { @@ -850,6 +867,6 @@ brw_allocate_vgrf(fs_visitor &s, brw_reg_type type, unsigned count) brw_reg brw_allocate_vgrf_units(fs_visitor &s, unsigned units_of_REGSIZE) { - return brw_vgrf(s.alloc.allocate(units_of_REGSIZE), BRW_TYPE_UD); + return brw_vgrf(brw_allocate_vgrf_number(s, units_of_REGSIZE), BRW_TYPE_UD); } diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index 0e39bfc57c5..27e490b448a 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -31,7 +31,6 @@ #include "brw_cfg.h" #include "brw_compiler.h" #include "brw_inst.h" -#include "brw_ir_allocator.h" #include "compiler/nir/nir.h" #include "brw_analysis.h" @@ -226,7 +225,16 @@ public: gl_shader_stage stage; bool debug_enabled; - brw::simple_allocator alloc; + /* VGRF allocation. */ + struct { + /** Array of sizes for each allocation, in REG_SIZE units. */ + unsigned *sizes; + + /** Total number of VGRFs allocated. */ + unsigned count; + + unsigned capacity; + } alloc; const brw_base_prog_key *const key; diff --git a/src/intel/compiler/brw_fs_visitor.cpp b/src/intel/compiler/brw_fs_visitor.cpp index b3e7cc73d11..8f16aea6bc6 100644 --- a/src/intel/compiler/brw_fs_visitor.cpp +++ b/src/intel/compiler/brw_fs_visitor.cpp @@ -446,6 +446,10 @@ fs_visitor::init() this->gs.control_data_bits_per_vertex = 0; this->gs.control_data_header_size_bits = 0; + + this->alloc.capacity = 0; + this->alloc.sizes = NULL; + this->alloc.count = 0; } fs_visitor::~fs_visitor() diff --git a/src/intel/compiler/brw_inst.cpp b/src/intel/compiler/brw_inst.cpp index 637f602dd6f..3e80d8f57ab 100644 --- a/src/intel/compiler/brw_inst.cpp +++ b/src/intel/compiler/brw_inst.cpp @@ -3,6 +3,7 @@ * SPDX-License-Identifier: MIT */ +#include "brw_fs.h" #include "brw_eu.h" #include "brw_fs.h" #include "brw_cfg.h" diff --git a/src/intel/compiler/brw_ir_allocator.h b/src/intel/compiler/brw_ir_allocator.h deleted file mode 100644 index 85bd1e69bef..00000000000 --- a/src/intel/compiler/brw_ir_allocator.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright © 2010-2014 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#pragma once - -#include "util/compiler.h" -#include "util/glheader.h" -#include "util/macros.h" -#include "util/rounding.h" -#include "util/u_math.h" - -namespace brw { - /** - * Simple allocator used to keep track of virtual GRFs. - */ - class simple_allocator { - public: - simple_allocator() : - sizes(NULL), count(0), capacity(0) - { - } - - ~simple_allocator() - { - free(sizes); - } - - unsigned - allocate(unsigned size) - { - assert(size > 0); - if (capacity <= count) { - capacity = MAX2(16, capacity * 2); - sizes = (unsigned *)realloc(sizes, capacity * sizeof(unsigned)); - } - - sizes[count] = size; - - return count++; - } - - /** - * Array of sizes for each allocation. The allocation unit is up to the - * back-end, but it's expected to be one scalar value in the FS back-end - * and one vec4 in the VEC4 back-end. - */ - unsigned *sizes; - - /** Total number of VGRFs allocated. */ - unsigned count; - - private: - unsigned capacity; - }; -} diff --git a/src/intel/compiler/meson.build b/src/intel/compiler/meson.build index ba27b974fa4..8cfc3116d67 100644 --- a/src/intel/compiler/meson.build +++ b/src/intel/compiler/meson.build @@ -60,7 +60,6 @@ libintel_compiler_brw_files = files( 'brw_generator.h', 'brw_inst.cpp', 'brw_inst.h', - 'brw_ir_allocator.h', 'brw_isa_info.h', 'brw_lower.cpp', 'brw_lower_dpas.cpp',