-
-
Notifications
You must be signed in to change notification settings - Fork 8
Various fixes against the v25 branch. #13
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
base: v25
Are you sure you want to change the base?
Conversation
The code was previously passing a pointer to the handle to c code. The pointer could be garbage collected before being used.
… that can be passed as an unsafe.Pointer or as a void* in c.
|
Fixed the handle issue by introducing our own |
|
Note: i've now forked the repository and added more things on the main branch, that you might not want to have upstream. This includes improved garbage collection of wgpu resources, makeing calls to |
|
It would be really nice to hear from the maintainers, if there are plans to either merge these improvements or cherry pick certain things out of it. |
|
@kkoreilly and I will have a chance to discuss this soon and will post an update within a couple of weeks hopefully! |
kkoreilly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oliverbestmann Thanks for these changes! Apologies for the very delayed response, I've been quite busy.
Overall things look good, I just have a couple comments below.
| (queue, buf, offset, addr, x, n) => { | ||
| const mem = wasm.instance.exports.mem.buffer; | ||
| const data = new Uint8ClampedArray(mem, addr, n); | ||
| return queue.writeBuffer(buf, offset, data, x, n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this change is necessary as opposed to the previous jsx.BytesToJS approach. Does this solve the occasional crashing that occurred previously, or is there another motivation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance iirc. It was precisely jumping to is and back a billion of times. Also yes, it crashed here previously, that got better now. One more thing: As you only take the uintptr of the Adress, the gc can theoretically dealloc the slice before it is used at the end of the function.
| ) | ||
|
|
||
| require ( | ||
| cogentcore.org/core v0.3.12 // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is core now an indirect dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I got rid of that too. I would need to check for what that is used ;)
|
@oliverbestmann The changes on your main branch look good overall, and if you are interested in filing separate PRs for them, that would be awesome (no worries if not). For the binary size limit, I wonder whether it might be easier to use different modules within the same branch rather than in separate branches? You could have separate Could you briefly explain how you implemented the garbage collection and whether there are any major negative side effects of that? Thanks for all of your contributions, and apologies again for our unresponsiveness, I've been very busy but should hopefully have more time to respond going forward. |
|
Regarding the binary size limit: I am not sure if I tried that. I think the size limit is per shallow clone of the repository, not the module subdirectory. Garbage collection: it is really just registering finalizers like here: https://github.com/oliverbestmann/webgpu/blob/main/wgpu/wgpu.go#L122 Special care needs to be taken when addRef is used, see a few lines above. The release method was made idempotent, so it can be called multiple times without crashing: https://github.com/oliverbestmann/webgpu/blob/main/wgpu/gen_types.go#L266 I am currently also very busy due to $work and family, so I probably won't create multiple pull requests. I am sorry! |
|
One consideration for timing of update of underlying libraries, assuming there remains some kind of cost to updating the libraries more frequently (hopefully @kkoreilly 's proposed solution might avoid that??) is the possible resolution of this issue: gfx-rs/wgpu#8119 -- this would probably be the single biggest issue fix for my usage. |
I can split the PR up into multiple small onces, but as the v25 PR is already one single big PR, i just went with another big one ;)
cgo.HandleDesiredMaximumFrameLatencyinSurfaceConfigurationQueue.WriteBufferandQueue.WriteTextureVertexFormat.Size()Texturefor js.