mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 13:00:28 +00:00
vendor/wgpu: handle nil better in wgpu.js
This commit is contained in:
12
vendor/wgpu/wgpu.js
vendored
12
vendor/wgpu/wgpu.js
vendored
@@ -3265,6 +3265,10 @@ class WebGPUObjectManager {
|
||||
* @returns {number}
|
||||
*/
|
||||
create(object) {
|
||||
if (object === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.objects[this.idx] = { references: 1, object };
|
||||
this.idx += 1;
|
||||
return this.idx;
|
||||
@@ -3280,6 +3284,10 @@ class WebGPUObjectManager {
|
||||
|
||||
/** @param {number} idx */
|
||||
release(idx) {
|
||||
if (idx === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.objects[idx-1].references -= 1;
|
||||
if (this.objects[idx-1].references == 0) {
|
||||
delete this.objects[idx-1];
|
||||
@@ -3288,6 +3296,10 @@ class WebGPUObjectManager {
|
||||
|
||||
/** @param {number} idx */
|
||||
reference(idx) {
|
||||
if (idx === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.objects[idx-1].references += 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user