diff options
author | Daniel Schürmann <daniel@schuermann.dev> | 2022-10-21 11:09:46 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2022-10-25 09:08:08 +0000 |
commit | a36e27e507d4a16678ccd0e873883956a7e6302a (patch) | |
tree | 893a8430c44397e66ade9834870c68e05b6bf0be | |
parent | 43d93c32c94016cbbee775b3b0c75a64fe583f4c (diff) | |
download | mesa-a36e27e507d4a16678ccd0e873883956a7e6302a.tar.gz |
aco: change thread_local memory resource to pointer
Apparently the TLS constructor doesn't work well if RADV
is instantiated multiple times and/or used by a program with
already existing threads.
Fixes: a128d444cbf4f74b0bdd4a8ae3f1cd2a52dee122 ('aco: use monotonic_buffer_resource for instructions')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19219>
-rw-r--r-- | src/amd/compiler/aco_interface.cpp | 6 | ||||
-rw-r--r-- | src/amd/compiler/aco_ir.cpp | 3 | ||||
-rw-r--r-- | src/amd/compiler/aco_ir.h | 5 |
3 files changed, 5 insertions, 9 deletions
diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp index 89d3bc6ea89..03544424c2e 100644 --- a/src/amd/compiler/aco_interface.cpp +++ b/src/amd/compiler/aco_interface.cpp @@ -257,8 +257,6 @@ aco_compile_shader(const struct aco_compiler_options* options, if (program->collect_statistics) stats_size = aco::num_statistics * sizeof(uint32_t); - aco::instruction_buffer.release(); - (*build_binary)(binary, shaders[shader_count - 1]->info.stage, args->is_gs_copy_shader, @@ -310,8 +308,6 @@ aco_compile_vs_prolog(const struct aco_compiler_options* options, if (get_disasm) disasm = get_disasm_string(program.get(), code, exec_size); - aco::instruction_buffer.release(); - (*build_prolog)(binary, config.num_sgprs, config.num_vgprs, @@ -357,8 +353,6 @@ aco_compile_ps_epilog(const struct aco_compiler_options* options, if (get_disasm) disasm = get_disasm_string(program.get(), code, exec_size); - aco::instruction_buffer.release(); - (*build_epilog)(binary, config.num_sgprs, config.num_vgprs, diff --git a/src/amd/compiler/aco_ir.cpp b/src/amd/compiler/aco_ir.cpp index f7b0ecb6f29..583250f56ed 100644 --- a/src/amd/compiler/aco_ir.cpp +++ b/src/amd/compiler/aco_ir.cpp @@ -32,7 +32,7 @@ namespace aco { -thread_local aco::monotonic_buffer_resource instruction_buffer(65536); +thread_local aco::monotonic_buffer_resource* instruction_buffer = nullptr; uint64_t debug_flags = 0; @@ -76,6 +76,7 @@ init_program(Program* program, Stage stage, const struct aco_shader_info* info, enum amd_gfx_level gfx_level, enum radeon_family family, bool wgp_mode, ac_shader_config* config) { + instruction_buffer = &program->m; program->stage = stage; program->config = config; program->info = *info; diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index a06c3bc7507..9220fec588e 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1778,7 +1778,7 @@ struct Pseudo_reduction_instruction : public Instruction { static_assert(sizeof(Pseudo_reduction_instruction) == sizeof(Instruction) + 4, "Unexpected padding"); -extern thread_local aco::monotonic_buffer_resource instruction_buffer; +extern thread_local aco::monotonic_buffer_resource* instruction_buffer; struct instr_deleter_functor { /* Don't yet free any instructions. They will be de-allocated @@ -1796,7 +1796,7 @@ create_instruction(aco_opcode opcode, Format format, uint32_t num_operands, { std::size_t size = sizeof(T) + num_operands * sizeof(Operand) + num_definitions * sizeof(Definition); - void* data = instruction_buffer.allocate(size, alignof(uint32_t)); + void* data = instruction_buffer->allocate(size, alignof(uint32_t)); memset(data, 0, size); T* inst = (T*)data; @@ -2155,6 +2155,7 @@ enum class CompilationProgress { class Program final { public: + aco::monotonic_buffer_resource m{65536}; std::vector<Block> blocks; std::vector<RegClass> temp_rc = {s1}; RegisterDemand max_reg_demand = RegisterDemand(); |