Hi Philip,
Can you provide a test case? The following works fine in Chrome, Firefox and Safari on macOS. It's suspicious that the pixelStorei call would fail with that reason. This doesn't have the shaders and draw calls to draw the texture to the screen, but changing it to an R8 and RED type texture allows blitting to the default back buffer, and that works.
---- contents of "r8ui.html" -----
<canvas id="c" width="16" height="16">
</canvas>
<div id="output">
</div>
<script>
function output(str) {
document.getElementById("output").innerHTML += "<br>" + str;
}
let c = document.getElementById("c");
let gl = c.getContext("webgl2", { antialias: false });
let t = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, t);
const textureWidth = 15;
const textureHeight = 15;
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.R8UI, textureWidth, textureHeight);
//gl.texStorage2D(gl.TEXTURE_2D, 1, gl.R8, textureWidth, textureHeight);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
const data = new Uint8Array(textureWidth * textureHeight);
for (yy = 0; yy < textureHeight; ++yy) {
for (xx = 0; xx < textureWidth; ++xx) {
data[textureWidth * yy + xx] = textureWidth * yy + xx;
}
}
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, textureWidth, textureHeight, gl.RED_INTEGER, gl.UNSIGNED_BYTE, data);
//gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, textureWidth, textureHeight, gl.RED, gl.UNSIGNED_BYTE, data);
let err = gl.getError();
if (err) {
output("OpenGL Error: " + err);
} else {
output("No OpenGL errors!");
}
// This doesn't work when blitting an integer texture to a non-integer texture
//let fb = gl.createFramebuffer();
//gl.bindFramebuffer(gl.READ_FRAMEBUFFER, fb);
//gl.framebufferTexture2D(gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, t, 0);
//gl.blitFramebuffer(0, 0, textureWidth, textureHeight, 0, 0, textureWidth, textureHeight, gl.COLOR_BUFFER_BIT, gl.NEAREST);
</script>
---- end contents of "r8ui.html" -----
Thanks,
-Ken