Direct3D9: after enabling mipmaps my texture coordinates seem to be wrong

414 views Asked by At

I have a texture that contains symbols and characters that I use to put strings and icons on my final render target. To produce a string for example, I render every character as a single quad with the appropriate texture coordinates.

My problem starts when I try to use mipmaps for the texture containing all my symbols. Without mipmaps, everything works as intended. After changing only the CreateTexture() call to generate all mip levels and adding D3DUSAGE_AUTOGENMIPMAP to the usage parameter, I only get garbled output like this:

enter image description here

The texture is created like this:

CreateTexture(width, height, 0, D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_texture, nullptr);

I use the following texture filtering when rendering:

SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

Everything that is rendered is still part of the texture but the texture coordinates seem to be all wrong somehow. I tried debugging this issue with PIX but there my render target looks exactly as intended. (I believe, PIX uses software rendering while my GPU is an Nvidia Quadro with the latest drivers.)

I don't really know where I should keep looking. My texture coordinates should be correct as everything works without mipmaps. Did I miss something when switching on mipmapping for this texture? Any ideas what could be causing this?

EDIT: I tried this with the reference driver (D3DDEVTYPE_REF instead of D3DDEVTYPE_HAL) and have the same problem, which suggests that it's not a driver issue but in the application code. Still, I have no idea where to look as it's working if I don't use mipmaps.

0

There are 0 answers