mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-11 16:00:27 +01:00
r600/sfn:explicitly initialize the memory pool
This reduces the overhead of checking with each allocation whether the pool is already initialized. Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18983>
This commit is contained in:
parent
04aea1c0ba
commit
e840645bb7
4 changed files with 23 additions and 7 deletions
|
|
@ -67,7 +67,6 @@ MemoryPool::MemoryPool() noexcept : impl(nullptr)
|
|||
MemoryPool& MemoryPool::instance()
|
||||
{
|
||||
static thread_local MemoryPool me;
|
||||
me.initialize();
|
||||
return me;
|
||||
}
|
||||
|
||||
|
|
@ -85,11 +84,13 @@ void MemoryPool::initialize()
|
|||
|
||||
void *MemoryPool::allocate(size_t size)
|
||||
{
|
||||
assert(impl);
|
||||
return impl->pool->allocate(size);
|
||||
}
|
||||
|
||||
void *MemoryPool::allocate(size_t size, size_t align)
|
||||
{
|
||||
assert(impl);
|
||||
return impl->pool->allocate(size, align);
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ void MemoryPool::release_all()
|
|||
|
||||
void init_pool()
|
||||
{
|
||||
MemoryPool::instance();
|
||||
MemoryPool::instance().initialize();
|
||||
}
|
||||
|
||||
void release_pool()
|
||||
|
|
|
|||
|
|
@ -638,6 +638,9 @@ bool r600_lower_to_scalar_instr_filter(const nir_instr *instr, const void *)
|
|||
|
||||
class MallocPoolRelease {
|
||||
public:
|
||||
MallocPoolRelease() {
|
||||
r600::init_pool();
|
||||
}
|
||||
~MallocPoolRelease() {
|
||||
r600::release_pool();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@ protected:
|
|||
void check(const Instr& eval, const Instr& expect);
|
||||
void check(const string& init, const Instr& expect);
|
||||
|
||||
InstrFactory m_instr_factory;
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
InstrFactory *m_instr_factory;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -693,7 +696,7 @@ TestInstrFromString::TestInstrFromString()
|
|||
|
||||
PInst TestInstrFromString::from_string(const std::string& s)
|
||||
{
|
||||
return m_instr_factory.from_string(s, 0);
|
||||
return m_instr_factory->from_string(s, 0);
|
||||
}
|
||||
|
||||
void TestInstrFromString::check(const Instr& eval, const Instr& expect)
|
||||
|
|
@ -714,15 +717,24 @@ void TestInstrFromString::check(const string& init, const Instr& expect)
|
|||
|
||||
void TestInstrFromString::add_dest_from_string(const char *init)
|
||||
{
|
||||
m_instr_factory.value_factory().dest_from_string(init);
|
||||
m_instr_factory->value_factory().dest_from_string(init);
|
||||
}
|
||||
|
||||
void TestInstrFromString::add_dest_vec4_from_string(const char *init)
|
||||
{
|
||||
RegisterVec4::Swizzle dummy;
|
||||
m_instr_factory.value_factory().dest_vec4_from_string(init, dummy);
|
||||
m_instr_factory->value_factory().dest_vec4_from_string(init, dummy);
|
||||
}
|
||||
|
||||
void TestInstrFromString::SetUp()
|
||||
{
|
||||
MemoryPool::instance().initialize();
|
||||
m_instr_factory = new InstrFactory;
|
||||
}
|
||||
|
||||
void TestInstrFromString::TearDown()
|
||||
{
|
||||
MemoryPool::instance().free();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ class TestShaderFromString : public ::testing::Test
|
|||
{
|
||||
public:
|
||||
void SetUp() override {
|
||||
m_instr_factory = new InstrFactory();
|
||||
init_pool();
|
||||
m_instr_factory = new InstrFactory();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue