WaterMediaTeam / watermedia

Library and API for Multimedia, Powered by LibVLC. Working on pure JAVA and all Minecraft Modloaders
13 stars 10 forks source link

Optimized the applyBuffer method. #65

Closed zFERDQFREZrzfq closed 6 months ago

zFERDQFREZrzfq commented 6 months ago

Hello again :)

I did it again XD

First, I found out that it's possible to configure OpenGL texture to fully avoid the byteswapping using the GL_UNSIGNED_INT_8_8_8_8_REV format (REV stands for REVERSE, so instead of expecting BGRA, it can take the Java's ARGB natively).

Then, I noticed that getRGB was awfully slow, so I tried porting the replacement I did on 2.0.40.

On 2.0.41, the applyBuffer method seems to be called only when a frame is loading an image so I tested my changes by building a wall of frames : image

(the second row is a 5 MB gif)

The difference in loading time is perceptible, especially visible when I use the "reload all" button.

I wanted to have numbers to compare, so I did some profiling using the Spark mod. I started a 20 seconds profiling and I clicked the "reload all" button 5 times with 2.0.41 and modified one.

Here is what I get :

2.0.41 : image

Modified : image

Looks like more than 4x faster loading, enabling for moooooooore frames :)

zFERDQFREZrzfq commented 6 months ago

I just removed a commented line I had forgot

SrRapero720 commented 6 months ago

is not necesary force-push for corrections. i can basically do squash and merge and compacts every commit in one. about the change... i am evaluating how to move the whole data procesing into ImageFetch (making it async) just to reduce render thread overload, but this definetly helps to even make loading times less noticeable.

SrRapero720 commented 6 months ago

if you can make the same change for master i whould preciated it

SrRapero720 commented 6 months ago

i breaked the PR rebasing my local changes ._.

zFERDQFREZrzfq commented 6 months ago

is not necesary force-push for corrections. i can basically do squash and merge and compacts every commit in one. about the change... i am evaluating how to move the whole data procesing into ImageFetch (making it async) just to reduce render thread overload, but this definetly helps to even make loading times less noticeable.

Oh, ok I didn't knew we could squash on the webui. It's a good idea, it could speed things up a lot to prepare the final buffer offthread and build an in-memory cache of loaded images that could even use a hash (maybe the URL one?) as a key, so that all the frames displaying the same image could use the same buffer, but this may be hard to implement...