Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
42 user(s) are online (23 user(s) are browsing Forums)

Members: 1
Guests: 41

LiveForIt, more...

Support us!

Headlines

 
  Register To Post  

« 1 ... 6 7 8 (9)
Re: The OpenGL ES 2.0 thread
Just can't stay away
Just can't stay away


See User information
@elfpipe

What kind of problems? Is there some GL error or anything if you run glSnoop?

Go to top
Re: The OpenGL ES 2.0 thread
Just can't stay away
Just can't stay away


See User information
@Capehill

glCompileShader returns a GL_COMPILE_STATUS of 0, when the call is made in the new thread. glGetShaderInfoLog in this case returns nothing.

glSnoop does an enormous amount of logging. It also interestingly removes the compile error. I get this in the log:

Quote:
[262.857543] Shell Process 'threadedqopenglwidget': W3DN_DrawArrays: <- Result 22 (W3DNEC_NOSHADERPIPELINE)
[262.866984] Shell Process 'threadedqopenglwidget': Warning: unsuccessful operation detected
[262.875127] Shell Process 'threadedqopenglwidget': GL error 1286 (GL_INVALID_FRAMEBUFFER_OPERATION) detected after DrawArrays


EDIT: It could be an issue with context sharing. Maybe I have some wiggle room. EDIT: Probably not, though.


Edited by elfpipe on 2025/2/2 12:27:57
Edited by elfpipe on 2025/2/2 14:05:08
Edited by elfpipe on 2025/2/3 8:53:37
Go to top
Re: The OpenGL ES 2.0 thread
Home away from home
Home away from home


See User information
@All
Do not know if it worth to report anymore, due to all known "dunno if anything will be released" , but seems i found another bug in ogles2 (at least i think so): glBindTexture(GL_TEXTURE_2D, 0) leak memory for no reasson and on exit not free it as well.

That call should just unbind the currently bound 2D texture and restore texture unit 0’s binding to the GLES default object. It should not allocate anything per call. And on x86/etc that it. But seems on our ogles2 realisation this eat memory a lot with no reasson.

I.e:

- Binding real texture IDs does not leak.
- Cycling between real texture IDs does not leak.
- glActiveTexture(GL_TEXTURE0) alone does not leak.
- glBindTexture(GL_TEXTURE_2D, 0) leaks heavily.


It looks like OGLES2 internal bug is: when texture ID 0 is bound, the library creates or realizes some internal “default/no texture” Nova-side object/state each time,
but does not reuse or free it. Or it triggers a state/submit path that appends retained objects for texture 0.

There is SDL2 based test case if anyone need it:

#include <SDL.h>
#include <SDL_opengles2.h>

#include <stdio.h>

static GLuint create_texture(void)
{
    static const 
unsigned char pixel[4] = {255U255U255U255U};
    
GLuint texture;

    
texture 0U;
    
glGenTextures(1, &texture);
    
glBindTexture(GL_TEXTURE_2Dtexture);
    
glPixelStorei(GL_UNPACK_ALIGNMENT1);
    
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
    
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
    
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_SGL_CLAMP_TO_EDGE);
    
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_TGL_CLAMP_TO_EDGE);
    
glTexImage2D(GL_TEXTURE_2D0GL_RGBA110GL_RGBAGL_UNSIGNED_BYTEpixel);
    return 
texture;
}

int main(int argcchar **argv)
{
    
SDL_Window *window;
    
SDL_GLContext context;
    
GLuint texture;
    
unsigned int start_ms;
    
unsigned int last_ms;
    
unsigned long frames;
    
unsigned long binds;

    (
void)argc;
    (
void)argv;

    if (
SDL_Init(SDL_INIT_VIDEO SDL_INIT_TIMER) != 0) {
        return 
1;
    }

    (
void)SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASKSDL_GL_CONTEXT_PROFILE_ES);
    (
void)SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION2);
    (
void)SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION0);
    (
void)SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER1);

    
window SDL_CreateWindow(
        
"glBindTexture 0 leak",
        
SDL_WINDOWPOS_CENTERED,
        
SDL_WINDOWPOS_CENTERED,
        
320,
        
240,
        
SDL_WINDOW_OPENGL SDL_WINDOW_SHOWN);
    if (
window == NULL) {
        
SDL_Quit();
        return 
1;
    }

    
