Jump to content
  • Advertisement
Sign in to follow this  
wforl

Typless InputLayout

This topic is 3046 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

Is it possible to have a typeless vertex layout? So that instead of having a mass of different vertex descriptions, which all result in the same number of bytes per vertex, you just define a number of fixed types, say 4float, 8float and 12float types, and then let the vertex shader interpret the data in each vertex by the vertex shader input signature.

For example, I would like to define these vertexDescriptions :


D3D10_INPUT_ELEMENT_DESC vertexDesc4Float[] =
{
{"1", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}
};

D3D10_INPUT_ELEMENT_DESC vertexDesc8Float[] =
{
{"1", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"2", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}

};

D3D10_INPUT_ELEMENT_DESC vertexDesc12Float[] =
{
{"1", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"2", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
{"3", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}
};



And then use them in some VertexShader like this. ( vertexDesc8Float in this example )


struct VS_IN // 8 floats
{
float3 Pos;
float Opacity;
float2 UV1;
float2 UV2;
};

VS_OUT VS(VS_IN vIn)
{
}

// or maybe

struct VS_IN // 8 floats
{
float3 Pos;
float Opacity;
float2 UV1;
float Param1;
float Param2;
};

VS_OUT VS(VS_IN vIn)
{
}



The only way I can see to do this, is something messy like the following, but was wondering if there was a better way?


struct VS_IN // 8 floats
{
float4 f1 : 1;
float4 f2 : 2;
};

VS_OUT VS(VS_IN vIn)
{
float3 Pos = f1.xyz;
float Opacity = f1.w;
float2 Uv1 = f2.xy;
float2 Uv2= f2.zw;
}

struct VS_IN // 8 floats
{
float4 f1 : 1;
float4 f2 : 2;
};

VS_OUT VS(VS_IN vIn)
{
float3 Pos = f1.xyz;
float Opacity = f1.w;
float2 Uv1 = f2.xy;
float Param1 = f2.z;
float Param2 = f2.w;
}

Share this post


Link to post
Share on other sites
Advertisement
No, this could not work as the Semantic Name of the input elements is used to find the right element for the input signature register.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!