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-01-27 23:30:59 +0300
committerJacques Lucke <mail@jlucke.com>2020-01-27 23:30:59 +0300
commita39dc76dec5a8e3b0632350ba2441057ae69f97e (patch)
tree2f9a3999de1a8cdb38f3b2f1dd9e8c51a4b516e2 /source/blender/simulations
parent3f29c1dd390a7a22c39b930f74d49451cf396ef9 (diff)
pass buffer cache to functions via context
Diffstat (limited to 'source/blender/simulations')
-rw-r--r--source/blender/simulations/bparticles/actions.cpp3
-rw-r--r--source/blender/simulations/bparticles/block_step_data.hpp8
-rw-r--r--source/blender/simulations/bparticles/events.cpp9
-rw-r--r--source/blender/simulations/bparticles/forces.cpp1
-rw-r--r--source/blender/simulations/bparticles/particle_action.cpp8
-rw-r--r--source/blender/simulations/bparticles/particle_action.hpp8
-rw-r--r--source/blender/simulations/bparticles/simulate.cpp10
7 files changed, 42 insertions, 5 deletions
diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp
index 8f6970ef3a7..e0bef9167df 100644
--- a/source/blender/simulations/bparticles/actions.cpp
+++ b/source/blender/simulations/bparticles/actions.cpp
@@ -44,6 +44,7 @@ static void update_position_and_velocity_offsets(ParticleActionContext &context)
void ConditionAction::execute(ParticleActionContext &context)
{
ParticleFunctionEvaluator inputs{m_inputs_fn, context.mask(), context.attributes()};
+ inputs.context_builder().set_buffer_cache(context.buffer_cache());
inputs.compute();
Vector<uint> true_pindices, false_pindices;
@@ -72,6 +73,7 @@ void SetAttributeAction::execute(ParticleActionContext &context)
GenericMutableArrayRef attribute = *attribute_opt;
ParticleFunctionEvaluator inputs{m_inputs_fn, context.mask(), context.attributes()};
+ inputs.context_builder().set_buffer_cache(context.buffer_cache());
inputs.compute();
for (uint pindex : context.mask()) {
@@ -103,6 +105,7 @@ void SpawnParticlesAction::execute(ParticleActionContext &context)
uint array_size = context.mask().min_array_size();
ParticleFunctionEvaluator inputs{m_spawn_function, context.mask(), context.attributes()};
+ inputs.context_builder().set_buffer_cache(context.buffer_cache());
inputs.compute();
LargeScopedArray<int> particle_counts(array_size, -1);
diff --git a/source/blender/simulations/bparticles/block_step_data.hpp b/source/blender/simulations/bparticles/block_step_data.hpp
index 4e33a148ccc..d89cb60fae5 100644
--- a/source/blender/simulations/bparticles/block_step_data.hpp
+++ b/source/blender/simulations/bparticles/block_step_data.hpp
@@ -3,17 +3,20 @@
#include "FN_attributes_ref.h"
#include "BLI_float_interval.h"
+#include "BLI_buffer_cache.h"
#include "simulation_state.hpp"
namespace BParticles {
+using BLI::BufferCache;
using BLI::FloatInterval;
using FN::AttributesRef;
using FN::MutableAttributesRef;
struct BlockStepData {
SimulationState &simulation_state;
+ BufferCache &buffer_cache;
MutableAttributesRef attributes;
MutableAttributesRef attribute_offsets;
MutableArrayRef<float> remaining_durations;
@@ -39,6 +42,11 @@ class BlockStepDataAccess {
return m_step_data.simulation_state;
}
+ BufferCache &buffer_cache()
+ {
+ return m_step_data.buffer_cache;
+ }
+
uint array_size() const
{
return m_step_data.array_size();
diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp
index ea1d759ece7..4b212beee74 100644
--- a/source/blender/simulations/bparticles/events.cpp
+++ b/source/blender/simulations/bparticles/events.cpp
@@ -15,6 +15,7 @@ void AgeReachedEvent::filter(EventFilterInterface &interface)
AttributesRef attributes = interface.attributes();
ParticleFunctionEvaluator inputs{m_inputs_fn, interface.mask(), interface.attributes()};
+ inputs.context_builder().set_buffer_cache(interface.buffer_cache());
inputs.compute();
float end_time = interface.step_end_time();
@@ -65,9 +66,11 @@ void CustomEvent::filter(EventFilterInterface &interface)
FN::EventFilterDurationsContext durations_context = {interface.remaining_durations()};
ParticleFunctionEvaluator inputs{m_inputs_fn, interface.mask(), interface.attributes()};
- inputs.context_builder().add_global_context(end_time_context);
- inputs.context_builder().add_element_context(durations_context,
- FN::MFElementContextIndices::FromDirectMapping());
+ FN::MFContextBuilder &context_builder = inputs.context_builder();
+ context_builder.set_buffer_cache(interface.buffer_cache());
+ context_builder.add_global_context(end_time_context);
+ context_builder.add_element_context(durations_context,
+ FN::MFElementContextIndices::FromDirectMapping());
inputs.compute();
for (uint pindex : interface.mask()) {
diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp
index f7544171b3a..79a0f026008 100644
--- a/source/blender/simulations/bparticles/forces.cpp
+++ b/source/blender/simulations/bparticles/forces.cpp
@@ -13,6 +13,7 @@ void CustomForce::add_force(ForceInterface &interface)
MutableArrayRef<float3> dst = interface.combined_destination();
ParticleFunctionEvaluator inputs{m_inputs_fn, interface.mask(), interface.attributes()};
+ inputs.context_builder().set_buffer_cache(interface.buffer_cache());
inputs.compute();
for (uint pindex : interface.mask()) {
diff --git a/source/blender/simulations/bparticles/particle_action.cpp b/source/blender/simulations/bparticles/particle_action.cpp
index 42ec6728333..800dbeffc62 100644
--- a/source/blender/simulations/bparticles/particle_action.cpp
+++ b/source/blender/simulations/bparticles/particle_action.cpp
@@ -15,6 +15,8 @@ ParticleAction::~ParticleAction()
void ParticleAction::execute_from_emitter(AttributesRefGroup &new_particles,
EmitterInterface &emitter_interface)
{
+ BufferCache buffer_cache;
+
for (MutableAttributesRef attributes : new_particles) {
ParticleCurrentTimesContext current_times_context;
current_times_context.current_times = attributes.get<float>("Birth Time");
@@ -22,6 +24,7 @@ void ParticleAction::execute_from_emitter(AttributesRefGroup &new_particles,
ParticleActionContext context(emitter_interface.particle_allocator(),
IndexMask(attributes.size()),
attributes,
+ buffer_cache,
{BLI::get_class_id<ParticleCurrentTimesContext>()},
{(void *)&current_times_context});
this->execute(context);
@@ -39,6 +42,7 @@ void ParticleAction::execute_for_new_particles(AttributesRefGroup &new_particles
ParticleActionContext context(parent_context.particle_allocator(),
IndexMask(attributes.size()),
attributes,
+ parent_context.buffer_cache(),
{BLI::get_class_id<ParticleCurrentTimesContext>()},
{(void *)&current_times_context});
this->execute(context);
@@ -55,6 +59,7 @@ void ParticleAction::execute_for_new_particles(AttributesRefGroup &new_particles
ParticleActionContext context(offset_handler_interface.particle_allocator(),
IndexMask(attributes.size()),
attributes,
+ offset_handler_interface.buffer_cache(),
{BLI::get_class_id<ParticleCurrentTimesContext>()},
{(void *)&current_times_context});
this->execute(context);
@@ -75,6 +80,7 @@ void ParticleAction::execute_from_event(EventExecuteInterface &event_interface)
event_interface.particle_allocator(),
event_interface.pindices(),
event_interface.attributes(),
+ event_interface.buffer_cache(),
{BLI::get_class_id<ParticleCurrentTimesContext>(),
BLI::get_class_id<ParticleIntegratedOffsets>(),
BLI::get_class_id<ParticleRemainingTimeInStep>()},
@@ -87,6 +93,7 @@ void ParticleAction::execute_for_subset(IndexMask mask, ParticleActionContext &p
ParticleActionContext context(parent_context.particle_allocator(),
mask,
parent_context.attributes(),
+ parent_context.buffer_cache(),
parent_context.custom_context_ids(),
parent_context.custom_contexts());
this->execute(context);
@@ -111,6 +118,7 @@ void ParticleAction::execute_from_offset_handler(OffsetHandlerInterface &offset_
offset_handler_interface.particle_allocator(),
offset_handler_interface.mask(),
offset_handler_interface.attributes(),
+ offset_handler_interface.buffer_cache(),
{BLI::get_class_id<ParticleCurrentTimesContext>(),
BLI::get_class_id<ParticleIntegratedOffsets>(),
BLI::get_class_id<ParticleRemainingTimeInStep>()},
diff --git a/source/blender/simulations/bparticles/particle_action.hpp b/source/blender/simulations/bparticles/particle_action.hpp
index 9b0341c8f8d..b52904a40d1 100644
--- a/source/blender/simulations/bparticles/particle_action.hpp
+++ b/source/blender/simulations/bparticles/particle_action.hpp
@@ -17,6 +17,7 @@ class ParticleActionContext {
ParticleAllocator &m_particle_allocator;
IndexMask m_mask;
MutableAttributesRef m_attributes;
+ BufferCache &m_buffer_cache;
ArrayRef<BLI::class_id_t> m_custom_context_ids;
ArrayRef<void *> m_custom_contexts;
@@ -25,11 +26,13 @@ class ParticleActionContext {
ParticleActionContext(ParticleAllocator &particle_allocator,
IndexMask mask,
MutableAttributesRef attributes,
+ BufferCache &buffer_cache,
ArrayRef<BLI::class_id_t> custom_context_ids,
ArrayRef<void *> custom_contexts)
: m_particle_allocator(particle_allocator),
m_mask(mask),
m_attributes(attributes),
+ m_buffer_cache(buffer_cache),
m_custom_context_ids(custom_context_ids),
m_custom_contexts(custom_contexts)
{
@@ -72,6 +75,11 @@ class ParticleActionContext {
return nullptr;
}
}
+
+ BufferCache &buffer_cache()
+ {
+ return m_buffer_cache;
+ }
};
class ParticleAction {
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 84b3a14b979..8214a3dff87 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -299,8 +299,14 @@ BLI_NOINLINE static void simulate_particle_chunk(SimulationState &simulation_sta
}
MutableAttributesRef attribute_offsets(offsets_info, offset_buffers, amount);
- BlockStepData step_data = {
- simulation_state, attributes, attribute_offsets, remaining_durations, end_time};
+ BufferCache buffer_cache;
+
+ BlockStepData step_data = {simulation_state,
+ buffer_cache,
+ attributes,
+ attribute_offsets,
+ remaining_durations,
+ end_time};
IntegratorInterface interface(step_data, IndexRange(amount).as_array_ref());
integrator.integrate(interface);