12.07.2015 Views

surface caching and quake's triangle models

surface caching and quake's triangle models

surface caching and quake's triangle models

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ined on dem<strong>and</strong> into what I call <strong>surface</strong>s: lit, textured rectangles that are used as theinput to the texture mapper. Building <strong>surface</strong>s takes time, so performance is enhancedby <strong>caching</strong> the <strong>surface</strong>s from one frame to the next. As I pointed out inChapter 68, 3-D hardware accelerators are designed to optimize Gouraud shading,but <strong>surface</strong> <strong>caching</strong> can also work on hardware accelerators, with some significantquality advantages.The <strong>surface</strong>-<strong>caching</strong> architecture of the Verite version of Quake (which we callVQuake) is essentially the same as in the software-only version of Quake: The CPUbuilds <strong>surface</strong>s on dem<strong>and</strong>, which are then downloaded to the accelerator’s memory<strong>and</strong> cached there. There are couple a of key differences, however: the need to download<strong>surface</strong>s, <strong>and</strong> the requirement that the <strong>surface</strong>s be in 16-bit-per-pixel (bpp) format.Downloading <strong>surface</strong>s to the accelerator is a performance hit that doesn’t exist inthe software-only version. Although Verite uses DMA to download <strong>surface</strong>s, DMAdoes in fact steal performance from the CPU. This cost is increased by the requirementfor 16-bpp <strong>surface</strong>s, because twice as much data must be downloaded. Worsestill, it takes about twice as long to build 16-bpp <strong>surface</strong>s as 8-bpp <strong>surface</strong>s, so the costof missing the <strong>surface</strong> cache is well over twice as expensive in VQuake as in Quake.Fortunately, there’s 4 MB of memory on Verite-based adapters, so the <strong>surface</strong> cachedoesn’t miss very often <strong>and</strong> VQuake runs fine (<strong>and</strong> looks very good, thanks to bilineartexture filtering, which by itself is pretty much worth the cost of 3-D hardware), butit’s nonetheless true that a completely straightforward port of the <strong>surface</strong>-<strong>caching</strong>model is not as appealing for hardware as for software. This is especially true at highresolutions, where the needs of the <strong>surface</strong> cache increase due to more detailed<strong>surface</strong>s but available memory decreases due to frame buffer size.Does my recent experience indicate that as the PC market moves to hardware, there’sno choice but to move to Gouraud shading, despite the quality issues? Not at all.First of all, <strong>surface</strong> <strong>caching</strong> does still work well, just not as relatively well compared toGouraud shading as is the case in software. Second, there are least at two alternativesthat preserve the advantages of <strong>surface</strong> <strong>caching</strong> without many of the disadvantagesnoted above.Letting the Graphics Card Build the TexturesOne obvious solution is to have the accelerator card build the textures, rather thanhaving the CPU build <strong>and</strong> then download them. This eliminates downloading completely,<strong>and</strong> lets the accelerator, which should be faster at such things, do the texelmanipulation. Whether this is actually faster depends on whether the CPU or theaccelerator is doing more of the work overall, but it eliminates download time, whichis a big help. This approach retains the ability to composite other effects, such assplatters <strong>and</strong> dents, onto <strong>surface</strong>s, but by the same token retains the high memoryrequirements <strong>and</strong> dynamic lighting performance impact of the <strong>surface</strong> cache. It alsorequires that the 3-D API <strong>and</strong> accelerator being used allow drawing into a texture,Surface Caching <strong>and</strong> Quake’s Triangle Models 1261

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!