OpenGL es 2.0在某些设备上呈现问题

时间:2016-08-09 01:01:21

标签: android xamarin.android opengl-es-2.0 samsung-mobile opentk

我在某些Android设备上遇到了一个非常离奇的OpenGL ES 2.0问题。我使用OpenTK和Xamarin.Android

以下方法呈现屏幕,为了测试目的,它的上限为1FPS:

int hexagonID = 15;
    protected override void OnRenderFrame(FrameEventArgs e)
    {
        base.OnRenderFrame(e);
        br.updateHex(hexagonID++, GameUtils.Green, true); 
        GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        GL.Enable(EnableCap.Blend);
        GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        GL.Clear(ClearBufferMask.ColorBufferBit);
        spriteMapTexture.use();
        program.Uniforms["mvp"].SetData<Matrix4>(mvp);
        program.Uniforms["hextex"].SetData<int>(0);
        br.RenderBoard();
        SwapBuffers();
    }

RenderBoard方法:

 //Render the board
    public void RenderBoard()
    {
        _program.Use();
        boardVAO.Bind();
        unsafe
        {
            fixed (uint* ptr = indices)
            {
                GL.DrawElements(BeginMode.Triangles, indices.Length, DrawElementsType.UnsignedInt, new IntPtr(ptr));
            }
        }
        boardVAO.Unbind();
        _program.Unuse();
    }

预期的行为是六边形的颜色每秒都在变化。此代码可在运行Adreno 330&amp; IC的OnePlusOne手机上运行 ES 3.00

但是,此代码在运行Adreno 225&amp ;;的三星Galaxy S3上无法正常工作 ES 2.00。我不明白为什么会出现这种情况,因为我没有调用任何3.00函数,而且我的着色器是为GLSL 1.00

编写的。

截图: OnePlusOne,几秒后的预期行为 enter image description here

Galaxy S3,几秒钟后没有变化 enter image description here

libEGL追踪:

08-08 20:54:36.026 D/libEGL  (18551): glGetError();
08-08 20:54:36.977 D/libEGL  (18551): glBindBuffer(GL_ARRAY_BUFFER, 2); 
//update Board Buffer
08-08 20:54:36.977 D/libEGL  (18551): glGetError();
08-08 20:54:36.987 D/libEGL  (18551): glBufferData(GL_ARRAY_BUFFER, 17920, (const GLvoid *) 0x00000000, GL_DYNAMIC_DRAW);
08-08 20:54:36.987 D/libEGL  (18551): glBufferSubData(GL_ARRAY_BUFFER, 0, 17920, (const GLvoid *) 0x67b15020);
08-08 20:54:36.987 D/libEGL  (18551): glGetError();
08-08 20:54:36.997 D/libEGL  (18551): glBindBuffer(GL_ARRAY_BUFFER, 3);
08-08 20:54:36.997 D/libEGL  (18551): glGetError();
08-08 20:54:36.997 D/libEGL  (18551): glBufferData(GL_ARRAY_BUFFER, 8960, (const GLvoid *) 0x00000000, GL_DYNAMIC_DRAW);
08-08 20:54:36.997 D/libEGL  (18551): glBufferSubData(GL_ARRAY_BUFFER, 0, 8960, (const GLvoid *) 0x67b1a020);
08-08 20:54:36.997 D/libEGL  (18551): glGetError();
//Clear and Blending
08-08 20:54:37.007 D/libEGL  (18551): glClearColor(0, 0, 0, 1);
08-08 20:54:37.007 D/libEGL  (18551): glEnable(GL_BLEND);
08-08 20:54:37.007 D/libEGL  (18551): glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
08-08 20:54:37.007 D/libEGL  (18551): glClear(GL_COLOR_BUFFER_BIT);
08-08 20:54:37.007 D/libEGL  (18551): glActiveTexture(GL_TEXTURE0);
08-08 20:54:37.007 D/libEGL  (18551): glBindTexture(GL_TEXTURE_2D, 1);
08-08 20:54:37.007 D/libEGL  (18551): glGetError();
08-08 20:54:37.017 D/libEGL  (18551): glUseProgram(3);
08-08 20:54:37.017 D/libEGL  (18551): glGetError();
//set uniforms
08-08 20:54:37.017 D/libEGL  (18551): const GLfloat value[] = {
08-08 20:54:37.017 D/libEGL  (18551):     0.00277778, 0, 0, 0,
08-08 20:54:37.017 D/libEGL  (18551):     0, -0.0015625, 0, 0,
08-08 20:54:37.017 D/libEGL  (18551):     0, 0, -1, 0,
08-08 20:54:37.017 D/libEGL  (18551):     -1, 1, 0, 1
08-08 20:54:37.017 D/libEGL  (18551): };
08-08 20:54:37.027 D/libEGL  (18551): glUniformMatrix4fv(0, 1, GL_FALSE, value);
08-08 20:54:37.027 D/libEGL  (18551): glUniform1i(1, 0);
//draw elements
08-08 20:54:37.027 D/libEGL  (18551): glBindVertexArrayOES(1);
08-08 20:54:37.027 D/libEGL  (18551): glGetError();
08-08 20:54:37.027 D/libEGL  (18551): glDrawElements(GL_TRIANGLES, 2880, GL_UNSIGNED_INT, (const GLvoid *) 0x67b12020);
08-08 20:54:37.027 D/libEGL  (18551): glBindVertexArrayOES(0);
08-08 20:54:37.027 D/libEGL  (18551): glGetError();
08-08 20:54:37.027 D/libEGL  (18551): glUseProgram(0);
08-08 20:54:37.027 D/libEGL  (18551): glGetError();

任何见解都非常适合

更新:

我从logcat发现了以下消息,不确定它们是否相关

08-08 20:54:31.321 W/Adreno-GSL(18551): <get_panel_settings:3802>: Android framework reported version 2. So, don't force ES30

08-08 20:54:31.521 W/Adreno-EGL(18551): <qeglDrvAPI_eglGetConfigAttrib:603>: EGL_BAD_ATTRIBUTE

UPDATE2:我的指数是uint,这可能是问题吗?

更新3:我已将问题缩小到运行Android 4.4.2的设备;我将4.4.2手机升级到6.0,这个问题就消失了。 4.4.2中有错误吗?

0 个答案:

没有答案