diff --git a/core/renderer/CCRenderer.cpp b/core/renderer/CCRenderer.cpp index 622b4a6723..d3327a8a5d 100644 --- a/core/renderer/CCRenderer.cpp +++ b/core/renderer/CCRenderer.cpp @@ -995,8 +995,10 @@ void Renderer::TriangleCommandBufferManager::createBuffer() { auto device = backend::Device::getInstance(); -#ifdef AX_USE_METAL - // Metal doesn't need to update buffer to make sure it has the correct size. + // Not initializing the buffer before passing it to updateData for Android/OpenGL ES. + // This change does fix the Android/OpenGL ES performance problem + // If for some reason we get reports of performance issues on OpenGL implementations, + // then we can just add pre-processor checks for OpenGL and have the updateData() allocate the full size after buffer creation. auto vertexBuffer = device->newBuffer(Renderer::VBO_SIZE * sizeof(_verts[0]), backend::BufferType::VERTEX, backend::BufferUsage::DYNAMIC); if (!vertexBuffer) @@ -1009,32 +1011,6 @@ void Renderer::TriangleCommandBufferManager::createBuffer() vertexBuffer->release(); return; } -#else - auto tmpData = malloc(Renderer::VBO_SIZE * sizeof(V3F_C4B_T2F)); - if (!tmpData) - return; - - auto vertexBuffer = device->newBuffer(Renderer::VBO_SIZE * sizeof(V3F_C4B_T2F), backend::BufferType::VERTEX, - backend::BufferUsage::DYNAMIC); - if (!vertexBuffer) - { - free(tmpData); - return; - } - vertexBuffer->updateData(tmpData, Renderer::VBO_SIZE * sizeof(V3F_C4B_T2F)); - - auto indexBuffer = device->newBuffer(Renderer::INDEX_VBO_SIZE * sizeof(unsigned short), backend::BufferType::INDEX, - backend::BufferUsage::DYNAMIC); - if (!indexBuffer) - { - free(tmpData); - vertexBuffer->release(); - return; - } - indexBuffer->updateData(tmpData, Renderer::INDEX_VBO_SIZE * sizeof(unsigned short)); - - free(tmpData); -#endif _vertexBufferPool.emplace_back(vertexBuffer); _indexBufferPool.emplace_back(indexBuffer);