Jump to content

  • Log In with Google      Sign In   
  • Create Account

How can pass a Texture2D array from XNA to HLSL?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 ShotoReaper   Members   -  Reputation: 149

Like
0Likes
Like

Posted 12 July 2012 - 09:53 AM

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:

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;


Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 3921

Like
0Likes
Like

Posted 12 July 2012 - 10:11 AM

Hmmm.... texture arrays aren't supported in DirectX 9 (and hence XNA). I'm surprised the HLSL compiles.

#3 mhagain   Crossbones+   -  Reputation: 7978

Like
2Likes
Like

Posted 12 July 2012 - 03:57 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#4 ShotoReaper   Members   -  Reputation: 149

Like
0Likes
Like

Posted 13 August 2012 - 12:56 PM

Ok, thanks for the answers!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS