Track compositor effects that use motion vectors so we enable required logic
This commit is contained in:
parent
292e50e17e
commit
1690ede988
|
@ -1040,7 +1040,7 @@ void MeshStorage::update_mesh_instances() {
|
||||||
|
|
||||||
//process skeletons and blend shapes
|
//process skeletons and blend shapes
|
||||||
uint64_t frame = RSG::rasterizer->get_frame_number();
|
uint64_t frame = RSG::rasterizer->get_frame_number();
|
||||||
bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0);
|
bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0) || (RendererCompositorStorage::get_singleton()->get_num_compositor_effects_with_motion_vectors() > 0);
|
||||||
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
|
RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin();
|
||||||
|
|
||||||
while (dirty_mesh_instance_arrays.first()) {
|
while (dirty_mesh_instance_arrays.first()) {
|
||||||
|
@ -1711,7 +1711,7 @@ void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index,
|
||||||
|
|
||||||
_multimesh_make_local(multimesh);
|
_multimesh_make_local(multimesh);
|
||||||
|
|
||||||
bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0);
|
bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0) || (RendererCompositorStorage::get_singleton()->get_num_compositor_effects_with_motion_vectors() > 0);
|
||||||
if (uses_motion_vectors) {
|
if (uses_motion_vectors) {
|
||||||
_multimesh_enable_motion_vectors(multimesh);
|
_multimesh_enable_motion_vectors(multimesh);
|
||||||
}
|
}
|
||||||
|
@ -1934,7 +1934,7 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
|
||||||
ERR_FAIL_NULL(multimesh);
|
ERR_FAIL_NULL(multimesh);
|
||||||
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
|
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
|
||||||
|
|
||||||
bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0);
|
bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0) || (RendererCompositorStorage::get_singleton()->get_num_compositor_effects_with_motion_vectors() > 0);
|
||||||
if (uses_motion_vectors) {
|
if (uses_motion_vectors) {
|
||||||
_multimesh_enable_motion_vectors(multimesh);
|
_multimesh_enable_motion_vectors(multimesh);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1306,7 +1306,7 @@ void ParticlesStorage::_particles_update_buffers(Particles *particles) {
|
||||||
userdata_count = particle_shader_data->userdata_count;
|
userdata_count = particle_shader_data->userdata_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uses_motion_vectors = RSG::viewport->get_num_viewports_with_motion_vectors() > 0;
|
bool uses_motion_vectors = RSG::viewport->get_num_viewports_with_motion_vectors() > 0 || (RendererCompositorStorage::get_singleton()->get_num_compositor_effects_with_motion_vectors() > 0);
|
||||||
bool index_draw_order = particles->draw_order == RS::ParticlesDrawOrder::PARTICLES_DRAW_ORDER_INDEX;
|
bool index_draw_order = particles->draw_order == RS::ParticlesDrawOrder::PARTICLES_DRAW_ORDER_INDEX;
|
||||||
bool enable_motion_vectors = uses_motion_vectors && index_draw_order && !particles->instance_motion_vectors_enabled;
|
bool enable_motion_vectors = uses_motion_vectors && index_draw_order && !particles->instance_motion_vectors_enabled;
|
||||||
bool only_instances_changed = false;
|
bool only_instances_changed = false;
|
||||||
|
@ -1389,7 +1389,7 @@ void ParticlesStorage::update_particles() {
|
||||||
|
|
||||||
RENDER_TIMESTAMP("Update GPUParticles");
|
RENDER_TIMESTAMP("Update GPUParticles");
|
||||||
uint32_t frame = RSG::rasterizer->get_frame_number();
|
uint32_t frame = RSG::rasterizer->get_frame_number();
|
||||||
bool uses_motion_vectors = RSG::viewport->get_num_viewports_with_motion_vectors() > 0;
|
bool uses_motion_vectors = RSG::viewport->get_num_viewports_with_motion_vectors() > 0 || (RendererCompositorStorage::get_singleton()->get_num_compositor_effects_with_motion_vectors() > 0);
|
||||||
while (particle_update_list.first()) {
|
while (particle_update_list.first()) {
|
||||||
//use transform feedback to process particles
|
//use transform feedback to process particles
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,23 @@ void RendererCompositorStorage::compositor_effect_initialize(RID p_rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererCompositorStorage::compositor_effect_free(RID p_rid) {
|
void RendererCompositorStorage::compositor_effect_free(RID p_rid) {
|
||||||
// TODO remove this RID from any compositor that uses it.
|
CompositorEffect *effect = compositor_effects_owner.get_or_null(p_rid);
|
||||||
|
ERR_FAIL_NULL(effect);
|
||||||
|
|
||||||
|
// Remove this RID from any compositor that uses it.
|
||||||
|
List<RID> compositor_rids;
|
||||||
|
compositor_owner.get_owned_list(&compositor_rids);
|
||||||
|
for (const RID &compositor_rid : compositor_rids) {
|
||||||
|
Compositor *compositor = compositor_owner.get_or_null(compositor_rid);
|
||||||
|
if (compositor) {
|
||||||
|
compositor->compositor_effects.erase(p_rid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update motion vector count if needed.
|
||||||
|
if (effect->is_enabled && effect->flags.has_flag(RS::CompositorEffectFlags::COMPOSITOR_EFFECT_FLAG_NEEDS_MOTION_VECTORS)) {
|
||||||
|
num_compositor_effects_with_motion_vectors--;
|
||||||
|
}
|
||||||
|
|
||||||
compositor_effects_owner.free(p_rid);
|
compositor_effects_owner.free(p_rid);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +86,14 @@ void RendererCompositorStorage::compositor_effect_set_enabled(RID p_effect, bool
|
||||||
CompositorEffect *effect = compositor_effects_owner.get_or_null(p_effect);
|
CompositorEffect *effect = compositor_effects_owner.get_or_null(p_effect);
|
||||||
ERR_FAIL_NULL(effect);
|
ERR_FAIL_NULL(effect);
|
||||||
|
|
||||||
|
if (effect->is_enabled != p_enabled && effect->flags.has_flag(RS::CompositorEffectFlags::COMPOSITOR_EFFECT_FLAG_NEEDS_MOTION_VECTORS)) {
|
||||||
|
if (p_enabled) {
|
||||||
|
num_compositor_effects_with_motion_vectors++;
|
||||||
|
} else {
|
||||||
|
num_compositor_effects_with_motion_vectors--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
effect->is_enabled = p_enabled;
|
effect->is_enabled = p_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +122,18 @@ void RendererCompositorStorage::compositor_effect_set_flag(RID p_effect, RS::Com
|
||||||
CompositorEffect *effect = compositor_effects_owner.get_or_null(p_effect);
|
CompositorEffect *effect = compositor_effects_owner.get_or_null(p_effect);
|
||||||
ERR_FAIL_NULL(effect);
|
ERR_FAIL_NULL(effect);
|
||||||
|
|
||||||
|
if (effect->is_enabled && p_flag == RS::CompositorEffectFlags::COMPOSITOR_EFFECT_FLAG_NEEDS_MOTION_VECTORS) {
|
||||||
|
bool was_set = effect->flags.has_flag(RS::CompositorEffectFlags::COMPOSITOR_EFFECT_FLAG_NEEDS_MOTION_VECTORS);
|
||||||
|
|
||||||
|
if (was_set != p_set) {
|
||||||
|
if (p_set) {
|
||||||
|
num_compositor_effects_with_motion_vectors++;
|
||||||
|
} else {
|
||||||
|
num_compositor_effects_with_motion_vectors--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (p_set) {
|
if (p_set) {
|
||||||
effect->flags.set_flag(p_flag);
|
effect->flags.set_flag(p_flag);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
class RendererCompositorStorage {
|
class RendererCompositorStorage {
|
||||||
private:
|
private:
|
||||||
static RendererCompositorStorage *singleton;
|
static RendererCompositorStorage *singleton;
|
||||||
|
int num_compositor_effects_with_motion_vectors = 0;
|
||||||
|
|
||||||
// Compositor effect
|
// Compositor effect
|
||||||
struct CompositorEffect {
|
struct CompositorEffect {
|
||||||
|
@ -59,6 +60,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static RendererCompositorStorage *get_singleton() { return singleton; }
|
static RendererCompositorStorage *get_singleton() { return singleton; }
|
||||||
|
int get_num_compositor_effects_with_motion_vectors() const { return num_compositor_effects_with_motion_vectors; }
|
||||||
|
|
||||||
RendererCompositorStorage();
|
RendererCompositorStorage();
|
||||||
virtual ~RendererCompositorStorage();
|
virtual ~RendererCompositorStorage();
|
||||||
|
|
Loading…
Reference in New Issue