Сбой glReadPixels в WebGL2 в Chrome на Mac - PullRequest
0 голосов
/ 30 ноября 2018

У меня есть этот простой код matmul, написанный для WebGL 2. Этот код и параметры работают без проблем в Chrome для Windows.Тем не менее, я последовательно получаю эту ошибку в Chrome на Mac, когда я использую webgl2 идентификатор контекста.

GL_INVALID_OPERATION : glReadPixels: format and type incompatible with the current read framebuffer

Вот параметры, которые я использую:

readOutput(gl, width, height, gl.RED, gl.FLOAT, c);
...
function readOutput(gl, width, height, format, type, buffer) {
  gl.readPixels(0, 0, width, height, format, type, buffer);
}

, и вот как ясоздал текстуру:

const texA = createTexture(gl, gl.R32F, gl.RED, gl.FLOAT, shapeA[1], shapeA[0], a);

и, наконец, вот код для createTexture:

function createTexture(gl, internalFormat, format, type, width, height, data) {
  // Create the texture
  const texture = gl.createTexture();
  gl.bindTexture(gl.TEXTURE_2D, texture);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_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);
  gl.texImage2D(
    gl.TEXTURE_2D,
    0,  // 0 - no mipmaps
    internalFormat, width, height,
    0,  // Always 0 in OpenGL ES.
    format, type, data);
  checkError(gl);
  return texture;
}
...