Ilekroć używam tekstur w WebGL Firefox (Firefox Developer Edition 50.0a2 dla OSX, aby być wykopywac zaladowanie) Wyjścia te ostrzeżenia w konsoli:Unikać konwersja strona CPU z texImage2D Firefox
Error: WebGL: texSubImage2D: Incurred CPU-side conversion, which is very slow
Error: WebGL: texSubImage2D: Incurred CPU pixel conversion, which is very slow
Error: WebGL: texSubImage2D: Chosen format/type incurred an expensive reformat: 0x1908/0x1401
Czy istnieje jakiś sposób, aby unikać tego? Próbowałem wszystkich kombinacji dozwolonych formatów i typów dla wywołania texImage2D
, ale otrzymuję konwersję na procesor, bez względu na to, co próbuję.
Tutaj jest minimalny przykład pokazujący, co robię:
var gl = document.querySelector('canvas').getContext('webgl');
var textureSize = 512;
var canvas = document.createElement('canvas');
canvas.width = textureSize;
canvas.height = textureSize;
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 1, 0, 0.0)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';
ctx.fillRect(0, 0, 400, 400);
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
<canvas />
Spróbuj użyć 'gl.texImage2D (cel, poziom, format wewnętrzny, szerokość, wysokość, obramowanie, format, typ, ArrayBufferView? Piksele)'; wersję texImage2D i ustaw argumenty 'width' i' height' na twój 'textureSize' – Blindman67