Handling Lightweight MIP Map Textures
Because the MIP sublevels of lightweight MIP-map textures are implicit and do not have corresponding DirectDraw surface structures (DD_SURFACE_LOCAL, DD_SURFACE_GLOBAL and DD_SURFACE_MORE), a DirectX 9.0 version driver can determine if a MIP-map texture is lightweight and thus avoid creating unnecessary driver surface structures to save memory. To determine if a MIP-map texture is lightweight, the driver verifies if the DDSCAPS3_LIGHTWEIGHTMIPMAP bit in the dwCaps3 member of the DDSCAPSEX (DDSCAPS2) structure for the texture surface is set.
Note that all MIP-map textures in DirectX 9.0 are lightweight by default.
The DirectX 9.0 version driver observes the following rules when handling lightweight and heavyweight MIP-map textures:
A DirectX 9.0 and later driver can receive a D3DDP2OP_TEXBLT operation code in which the source MIP-map texture is heavyweight and the destination MIP-map texture is lightweight or vice versa. Of course, the driver can also receive a D3DDP2OP_TEXBLT in which both source and destination MIP-map textures are lightweight.
Because a system memory lightweight MIP-map texture consumes only a single surface of memory, the entire MIP map is visible to the driver within the top-level surface. The driver is never required to perform a texture operation directly from a system memory lightweight MIP-map texture. Such a MIP-map texture can only be the source of a D3DDP2OP_TEXBLT.
The following MIP-mapped textures must be heavyweight because locks and direct writes to video or AGP memory corresponding to each sublevel are possible with such textures:
- Render target
- Depth stencil
- Vendor formatted
Therefore, a full surface data structure is required per sublevel.
Because a video or AGP memory lightweight MIP-map texture is never locked or referenced by other DDIs, such as DdBlt, the driver determines the sublevel placement for such a MIP-map texture. Therefore, full surfaces (explicit fpVidmem members of the DD_SURFACE_GLOBAL structure) for the sublevels of such a MIP-map texture are not required.
Driver-managed lightweight MIP-map textures are also restricted to a single surface and must use exactly the same layout that Direct3D uses with system memory lightweight MIP-map textures. Note that this has no adverse effect (other than implementation cost) because the corresponding resident (video and AGP) MIP-map textures can have their own implementation-specific layout.