您认为这两个iOS设备的VBO设置中哪个更快?
|
在我进行大量数据测试之前,我以为我会先选拔你的大脑,
您认为这两种针对iOS设备的vbo设置中哪个更快?在openGL-ES 1.x环境中。
设置一个空白的主GL_ELEMENT_ARRAY_BUFFER,然后使用运行循环中的glBufferSubData子填充当时需要的索引数据,
其他设置是先设置单个GL_ELEMENT_ARRAY_BUFFER,然后在运行循环中使用glBindBuffer。
(在两种情况下,\“ DrawOutShape \”下面都是运行循环中的唯一例程)
更新:为了让人们将来参考,我相信我已经在示例3中找到了做到这一点的最佳方法(如果有误,请更正)。
一个简单的问题:是否有更好的方法来做这行“((GLushort *)(sizeof(GLushort)* shapetest2-> deOffset)\”
更新2:供人们将来参考,在伪实例化中,如果您现在想在iOS中实例化,则无法在运行循环中设置数据(有很多块,然后旋转,缩放和放置)并且在运行循环结束时只有一个glDrawElements可以同时将它们全部拉出,然后再开始循环(不会使速度变差),每个\“ shape \”必须有一个glDrawElements ”。不幸的是,您的运行循环中。...我已经确定是openGL-ES还是将来版本的Apple,使它可以通过单个glDrawElements实例化,这可以使FPS大幅提高,例如5次。它是一堵砖墙,使ES迅速向海事组织前进。
范例1:
static const GLushort test2Trips[] =
{
24, 25, 27, 25, 26, 27,
28, 29, 31, 29, 30, 31,
32, 33, 35, 33, 34, 35,
36, 37, 39, 37, 38, 39,
40, 41, 43, 41, 42, 43,
44, 45, 47, 45, 46, 47,
48, 49, 51, 49, 50, 51,
52, 53, 55, 53, 54, 55,
56, 57, 59, 57, 58, 59,
60, 61, 63, 61, 62, 63,
64, 65, 67, 65, 66, 67,
68, 69, 71, 69, 70, 71,
};
//-------------------------
static inline void shapetest2Setup(void)
{
shapetest2 = malloc(sizeof(shapeBase));
shapetest2->stripsName[1] = NULL;
shapetest2->tripsName = &test2Trips;
shapetest2->fansName = NULL;
shapetest2->dataName = &test2Data;
shapetest2->totStrips = 0;
shapetest2->stripsNum[1] = 0;
shapetest2->tripsNum = 72;
shapetest2->totFans = 0;
shapetest2->listOfInserts = NULL;
shapetest2->center = Vertex3DMake( 0.000000, -0.000000, 2.000000 );
shapetest2->radius = Vertex3DMake( 1.000000, 1.000000, 2.000000 );
shapetest2->indexSize = sizeof(test2Trips);
shapetest2->deOffset = 24;
dataSize += sizeof(test2Data);
if (sizeof(test2Trips) > indexSize) indexSize = sizeof(test2Trips);
}
// endOfShapetest2
//--------------------------------------------------------
//-------------------------
static inline void CreateVBOs(void)
{
GLsizeiptr theDataSize = 0;
glGenBuffers(1, &mainBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mainBuffer);
glBufferData(GL_ARRAY_BUFFER, dataSize, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, theDataSize, sizeof(test1Data), test1Data);
theDataSize += sizeof(test1Data);
glBufferSubData(GL_ARRAY_BUFFER, theDataSize, sizeof(test2Data), test2Data);
glGenBuffers(1, &mainIndex);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mainIndex);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize, NULL, GL_STATIC_DRAW);
}
//------------------------------------------------------
static inline void DrawOutShape(void)
{
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, shapetest2->indexSize, shapetest2->tripsName);
glDrawElements(GL_TRIANGLES, shapetest2->tripsNum, GL_UNSIGNED_SHORT, (void*)0);
}
范例2:
static const GLushort test2Trips[] =
{
24, 25, 27, 25, 26, 27,
28, 29, 31, 29, 30, 31,
32, 33, 35, 33, 34, 35,
36, 37, 39, 37, 38, 39,
40, 41, 43, 41, 42, 43,
44, 45, 47, 45, 46, 47,
48, 49, 51, 49, 50, 51,
52, 53, 55, 53, 54, 55,
56, 57, 59, 57, 58, 59,
60, 61, 63, 61, 62, 63,
64, 65, 67, 65, 66, 67,
68, 69, 71, 69, 70, 71,
};
//-------------------------
static inline void shapetest2Setup(void)
{
shapetest2 = malloc(sizeof(shapeBase));
shapetest2->stripsName[1] = NULL;
shapetest2->tripsName = &test2Trips;
shapetest2->fansName = NULL;
shapetest2->dataName = &test2Data;
shapetest2->totStrips = 0;
shapetest2->stripsNum[1] = 0;
shapetest2->tripsNum = 72;
shapetest2->totFans = 0;
shapetest2->listOfInserts = NULL;
shapetest2->center = Vertex3DMake( 0.000000, -0.000000, 2.000000 );
shapetest2->radius = Vertex3DMake( 1.000000, 1.000000, 2.000000 );
shapetest2->indexSize = sizeof(test2Trips);
shapetest2->deOffset = 24;
dataSize += sizeof(test2Data);
if (sizeof(test2Trips) > indexSize) indexSize = sizeof(test2Trips);
glGenBuffers(1, &shapetest2->indexName);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapetest2->indexName);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(test2Trips), test2Trips, GL_STATIC_DRAW);
}
// endOfShapetest2
//--------------------------------------------------------
//-------------------------
static inline void CreateVBOs(void)
{
GLsizeiptr theDataSize = 0;
glGenBuffers(1, &mainBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mainBuffer);
glBufferData(GL_ARRAY_BUFFER, dataSize, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, theDataSize, sizeof(test1Data), test1Data);
theDataSize += sizeof(test1Data);
glBufferSubData(GL_ARRAY_BUFFER, theDataSize, sizeof(test2Data), test2Data);
}
//------------------------------------------------------
static inline void DrawOutShape(void)
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapetest2->indexName);
glDrawElements(GL_TRIANGLES, shapetest2->tripsNum, GL_UNSIGNED_SHORT, (void*)0);
}
范例3:
static const GLushort test1Trips[] =
{
0, 1, 3, 1, 2, 3,
4, 5, 7, 5, 6, 7,
8, 9, 11, 9, 10, 11,
12, 13, 15, 13, 14, 15,
16, 17, 19, 17, 18, 19,
20, 21, 23, 21, 22, 23,
};
static const GLushort test2Trips[] =
{
24, 25, 27, 25, 26, 27,
28, 29, 31, 29, 30, 31,
32, 33, 35, 33, 34, 35,
36, 37, 39, 37, 38, 39,
40, 41, 43, 41, 42, 43,
44, 45, 47, 45, 46, 47,
48, 49, 51, 49, 50, 51,
52, 53, 55, 53, 54, 55,
56, 57, 59, 57, 58, 59,
60, 61, 63, 61, 62, 63,
64, 65, 67, 65, 66, 67,
68, 69, 71, 69, 70, 71,
};
//-------------------------
static inline void shapetest2Setup(void)
{
shapetest2 = malloc(sizeof(shapeBase));
shapetest2->stripsName[1] = NULL;
shapetest2->tripsName = &test2Trips;
shapetest2->fansName = NULL;
shapetest2->dataName = &test2Data;
shapetest2->totStrips = 0;
shapetest2->stripsNum[1] = 0;
shapetest2->tripsNum = 72;
shapetest2->totFans = 0;
shapetest2->listOfInserts = NULL;
shapetest2->center = Vertex3DMake( 0.000000, -0.000000, 2.000000 );
shapetest2->radius = Vertex3DMake( 1.000000, 1.000000, 2.000000 );
shapetest2->indexSize = sizeof(test2Trips);
shapetest2->deOffset = 24;
dataSize += sizeof(test2Data);
indexSize += sizeof(test2Trips);
}
// endOfShapetest2
//--------------------------------------------------------
//-------------------------
static inline void CreateVBOs(void)
{
GLintptr theDataOffset = 0;
GLintptr theIndexOffset = 0;
glGenBuffers(1, &mainBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mainBuffer);
glBufferData(GL_ARRAY_BUFFER, dataSize, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, theDataOffset, sizeof(test1Data), test1Data);
theDataOffset += sizeof(test1Data);
glBufferSubData(GL_ARRAY_BUFFER, theDataOffset, sizeof(test2Data), test2Data);
theDataOffset += sizeof(test2Data);
glGenBuffers(1, &mainIndex);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mainIndex);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, theIndexOffset, sizeof(test1Trips), test1Trips);
theIndexOffset += sizeof(test1Trips);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, theIndexOffset, sizeof(test2Trips), test2Trips);
theIndexOffset += sizeof(test2Trips);
}
//------------------------------------------------------
static inline void DrawOutShape(void)
{
glDrawElements(GL_TRIANGLES, shapetest2->tripsNum, GL_UNSIGNED_SHORT, (GLushort*)(sizeof(GLushort)*shapetest2->deOffset));
}
没有找到相关结果
已邀请:
0 个回复