filament
filament copied to clipboard
GLError when using RenderTarget to render at an external GL texture
Discussed in https://github.com/google/filament/discussions/6223
Originally posted by starccode October 26, 2022 Hi, I'm trying to render the engine's output into an external openGL texture that created outside of filament. Besides all of the work is at iOS platform and openGL backend, here is my solution:
First, create engine with shareGLContext, and a headless swapChain instead of CAEGLayer surface:
_engine = Engine::create(Engine::Backend::OPENGL, nullptr, sharedGLContext)
_swapChain = _engine->createSwapChain(width, height);
Then, create renderTarget with a import texture and config the view:
_color = Texture::Builder()
.width(width).height(height).levels(1)
.import(textureId)
.usage(Texture::Usage::COLOR_ATTACHMENT | Texture::Usage::SAMPLEABLE |
Texture::Usage::STENCIL_ATTACHMENT)
.format(Texture::InternalFormat::RGBA8).build(*_engine);
_renderTarget = RenderTarget::Builder()
.texture(RenderTarget::AttachmentPoint::COLOR, _color)
.build(*_engine);
_view = _engine->createView();
_view->setScene(_scene);
_view->setCamera(_camera);
_view->setRenderTarget(_renderTarget);
_view->
Finally, render the result to the view:
if (_renderer->beginFrame(_swapChain)) {
_renderer->render(_view);
_renderer->endFrame();
}
But the problem I met is that when I run the code with debug mode, I receive "GLError 1282" message as following:
and when I run it with release mode, it can render the result to the import texture as following:
but the fps is lower than render to a CAEGLayer.
If there anyone can explain the "GLError 1282" error, and how to solve this problem? Besides, the problem can reproduce at gltf-view sample workspace.
That error is not render target related. @bejado, any idea?
@starccode What version of Filament are you using? I think we removed OpenGL::updateBuffer
in favor of OpenGL::updateBufferObject
some time ago.
It'd also be helpful if you copied that CHECK_GL_ERROR(utils::slog.e)
statement after each of the nearby gl*
function calls to see exactly which one is causing the error (glBufferSubData
, glBufferData
, etc).
I'm using an old version 1.21.2.
And It seems raise error since glBindBuffer()
And I run the code at version 1.25.0 of filament gltf-viewer sample. The GLError disappear, but receive a warning:
And besides, the memory increase constantly.
I analyze it through Profile, and it turns:
I've just run the sample project "gltf-Viewer" without any extra code, and I found that the memory also increase at openGL backend as shown above. But it works right at metal backend.
To Reproduce run the sample project "gltf-Viewer"
filament Version 1.28.3
Thanks for helping investigate. It's possible we have a memory leak with the OpenGL backend on iOS. Are you able to switch to the Metal backend? We're in the process of phasing out the OpenGL/iOS backend so this won't be high priority for us.