BipBip
Posts: 4
Joined: Thu Aug 17, 2017 11:03 pm

OpenglES draw multiple objects

Fri Aug 18, 2017 9:35 am

Hello,


I want to know if it's possible that someone can tell me if there is a solution to remplace multiple draw calls (with glDrawArrays) in one call. I draw many object with their own matrix transformation on my egl context and it's very slow. I looked in GLES2/gl2ext.h and saw glMultiDrawArraysEXT but for no reason it gives me a segmentation fault (same things with glGenVertexArrays). I work on a raspberry pi 3 model B and with OpenglES 2.0.

thanks.

Best regard

User avatar
Paeryn
Posts: 1947
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: OpenglES draw multiple objects

Fri Aug 18, 2017 1:14 pm

The glMultiDrawArraysEXT and glGenVertexArrayOES extensions aren't supported by the standard broadcom drivers, are you are compiling with the MESA drivers (I don't know if MESA support those extensions)?

glMultiDrawArraysEXT() won't allow you to draw multiple objects if they each need their own transform matrix as there's no way to change the uniforms between each object.
She who travels light — forgot something.

BipBip
Posts: 4
Joined: Thu Aug 17, 2017 11:03 pm

Re: OpenglES draw multiple objects

Fri Aug 18, 2017 4:35 pm

Hi,

thanks for your reply.


I don't use MESA drivers and yes I saw it supports this extensions (checked with https://gist.github.com/jvcleave/8657864). But I saw somewhere that Mesa is not accelerated as Broadcom, is it true ? how is it possible to rendering object faster even without extensions ?


thanks.

best regard

dave j
Posts: 101
Joined: Mon Mar 05, 2012 2:19 pm

Re: OpenglES draw multiple objects

Sat Aug 19, 2017 11:23 am

First of all you should look into using index buffers and glDrawElements rather than using glDrawArrays as it will help speed thing up.

NVIDIA produced a paper on GLSL Pseudo-Instancing. It's very old but the technique should be usable with OpenGLES 2.0. You still need a draw call for each mesh but the idea is to pass the transformation matrix using vertex data. The paper passes per instance data using glMultiTexCoord (I told you it was old) but using glVertexAttribute will work with OpenGL ES 2.0.

BipBip
Posts: 4
Joined: Thu Aug 17, 2017 11:03 pm

Re: OpenglES draw multiple objects

Sun Aug 20, 2017 1:50 pm

Thanks for your your answer, I read the paper and did some research but I found this solution is for static object and my objects (Which are of the same shape) can move ...

dave j
Posts: 101
Joined: Mon Mar 05, 2012 2:19 pm

Re: OpenglES draw multiple objects

Sun Aug 20, 2017 2:42 pm

There's no reason why it wouldn't work for objects that move. It just passes the transform matrix as vertex attributes rather than uniforms. You just need to calculate the transform matrix for each object (or pass the minimum you need to change, say position, and calculate the transform matrix in the shader). You can download the source to a demo of the technique from this page (search for pseudo instancing). It's very old though - you'll have to convert the pre-standardised GLSL support into more modern stuff.

BipBip
Posts: 4
Joined: Thu Aug 17, 2017 11:03 pm

Re: OpenglES draw multiple objects

Mon Aug 21, 2017 7:03 am

Thank you, I didn't understand everything but I will test.


Best regard

Return to “OpenGLES”

Who is online

Users browsing this forum: No registered users and 2 guests