Why not use DXGI_FORMAT_R11G11B10_FLOAT? There's plenty of nice formats. Or a single R32_UINT and pack your normal manually, no big deal. No need to ever use R32G32B32_FLOAT format for normals transfer! If you can have normals in screen-space, definitely go pack them according to one of the methods linked. I use #4 to my greatest pleasure in screen space (1 float3 to float2 (stored as R16G16_FLOAT)).
Regarding HLSL, you just write your float, float2, float3, whatever happily and depending on the bound target view (RTV, DSV, UAV?) format, the conversion happens automatically. There is no HLSL construct for "half", there is no need.
There is no sense of packing data in between the shader stages (such as from vertex shader to hull shader or such). You can happily send i.e. R8_UNORM buffers to input assembler (or bind them as SRV) and your shaders see whatever type (such as float) automatically. The same at output.
I'd split your struct into separate streams of positions, normals, temperatures etc, with formats R32G32B32_FLOAT, R11G11B10_FLOAT, R8_UNORM, etc., for example.
I think you misunderstand what I'm doing, though it is perfectly possible that I'm misunderstanding what you're suggesting.
The generated data comes from a compute shader, which is not part of the normal rendering pipeline.
It is stored in a structured buffer, which can only contain hlsl data types (afaik), and as you mentioned, half is not available.
If I was able to use formats such as R11G11B10_FLOAT there would be no issues.
For the view space normals in my geometry buffer I do in fact use an R16G16 format with packing method #4 and it works brilliantly.
Have you considered alignment of data ?
struct PlanetVertex
{
float3 Position;
float3 Normal;
float Temperature;
float Humidity;
};
That's 2x 4-component vectors, considering that you want the data aligned, using 16 instead of 32 bit could be your best bet.
Well... no. I have not.
Do I have to consider this with structured buffers?
Right now I have this:
struct PlanetVertex
{
float3 Position;
uint2 PackedNormalTempHumidity;
};
With PackedNormalTempHumidity being packed as
X = float2(Normal.x, Normal.y)
Y = float2(Temperature, Humidity)
Though there are some minor precision issues with the 2 channel normal vector when z is close to 0
I might go for something like this instead:
struct PlanetVertex
{
float3 Position;
uint2 PackedNormalTemp
uint PackedHumiditySomethingelse;
};
With a 3 channel normal vector with 16bit/channel
Edited by Hyunkel, 06 June 2012 - 09:25 AM.