From 747b20cf9d8c9bd37c0411df641b4bfac509e6f8 Mon Sep 17 00:00:00 2001 From: Yochai Shefi Simchon Date: Mon, 20 Jun 2011 16:34:17 +0300 Subject: [PATCH] 1.1 Translator: fix drawing of GL_POINT_SIZE_ARRAY When translating point size arrays from GLES to GL, an optimization was implemented where all points of the same size in an array or elements array where drawn together. This is wrong, since it means points are not drawn in the order the app has requested, creating the wrong result when points in the array are overlapping in screen space. So removed this mechanism, and now just drawing the points in the right order. Some optimization is still there, where if there are several consecutive points of the same size they are drawn together. The change in GLEScmImp.cpp is only to make the condition more readable - the functionality is identical. --- .../libs/Translator/GLES_CM/GLEScmContext.cpp | 78 ++++++++++--------- .../libs/Translator/GLES_CM/GLEScmImp.cpp | 15 ++-- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp index 7092e10c2..1df4b5db1 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp @@ -136,31 +136,6 @@ void GLEScmContext::setupArraysPointers(GLESConversionArrays& cArrs,GLint first, s_glDispatch.glClientActiveTexture(activeTexture); } -void GLEScmContext::drawPoints(PointSizeIndices* points) { - - GLushort* indices = NULL; - int last_size = 0; - - //drawing each group of vertices by the points size - for(PointSizeIndices::iterator it = points->begin();it != points->end(); it++) { - int count = (*it).second.size(); - int pointSize = (*it).first; - std::vector& arr = (*it).second; - - if(count > last_size) { - if(indices) delete [] indices; - indices = new GLushort[count]; - } - int i = 0 ; - for(std::vector::iterator it2 = arr.begin();it2 != arr.end();it2++) { - indices[i++] = (*it2); - } - s_glDispatch.glPointSize(pointSize); - s_glDispatch.glDrawElements(GL_POINTS,count,GL_UNSIGNED_SHORT,indices); - } - if(indices) delete [] indices; -} - void GLEScmContext::drawPointsData(GLESConversionArrays& cArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices_in,bool isElemsDraw) { const char *pointsArr = NULL; int stride = 0; @@ -179,23 +154,52 @@ void GLEScmContext::drawPointsData(GLESConversionArrays& cArrs,GLint first,GLsi stride = sizeof(GLfloat); } - //filling arrays before sorting them - PointSizeIndices points; + if(isElemsDraw) { - for(int i=0; i< count; i++) { - GLushort index = (type == GL_UNSIGNED_SHORT? - static_cast(indices_in)[i]: - static_cast(indices_in)[i]); - GLfloat pSize = *((GLfloat*)(pointsArr+(index*stride))); - points[pSize].push_back(index); + int tSize = type == GL_UNSIGNED_SHORT ? 2 : 1; + + int i = 0; + while(i(indices_in)[i]: \ + static_cast(indices_in)[i]) + + GLfloat pSize = *((GLfloat*)(pointsArr+(INDEX*stride))); + i++; + + while(i < count && pSize == *((GLfloat*)(pointsArr+(INDEX*stride)))) + { + sCount++; + i++; + } + + s_glDispatch.glPointSize(pSize); + s_glDispatch.glDrawElements(GL_POINTS, sCount, type, (char*)indices_in+sStart*tSize); } } else { - for(int i=0; i< count; i++) { - GLfloat pSize = *((GLfloat*)(pointsArr+(first+i*stride))); - points[pSize].push_back(i+first); + int i = 0; + while(isetupArraysPointers(tmpArrs,first,count,0,NULL,true); - if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){ - ctx->dispatcher().glDrawArrays(mode,first,count); - } - else{ + if(mode == GL_POINTS && ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){ ctx->drawPointsArrs(tmpArrs,first,count); } + else + { + ctx->dispatcher().glDrawArrays(mode,first,count); + } } GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *elementsIndices) { @@ -577,11 +578,11 @@ GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type } ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false); - if(mode != GL_POINTS || !ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){ - ctx->dispatcher().glDrawElements(mode,count,type,indices); + if(mode == GL_POINTS && ctx->isArrEnabled(GL_POINT_SIZE_ARRAY_OES)){ + ctx->drawPointsElems(tmpArrs,count,type,indices); } else{ - ctx->drawPointsElems(tmpArrs,count,type,indices); + ctx->dispatcher().glDrawElements(mode,count,type,indices); } }