• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

#ActualFlicklizic

Posted 19 March 2013 - 09:27 AM

Hello, 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... 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...

#4Flicklizic

Posted 19 March 2013 - 09:19 AM

Hello, 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... 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 initialize correcly 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...

#3Flicklizic

Posted 18 March 2013 - 08:37 PM

Hello, 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 BoneMatrixBuffer
{
InstanceInfo Instance[MAX_NUMBER_INSTANCES];
};


And I'm getting wrong results... 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 initialize correcly 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...

#2Flicklizic

Posted 18 March 2013 - 08:15 PM

Hello, 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 BoneMatrixBuffer
{
InstanceInfo Instance[MAX_NUMBER_INSTANCES];
};


And I'm getting wrong results... 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 initialize correcly 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...

#1Flicklizic

Posted 18 March 2013 - 08:14 PM

Hello, 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 BoneMatrixBuffer { InstanceInfo Instance[MAX_NUMBER_INSTANCES]; };

And I'm getting wrong results... 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 initialize correcly 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...

PARTNERS