On Mon, 25 Oct 1999, Martin Lexa wrote:
> O.K I'l look at textures. Could you explain me how should I load
> textures into memory and then get it to triangle func. And how are these
> persepective correction parameters computed?
Allright,
The next text is based on my own ideas and not based on any experience.
Therefore I forward it to the GGI mailinglist, I hope to get some comments
from there.
Before you can load textures first this:
The driver should have some memory management. In my eyes, this has to be
in the KGI(con) driver, and not in the libraries, for otherwise many
libraries would have to implement the same memorymanagement. Just
thinking: it could be done by libggi too, but would maybe require chipset
specific code in libggi. A few weeks ago we had a thread on the GGI
mailinglist about this, and some kgi_commands were proposed to do the job.
I'm working on code for this at the moment.
Well, loading textures is not very hard. You just copy a bunch of pixels
to the video memory, and keep in mind where the texture starts en what
size it is. Talking about ViRGE: You can use mipmaps by storing two
textures right after each other (in different sizes) but for it's only
ViRGE, you don't want to use mipmaps (unless you want to play Quake 1 in
320x240 at 1 fpm(inute)). So forget mipmapping for now. (Unless Jon is
gonna shoot me for saying this, he knows the S3 chips better as I do) (Yes
Jon, that was a hint :) (And no, not to shoot me)
The memory management scheme I had in mind is (for our ViRGE 3D
accelleration)
The 2d framebuffer starts at offset 0 and is virt.x * virt.y * bpp / 8
bytes.
Directly after that the Z buffer starts, size : virt.x * virt.y * 2 bytes.
After this the texture buffer is located
The last 1K is (can be) used for hardware cursors. Thinking : Is that
2-colour cursor not only nice in 2D mode ? Maybe this 1 K can be used for
textures too, our ViRGE cards are low on memory already.
Nice issue here is when you can overwrite texture data in the videomemory.
You try to keep as many textures as possible stored in videomemory, but
with 1,2 or 4 MB the ViRGE can't store many :( At the moment I'm thinking
of a mixture between LRU and LFU (Least Recently and Frequently used)
The calculation of the perspective correction parameters is a hard math
job. Don't know how to do it (I can start the math calculations, but I
think there must be a good source of info for this.) First get a texture
on-screen, we'll see about this later. Anyone on the GGI list having info
about this ?
Pfft... man, what a huge job is it to write a videodriver if you don;t
have time to do it.
Jos