Jump to content
  • Advertisement
Nightheart

DX11 Packing and Unpacking of the DXGI_Format in HLSL

Recommended Posts

Posted (edited)

Hi,

currently I am trying to programm a  snow shader consisting of snow deformation and a snowing particle effect. My problem is that I need to use a UAV preferably an RWTexture2D which consists of 2 16bit float values (R16G16_Float) but only R32_UINT allows simultaneous writes. I saw in the documentation that there is a possibilty to cast those in HLSL by including D3DX_DXGIFormatConvert.inl but my program does not find the header.

 

So this is my problem how do I properly include the format convert?

Any thoughts?

Edited by Nightheart

Share this post


Link to post
Share on other sites
Advertisement

This is part of my (not finished) shader code.

But as you can see at the top of the code piece the first include is just fine. Probably because the file lies in the same folder as the shader file including it, but when it comes to the dxgi format convert file it does not find it. Down below is the additional include directories added though as well as in the main project. If I wanted to include the file in C++ it would be found so it is definetly there.

So how would I go about that problem?

 example.thumb.PNG.9ff4a6d30b2c0062bfa81ca6d3b61517.PNGlinking.thumb.PNG.500ae37733b1cb70e4307b460857b167.PNG

Share this post


Link to post
Share on other sites
Posted (edited)

I see, so you might try #include <d3dx_dxgiformatconvert.inl> to search your additional HLSL effects compiler includes? If that doesn't work maybe just put a copy of it alongside the first SnowShaders.hlsl file and see if the compiler still complains? Do you actually have that file d3dx_dxgiformatconvert.inl along your DXSDK_DIR path?

Edited by Steve_Segreto

Share this post


Link to post
Share on other sites

This still does not resolve the problem, so the only solution would be to put all required files into the local folder?example.thumb.PNG.3f56ad32760b0a463155f4d85dd7364c.PNG

Share this post


Link to post
Share on other sites

Shader compiles won't go look in the DXSDK folder for their includes unless you jump through some hoops. The easiest thing to do would be to either copy that .inl file directly into your project or simply lift the functions you want into your own file.

You can just copy the body of these two functions into your code directly:

XMFLOAT2 D3DX_R16G16_FLOAT_to_FLOAT2(UINT packedInput)
UINT     D3DX_FLOAT2_to_R16G16_FLOAT(hlsl_precise XMFLOAT2 unpackedInput)

And if you don't want to drag in extra bits of the file like XMFLOAT2, just use replace "XMFLOAT2" with "float2", "UINT" with "uint" and remove the references to D3DX11INLINE.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!