|
50 | 50 | texCoord = texCoord0; |
51 | 51 | } |
52 | 52 | </script> |
| 53 | +<script id="trivial-vs" type="text/plain"> |
| 54 | +void main() |
| 55 | +{ |
| 56 | + gl_Position = vec4(0,0,0,1); |
| 57 | +} |
| 58 | +</script> |
| 59 | +<script id="tex-point-fs" type="text/plain"> |
| 60 | +precision mediump float; |
| 61 | +uniform sampler2D uSampler; |
| 62 | +void main() |
| 63 | +{ |
| 64 | + gl_FragColor = texture2D(uSampler, vec2(0)); |
| 65 | +} |
| 66 | +</script> |
53 | 67 | <script> |
54 | 68 | "use strict"; |
55 | 69 | var gl; |
|
128 | 142 | var y = Math.floor(ii / 2); |
129 | 143 | wtu.checkCanvasRect(gl, x, y, 1, 1, colors[ii]); |
130 | 144 | } |
| 145 | + |
| 146 | + debug(""); |
| 147 | + debug("Swizzle applied to correct ActiveTexture index"); |
| 148 | + |
| 149 | + { |
| 150 | + const prog = wtu.setupProgram( |
| 151 | + gl, |
| 152 | + ["trivial-vs", "tex-point-fs"]); |
| 153 | + prog.uSampler = gl.getUniformLocation(prog, "uSampler"); |
| 154 | + gl.useProgram(prog); |
| 155 | + gl.viewport(0, 0, 1, 1); |
| 156 | + gl.activeTexture(gl.TEXTURE0); |
| 157 | + wtu.glErrorShouldBe(gl, gl.NO_ERROR); |
| 158 | + |
| 159 | + const tex0_rgba8 = gl.createTexture(); |
| 160 | + gl.bindTexture(gl.TEXTURE_2D, tex0_rgba8); |
| 161 | + const tex0_rgba8_data = new Uint8Array([10, 20, 30, 40]); |
| 162 | + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, tex0_rgba8_data); |
| 163 | + |
| 164 | + const tex2_a8 = gl.createTexture(); |
| 165 | + gl.bindTexture(gl.TEXTURE_2D, tex2_a8); |
| 166 | + gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, 1, 1, 0, gl.ALPHA, gl.UNSIGNED_BYTE, null); |
| 167 | + |
| 168 | + window.control = new Uint8Array(4); |
| 169 | + window.after_swizzle_applied = new Uint8Array(4); |
| 170 | + |
| 171 | + gl.bindTexture(gl.TEXTURE_2D, tex0_rgba8); |
| 172 | + gl.drawArrays(gl.POINTS, 0, 1); |
| 173 | + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, window.control); |
| 174 | + shouldBeString("window.control", tex0_rgba8_data.toString()); |
| 175 | + |
| 176 | + gl.activeTexture(gl.TEXTURE2); |
| 177 | + gl.bindTexture(gl.TEXTURE_2D, tex2_a8); |
| 178 | + gl.uniform1i(prog.uSampler, 2); |
| 179 | + gl.activeTexture(gl.TEXTURE0); |
| 180 | + gl.drawArrays(gl.POINTS, 0, 1); |
| 181 | + // Firefox would apply the A8-on-R8 swizzle to whatever tex-unit was active. |
| 182 | + |
| 183 | + gl.uniform1i(prog.uSampler, 0); |
| 184 | + gl.drawArrays(gl.POINTS, 0, 1); |
| 185 | + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, window.after_swizzle_applied); |
| 186 | + shouldBeString("window.after_swizzle_applied", tex0_rgba8_data.toString()); |
| 187 | + // Firefox would then get 0,0,0,10 here, as the [ZERO,ZERO,ZERO,RED] swizzle was applied to our |
| 188 | + // 10,20,30,40 texture. |
| 189 | + } |
131 | 190 | } |
132 | 191 |
|
133 | 192 | init(); |
|
0 commit comments