aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Zylinski <karl@zylinski.se>2025-12-29 17:42:19 +0100
committerKarl Zylinski <karl@zylinski.se>2025-12-29 17:42:19 +0100
commitfb52238e369dc5c1712d2eca2c787473af59bca3 (patch)
tree079dd2ce3cd502e33091639805880d13ec7a64c8
parent3f9aefda202f9677987d72c0be52417772315edc (diff)
Fix bugs in odin.js:GetActiveUniformBlockName
-rw-r--r--core/sys/wasm/js/odin.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/sys/wasm/js/odin.js b/core/sys/wasm/js/odin.js
index e90ccc124..063fd990c 100644
--- a/core/sys/wasm/js/odin.js
+++ b/core/sys/wasm/js/odin.js
@@ -1304,17 +1304,21 @@ class WebGLInterface {
this.assertWebGL2();
return this.ctx.getUniformBlockIndex(this.programs[program], this.mem.loadString(uniformBlockName_ptr, uniformBlockName_len));
},
- GetActiveUniformBlockName: (program, uniformBlockIndex, buf_ptr, buf_len, length_ptr) => {
+ GetActiveUniformBlockName: (program, uniformBlockIndex, name_buf_ptr, name_buf_len, name_length_ptr) => {
this.assertWebGL2();
let name = this.ctx.getActiveUniformBlockName(this.programs[program], uniformBlockIndex);
- let n = Math.min(buf_len, name.length);
- name = name.substring(0, n);
- this.mem.loadBytes(buf_ptr, buf_len).set(new TextEncoder().encode(name))
- this.mem.storeInt(length_ptr, n);
+ if (name_buf_ptr && name_buf_len > 0) {
+ let n = Math.min(name_buf_len, name.length);
+ name = name.substring(0, n);
+ this.mem.loadBytes(name_buf_ptr, name_buf_len).set(new TextEncoder().encode(name));
+ this.mem.storeInt(name_length_ptr, n);
+ } else if (name_length_ptr) {
+ this.mem.storeInt(name_length_ptr, name.length);
+ }
},
GetActiveUniforms: (program, uniformIndices_ptr, uniformIndices_len, pname, res_ptr) => {
- thid.assertWebGL2();
+ this.assertWebGL2();
let indices = this.mem.loadU32Array(uniformIndices_ptr, uniformIndices_len);
this.ctx.getActiveUniforms(this.programs[program], indices, pname)
this.mem.loadI32Array(res_ptr, indices.length).set(indices)
@@ -1323,7 +1327,7 @@ class WebGLInterface {
this.assertWebGL2();
let res = this.ctx.getActiveUniformBlockParameter(this.programs[program], uniformBlockIndex, pname);
- if (e instanceof Uint32Array) { // for pname GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
+ if (res instanceof Uint32Array) { // for pname GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES
this.mem.loadU32Array(params_ptr, res.length).set(res)
} else {
this.mem.storeI32(params_ptr, res)