CNFGBlitImage performance
Closed this issue · 12 comments
I should probably stop making issues so frequently :], but images are important to me.
I tried drawing some images, but realized, the performance isn't good. 1920*1080 image can take about 6 or 7 ms, and uses a lot of cpu. Is this a known issue?
Btw, I use GNFGOGL. It seems like rasterizer has smaller overhead, but performs worse with bigger images.
As I can see CNFGBlitImage uses glTexImage2D. That means it creates, allocates and uploads to texture each time. That is slow way.
Much faster to create texture one time using glTexImage2D and then only upload to it using glTexSubImage2D. That will work much faster.
So should I just do it manually? If yes, how do i do that?
Oh, I found a good resource on this. Should I keep this issue open? I feel like generating new texture every loop is bad idea, but I don't know, if it was intended that way.
Also check if your GPU can handle texture size bigger then 1024x1024, it can be a reason for slow texture management since it will allocate 1024x1024x4 to handle 1920x1080.
- You can write InitCNFGBlitImage function to init texture only once.
- Also change CNFGBlitImage function to use glTexSubImage2D instead.
- Post result here:)
Also check if your GPU can handle texture size bigger then 1024x1024, it can be a reason for slow texture management since it will allocate 1024x1024x4 to handle 1920x1080.
Even if my graphics card didn't support that big textures, the problems stay on even smaller textures.
- You can write InitCNFGBlitImage function to init texture only once.
- Also change CNFGBlitImage function to use glTexSubImage2D instead.
- Post result here:)
I'm not exactly sure, how to do that. I don't really know opengl, and making it work with rawdraw would be harder I guess. I already looked at the code of CNFGBlitImage, and it uses some global variables, so I'm not really sure how to get around those. I will just try waiting for @cnlohr's response to this.
Ok, I managed to do it somehow. I will share some data in a bit.
Ok, it is really fast. The times seem to be static. I can now draw 4096*4096 big texture in about 0.00009 seconds. This time doesn't seem to change. I can't seem to make it, so you can have multiple textures. I only replaced the texture global variable for a custom one, so I will try it with others.
I don't know, how to solve this. I have it here, so you can look at it.
CNFGBlitImage passes *data in parameters, so during init You have to allocate buffers for each texture and pass pointer to CNFGBlitImage. It will update texture @ given pointer using glTexSubImage2D
I don't really know opengl. Could you help me with this?
Ok, I somehow managed to make it work. I will make a PR.