Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am trying to pass in a uint4 into the shader but my input layout keeps failing when trying to load the shader.

shader.fx

uint4  values : UINT4_0;  // VertexInput

Input layout

{ "UINT4", 0, DXGI_FORMAT_R32G32B32A32_UINT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 }

Does that seem right?

I am a bit confused why there is an error here.

share|improve this question
    
What is the error? –  Josh Petrie Jan 9 '14 at 23:51
    
@JoshPetrie I haven't written the handle for the Sysout for the error. My program just crashes trying to CreateInputLayout which almost 100% of time for me was because of an error in the input description. And this was the only thing I changed which caused to me to get the error. And I can't for the life of me figure where the input description is not correct. This issue was also caused when I tried to input a semantic that had a number attached to it...i.e. "FLOAT4_0" and "UINT4_0", however input semantics like "COLOR0" and "POSITION0" always work. –  bluejamesbond Jan 9 '14 at 23:54
    
For a semantic called UINT4_0 in the shader, you probably need to set the name to "UINT4_" in the input layout, not "UINT4". –  Nathan Reed Jan 10 '14 at 1:40
    
@NathanReed Yes, that works. I have added that to answer. –  bluejamesbond Jan 10 '14 at 5:08

1 Answer 1

up vote 0 down vote accepted

I found a way to do this and I thought I will post it here since it will help others. In order to pass in a UINT4 into an HLSL, you must have the following:

1. InputLayout

{ "UINT4_", 0, DXGI_FORMAT_R32G32B32A32_UINT, 0, D3D10_APPEND_ALIGNED_ELEMENT, D3D10_INPUT_PER_VERTEX_DATA, 0 }

2. InputVertex

 uint4 valuesUnsigned: UINT4_0;   

3. Input Data Structure

struct UINT4__
    {
        unsigned int a1;
        unsigned int a2;
        unsigned int a3;
        unsigned int a4;

        UINT4__(){};

        UINT4__(unsigned int x, unsigned int y, unsigned int z, unsigned int w)
        {
            a1 = x;
            a2 = y;
            a3 = z;
            a4 = w;
        }
    };

EDIT: Added what NathanReed has said in one of his comments on this question.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.