Skip to content

Conversation

@DevPoodle
Copy link
Contributor

Closes #8447.

I've added a little section at the end of the compute shader tutorial to remind the reader to free RID's when they're finished using them. I also went through and removed some static type hints from the code blocks on this page to make it more consistent with the rest of the manual.

@tetrapod00 tetrapod00 added enhancement area:manual Issues and PRs related to the Manual/Tutorials section of the documentation topic:shaders labels Mar 4, 2025
@tetrapod00 tetrapod00 requested a review from a team March 4, 2025 22:52
@thibault
Copy link
Contributor

Hi. I stumbled upon this PR while searching about this topic. While this addition is very useful, I feel it would be interesting to add more details about the reason it is necessary to clear rids. Like, you have to clear rids, but why? Does the entire resource stays in memory forever? Or is there a limited amount of available rids?

@thibault
Copy link
Contributor

Another comment : On the water_plane demo on godot-demo-projects, you can find this comment related to rid freeing code:

Note that our sets and pipeline are cleaned up automatically as they are dependencies :P

I find that rather confusing, so it seems there's a little more to it than just clearing every single created RID? (sorry if it outside the current PR initial scope).

@DevPoodle
Copy link
Contributor Author

DevPoodle commented Mar 28, 2025

@thibault Clearing RID's is important because by default their memory isn't cleared when they go out of scope, meaning you can very easily cause a memory leak when using them. As for the types of RID's that are cleared automatically, if you free the shader first, then I believe it also frees the pipeline and uniform sets. I think that would be better documented under the create_shader and free_rid methods than here though.

Edit: There's already a PR for it: #103113

@skyace65 skyace65 merged commit 1a9c81e into godotengine:master Apr 6, 2025
2 checks passed
@skyace65
Copy link
Contributor

skyace65 commented Apr 6, 2025

Thanks! And congrats on your first merged PR!

@DevPoodle DevPoodle deleted the compute-shader branch May 15, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:manual Issues and PRs related to the Manual/Tutorials section of the documentation enhancement topic:shaders

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add More Reminders to Free RID's

4 participants