Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for GPU Generation Hitting Rid Allocation Limit #735

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions generators/generate_block_gpu_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void GenerateBlockGPUTask::prepare(GPUTaskContext &ctx) {
// Note, this internally locks RenderingDeviceVulkan's class mutex. Which means it could perhaps be used outside
// of the compute list (which already locks the class mutex until it ends). Thankfully, it uses a recursive
// Mutex (instead of BinaryMutex)
const RID generator_uniform_set =
_generator_uniform_set =
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in a for loop. You will still leak RIDs in different setups.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yeah tunnel vision. I'll have to fix that. I'm surprised the change is making a much of a difference at all given that added context.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-box situations occur in particular cases (notably edited terrain) that you might not have encountered.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. The other places using uniform_set_create are in the render_detail_texture_gpu_task which I also wouldn't have seen. So I'll try turning that on and doing some edits in the next pass.

zylann::godot::uniform_set_create(rd, generator_uniforms, generator_shader_rid, 0);

{
Expand All @@ -160,7 +160,7 @@ void GenerateBlockGPUTask::prepare(GPUTaskContext &ctx) {
}
{
ZN_PROFILE_SCOPE_NAMED("compute_list_bind_uniform_set");
rd.compute_list_bind_uniform_set(compute_list_id, generator_uniform_set, 0);
rd.compute_list_bind_uniform_set(compute_list_id, _generator_uniform_set, 0);
}

const Box3i &box = boxes_to_generate[box_index];
Expand Down Expand Up @@ -464,7 +464,8 @@ void GenerateBlockGPUTask::collect(GPUTaskContext &ctx) {
}

zylann::godot::free_rendering_device_rid(rd, _generator_pipeline_rid);

zylann::godot::free_rendering_device_rid(rd, _generator_uniform_set);

for (RID rid : _modifier_pipelines) {
zylann::godot::free_rendering_device_rid(rd, rid);
}
Expand Down
1 change: 1 addition & 0 deletions generators/generate_block_gpu_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class GenerateBlockGPUTask : public IGPUTask {

StdVector<BoxData> _boxes_data;
RID _generator_pipeline_rid;
RID _generator_uniform_set;
StdVector<RID> _modifier_pipelines;
};

Expand Down