提交 50c36dc3 编写于 作者: M Matt Pharr

monotonic_buffer_resource: pass allocs and frees directly to upstream

上级 971a4bc2
...@@ -75,11 +75,10 @@ void *monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) { ...@@ -75,11 +75,10 @@ void *monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
// so this is tied to pbrt's current usage of them... // so this is tied to pbrt's current usage of them...
CHECK(constructTID == std::this_thread::get_id()); CHECK(constructTID == std::this_thread::get_id());
#endif #endif
if (bytes > block_size) if (bytes > block_size)
// We've got a big allocation; let the current block be so that // We've got a big allocation; let the current block be so that
// smaller allocations have a chance at using up more of it. // smaller allocations have a chance at using up more of it.
return allocate_block(bytes)->ptr; return upstream->allocate(bytes, align);
if ((current_pos % align) != 0) if ((current_pos % align) != 0)
current_pos += align - (current_pos % align); current_pos += align - (current_pos % align);
......
...@@ -576,7 +576,10 @@ class alignas(64) monotonic_buffer_resource : public memory_resource { ...@@ -576,7 +576,10 @@ class alignas(64) monotonic_buffer_resource : public memory_resource {
void *do_allocate(size_t bytes, size_t align) override; void *do_allocate(size_t bytes, size_t align) override;
void do_deallocate(void *p, size_t bytes, size_t alignment) override { void do_deallocate(void *p, size_t bytes, size_t alignment) override {
// no-op if (bytes > block_size)
// do_allocate() passes large allocations on to the upstream memory resource,
// so we might as well deallocate when it's possible.
upstream->deallocate(p, bytes);
} }
bool do_is_equal(const memory_resource &other) const noexcept override { bool do_is_equal(const memory_resource &other) const noexcept override {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册