Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8761995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:25:10+00:00 2026-06-13T15:25:10+00:00

I am trying to add things to my working code, but it is returning

  • 0

I am trying to add things to my working code, but it is returning an error [Invalid Arg] when calling CreateInputLayout().

It works before I add the texture stuff, but fails when I add it.
The shader file compiled with no errors.
I think the way I made the layout is bad. Is this correct?

C++ Vertex structure:

struct VertexData{
    XMFLOAT3 Pos;
    XMFLOAT4 Color;
    XMFLOAT2 TexCoord;
};

C++ Layout:

    D3D11_INPUT_ELEMENT_DESC inputLayout[]={
        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    }; uint lSize=sizeof(inputLayout)/sizeof(inputLayout[0]);

Shader code:

    // Stuff from DX Tutorial 7
Texture2D txDiffuse : register( t0 );
SamplerState samLinear : register( s0 );

cbuffer ViewData : register(b0){
    matrix World;
    matrix View;
    matrix Projection;
}

struct VS_INPUT{
    float4 pos : SV_POSITION;
    float4 color : COLOR0;
    float2 tex : TEXCOORD0;
};
struct PS_INPUT{
    float4 pos : SV_POSITION;
    float4 color : COLOR0;
    float2 tex : TEXCOORD0;
};

PS_INPUT VS(VS_INPUT input){
    PS_INPUT output=(PS_INPUT)0;

    output.pos=mul(input.pos, World);
    output.pos=mul(output.pos, View);
    output.pos=mul(output.pos, Projection);

    output.color = input.color;

    output.tex = input.tex;

    return output;
}

float4 PS(PS_INPUT input) : SV_Target {
    return input.color;
}

Edit:

After a bunch of twiddling with the shader code, I found that if I change the semantics of the…
1st position to: float4 pos : POSITION;
2nd position to: float4 pos : SV_POSITION;
…the input layout successfully creates.

I tried both without the SV_ [system value] prefix, but that also failed. I dont know why I cant have them be the same.

The Semantics seem a bit magical. Not sure if I should answer my own Q with this, or wait for someone smarter to answer better.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:25:11+00:00Added an answer on June 13, 2026 at 3:25 pm

    Your structs do not match:

    struct VertexData
    {
        XMFLOAT3 Pos;  // float3 here
        XMFLOAT4 Color;
        XMFLOAT2 TexCoord;
    };
    
    struct VS_INPUT{
        float4 pos : SV_POSITION; // float4 here
        float4 color : COLOR0;
        float2 tex : TEXCOORD0;
    };
    

    For position in 3D space I prefer to use float3. So, as your input layout:

    "POSITION", 0, R32G32B32_FLOAT
    

    About semantics magic:
    Names in HLSL must match input layout names. For example:

    Layout:

    { "POSITION", 0, .. }
    

    Vertex Shader:

    float4 pos : POSITION0;
    

    The only exception is that pixel shader must always have float4 pos : SV_POSITION semantics for the input position of pixel (It is a one of the System Value semantics).

    And as a bonus, some commonly used stuff I’d like to recommend:

    • int size = ARRYSIZE(inputayoutDesc);
    • use D3D11_APPEND_ALIGNED_ELEMENT instead of 12, 28, numbers as alignment offset.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to transfer the following mockup into working dynamic code but I'm having
I am trying add picture boxes dynamically. My code is as PictureBox picture =
Im new to asp.net mvc. I'm trying add new model class but it got
Trying to add a blank sample app for a rails tutorial to GitHub, but
Trying to add a class object into a List using reflection, but when invoking
I'm trying to generate a call tree for code I'm working on (I didn't
I was working on refactoring some c# code with ReSharper. One of the things
I have the following code that I'm trying to get working. What I want
I am still working on this and I been trying to add in different
I found all things working with alert box,dialog box but when i try creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.