Galaxy Note3(SM-N900L,SDK 5.0)上发生了GLES20.glTexImage2D GL_OUT_OF_MEMORY

时间:2016-02-18 03:26:44

标签: android out-of-memory opengl-es-2.0 glsurfaceview

创建GLSurfaceView时,调用GLES20.glGenTextures,然后每次调用GLThread中的GLES20.glDeleteTextures,但有时会发生gl_out_of_memory。我该如何解决这个问题?

[错误日志]

02-18 11:44:04.317: W/Adreno-GSL(25831): <sharedmem_gpumem_alloc_id:1498>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
02-18 11:44:04.317: E/Adreno-GSL(25831): <gsl_memory_alloc_pure:2042>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
02-18 11:44:04.327: I/Timeline(25831): Timeline: Activity_idle id: android.os.BinderProxy@325bb5f9 time:1454439379
02-18 11:44:04.357: W/Adreno-GSL(25831): <sharedmem_gpumem_alloc_id:1498>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
02-18 11:44:04.357: E/Adreno-GSL(25831): <gsl_memory_alloc_pure:2042>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
02-18 11:44:04.357: W/Adreno-ES20(25831): <core_glTexImage2D:539>: GL_OUT_OF_MEMORY
02-18 11:44:05.197: E/qdmemalloc(25831): ion: Failed to map memory in the client: Out of memory
02-18 11:44:05.197: E/qdgralloc(25831): Could not mmap handle 0xa1fdaba0, fd=43 (Out of memory)
02-18 11:44:05.197: E/qdgralloc(25831): gralloc_register_buffer: gralloc_map failed
02-18 11:44:05.197: W/GraphicBufferMapper(25831): registerBuffer(0xa1fdaba0) failed -12 (Out of memory)
02-18 11:44:05.197: E/GraphicBuffer(25831): unflatten: registerBuffer failed: Out of memory (-12)
02-18 11:44:05.197: E/Surface(25831): dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -12
02-18 11:44:05.197: W/Adreno-EGLSUB(25831): <DequeueBuffer:720>: dequeue native buffer fail: Out of memory, buffer=0x0, handle=0x0
02-18 11:44:05.197: E/qdmemalloc(25831): ion: Failed to map memory in the client: Out of memory
02-18 11:44:05.197: E/qdgralloc(25831): Could not mmap handle 0xb3bcb380, fd=49 (Out of memory)
02-18 11:44:05.197: E/qdgralloc(25831): gralloc_register_buffer: gralloc_map failed
02-18 11:44:05.197: W/GraphicBufferMapper(25831): registerBuffer(0xb3bcb380) failed -12 (Out of memory)
02-18 11:44:05.197: E/GraphicBuffer(25831): unflatten: registerBuffer failed: Out of memory (-12)
02-18 11:44:05.197: E/Surface(25831): dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -12
02-18 11:44:05.197: W/Adreno-EGLSUB(25831): <DequeueBuffer:720>: dequeue native buffer fail: Out of memory, buffer=0x0, handle=0x0
02-18 11:44:05.197: W/Adreno-EGL(25831): <qeglDrvAPI_eglSwapBuffers:3702>: EGL_BAD_SURFACE
02-18 11:44:05.197: W/OpenGLRenderer(25831): swapBuffers encountered EGL_BAD_SURFACE on 0x877fea00, halting rendering...
02-18 11:44:06.207: A/libc(25831): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x54 in tid 25848 (RenderThread)

[创建表面时,调用glTexImage2D。]

    mProgram_y_texture = GLES20.glGetUniformLocation(mProgram, "y_texture");
    mYTextureHandle = new int[1];
    GLES20.glGenTextures(1, mYTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mYTextureHandle[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, VIDEO_WIDTH, VIDEO_HEIGHT, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

    mProgram_u_texture = GLES20.glGetUniformLocation(mProgram, "u_texture");
    mUTextureHandle = new int[1];
    GLES20.glGenTextures(1, mUTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mUTextureHandle[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, VIDEO_WIDTH/2, VIDEO_HEIGHT/2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

    mProgram_v_texture = GLES20.glGetUniformLocation(mProgram, "v_texture");
    mVTextureHandle = new int[1];
    GLES20.glGenTextures(1, mVTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mVTextureHandle[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, VIDEO_WIDTH/2, VIDEO_HEIGHT/2, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);

[当表面被破坏时,调用glDeleteTextures。]

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mYTextureHandle[0]);
    GLES20.glDeleteTextures(1, mYTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE1);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mUTextureHandle[0]);
    GLES20.glDeleteTextures(1, mUTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE2);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mVTextureHandle[0]);
    GLES20.glDeleteTextures(1, mVTextureHandle, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

0 个答案:

没有答案