Jump to content
  • Advertisement
Sign in to follow this  
Cigguh

HLSL. Should i change vertex declaration?

This topic is 4227 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 wrote an effect file that works fine but only under PS_2_0, i also wanna make technique to run it under PS_1_1 for better compatibility. I cutted down instructions to make them fit 1_1 version limits but i used all 8 TEXCOORDs for my high quality technique and for low quality one i need only 5 TEXCOORDs. Should i change my vertex declaration from:
    D3DVERTEXELEMENT9 declMesh1[] =
    {
        { 0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_POSITION, 0 },
        { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_NORMAL,   0 },

        { 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 0 },
		{ 0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 1 },
        { 0, 40, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 2 },
		{ 0, 48, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 3 },
        { 0, 56, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 4 },
		{ 0, 64, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 5 },
		{ 0, 72, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 6 },
		{ 0, 80, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 7 },
        D3DDECL_END()
    };

to a:
    D3DVERTEXELEMENT9 declMesh1[] =
    {
        { 0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_POSITION, 0 },
        { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_NORMAL,   0 },

        { 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 0 },
		{ 0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 1 },
        { 0, 40, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 2 },
		{ 0, 48, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 3 },
        { 0, 56, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,  D3DDECLUSAGE_TEXCOORD, 4 },
        D3DDECL_END()
    };

or i can just take them out of my vertexinput structure in shader and directx will handle it by itself? (i hope it will). Thanks for your help.

Share this post


Link to post
Share on other sites
Advertisement
You can get away with keeping the data around, and the full vertex declaration, but it might not be the best idea.

Shader 1 cards are, most likely, going to be slower than shader 2 cards. Forcing them to traverse more data will only hurt them further. I'd strip the data out, if it's not too much trouble.

Vertex input data is fetched/cached on 32 byte boundaries. Your 5 tex vertex is 64 bytes, which works well. Your 8 tex vertex is only 88 bytes, which will ofter require 4 fetches, not just 3. Depending on how your faces refer to your vertices, you might actually see a slight speed boost if you pad this vertex to 96 bytes, as each vertex will only require 3 fetches because it's nicely aligned.

Share this post


Link to post
Share on other sites
IIRC PS1.1 only supports 4 textures, each with one coord set. Does your shader compile with the 5 coord sets?

Share this post


Link to post
Share on other sites
Yeh sure, i forgot. I took 5-th texcoord out for the shader (lil bit later) to compile it under PS1.1

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!