简体   繁体   English

为什么遵循GLES代码在Windows CE 6.0上生成DataAbort?

[英]Why following GLES code generates DataAbort on Windows CE 6.0?

I'm developing Windows CE OpenGL application with Qt 4.8 and Open GL ES 1.0. 我正在使用Qt 4.8和Open GL ES 1.0开发Windows CE OpenGL应用程序。 The problem is that following code causes unpredictable DataAbort Exception (unpredictable because it can occur in few seconds after start or in a few hours). 问题在于以下代码会导致不可预测的DataAbort异常(不可预测,因为它可能在启动后几秒钟或几小时内发生)。 Can it be a driver issue or am I doing something wrong? 可能是驱动程序问题,还是我做错了什么? PS Tested this code without Qt - same behavior. PS测试了没有Qt的此代码-相同的行为。

// GLWidget.hpp

#pragma pack(push, 1)
struct drPoint {

    GLfloat x;
    GLfloat y;
    GLfloat R;
    GLfloat G;
    GLfloat B;
    GLfloat A;

};
#pragma pack(pop)

class GLWidget : public QGLWidget {

    Q_OBJECT

public:
    GLWidget(QWidget *parent = 0);
    ~GLWidget();


private:

    drPoint*    arr;
    unsigned int ui32Vbo;

    void initializeGL();
    void paintGL();
    void resizeGL(int width, int height);

};

// GLWidget.cpp

GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent) {}

void GLWidget::initializeGL() {

        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glPointSize(1.0);

        arr = new drPoint[this->height()];

        for (int i = 0; i < this->height(); ++i) {

            arr[i].x    = 0;
            arr[i].y    = i;
            arr[i].R    = 1.0f;
            arr[i].G    = 0.0f;
            arr[i].B    = 0.0f;
            arr[i].A    = 1.0f;

        }

        glEnable(GL_VERTEX_ARRAY);
        glEnable(GL_COLOR_ARRAY);

        glGenBuffers(1, &ui32Vbo);
        glBindBuffer(GL_ARRAY_BUFFER, ui32Vbo);
        glBufferData(GL_ARRAY_BUFFER, sizeof(drPoint) * this->height(), arr, GL_DYNAMIC_DRAW);
        glVertexPointer(2, GL_FLOAT, sizeof(GLfloat) * 6, (void*)0);
        glColorPointer(4, GL_FLOAT, sizeof(GLfloat) * 6, (void*)(sizeof(GLfloat) * 2));
        glBindBuffer(GL_ARRAY_BUFFER, 0);

    }

void GLWidget::paintGL() {

    // Some buffer filling code

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    glBindBuffer(GL_ARRAY_BUFFER, ui32Vbo);
    glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(drPoint) * this->height(), arr);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glDrawArrays(GL_POINTS, 0, this->height());

    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);

}

