Write to R11G11B10_FLOAT from shader

Started by
6 comments, last by Papaboo 6 years, 10 months ago

Hey all.

I'm using the R11G11B10_FLOAT format my preconvoluted environment maps, because the format really shines for those. Currently I convolute the environment maps on the CPU, encode from float3 to R11G11B10f on the CPU as well and then upload the resulting pixels to the GPU.

Now I would like to move my convolution from the CPU to a compute shader for fun and no profit, but I've 'hit a bit of a snag'. As I'm using DirectX 11.1 I can't expect my hardware to support UAVs with this format. If I could create a UAV with the format R32_INT, then I would happily do that and encode the colors myself in the compute shader, but that won't work either. As far as I understand the documentation there's also no way for me to use any of the typeless formats, since none of them have an [11, 11, 10] bit layout and that is somehow a requirement.

So, is there any way for me to convolute a texture on the GPU and store the result in a mipmapped texture with the format R11G11B10_FLOAT?

Cheers

Asger

From the desk of Dr. John Zoidberg, MD
Advertisement

Support for UAV typed stores to R11G11B10_FLOAT is required for FEATURE_LEVEL_11_0, as indicated by this chart. What's optional is support for UAV typed loads is what's optional. So in other words if you only need to write to a R11G11B10 texture, then you're fine. You'll only need the extended UAV typed load support if you want to read from a UAV with that format.

Brilliant. How does that not conflict with the info on this page though? I read that as only R32_FLOAT, R32_UINT and R32_SINT is guaranteed supported by DX11.0 and that I would need 11.3 for R11G11B10 loads.

Whatever error I had yesterday that caused an E_INVALID_ARG on UAV creation seems to have magically disappeared though, so I guess I'm good to go. Time to blur environments to kingdom come.

From the desk of Dr. John Zoidberg, MD

Hmm I have a follow up question. Can I have one mipmap bound for read via a SRV and then write to another via an UAV? Right now it looks like I can't read from any mipmap as long as any mipmap UAV is bound. If not, then that makes it a bit hard to do recursive convolution.

From the desk of Dr. John Zoidberg, MD

That page you linked is only talking about loads, and not stores. Stores have always been supported for most formats, but loads have optional support.

You can read from one mip level of a texture as an SRV while simultaneously writing to another mip level of the same texture using a UAV. You just have to make sure that your SRV and UAV are created so that they only "target" a single mip level of the texture, otherwise you will get errors from the validation layer. This means you will need N-1 SRV's and N-1 UAV's for a texture that has N mip levels to generate a mip chain 1 mip level at a time. You can control the mip level available to an SRV by setting the "MostDetailedMip" and "MipLevels" member of the D3D11_TEX2D_SRV structure, which is part of D3D11_SHADER_RESOURCE_VIEW_DESC. Unordered access view descriptions have the "MipSlice" member which lets you achieve the same thing.

Deleted repost

From the desk of Dr. John Zoidberg, MD

As long as the SRV and UAV correctly target different mip levels you should be able to do it, yes.

Yup, now it works. Thanks for all the help.

From the desk of Dr. John Zoidberg, MD

This topic is closed to new replies.

Advertisement