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: a128d444cb ('aco: use monotonic_buffer_resource for instructions')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19219>
This commit is contained in:
committed by
Marge Bot
parent
43d93c32c9
commit
a36e27e507
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user