Sign in to follow this  
Macin Software

Is the binded GL_TEXTURE bitmap data stored in CPU or GPU?

Recommended Posts

I have optimization idea, I dont remember if I talked about that in some of my previous threads. Anyway, here it is - I would texture 3angles from atlas without glBegin/glEnd. My goal is to do it without GLSL because of compatibility reasons. There would be problem with tiling, which I solved sooner with GLSL, and now I want it without. So my first question (I cant find the answer anywhere) is where is actually stored the binded texture? If you will say GPU, then this plan falls.

If you will say CPU, here I go: so far without mipmaps. The atlas will have sub-images stored not as you see them, but linear (it will be like starting pointer, from which the bitmap will be stored in width*height*color of elements, then next one, then next one, and so. Then I will somehow change the place in memory where is pointer to binded texture and its width and height, and change those for particular texture - then render stuff - then change it to next texture values and so. This would save me all the begin-end-bindtexture slowdown AND textures would tile. But. The possibility of solution actually depends on where are those things stored in memory, so... anybody knows?

Share this post


Link to post
Share on other sites

Textures are stored on the GPU.

Technically, the driver can page them out to the CPU when it needs to conserve RAM, and will move them back as required... but the abstraction is that they're always present on the GPU.

 

I would texture 3angles from atlas without glBegin/glEnd. My goal is to do it without GLSL because of compatibility reasons.
GLSL became core in GL2.1, in 2006, and acceptable use of glBegin/glEnd goes back to the same era -- so keep in mind that you're targeting PC's that are a decade old :)

I guess those are the PC's that are most in need of optimizations though!

Share this post


Link to post
Share on other sites

(less important)

Still, some people have those PCs and I want this to be as fast as possible. "You have old PC" is cheap to say, but it will not improve my skills or satisfy me at all. I felt like idiot when Quake3, that looks nicer than my game so far (approx Quake1 by now, realistic plan to the deadline is something between Q2 and UT2k4) was running on 90fps on testing comp while my game had only 2fps. I improved it to 48fps + multithreaded update/display, so the speed is acceptable now, but I feel it would want a bit more with bigger maps and more effects than just multitextured static lighting, so I am looking for the ways possible.

About glBegin/glEnd - yes, everybody suggests VBOs and I knew you will, but I have tried VBOs, its the same - I could easily do both, it just doesnt matter for me. I have chosen begin-end because the code looks nicer with the same functionality and speed. Its unimportant since it does the same stuff. Only things that changes is that code is a bit uglier and you have to do a bit more stuff around. VBOs anyway cannot switch textures themselves, so they dont help me in any way.

 

(actual question)

I would not change textures, I would just make OpenGL think that texture is just a portion of itself. Just change pointer, width and height while letting binded texture be. You said driver can page this, how its done?

Share this post


Link to post
Share on other sites

as far as you call glTexImage2d or something liek that its passed to gpu, unless it has no memory free then its goint to ram, anyway i don't think you might be even able to fetch the address even if its in ram you may not be even able to check that (but it should be possible but i think noone ever cared) this is better solution to use glsl for that and you dont need to use mipmaps, unless driver forces you to do so. (then youll get artifacts)

 

anyway i was trying to do something maybe not similar but i tried to wank with pointers of textures, totally not worth it you'll see when it comes to destroy objects on non windows platforms/

Edited by WiredCat

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this