1

I'm having problems with the use of constant buffers with arrays, currently I'm sending an array of size 100 for my vertex shader, like this:

/////////////
// DEFINES //
/////////////
#define MAX_NUMBER_INSTANCES 100

/////////////
// STRUCTS // 
///////////// 
struct InstanceInfo 
{ 
   matrix InstanceWorldMatrix; 
   uint CurrentFrame; 
   uint TotalFrames; 
   uint AnimationType; 
   float DeltaTime; 
}; 

///////////// 
// BUFFERS // 
///////////// 
cbuffer InstanceBuffer 
{ 
   InstanceInfo Instance[MAX_NUMBER_INSTANCES]; 
};

And I'm getting wrong results at shader... Here is my C++ buffer: (almost the same)

struct InstanceInfo
{
     D3DXMATRIX worldMatrix;
     unsigned int currentFrame;
     unsigned int totalFrames;
     unsigned int animationType;
     float deltaTime;
};

The buffer is initialized correctly with the size: sizeof(InstanceInfo)*MAX_NUMBER_INSTANCES (MAX_NUMBER_INSTANCES in my c++ code is 100 too) and the data is copied correctly too. (I double checked them)

I know that there is the packing rule but I cant find where is my error (probably is in front of me but I cant see it...)

If someone can help me...

1 Answer 1

2

Ok I solved the problem, if anyone is having this same problem remember to see if the previous buffer is working correctly first (this can cause a ripple effect on all upcoming buffers)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.