How to generate MipMap on DirectX12?

Started by
4 comments, last by Neooooo 1 year, 3 months ago

I have a question ,when I learn DirectX12,that how to generate Mipmaps on DirectX12.

For example,I create a resource to store depth value on GPU.When I need to write data to this resource,I can bind RTV or DSV to this resource.Then,I want to use this texture resource to render in second pass.For better filter,I hope this texture resource has Mipmaps.What should I do to achieve this purpose on DirectX12 ?

I remember that DirectX11 has GenerateMips() method. Does DirectX12 have similar method ? If not, how to generate mipmaps on DirectX12? Compute Shader?

Thanks very much for your reading! And I look forward to your reply.

None

Advertisement

From microsoft.com:

Fixed function rendering

In Direct3D 11 there were a few methods that simplified various higher level operations, such as GenerateMips (creating full mip chains) and DrawAuto (using stream output as shader input without further input from the app). These methods are not available in Direct3D 12, the app needs to handle these operations by creating shaders to perform them.

Generate Mipmaps Compute Shader

@PAM79 Awesome! Thanks for your answer!

None

Keep in mind downsampling is not always enough. Likely you want compressed textures which are faster and need less memory. But the CS example does not cover compression, which is more difficult than downsampling.

So for static textures you likely want to use offline compression tools, and save the texture with mips in a compressed format to disk.
That's easy and ‘wastes’ only one third of storage compared to not storing mips.

Ofc. compression is no must. So if you generate a texture dynamically for one time use (e.g. shadow maps, heightmap of water simulation for ripples in puddles, dynamic reflection cubemaps, etc.), it's fine to generate just the mips and keep it uncompressed.
(I did not spot that's your intend after reading post too quickly.)

@JoeJ I appreciate your answer! I already know how to use mipmaps in DirectX12.

None

This topic is closed to new replies.

Advertisement