[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] More driver bugs: Getting FRAMEBUFFER_INCOMPLETE for a texture that is not "texture complete" on some cards.
- To: public webgl <firstname.lastname@example.org>
- Subject: [Public WebGL] More driver bugs: Getting FRAMEBUFFER_INCOMPLETE for a texture that is not "texture complete" on some cards.
- From: "Gregg Tavares (wrk)" <email@example.com>
- Date: Thu, 16 Dec 2010 15:09:18 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1292540962; bh=1zjCDGtO0kmmLnmSCNnDy2uVKmM=; h=MIME-Version:Date:Message-ID:Subject:From:To:Content-Type; b=c2vlEoaUxS/qpk9/w1+1AGDmlZx0quhL9v4uKs/hNWKfawtY4fDqQk9JIOHIRGKdZ Y9mFnOIIo67dDRGLH7rjg==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=drsxAJ4++Z4OFkszLG1cjzo+3GKVnD79SLgVzkUPsEc=; b=ZHHjnGIs4INxNPUGCOej8Oo2gxRoe3aGZMcFwkRtP0GjMi2pR5ySsjBHPqwDmekUrE a/ye/Ls+2clvBe9FBehA==
- Domainkey-signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:date:message-id:subject:from:to:content-type; b=OiI+2Hr9XPif4Pa15sf4ELfwXOM5EasOUN2XSQr5SWWTMkiFE9NTC55zri3QP1bHWE SA8nZ6OfB8CRS7a8A1yQ==
- List-id: Public WebGL Mailing List <public_webgl.khronos.org>
- Sender: firstname.lastname@example.org
So we were informed of a new issue.
If you bind a texture to a framebuffer and that texture is not "texture complete" then on some (all?) nvidia drivers it wrongly return FRAMEBUFFER_UNSUPPORED.
In other words,
// create a 32x32 texture
tex = gl.createTexture();
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 32, 32, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
// attach that texture to a framebuffer
fbo = gl.createFramebuffer();
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
// check that it's complete
var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
ASSERT(status == gl.FRAMEBUFFER_COMPLETE);
This code will wrongly fail on some nvidia drivers.
The issue is apparently that bad nvidia drivers require the textures to either have all their mips or be set to use filtering that does not require mips.
The workaround is to add this line
// because the default for a texture is gl.NEAREST_MIPMAP_LINEAR
// we need to set it to something that doesn't need mips.
gl.texParameteriv(gl.TEXTURE_2D, TEXTURE_MIN_FILTER, gl.LINEAR);
So, for WebGL what if anything should we do?
1) Ignore the issue
You couldn't render with the texture without setting filtering anyway. Mostly like you just have to re-order your initialization to set the texParameter before setting up your FBO instead of after.
2) Try to fix it inside WebGL implementations
I think you'd basically have to track if a texture is being used as an fbo. When it is (either on bindFramebuffer or framebufferTexture2D) you'd have to set its filtering to LINEAR or NEAREST while resetting any previously bound framebuffer texture back to it's original user specified filters. You'd also have to wrap texParameteriv and getTexParameter so that they shadowed the settings since if the texture is currently being used as a render target you can neither set or query its parameters and expect to get the correct result.
3) Change the WebGL spec to have the same requirements so the failure is consistent
You'd again have track which textures are currently being rendered too. Before each draw call you'd have to see if the texture being rendered to meets the conditions above. If not generate GL_INVALID_FRAMEBUFFER_OPERATION on top of GL_FRAMEBUFFER_INCOMPLETE on checkFramebufferStatus.