1
\$\begingroup\$

I'm making a 2D game in which I create some textures dynamically for displaying as simple 2D quads. To achieve this, I call ID3D11Device::CreateTexture2D that requires a D3D11_TEXTURE2D_DESC.

typedef struct D3D11_TEXTURE2D_DESC {
  UINT             Width;
  UINT             Height;
  UINT             MipLevels;
  UINT             ArraySize;
  DXGI_FORMAT      Format;
  DXGI_SAMPLE_DESC SampleDesc;
  D3D11_USAGE      Usage;
  UINT             BindFlags;
  UINT             CPUAccessFlags;
  UINT             MiscFlags;
} D3D11_TEXTURE2D_DESC;

One of the fields is MipLevels. What I understand about this is that mipmaps consist of a collection of the same texture downscaled for better representation and performance of them when they are far away from the view camera.

Since what I'm making is a 2D game, I don't need this feature and I want to disable it. Is there any way to do so? At first, I thought I could just set miplevels parameter to 0, but then I read this:

MipLevels Type: UINT The maximum number of mipmap levels in the texture. See the remarks in D3D11_TEX1D_SRV. Use 1 for a multisampled texture; or 0 to generate a full set of subtextures.

and:

pInitialData [in] Type: const D3D11_SUBRESOURCE_DATA* A pointer to an array of D3D11_SUBRESOURCE_DATA structures that describe subresources for the 2D texture resource. Applications cannot specify NULL for pInitialData when creating IMMUTABLE resources (see D3D11_USAGE). If the resource is multisampled, pInitialData must be NULL because multisampled resources cannot be initialized with data when they are created.

This is what confuses me. I want to create an IMMUTABLE 2D texture (once it's dynamically generated at runtime it's not going to change anymore) plus I don't want any mipmap levels. How am I supposed to do this?

\$\endgroup\$
1
\$\begingroup\$

If you set your MiPLevels to 1, and ArraySize to 1, it will just have one miplevel. thats all you do to it. beacuse you cannot simply "disable" mipmaping, since it´s a part of the GPU pipeline.

\$\endgroup\$
4
  • \$\begingroup\$ The problem is that I want an IMMUTABLE resource and it says that multisampled resources can't be initialized when they are created. (Thus, I cannot create it as immutable. This doesn't make much sense to me. :/) \$\endgroup\$
    – Kaboose
    May 8 '13 at 10:15
  • \$\begingroup\$ you have to fill the texture up with data when you create it. thats all. \$\endgroup\$
    – Tordin
    May 8 '13 at 10:35
  • \$\begingroup\$ Just tried it and it actually works, despite what msdn says. Thanks. \$\endgroup\$
    – Kaboose
    May 8 '13 at 15:40
  • \$\begingroup\$ They can sometimes write their docs in a confusing way. \$\endgroup\$
    – Tordin
    May 10 '13 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .