Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


How to generate mipmap for a texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 jerrycao_1985   Members   -  Reputation: 140

Like
0Likes
Like

Posted 27 March 2013 - 04:30 AM

hi all

 

Here is my case:

An empty 2d texture is created and then it is filled with some memory without mipmap information.

 

I want to generate mip mapping for the texture.

It's dx11. I see there is an interface called "GenerateMips" could do some sort of job.

But "GenerateMips" requires the "D3D11_RESOURCE_MISC_GENERATE_MIPS" , which is only available if the texture is both a render target and shader resource.

My texture is just used for texture mapping , it's not a render target of course.

 

So how can I generate mip map using DX11 interface.
( I know I can generate mipmap using cpu code , but I just want to know the professional way of doing it.)

 

Thanks



Sponsor:

#2 Norman Barrows   Crossbones+   -  Reputation: 2205

Like
0Likes
Like

Posted 27 March 2013 - 08:12 AM

So how can I generate mip map using DX11 interface.
( I know I can generate mipmap using cpu code , but I just want to know the professional way of doing it.)

 

if the dx11 API doesn't provide that functionality, you'll have to do it yourself. actually a great opportunity to implement mipmaps that don't blend the background into the edge of sprite textures. odds are either way (your code or DX11 code) the work will be done by the cpu, not gpu.


Norm Barrows

Rockland Software Productions

"Building PC games since 1988"

 

rocklandsoftware.net

 


#3 TheKreature   Crossbones+   -  Reputation: 478

Like
0Likes
Like

Posted 27 March 2013 - 09:40 AM

- If you have photoshop you can generate the mipmap chain using the nvidia dds plugin:

  https://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop

- For mipmap generation, you could integrate nvidia texture tools into your pipeline: http://code.google.com/p/nvidia-texture-tools/

- If you are looking for a general "howto" on generating and loading the chain, I would suggest checking out the replacement code for D3DX load texture:

  (This uses WIC (Windows Imaging Components) and I would not touch it with a 10 ft pole, however, it does show you the steps needed to load the mipmap chain etc...).

  http://msdn.microsoft.com/en-us/library/windows/apps/jj651550.aspx

- I think MJP's framework supports this, along with hieroglyph if you feel like diving through their code:

  (I think hieroglyph integrated the texture code from the Microsoft example when d3dx was phased out).

  http://mynameismjp.wordpress.com/

  http://hieroglyph3.codeplex.com/


Edited by sensate, 27 March 2013 - 09:42 AM.


#4 Jason Z   Crossbones+   -  Reputation: 5164

Like
0Likes
Like

Posted 27 March 2013 - 11:20 AM

- I think MJP's framework supports this, along with hieroglyph if you feel like diving through their code:

(I think hieroglyph integrated the texture code from the Microsoft example when d3dx was phased out).

http://mynameismjp.wordpress.com/

http://hieroglyph3.codeplex.com/

Hieroglyph uses DirectXTK now that D3DX is deprecated, which is the same WIC method that you mentioned above.  Actually there is an alternative to WIC available in DirectXTK too, so you should take a look and see if it will work for you.

 

But the OP was specifically taking about generating the texture at runtime and then producing the mip-maps.  @jerrycao_1985: Have you tried creating your texture with the render target usage flag, even if you won't use it for a render target?  It would be worth a try to see if it allows you to generate your mips that way.  Otherwise, what the others have said is right - you will probably have to generate the mips on the CPU...



#5 TheKreature   Crossbones+   -  Reputation: 478

Like
0Likes
Like

Posted 27 March 2013 - 06:36 PM

Yes.

- If he is targeting Direct3d11 with non Direct3d11 conformant hardware he will have to generate the pyramid on the cpu. Which is why I suggested looking at the nvidia texture tools library.

- If he is targeting Direct3d11 with Direct3d11 conformant hardware he can use compute shaders (and apply compression as needed):

http://code.msdn.microsoft.com/windowsdesktop/BC6HBC7-DirectCompute-35e8884a

 

I have not tried applying rendertarget flags to a texture that I'm uploading data to from a staging resource before (never had the need).

I would be intrigued to hear if this works. If it does, this is of course the simplest line to follow, however you thenmiss out on writing a bunch of code that will be useful to you for as long as you continue to render (as long as you don't write it using DirectCompute).


Edited by sensate, 27 March 2013 - 11:08 PM.


#6 Jason Z   Crossbones+   -  Reputation: 5164

Like
1Likes
Like

Posted 28 March 2013 - 03:45 PM

I would be intrigued to hear if this works. If it does, this is of course the simplest line to follow, however you thenmiss out on writing a bunch of code that will be useful to you for as long as you continue to render (as long as you don't write it using DirectCompute).

Maybe as a learning exercise, but I haven't ever had the need to generate my own mip-maps...  Can you think of other cases where this would be beneficial code to write?  Seems like a good thing to use a library for, but that is only my opinion.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS