From github: https://github.com/niels747/2D-Weather-Sandbox/issues/99#issuecomment-1817703743 > Found this little nugget. > > WebGL warning: readPixels: Format and type RGBA_INTEGER/<enum 0x1400> incompatible with this RGBA8I attachment. This framebuffer requires either RGBA_INTEGER/INT or getParameter(IMPLEMENTATION_COLOR_READ_FORMAT/_TYPE) RGBA_INTEGER/INT. > > For some reason this fixes it. It probably blows up memory usage. > ``` > gl.readBuffer(gl.COLOR_ATTACHMENT2); > var wallTextureValues = new Int32Array(4 * sim_res_y); > gl.readPixels(simXpos, 0, 1, sim_res_y, gl.RGBA_INTEGER, gl.INT, wallTextureValues); // read a vertical column of cells > ``` > Using Int32Array and gl.INT where ever wallTextureValues is populated fixes both this issue, and the unreported issue of weather stations not working on Firefox. No side effects on Chrome. > > Why? I don't know. So this is an attempt to call ReadPixels(RGBA_INTEGER,BYTE) from a RGBAI8 source. The only spec-guaranteed way to read from an "int-ish" format is `RGBA_INTEGER/INT`, but a driver *may* offer some other pair, that authors may query via `getParameter(IMPLEMENTATION_COLOR_READ_FORMAT/_TYPE)`. **So that's why switching to `gl.RGBA_INTEGER, gl.INT` works: It is a requirement for portability!** Authors *may choose* to check the alternative, which *might* happen to be supported by a driver: ``` const alternative = { format: gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT), type: gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE), }; if (alternative.format == gl.RGBA_INTEGER && alternative.type = gl.BYTE) { // the existing readPixels(RGBA_INTEGER,BYTE) code } else { // readPixels(gl.RGBA_INTEGER, gl.INT) code } ```
Bug 1908624 Comment 6 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
From github: https://github.com/niels747/2D-Weather-Sandbox/issues/99#issuecomment-1817703743 > Found this little nugget. > > WebGL warning: readPixels: Format and type RGBA_INTEGER/<enum 0x1400> incompatible with this RGBA8I attachment. This framebuffer requires either RGBA_INTEGER/INT or getParameter(IMPLEMENTATION_COLOR_READ_FORMAT/_TYPE) RGBA_INTEGER/INT. > > For some reason this fixes it. It probably blows up memory usage. > ``` > gl.readBuffer(gl.COLOR_ATTACHMENT2); > var wallTextureValues = new Int32Array(4 * sim_res_y); > gl.readPixels(simXpos, 0, 1, sim_res_y, gl.RGBA_INTEGER, gl.INT, wallTextureValues); // read a vertical column of cells > ``` > Using Int32Array and gl.INT where ever wallTextureValues is populated fixes both this issue, and the unreported issue of weather stations not working on Firefox. No side effects on Chrome. > > Why? I don't know. So this is an attempt to call ReadPixels(RGBA_INTEGER,BYTE) from a RGBAI8 source. The only spec-guaranteed way to read from an "int-ish" format is `RGBA_INTEGER/INT`, but a driver *may* offer some other pair, that authors may query via `getParameter(IMPLEMENTATION_COLOR_READ_FORMAT/_TYPE)`. **So that's why switching to `gl.RGBA_INTEGER, gl.INT` works: It is the only combo that is guaranteed to work on all computers!** Authors *may choose* to check the alternative, which *might* happen to be supported by a driver: ``` const alternative = { format: gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT), type: gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE), }; if (alternative.format == gl.RGBA_INTEGER && alternative.type = gl.BYTE) { // the existing readPixels(RGBA_INTEGER,BYTE) code } else { // readPixels(gl.RGBA_INTEGER, gl.INT) code } ```
From github: https://github.com/niels747/2D-Weather-Sandbox/issues/99#issuecomment-1817703743 > Found this little nugget. > > WebGL warning: readPixels: Format and type RGBA_INTEGER/<enum 0x1400> incompatible with this RGBA8I attachment. This framebuffer requires either RGBA_INTEGER/INT or getParameter(IMPLEMENTATION_COLOR_READ_FORMAT/_TYPE) RGBA_INTEGER/INT. > > For some reason this fixes it. It probably blows up memory usage. > ``` > gl.readBuffer(gl.COLOR_ATTACHMENT2); > var wallTextureValues = new Int32Array(4 * sim_res_y); > gl.readPixels(simXpos, 0, 1, sim_res_y, gl.RGBA_INTEGER, gl.INT, wallTextureValues); // read a vertical column of cells > ``` > Using Int32Array and gl.INT where ever wallTextureValues is populated fixes both this issue, and the unreported issue of weather stations not working on Firefox. No side effects on Chrome. > > Why? I don't know. So this is an attempt to call ReadPixels(RGBA_INTEGER,BYTE) from a RGBAI8 source. The only spec-guaranteed way to read from an "int-ish" format is `RGBA_INTEGER/INT`, but a driver *may* offer some other pair, that authors may query via `getParameter(IMPLEMENTATION_COLOR_READ_FORMAT/_TYPE)`. **So that's why switching to `gl.RGBA_INTEGER, gl.INT` works: It is the only combo that is guaranteed to work on all computers!** Authors *may choose* to check the alternative, which *might* happen to be supported by a driver: ``` const alternative = { format: gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT), type: gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE), }; if (alternative.format == gl.RGBA_INTEGER && alternative.type == gl.BYTE) { // the existing readPixels(RGBA_INTEGER,BYTE) code } else { // readPixels(gl.RGBA_INTEGER, gl.INT) code } ```