about Shader Arrays, Reflection and BindCount

Started by
0 comments, last by MJP 10 years, 10 months ago

Hi,

I have a question about DirectX 11. I wrote a shader containing an input array (RWTexture2D<float4> TextureOut[8]).

The shader reflection interface now tells me that there are 8 bind points with names like this

"TextureOut[0]"

"TextureOut[1]"

...

Since the D3D11_SHADER_INPUT_BIND_DESC structure contains a 'BindCount' field I had rather expected a single

resource binding with the name 'TextureOut' and a BindCount of 8. Why do I get 8 seperate bindings with bind count 1 instead?

I now wonder what the BindCount field is actually for and in which scenario it is larger than one?

Can anyone demystify this aspect of directX for me? Unfortunately the documention isnt much of a help.

Advertisement

Arrays of textures in shaders are really just a syntactical convenience, the underlying shader assembly doesn't actually have any support for them so the compiler just turns the array into N separate resource bindings. So it doesn't surprise me that the reflection interface would report it as N separate resource bindings, since that's essentially how you have to treat it on the C++ side of things.

It does seem weird that the BIND_DESC structure has a BindCount fieldthat suggests it would be used for cases like these, but I suppose it doesn't actually work that way. I wonder if that field actually gets used for anything.

This topic is closed to new replies.

Advertisement