void GLWidget::resizeGL(int width, int height)
{

    glViewport(0, 0, width, height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    float halfWidth  = width * 0.5f;
    float halfHeight = height * 0.5f;

    glOrthof(-halfWidth, halfWidth, -halfHeight, halfHeight, 0.0f, 10.0f);
    glTranslatef(-halfWidth, -halfHeight, 0.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

}

GLWidget::~GLWidget() {

    glDeleteBuffers(1, &ui32Vbo);

    delete [] arr;

}

And exception looks like this: 异常看起来像这样:

13:08:40.534>  Exception 'Data Abort'(4) Thread-Id=04930016(pth=8674ec28) PC=81221700 BVA=b6200040, dwInfo = 00001008
13:08:40.534>  R0=00000049  R1=00000001  R2=82f994e8  R3=00000000
13:08:40.534>  R4=00000000  R5=00000001  R6=00000049  R7=82f99978
13:08:40.534>  R8=82f9ac38  R9=82f9df0c R10=82f9df0c R11=000007e0
13:08:40.534> R12=00000000  SP=d354f840  Lr=8121edf8 Psr=6000011f
13:08:40.574>  R7=81235608
13:08:40.574>  R8=00000001  R9=00000002 R10=82f9df0c R11=82f9df0c
13:08:40.574> R12=812360e0  SP=ffffc634  Lr=812360f8 Psr=60000193
13:08:40.574> Exception 'Data Abort' (4): Thread-Id=04930016(pth=8674ec28), Proc-Id=00400002(pprc=82fa1448) 'NK.EXE', VM-active=04920016(pprc=8674e9ac) 'opengl_hello.exe'
13:08:40.574> PC=8121a6d8(NK.EXE+0x0001a6d8) RA=812360f8(kernel.dll+0x0000e0f8) SP=ffffc634, BVA=00000000
13:08:40.534> 360f8(kernel.dll+0x0000e0f8) SP=ffffc634, BVA=00000000
13:08:40.534> e4) PC=8121a6d8 BVA=b6200040, dwInfo = 00001008
13:08:40.534>  R0=81235608  R1=60000113  R2=b6200000  R3=82f9ac38
13:08:40.659>  R4=82f9d424  R5=00000000  R6=82f9ecc0 Proc-Id=00400002(pprc=82fa1448) 'NK.EXE', VM-active=04920016(pprc=8674e9ac) 'opengl_hello.exe'
13:08:40.659> PC=c00bb9a4(k.coredll.dll+0x0001b9a4) RA=812354c4(kernel.dll+0x0000d4c4) SP=d354f558, BVA=ffffffff

Sorry for posting such type of question ("What's wrong with the code?!"), but I could not find any solution approximately for about a month. 很抱歉张贴这种类型的问题(“代码有什么问题?!”),但是大约一个月左右我找不到任何解决方案。

PS Used GLES 1.0 lib from official Texas Instruments sdk. PS使用了官方德州仪器sdk的GLES 1.0库。 Hardware is DM3730 with PowerVR. 硬件为带PowerVR的DM3730。 PPS Found out that such behavior occurs only in D1 power state (In D0 works OK, and in D2 drawing stops because of SystemIdle). PPS发现这种行为仅在D1电源状态下才会发生(在D0中工作正常,而在D2中,绘图由于SystemIdle而停止)。

EDITED: I changed code to following but still got same crash. 编辑:我将代码更改为以下代码,但仍然崩溃。 For now it became more rare. 现在,它变得更加罕见。

#pragma pack(push, 1)
struct drPoint {

    GLfloat x;
    GLfloat y;

};
struct clrPoint {

    GLfloat R;
    GLfloat G;
    GLfloat B;
    GLfloat A;

};
#pragma pack(pop)

void GLWidget::initializeGL() {

        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glPointSize(1.0);

        arr = new drPoint[this->height()];
        clr = new clrPoint[this->height()];

        for (int i = 0; i < this->height(); ++i) {

            arr[i].x    = 0;
            arr[i].y    = i;
            clr[i].R    = 1.0f;
            clr[i].G    = 0.0f;
            clr[i].B    = 0.0f;
            clr[i].A    = 1.0f;

        }

        glEnable(GL_VERTEX_ARRAY);
        glEnable(GL_COLOR_ARRAY);

    }

void GLWidget::paintGL() {

    // Some buffer filling code

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    glVertexPointer(2, GL_FLOAT, 0, arr);
    glColorPointer(4, GL_FLOAT, 0, clr);
    glDrawArrays(GL_POINTS, 0, this->height());

    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);

}

And seems like without color everything works nice (or it just needs more time to crash). 似乎没有颜色,一切工作正常(或者只是需要更多时间崩溃)。

GLES 1.0 doesn't support VBOs only "Vertex Arrays". GLES 1.0仅支持VBO“顶点阵列”。

Your code is a mishmash between VBO and Vertex Array and you are not binding either one correctly. 您的代码是VBO与“顶点数组”之间的杂乱无章,并且您没有正确地绑定任何一个。

Please consult GLES for more information. 请咨询GLES以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM