Skip to content

Commit

Permalink
Add info about GL renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
aglitchman committed Jan 29, 2024
1 parent 74717cc commit 9a9d828
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ When you call `webgl_memory.get_info()`, the result is:

```lua
{
context = {
vendor = <string>,
renderer = <string>,
unmasked_vendor = <string>,
unmasked_renderer = <string>,
},
memory = {
buffer = <bytes used by buffers>,
texture = <bytes used by textures>,
Expand Down
18 changes: 14 additions & 4 deletions webgl_memory/lib/web/lib_webgl_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,34 @@ var LibraryWebGLMemory = {
return cstr;
},

addHeapSize: function (obj) {
addExtraInfo: function (obj) {
obj.memory.wasmheap = Module.HEAP8.length;
var gl = Module.ctx;
obj.context = {
vendor: gl.getParameter(gl.VENDOR),
renderer: gl.getParameter(gl.RENDERER)
};
var debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
if (debugInfo) {
obj.context.unmasked_vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
obj.context.unmasked_renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
}
return obj;
}
},

WebGLMemory_GetInfo: function (param, subparam) {
WebGLMemory_GetInfo: function () {
var ext = Module.ctx.getExtension("GMAN_webgl_memory");
if (ext) {
return WebGLMemory.cstringify(WebGLMemory.addHeapSize(ext.getMemoryInfo()));
return WebGLMemory.cstringify(WebGLMemory.addExtraInfo(ext.getMemoryInfo()));
} else {
if (!WebGLMemory.warnShown) {
WebGLMemory.warnShown = true;
console.warn(
"Unable to get the `GMAN_webgl_memory` extension - webgl-memory.js hasn't been loaded yet?"
);
}
return WebGLMemory.cstringify(WebGLMemory.addHeapSize({
return WebGLMemory.cstringify(WebGLMemory.addExtraInfo({
memory: {
buffer: 0,
texture: 0,
Expand Down

0 comments on commit 9a9d828

Please sign in to comment.