Skip to content

Commit 7a5b1ed

Browse files
committed
Merge pull request #99299 from Bonkahe/ResolveParticlesSetViewAxisThreadIssue
Move `_scene_particles_set_view_axis` to new static function to allow call to be done on render thread, preventing multi threaded error on compute shader execution.
2 parents 0dda6a9 + 7e3d480 commit 7a5b1ed

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

servers/rendering/renderer_scene_cull.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -3017,7 +3017,8 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
30173017
cull_data.cull->lock.lock();
30183018
RSG::particles_storage->particles_request_process(idata.base_rid);
30193019
cull_data.cull->lock.unlock();
3020-
RSG::particles_storage->particles_set_view_axis(idata.base_rid, -cull_data.cam_transform.basis.get_column(2).normalized(), cull_data.cam_transform.basis.get_column(1).normalized());
3020+
3021+
RS::get_singleton()->call_on_render_thread(callable_mp_static(&RendererSceneCull::_scene_particles_set_view_axis).bind(idata.base_rid, -cull_data.cam_transform.basis.get_column(2).normalized(), cull_data.cam_transform.basis.get_column(1).normalized()));
30213022
//particles visible? request redraw
30223023
RenderingServerDefault::redraw_request();
30233024
}
@@ -3192,6 +3193,10 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
31923193
}
31933194
}
31943195

3196+
void RendererSceneCull::_scene_particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis) {
3197+
RSG::particles_storage->particles_set_view_axis(p_particles, p_axis, p_up_axis);
3198+
}
3199+
31953200
void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_camera_data, const Ref<RenderSceneBuffers> &p_render_buffers, RID p_environment, RID p_force_camera_attributes, RID p_compositor, uint32_t p_visible_layers, RID p_scenario, RID p_viewport, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, bool p_using_shadows, RenderingMethod::RenderInfo *r_render_info) {
31963201
Instance *render_reflection_probe = instance_owner.get_or_null(p_reflection_probe); //if null, not rendering to it
31973202

servers/rendering/renderer_scene_cull.h

+2
Original file line numberDiff line numberDiff line change
@@ -1184,9 +1184,11 @@ class RendererSceneCull : public RenderingMethod {
11841184

11851185
void _scene_cull_threaded(uint32_t p_thread, CullData *cull_data);
11861186
void _scene_cull(CullData &cull_data, InstanceCullResult &cull_result, uint64_t p_from, uint64_t p_to);
1187+
static void _scene_particles_set_view_axis(RID p_particles, const Vector3 &p_axis, const Vector3 &p_up_axis);
11871188
_FORCE_INLINE_ bool _visibility_parent_check(const CullData &p_cull_data, const InstanceData &p_instance_data);
11881189

11891190
bool _render_reflection_probe_step(Instance *p_instance, int p_step);
1191+
11901192
void _render_scene(const RendererSceneRender::CameraData *p_camera_data, const Ref<RenderSceneBuffers> &p_render_buffers, RID p_environment, RID p_force_camera_attributes, RID p_compositor, uint32_t p_visible_layers, RID p_scenario, RID p_viewport, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_mesh_lod_threshold, bool p_using_shadows = true, RenderInfo *r_render_info = nullptr);
11911193
void render_empty_scene(const Ref<RenderSceneBuffers> &p_render_buffers, RID p_scenario, RID p_shadow_atlas);
11921194

0 commit comments

Comments
 (0)