i try to perform off screen rendering using FBO and using as target texture a Android native Buffer.
To do so, i created a Android GraphicBuffer (with width and height = 1024)
GraphicBuffer* buffer = new GraphicBuffer(texWidth, texHeight,
Then from that GraphicBuffer i get a native buffer handle that i use to create an EGLImage (ImageKHR)
EGLImageKHR pEGLImage = _eglCreateImageKHR(eglGetCurrentDisplay(),
EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, (EGLClientBuffer)anb, attrs);
Then i initialize the FBO in order to render into that ImageKHR
// create a framebuffer object
framebuffer = framebuffers;
//Create Depth buffer
Renderbuf = depthRb;
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, width, height);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, Renderbuf);
// Create GL texture, bind to GL_TEXTURE_2D, etc.
texture = textures;
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// attach the texture to FBO color attachment point
// check FBO status
int status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
//Then Bind the FBO
After that i’m doing my rendering that i expect to be at teh end in my GraphicBuffer
The problem i have is that i’m checking error after each gl call and there is no error; the FBO status is COMPLETE so NO error is raised. But when i look at the FBO nothing is rendered.
I tried that code on other GPUs and it is working fine so i’m suspecting that i’m missing something for SGX. But after long days of investigation still same result: Nothing is rendered.
It seems that Size is not the problem (Power of 2) may be RGB565 but is tried with RGB888 and still nothing.
COuld you help me giving idea for investigation or link on document or even better providing solution ?
Thanks in advance.
Did you try to use HAL_PIXEL_FORMAT_RGBA_8888 format of textures?
Yes i tried also but it is the same it is as if the FBO is not doing anything (even reporting the error)
If 565 was not supported i would expect an error no ?
I noticed that libui has very silent errors
What hardware has your device? I mean processor and gpu unit. Realization of libui is platform dependent. Open code from https://github.com/android/platform_frameworks_base/blob/dd1880ee5bea09e9d37c6db29ef20e49d619c094/libs/ui/GraphicBufferMapper.cpp said that U can create
Maybe U can more… But this must work. I can’t say about any optimization…
I tried with HAL_PIXEL_FORMAT_RGB_888 and teh result is the same.
I will try with HAL_PIXEL_FORMAT_RGBA_8888.
Thanks for the idea
Can you explain your use case? There are caveats when using EGLImage in this way, for example setting up a suitable synchronization framework to avoid tearing (if tearing is a concern). You should keep this in mind when deciding if using EGLImage is the best option for you.
I've discussed this issue with our driver team. The driver is designed in such a way that drawing commands issued for FBOs will not be executed until that FBO is referenced by the main framebuffer's rendering. The idea behind this is to optimize out FBO rendering that doesn't affect the final image to avoid redundant rendering.
I would suggest drawing an off-screen primitive that references the FBO (e.g. a triangle) into the main framebuffer to force the FBO to render, if you are not doing so already.
Let me know if this does not resolve your problem.
As you advised, i added some code to use the FBO to draw a rectangle into a pBuffer Surface.
But doing that didn’t change anything.
Sometime i can see part of my texture rendered into the FBO but that part of texture is not rendered at the right place. Even if it is not working the part of texture that is rendered seems OK which make me think that RGB565 is working fine.
As for texture that i bind to FBO i’m using a native_buffer given thanks to EGLImage, is Imagination expecting some specific parameter when creating the native buffer ?
Again the same code is working fine on LG2 Revolution using Adreno 200 or GalaxySII using MALI400-MP.
Do you have any new idea to try ? i would expect that FBO is working fine.
Thanks and Best Regards,