Jump to content
  • Advertisement
Sign in to follow this  
PyemanKOP

DX11 Auto Generate MipMap Not Working

This topic is 729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i want to use SampleLevel to use different mipmap levels manually but its not working as below image shows:

Untitled.png

as the picture shows it always use level 0 texture!

 

here is my code for loading a texture i use Directx Textue tool for loading also i use dx11:

HR(DirectX::CreateDDSTextureFromFileEx(
AngelCore::AngelSubSystemResources::GraphicDeviceResources::Device.Get(),
path.c_str(),MAXSIZE_T,D3D11_USAGE_DEFAULT,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE,0,
D3D11_RESOURCE_MISC_GENERATE_MIPS,false,
m_textureResource.GetAddressOf(), m_textureView.GetAddressOf()));

also i create my sampler state with below options:

D3D11_FILTER_ANISOTROPIC,D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_WRAP
, D3D11_TEXTURE_ADDRESS_WRAP, 
D3D11_COMPARISON_ALWAYS

what is the problem?

Share this post


Link to post
Share on other sites
Advertisement

I can't see what parameters you're using when you create the texture and shader resource view since you're using a helper function. Are you creating the texture with a full mipmap chain, or are you creating it with only 1 mip level? Are you creating the shader resource view with a full mipmap chain?

Share this post


Link to post
Share on other sites

I can't see what parameters you're using when you create the texture and shader resource view since you're using a helper function. Are you creating the texture with a full mipmap chain, or are you creating it with only 1 mip level? Are you creating the shader resource view with a full mipmap chain?

this function doesn't require anything,it will return shaderResourceView.

i also use that d3dx11 function but nothing changed.

Share this post


Link to post
Share on other sites

 What format is your texture?  The documentation page for ID3D11DeviceContext::GenerateMips notes a list of supported formats, and also notes that:

 

For all other unsupported formats, GenerateMips will silently fail.

 

Assuming that you are actually using a supported format, then you should review the documentation for the helper function you're using; this one I assume (although you really should have said so).  Note the discussion around the maxsize parameter, how it interacts with miplevels, and ensure that the behaviour you're requesting is the behaviour you actually want.  Also note that you must be calling the overload that takes your context as a param if you wish it to generate mips for you.

 

Finally, since you're loading a DDS file, why are you generating mips at runtime anyway?  DDS is capable of storing pregenerated mips, so you could consider that instead.

Share this post


Link to post
Share on other sites

 What format is your texture?  The documentation page for ID3D11DeviceContext::GenerateMips notes a list of supported formats, and also notes that:

 

For all other unsupported formats, GenerateMips will silently fail.

 

Assuming that you are actually using a supported format, then you should review the documentation for the helper function you're using; this one I assume (although you really should have said so).  Note the discussion around the maxsize parameter, how it interacts with miplevels, and ensure that the behaviour you're requesting is the behaviour you actually want.  Also note that you must be calling the overload that takes your context as a param if you wish it to generate mips for you.

 

Finally, since you're loading a DDS file, why are you generating mips at runtime anyway?  DDS is capable of storing pregenerated mips, so you could consider that instead.

ok. now i use this function:

HR(DirectX::CreateDDSTextureFromFileEx(
AngelCore::AngelSubSystemResources::GraphicDeviceResources::Device.Get(),
AngelCore::AngelSubSystemResources::GraphicDeviceResources::DeviceContext.Get()
,
path.c_str(),D3D10_FLOAT32_MAX,D3D11_USAGE_DEFAULT,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE,0,
D3D11_RESOURCE_MISC_GENERATE_MIPS,false,
m_textureResource.GetAddressOf(), m_textureView.GetAddressOf()));

but nothings changed!

how i'm suppose to generate static mipmaps?

Share this post


Link to post
Share on other sites

Now you're passing a float to a size_t parameter - have you warnings turned off?

 

Please read the documentation - it's legal to specify 0 for maxsize, which is probably the behaviour you actually want:

 

If '0', then if the attempt to create the Direct3D 11 resource fails and there are mipmaps present, it will retry assuming a maxsize based on the device's current feature level.

 

Again, note from the documentation (with my emphasis):

 

If a d3dContext is given to these functions, they will attempt to use the auto-generation of mipmaps features in the Direct3D 11 API if supported for the pixel format.

 

You really need to check the pixel format of your DDS file and confirm that it is a format for which automatic mipmap generation is supported.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!