diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-31 10:54:02 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-31 10:54:02 +0100 |
commit | c24e0065b256351fff13f486938c77f2c7cedd9c (patch) | |
tree | 1f4caf429630402580b097db4681ff5299b2717d /servers | |
parent | af1dfa1452365be036ee6a7fcff172e130e3f882 (diff) | |
parent | cfd5fe0f29fcc06df81bfe764b072b8463aac969 (diff) |
Merge pull request #72433 from clayjohn/Pointlight2D-crash
Avoid crash when CanvasTexture used with light decal atlas
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp | 3 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/storage_rd/light_storage.cpp | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index 0f4fa1b9c4..bd8c11186e 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -1550,6 +1550,9 @@ void RendererCanvasRenderRD::light_set_texture(RID p_rid, RID p_texture) { if (cl->texture == p_texture) { return; } + + ERR_FAIL_COND(p_texture.is_valid() && !texture_storage->owns_texture(p_texture)); + if (cl->texture.is_valid()) { texture_storage->texture_remove_from_decal_atlas(cl->texture); } diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp index cdecb3828b..ff859a668a 100644 --- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp @@ -232,6 +232,8 @@ void LightStorage::light_set_projector(RID p_light, RID p_texture) { return; } + ERR_FAIL_COND(p_texture.is_valid() && !texture_storage->owns_texture(p_texture)); + if (light->type != RS::LIGHT_DIRECTIONAL && light->projector.is_valid()) { texture_storage->texture_remove_from_decal_atlas(light->projector, light->type == RS::LIGHT_OMNI); } |