Skip to content

Commit

Permalink
Another library_webgl.js cleanup. NFC (#21458)
Browse files Browse the repository at this point in the history
Similar to #21457 but this one actually as a code size saving
  • Loading branch information
sbc100 committed Mar 1, 2024
1 parent 165133b commit bb77856
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
14 changes: 8 additions & 6 deletions src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1641,16 +1641,18 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
// those always when possible.
if (GLctx.currentPixelUnpackBufferBinding) {
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
} else if (pixels) {
return;
}
if (pixels) {
var heap = heapObjectForWebGLType(type);
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, heap, toTypedArrayIndex(pixels, heap));
} else {
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, null);
var index = toTypedArrayIndex(pixels, heap);
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, heap, index);
return;
}
return;
}
#endif
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixels ? emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, internalFormat) : null);
var pixelData = pixels ? emscriptenWebGLGetTexPixelData(type, format, width, height, pixels, internalFormat) : null;
GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixelData);
},

glTexSubImage2D__deps: ['$emscriptenWebGLGetTexPixelData'
Expand Down
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 569,
"a.html.gz": 379,
"a.js": 4589,
"a.js.gz": 2341,
"a.js": 4539,
"a.js.gz": 2315,
"a.wasm": 10451,
"a.wasm.gz": 6724,
"total": 15609,
"total_gz": 9444
"total": 15559,
"total_gz": 9418
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl2_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 354,
"a.html.gz": 266,
"a.js": 22323,
"a.js.gz": 11632,
"total": 22677,
"total_gz": 11898
"a.js": 22273,
"a.js.gz": 11608,
"total": 22627,
"total_gz": 11874
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 569,
"a.html.gz": 379,
"a.js": 4075,
"a.js.gz": 2170,
"a.js": 4056,
"a.js.gz": 2152,
"a.wasm": 10451,
"a.wasm.gz": 6724,
"total": 15095,
"total_gz": 9273
"total": 15076,
"total_gz": 9255
}
8 changes: 4 additions & 4 deletions test/code_size/hello_webgl_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 354,
"a.html.gz": 266,
"a.js": 21794,
"a.js.gz": 11450,
"total": 22148,
"total_gz": 11716
"a.js": 21775,
"a.js.gz": 11436,
"total": 22129,
"total_gz": 11702
}

0 comments on commit bb77856

Please sign in to comment.