examples: fixed uniform buffer release and unused var #269

Merged
PiergiorgioZagaria merged 1 commit from main into main 2022-05-08 16:48:05 +00:00
PiergiorgioZagaria commented 2022-05-08 16:46:32 +00:00 (Migrated from github.com)
  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.
- [X] By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.
emidoots (Migrated from github.com) approved these changes 2022-05-08 16:47:56 +00:00
emidoots (Migrated from github.com) reviewed 2022-05-08 16:51:43 +00:00
@ -125,4 +125,3 @@
defer uniform_buffer.release();
const bind_group = engine.gpu_driver.device.createBindGroup(
&gpu.BindGroup.Descriptor{
.layout = bgl,
emidoots (Migrated from github.com) commented 2022-05-08 16:51:43 +00:00

I think the reason this worked and was not an error, is because createBindGroup takes this uniform_buffer as a parameter. So it probably .reference()'s the uniform_buffer parameter and holds on to it. I think we maybe maintaining a duplicate reference needlessly now.

But I need to confirm this / dig into the Dawn source code & make sure this is true, review all examples for correctness, etc.

I think the reason this worked and was not an error, is because `createBindGroup` takes this `uniform_buffer` as a parameter. So it probably `.reference()`'s the `uniform_buffer` parameter and holds on to it. I think we maybe maintaining a duplicate `reference` needlessly now. But I need to confirm this / dig into the Dawn source code & make sure this is true, review all examples for correctness, etc.
PiergiorgioZagaria (Migrated from github.com) reviewed 2022-05-08 17:32:52 +00:00
@ -125,4 +125,3 @@
defer uniform_buffer.release();
const bind_group = engine.gpu_driver.device.createBindGroup(
&gpu.BindGroup.Descriptor{
.layout = bgl,
PiergiorgioZagaria (Migrated from github.com) commented 2022-05-08 17:32:52 +00:00

I think that release() just puts the memory that was allocated before in free memory, but doesn't change neither the contents neither uniform_buffer that points to what is now freed memory. Hence we would have probably seen something strange if we later allocated and wrote something to new allocated memory.

I think that `release()` just puts the memory that was allocated before in free memory, but doesn't change neither the contents neither uniform_buffer that points to what is now freed memory. Hence we would have probably seen something strange if we later allocated and wrote something to new allocated memory.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach!269
No description provided.