Handkor

I'm am trying to read height data from a texture to my vertex shader in XNA with tex2Dlod and I have come across a difference in setting between PC and XBOX360 and I was wondering if anyone could clarify.

On my PC I can fetch data without any problems using floating point texture using SurfaceFormat.Vector4. Now just from compiler errors I know the 360 does not support Vector4 textures but Single or Vector2 are supported except that when reading from the texture I get garbage unless I use SurfaceFormat.Color.

My initialization for my texture is now:

#if XBOX360
planetHeightMap = new RenderTarget2D(graphicsService.GraphicsDevice, 1024, 1024, 1, SurfaceFormat.Color);
#else
planetHeightMap = new RenderTarget2D(graphicsService.GraphicsDevice, 1024, 1024, 1, SurfaceFormat.Vector4);
#endif


So color does not work on PC and Vector4 does not work on the 360, does anyone have more information on why this is and what does the 360 support


Re: XNA Game Studio Express HLSL's tex2Dlod (Vertex Shader texture fetch) difference between PC and XBOX360?

Joel Martinez

Handkor wrote:

So color does not work on PC and Vector4 does not work on the 360, does anyone have more information on why this is and what does the 360 support
I agree that this would be pretty handy stuff to have documented. To add to this question, I think there should be a listing of the differences between the xbox and pc shader model support. see this post where Shawn Hargreaves says:

"XNA supports all the DX9 shader models on Windows (1.1, 1.3, 1.4, 2.0, 3.0). On Xbox it supports shader model 2.0, plus an extended Xbox-customised variant of 3.0."





Re: XNA Game Studio Express HLSL's tex2Dlod (Vertex Shader texture fetch) difference between PC and XBOX360?

Kyle0654

Windows supports the Color format (at least mine does). I'm hoping the Xbox supports the Alpha8 texture format, or I'm going to have to again recode a lot (it's tough coding for Xbox without an Xbox on hand).

I understand that the XNA team is pretty busy and probably doesn't have time to write up a lot of documentation (though I must admit some more documentation on this sort of thing would have been nice - it'd probably have saved time in the long run). The msdn2 documentation has some information on what's supported on Xbox, with an X being placed next to supported members (e.g. http://msdn2.microsoft.com/en-us/library/system.xml.xmlreader_members.aspx). However, there's no information on things like what surface formats are supported on the Xbox (http://msdn2.microsoft.com/en-us/library/microsoft.xna.framework.graphics.surfaceformat.aspx) or what the shader models offer that might be different from standard.

Perhaps a webpage or a wiki for this information, managed by the community, would be helpful Then we could ask questions here as they come up and gather information that may be helpful in the future.





Re: XNA Game Studio Express HLSL's tex2Dlod (Vertex Shader texture fetch) difference between PC and XBOX360?

Shawn Hargreaves - MSFT

For textures, Xbox supports pretty much every format there is, including 128 bit Vector4 textures (I say "pretty much" because I can't be bothered to go through the entire huge list in the native docs checking them all off right now, but I've never met one it doesn't support).

For rendertargets, the support is more limited: you have Color, 10.10.10.2, Rg32, Rgba64, HalfVector2, HalfVector4, Single, and Vector2. Notably you cannot render to Vector4 surfaces.

You cannot alpha blend when using a floating point rendertarget, and cannot do filtering when sampling from floating point textures, so make sure you select point sampling when using such data. I'm guessing this is the problem the original poster is running into: if you use anything other than point sampling on a floating point texture, it will probably just try to do linear interpolation as if the bit values were integers, which gives garbage results for float data.

We're working on getting the HLSL docs updated to cover the Xbox shader model in more detail.

Addendum: I found this table in the native XDK docs, listing Windows texture formats that are not supported on Xbox. Probably quicker than listing all the ones that are:

// The following are not supported on Xbox 360:
//
// D3DFMT_A8R3G3B2
// D3DFMT_R3G3B2
// D3DFMT_S1D15
// D3DFMT_S8D24
// D3DFMT_X8D24
// D3DFMT_X4S4D24
// D3DFMT_A8P8
// D3DFMT_P8
// D3DFMT_A4L4
// D3DFMT_R8G8B8
// D3DFMT_D16_LOCKABLE
// D3DFMT_D15S1
// D3DFMT_D24X4S4
// D3DFMT_D32F_LOCKABLE
// D3DFMT_LIN_D32
// D3DFMT_D32






Re: XNA Game Studio Express HLSL's tex2Dlod (Vertex Shader texture fetch) difference between PC and XBOX360?

Handkor

Thanks I'll try tonight with point sampling. My original code in DirectX was set to point sample and last night I only did a quick test reading from my diffuse map sampler, which is set to linear, instead of an actual displacement map.

The only thing that I'll miss but can easily work around was rendering position to a Vector4 surface and then using it for screen space post processing effects, but most of these can be replaced by only storing depth.





Re: XNA Game Studio Express HLSL's tex2Dlod (Vertex Shader texture fetch) difference between PC and XBOX360?

Shawn Hargreaves - MSFT

You may also find HalfVector4 useful in place of Vector4. Depending on what you're doing, that often has enough precision for the same kind of usages.