Jump to content
  • Advertisement
Tubby94

DX12 Multiple vertex buffers and Input slots Question

Recommended Posts

EDIT: I have now solved my problem after trail and error

 

Hi All,

I'm following Frank Luna's book, Introduction to 3D Game Programming with Directx 12, and have come to the point where there is an exercise to create a cube using 2 Vertex buffers; one for position, and one for color. I'm then supposed to bind these to different Input slots(0 and 1).

All is fine except my color data seems to be misinterpreted by the pipeline, no matter what color I specify to the vertices in my buffer, the cube will still be rendered as a predetermined assortment of colors. Am I missing anything important to achieving this goal? these are the steps I took so far:

Used Two vertex buffers to feed pipeline with vertices

struct VPosData {XMFLOAT3 Pos; };

struct VColorData {XMFLOAT4 Color; };  

Changed INPUT_ELEMENT_DESC accordingly

mInputLayout =
{
    { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, 
          D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },

    { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, 
         D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }
};

Bound the two vertex buffers to the input slots

mCommandList->IASetVertexBuffers(0, 1, &mBoxGeo->VertexBufferView()); //Input Slot 0 for verts

mCommandList->IASetVertexBuffers(1, 1, &mBoxGeo->VertexBufferView()); //Input Slot 1 for Color

The Textbook doesn't specify any extra steps to achieve this result, so at this point I'm not sure how to go about debugging this problem. Any feedback would be appreciated.

Edited by Tubby94
solved

Share this post


Link to post
Share on other sites
Advertisement
2 minutes ago, turanszkij said:

Seems to me like you are binding the same buffer twice, which is probably not what you want.

Yeah I figured this out after a lot of trail and error, I had to create another buffer that will hold the color data. Thanks for the reply

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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!