Jump to content
  • Advertisement
Sign in to follow this  
Hector San Roman Lanza

How can pass a Texture2D array from XNA to HLSL?

This topic is 2141 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!
I am trying send a Texture2D array from XNA in a EffectParameter to a HLSLTexture2DArray variable. The problem: XNA give me an error when i do it: [color=#4A4A4A]

[color=#4A4A4A]cannot convert from 'Microsoft.Xna.Framework.Graphics.Texture2D[]' to 'bool'

The code in XNA file:


Texture2D[] tex;
EffectParameter texArray
texArray.Parameter["xTextures"].SetValue(tex);


The code in HLSL file

Texture2DArray xTextures;

Share this post


Link to post
Share on other sites
Advertisement
Hmmm.... texture arrays aren't supported in DirectX 9 (and hence XNA). I'm surprised the HLSL compiles.

Share this post


Link to post
Share on other sites
It would probably compile alright as the shader compiler is a separate program, and all it knows about is the shader source code, the type of shader (vs, ps, etc) and the shader profile to be used (2_0, 3_0, etc). If the OP had set things up appropriately then there's no reason for the shader compiler to choke on it.

Just for the OP's info, a Texture2DArray in HLSL (for SM4.0+ hardware and with the appropriate API support) does not take an array of Texture2D objects like you are doing. The API defines a Texture2DArray type which is a different type of texture, taking an "arraysize" parameter that defines how many textures are in the array. This is much the same way as 3D textures or cubemaps are different types of textures. E.g. for D3D11 it is specified as part of the D3D11_TEXTURE2D_DESC struct which is used when creating the texture. If your API (XNA in this case) doesn't support this type of texture then you can't use one.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!