context SDL_GL_CreateContext(window);
    if (
context == NULL) {
        
SDL_DestroyWindow(window);
        
SDL_Quit();
        return 
1;
    }

    if (
SDL_GL_MakeCurrent(windowcontext) != 0) {
        
SDL_GL_DeleteContext(context);
        
SDL_DestroyWindow(window);
        
SDL_Quit();
        return 
1;
    }

    
texture create_texture();
    if (
texture == 0U || glGetError() != GL_NO_ERROR) {
        
SDL_GL_DeleteContext(context);
        
SDL_DestroyWindow(window);
        
SDL_Quit();
        return 
1;
    }

    
frames 0UL;
    
binds 0UL;
    
start_ms SDL_GetTicks();
    
last_ms start_ms;

    for (;;) {
        
SDL_Event event;
        
unsigned int now_ms;
        
int i;

        while (
SDL_PollEvent(&event)) {
            if (
event.type == SDL_QUIT ||
                (
event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
                goto 
done;
            }
        }

        for (
064; ++i) {
            
glBindTexture(GL_TEXTURE_2D0);
            ++
binds;
        }

        
SDL_GL_SwapWindow(window);
        
SDL_Delay(1);
        ++
frames;

        
now_ms SDL_GetTicks();
        if (
now_ms last_ms >= 1000U) {
            
printf("t=%u frames=%lu binds=%lu\n", (now_ms start_ms) / 1000Uframesbinds);
            
fflush(stdout);
            
last_ms now_ms;
        }
        if (
now_ms start_ms >= 20000U) {
            break;
        }
    }

done:
    
glDeleteTextures(1, &texture);
    (
void)SDL_GL_MakeCurrent(windowNULL);
    
SDL_GL_DeleteContext(context);
    
SDL_DestroyWindow(window);
    
SDL_Quit();
    return 
0;
}



It can be build for x86 too if need it (and there it will have no issues, of course).


Edited by kas1e on 2026/7/6 16:25:37
Edited by kas1e on 2026/7/6 16:31:37
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: The OpenGL ES 2.0 thread
Amigans Defender
Amigans Defender


See User information
I think I've found the same issue but I don't think it will be never fixed anymore..

i'm really tired...
Go to top
Re: The OpenGL ES 2.0 thread
Just can't stay away
Just can't stay away


See User information
@kas1e

glBindTexture(GL_TEXTURE_2D, 0) creates a new texture sampler each time and sets its parameters. So yes, it looks like a bug.

Go to top
Re: The OpenGL ES 2.0 thread
Just can't stay away
Just can't stay away


See User information
Hi @kas1e, @Capehill,

just had to post this - I spent basically all day today chasing a memory leak in my Unreal (1998) AmigaOS4 port and this thread is the reason I finally cracked it. Thank you both.

Quick version: RAM kept draining while playing, even standing completely still, worst in scenes with animated textures. Ruled out literally everything in my own code before finding this thread - sound, render options, pixel format, you name it, none of it made a difference.

Then I saw kas1e's post about glBindTexture(GL_TEXTURE_2D, 0) and went "...wait." Checked my code, and yep - I was calling exactly that, via a ResetTexture() helper, once per visible surface, up to 3 times each. In a normal scene that's easily hundreds of calls a frame. Explains everything.

Swapped it for binding a dummy 1x1 texture instead of 0, and the leak is just... gone. Tested standing still for 10 minutes, memory didn't budge.

So yeah - this is 100% a real bug that bites real applications, not just a synthetic test case. Really glad you found and reported it, would've been banging my head against this for a lot longer otherwise. Cheers!

MacStudio ARM M1 Max Qemu//Pegasos2 AmigaOs4.1 FE / AmigaOne x5000/40 AmigaOs4.1 FE
Go to top

  Register To Post
« 1 ... 6 7 8 (9)

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project