Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2020-02-10 14:42:24 +0300
committerJacques Lucke <mail@jlucke.com>2020-02-10 14:42:24 +0300
commitf363ff348c21802549b5138119b6142f84284707 (patch)
tree0a8a9169f72c34d3bbffd6438bbceea2c745df45 /source/blender/simulations/bparticles
parent003dc7ffc9e9eed43a02ec7662117df21c80356c (diff)
remove temporary allocator
Diffstat (limited to 'source/blender/simulations/bparticles')
-rw-r--r--source/blender/simulations/bparticles/actions.cpp2
-rw-r--r--source/blender/simulations/bparticles/emitters.cpp33
-rw-r--r--source/blender/simulations/bparticles/events.cpp2
-rw-r--r--source/blender/simulations/bparticles/integrator.cpp2
-rw-r--r--source/blender/simulations/bparticles/particle_action.cpp4
-rw-r--r--source/blender/simulations/bparticles/particle_function.cpp2
-rw-r--r--source/blender/simulations/bparticles/particle_function.hpp1
-rw-r--r--source/blender/simulations/bparticles/simulate.cpp33
8 files changed, 35 insertions, 44 deletions
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index e0bef9167df..d1776c9de6a 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -108,7 +108,7 @@ void SpawnParticlesAction::execute(ParticleActionContext &context)
inputs.context_builder().set_buffer_cache(context.buffer_cache());
inputs.compute();
- LargeScopedArray<int> particle_counts(array_size, -1);
+ Array<int> particle_counts(array_size, -1);
const MultiFunction &fn = m_spawn_function.fn();
for (uint param_index : fn.param_indices()) {
diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp
index d3fda3fc297..28e0667bdaf 100644
--- a/source/blender/simulations/bparticles/emitters.cpp
+++ b/source/blender/simulations/bparticles/emitters.cpp
@@ -18,7 +18,6 @@
namespace BParticles {
using BKE::SurfaceHook;
-using BLI::LargeScopedArray;
using BLI::VectorAdaptor;
static float random_float()
@@ -186,7 +185,7 @@ static BLI_NOINLINE bool sample_weighted_buckets(uint sample_amount,
{
BLI_assert(sample_amount == r_samples.size());
- LargeScopedArray<float> cumulative_weights(weights.size() + 1);
+ Array<float> cumulative_weights(weights.size() + 1);
compute_cumulative_distribution(weights, cumulative_weights);
if (sample_amount > 0 && cumulative_weights.as_ref().last() == 0.0f) {
@@ -262,37 +261,37 @@ void SurfaceEmitter::emit(EmitterInterface &interface)
return;
}
- LargeScopedArray<float> triangle_weights(triangles.size());
+ Array<float> triangle_weights(triangles.size());
get_average_triangle_weights(mesh, triangles, m_vertex_weights, triangle_weights);
- LargeScopedArray<float> triangle_areas(triangles.size());
+ Array<float> triangle_areas(triangles.size());
compute_triangle_areas(mesh, triangles, triangle_areas);
for (uint i : triangles.index_range()) {
triangle_weights[i] *= triangle_areas[i];
}
- LargeScopedArray<uint> triangles_to_sample(particles_to_emit);
+ Array<uint> triangles_to_sample(particles_to_emit);
if (!sample_weighted_buckets(particles_to_emit, triangle_weights, triangles_to_sample)) {
return;
}
- LargeScopedArray<float3> local_positions(particles_to_emit);
- LargeScopedArray<float3> local_normals(particles_to_emit);
- LargeScopedArray<float3> bary_coords(particles_to_emit);
+ Array<float3> local_positions(particles_to_emit);
+ Array<float3> local_normals(particles_to_emit);
+ Array<float3> bary_coords(particles_to_emit);
sample_looptris(
mesh, triangles, triangles_to_sample, local_positions, local_normals, bary_coords);
float epsilon = 0.01f;
- LargeScopedArray<float4x4> transforms_at_birth(particles_to_emit);
- LargeScopedArray<float4x4> transforms_before_birth(particles_to_emit);
+ Array<float4x4> transforms_at_birth(particles_to_emit);
+ Array<float4x4> transforms_before_birth(particles_to_emit);
m_transform.interpolate(birth_moments, 0.0f, transforms_at_birth);
m_transform.interpolate(birth_moments, -epsilon, transforms_before_birth);
- LargeScopedArray<float3> positions_at_birth(particles_to_emit);
+ Array<float3> positions_at_birth(particles_to_emit);
float4x4::transform_positions(transforms_at_birth, local_positions, positions_at_birth);
- LargeScopedArray<float3> surface_velocities(particles_to_emit);
+ Array<float3> surface_velocities(particles_to_emit);
for (uint i = 0; i < particles_to_emit; i++) {
float3 position_before_birth = transforms_before_birth[i].transform_position(
local_positions[i]);
@@ -300,13 +299,13 @@ void SurfaceEmitter::emit(EmitterInterface &interface)
interface.time_span().size();
}
- LargeScopedArray<float3> world_normals(particles_to_emit);
+ Array<float3> world_normals(particles_to_emit);
float4x4::transform_directions(transforms_at_birth, local_normals, world_normals);
- LargeScopedArray<float> birth_times(particles_to_emit);
+ Array<float> birth_times(particles_to_emit);
interface.time_span().value_at(birth_moments, birth_times);
- LargeScopedArray<SurfaceHook> emit_hooks(particles_to_emit);
+ Array<SurfaceHook> emit_hooks(particles_to_emit);
BKE::ObjectIDHandle object_handle(m_object);
for (uint i = 0; i < particles_to_emit; i++) {
emit_hooks[i] = SurfaceHook(object_handle, triangles_to_sample[i], bary_coords[i]);
@@ -419,13 +418,13 @@ void CustomEmitter::emit(EmitterInterface &interface)
new_particles.fill<float>("Birth Time", time_span.start());
break;
case BirthTimeModes::Linear: {
- LargeScopedArray<float> birth_times(new_particles.total_size());
+ Array<float> birth_times(new_particles.total_size());
time_span.sample_linear(birth_times);
new_particles.set<float>("Birth Time", birth_times);
break;
}
case BirthTimeModes::Random: {
- LargeScopedArray<float> birth_times(new_particles.total_size());
+ Array<float> birth_times(new_particles.total_size());
for (uint i = 0; i < particle_count; i++) {
birth_times[i] = time_span.value_at(random_float());
}
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index 4b212beee74..bb938952389 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -5,8 +5,6 @@
namespace BParticles {
-using BLI::LargeScopedVector;
-
/* Age Reached Event
******************************************/
diff --git a/source/blender/simulations/bparticles/integrator.cpp b/source/blender/simulations/bparticles/integrator.cpp
index 8cd83e4953b..3ab4fba5fc7 100644
--- a/source/blender/simulations/bparticles/integrator.cpp
+++ b/source/blender/simulations/bparticles/integrator.cpp
@@ -49,7 +49,7 @@ void EulerIntegrator::integrate(IntegratorInterface &interface)
MutableAttributesRef r_offsets = interface.attribute_offsets();
ArrayRef<float> durations = interface.remaining_durations();
- LargeScopedArray<float3> combined_force(interface.array_size());
+ Array<float3> combined_force(interface.array_size());
this->compute_combined_force(interface, combined_force);
auto last_velocities = interface.attributes().get<float3>("Velocity");
diff --git a/source/blender/simulations/bparticles/particle_action.cpp b/source/blender/simulations/bparticles/particle_action.cpp
index 9db3a914b9f..83dd7dc1ec5 100644
--- a/source/blender/simulations/bparticles/particle_action.cpp
+++ b/source/blender/simulations/bparticles/particle_action.cpp
@@ -6,8 +6,6 @@ BLI_CREATE_CLASS_ID(BParticles::ParticleRemainingTimeInStep)
namespace BParticles {
-using BLI::LargeScopedArray;
-
ParticleAction::~ParticleAction()
{
}
@@ -106,7 +104,7 @@ void ParticleAction::execute_for_subset(IndexMask mask, ParticleActionContext &p
void ParticleAction::execute_from_offset_handler(OffsetHandlerInterface &offset_handler_interface)
{
- LargeScopedArray<float> current_times(offset_handler_interface.array_size());
+ Array<float> current_times(offset_handler_interface.array_size());
for (uint pindex : offset_handler_interface.mask()) {
current_times[pindex] = offset_handler_interface.time_span(pindex).start();
}
diff --git a/source/blender/simulations/bparticles/particle_function.cpp b/source/blender/simulations/bparticles/particle_function.cpp
index 331d3ef2bce..d6ac4c44ce1 100644
--- a/source/blender/simulations/bparticles/particle_function.cpp
+++ b/source/blender/simulations/bparticles/particle_function.cpp
@@ -1,5 +1,3 @@
-#include "BLI_temporary_allocator.h"
-
#include "FN_multi_function_common_contexts.h"
#include "particle_function.hpp"
diff --git a/source/blender/simulations/bparticles/particle_function.hpp b/source/blender/simulations/bparticles/particle_function.hpp
index c16a4e4a5c0..0db087320cf 100644
--- a/source/blender/simulations/bparticles/particle_function.hpp
+++ b/source/blender/simulations/bparticles/particle_function.hpp
@@ -13,7 +13,6 @@
namespace BParticles {
using BLI::ArrayRef;
-using BLI::LargeScopedArray;
using BLI::Optional;
using BLI::Vector;
using FN::GenericArrayRef;
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 26fbc32e806..24af6827365 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -11,8 +11,7 @@
namespace BParticles {
-using BLI::LargeScopedArray;
-using BLI::LargeScopedVector;
+using BLI::ScopedVector;
using BLI::VectorAdaptor;
using FN::CPPType;
@@ -22,7 +21,7 @@ BLI_NOINLINE static void find_next_event_per_particle(
ArrayRef<Event *> events,
MutableArrayRef<int> r_next_event_indices,
MutableArrayRef<float> r_time_factors_to_next_event,
- LargeScopedVector<uint> &r_pindices_with_event)
+ ScopedVector<uint> &r_pindices_with_event)
{
r_next_event_indices.fill_indices(mask, -1);
r_time_factors_to_next_event.fill_indices(mask, 1.0f);
@@ -173,9 +172,9 @@ BLI_NOINLINE static void simulate_to_next_event(BlockStepData &step_data,
VectorAdaptor<uint> &r_unfinished_pindices)
{
uint amount = step_data.array_size();
- LargeScopedArray<int> next_event_indices(amount);
- LargeScopedArray<float> time_factors_to_next_event(amount);
- LargeScopedVector<uint> pindices_with_event;
+ Array<int> next_event_indices(amount);
+ Array<float> time_factors_to_next_event(amount);
+ ScopedVector<uint> pindices_with_event;
find_next_event_per_particle(step_data,
mask,
@@ -199,7 +198,7 @@ BLI_NOINLINE static void simulate_to_next_event(BlockStepData &step_data,
Vector<Vector<uint>> particles_per_event(system_info.events.size());
find_pindices_per_event(pindices_with_event, next_event_indices, particles_per_event);
- LargeScopedArray<float> current_times(amount);
+ Array<float> current_times(amount);
compute_current_time_per_particle(
pindices_with_event, step_data.remaining_durations, step_data.step_end_time, current_times);
@@ -216,10 +215,10 @@ BLI_NOINLINE static void simulate_with_max_n_events(BlockStepData &step_data,
ParticleAllocator &particle_allocator,
uint max_events,
ParticleSystemInfo &system_info,
- LargeScopedVector<uint> &r_unfinished_pindices)
+ ScopedVector<uint> &r_unfinished_pindices)
{
- LargeScopedArray<uint> pindices_A(step_data.array_size());
- LargeScopedArray<uint> pindices_B(step_data.array_size());
+ Array<uint> pindices_A(step_data.array_size());
+ Array<uint> pindices_B(step_data.array_size());
uint amount_left = step_data.attributes.size();
@@ -255,7 +254,7 @@ BLI_NOINLINE static void apply_remaining_offsets(BlockStepData &step_data,
IndexMask mask)
{
if (offset_handlers.size() > 0) {
- LargeScopedArray<float> time_factors(step_data.array_size());
+ Array<float> time_factors(step_data.array_size());
time_factors.fill_indices(mask, 1.0f);
OffsetHandlerInterface interface(step_data, mask, time_factors, particle_allocator);
@@ -290,17 +289,17 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationState &simulation_sta
uint amount = attributes.size();
BLI_assert(amount == remaining_durations.size());
+ BufferCache buffer_cache;
+
Integrator &integrator = *system_info.integrator;
const AttributesInfo &offsets_info = integrator.offset_attributes_info();
Vector<void *> offset_buffers;
for (const CPPType *type : offsets_info.types()) {
- void *ptr = BLI_temporary_allocate(type->size() * amount);
+ void *ptr = buffer_cache.allocate(type->size() * amount, type->alignment());
offset_buffers.append(ptr);
}
MutableAttributesRef attribute_offsets(offsets_info, offset_buffers, amount);
- BufferCache buffer_cache;
-
BlockStepData step_data = {simulation_state,
buffer_cache,
attributes,
@@ -318,7 +317,7 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationState &simulation_sta
IndexRange(amount).as_array_ref());
}
else {
- LargeScopedVector<uint> unfinished_pindices;
+ ScopedVector<uint> unfinished_pindices;
simulate_with_max_n_events(
step_data, particle_allocator, 10, system_info, unfinished_pindices);
@@ -330,14 +329,14 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationState &simulation_sta
}
for (void *buffer : offset_buffers) {
- BLI_temporary_deallocate(buffer);
+ buffer_cache.deallocate(buffer);
}
}
BLI_NOINLINE static void delete_tagged_particles_and_reorder(ParticleSet &particles)
{
auto kill_states = particles.attributes().get<bool>("Dead");
- LargeScopedVector<uint> indices_to_delete;
+ ScopedVector<uint> indices_to_delete;
for (uint i : kill_states.index_range()) {
if (kill_states[i]) {