jagenjo / Canvas2DtoWebGL

Ports (almost) all Canvas2D functions to the GPU so it can be mixed with a WebGL canvas.
MIT License
322 stars 57 forks source link

the benchmark problem #4

Closed ErosZy closed 7 years ago

ErosZy commented 7 years ago

just now, i try it in windows, the all of webgl benchmark is 60fps, but in osx, it really slower than canvas, i read your code, it cache the texture but it call draw method everytime, so i check the inspector result with webgl inspector, i find drawArray too often.

the same time, i test the pixi's bunny benchmark example, i find it call drawElement method once and it has prepare module to prevent upload too many textures in one requestAnimationFrame call.

so, it case the benchmark performance bad?

jagenjo commented 7 years ago

the problem is that other libraries like pixi use instancing, which mean they can draw thousand of images in one draw call, but to do that you have to know what the user is going to do next. Pixi uses its own data structure to contain the whole scene, so they know what objects will be drawn before starting to draw.

But Canvas2DtoWebGL does not try to impose any scene structure, and because of that it cannot predict what the user will do next.

The focus of Canvas2DtoWebGL is not to be faster than regular Canvas2D, but to allow to mix both kind of canvas seamlessly.