Sign in to follow this  

[dx10] uploading uint to shader

This topic is 3842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im uploading data to a shader like this:
struct Projector
{
	float4x4	worldViewIT 		: WorldViewInverseTranspose;
	float4x4	worldIT 			: WorldInverseTranspose;
	float4x4	worldViewProj 		: WorldViewProjection;
	float4x4	cameraWorld			: Camera;
};

struct InstanceData
{
	float4x4	cameraWorld			: Camera;
	float4x4	worldIT 			: WorldInverseTranspose;
	float4x4	worldViewProj 		: WorldViewProjection;
	float4x4	world 				: World;	

	Projector	projector[8]		: Projector;
	uint		projectorCount		: ProjectorCount;

};

InstanceData  gInstance[MAX_INSTANCE_CONSTANTS] : InstanceData;

problem im having is that im guessing uint is 4 bytes, but when i upload data, rendering is wrong, like some matrix values are offset. so either uint doesnt take 4 bytes, OR strats have some alignment? if i comment out the uint, all works correctly :-/

Share this post


Link to post
Share on other sites
Constant buffers have some additional aligment rules as the buffers are organized as 4 elements vectors were each element have 4 bytes. Therefore InstanaceData should be padded to the next multiple 16 byte size.

There may be some other aligment rules active. You should use shader reflection or take at leat a look at the disassambeld shader to get the real layout of the constant buffer.

Share this post


Link to post
Share on other sites

This topic is 3842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this