Generating Sublevels of MIP Map Textures

A display driver indicates support of automatically generating the sublevels of MIP-map textures by setting the DDCAPS2_CANAUTOGENMIPMAP bit of the dwCaps2 member of the DDCORECAPS structure. The driver specifies this DDCORECAPS structure in the ddCaps member of a DD_HALINFO structure. DD_HALINFO is returned by the driver's DrvGetDirectDrawInfo function. The display driver also indicates whether a particular surface format supports automatically generating sublevels by setting the D3DFORMAT_OP_AUTOGENMIPMAP flag in the dwOperations member of the DDPIXELFORMAT structure for the format.

When a texture surface is created, the Direct3D runtime sets the DDSCAPS3_AUTOGENMIPMAP bit of the dwCaps3 member of the DDSCAPSEX (DDSCAPS2) structure to indicate that the MIP-map sublevels for this texture can be automatically generated. If Direct3D directs some textures to automatically generate their MIP-map sublevels and some textures to not automatically generate, the driver can only perform blit operations (D3DDP2OP_TEXBLT) on these textures as described in the following scenarios:

  • The driver cannot blit from a source texture that auto-generates MIP maps to a destination texture that does not.

  • If the driver blits from a source texture that does not auto-generate MIP maps to a destination texture that does, the driver only blits the topmost matching level. The sublevels from the source texture are ignored. The destination sublevels can be generated.

  • Similarly, if the driver blits from source to destination textures that both auto-generate MIP maps, the driver only blits the topmost matching level. The sublevels from the source texture are ignored. The destination sublevels can be generated.

To generate the sublevels of a MIP-map texture, the driver receives a D3DDP2OP_GENERATEMIPSUBLEVELS command along with a D3DHAL_DP2GENERATEMIPSUBLEVELS structure. In order to receive this command, the texture's surface format must expose the D3DFORMAT_OP_AUTOGENMIPMAP flag.

For driver-managed resources, when the driver evicts and replaces a resource in video memory, the driver must use the last set filter type to automatically generate sublevels. Because Direct3D does not control the eviction and replacement of the resource, Direct3D does not send a D3DDP2OP_GENERATEMIPSUBLEVELS command to the driver.

The Direct3D runtime cannot call the driver's DdLock function or use any other DDI to access the sublevels of an auto-generated MIP-map texture. This implies that the sublevels for auto-generated MIP-map textures, like lightweight MIP-map textures, are "implicit" and can be specified by the driver as appropriate. The driver is not required to specify "complete" surface data structures. Note, however, that Direct3D must be able to call the driver's DdLock or DdBlt functions, send the D3DDP2OP_BLT command, or use any other DDI (for driver-managed textures, dynamic textures or vendor-specific formats only) to access the top level of an auto-generated MIP-map texture.