Sign in to follow this  

DX10: Can't set values in the fx constant buffer

This topic is 3295 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

I understand from my past post that Mr Jack Hoxley suggest the use of constant buffer. However I can't seem to setup the constant buffer. After copying in the matrices into the buffer and setting it in the ID3D10Effect, nothing turns up on screen. If I set the values using the normal pEffectMatrix->SetMatrix(), everything works as expected. Effect file cbuffer decleration:
cbuffer cbPerFrame : register(b0)
{
   float4x4 World      : WORLD : packoffset(c0);
   float4x4 View       : VIEW : packoffset(c4);
   float4x4 Projection : PROJECTION : packoffset(c12);
};

Texture2D <float4> DiffuseTexture	: DIFFUSE_TEXTURE;

CPP File:
Desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
Desc.Desc.ByteWidth = sizeof(float) * 48;
Desc.Desc.Usage = D3D10_USAGE_DEFAULT;
Desc.Desc.CPUAccessFlags = 0;
Desc.MiscFlags = 0;

//... create buffer etc

std::vector<BYTE> SystemCopy;
SystemCopy.resize(sizeof(float) * 48);

//Per Frame:
memcpy(&SystemCopy[0], &World, sizeof(D3DXMATRIX));
memcpy(&SystemCopy[64], &World, sizeof(D3DXMATRIX));
memcpy(&SystemCopy[128], &World, sizeof(D3DXMATRIX));
pD3DDevice->UpdateSubresource(pCBuffer, 0, 0, &SystemCopy[0], 0, 0);

pEffectConstantBufferVariable->SetConstantBuffer(pCBuffer);

//... set the textures and other stuff and draw....

I got the offset location to copy from the D3D10_EFFECT_VARIABLE_DESC.BufferOffset member field. Am I missing anything? or am i suppose to ditch the ID3D10Effect framework and go with the VS, PS, GS individually?

Share this post


Link to post
Share on other sites
As i know, ID3D10Effect has got A LOT, A LOT A LOT A LOT of bugs. It make mistakes also in variables order. For example, textures MUST be ever the last places variables, else PixelShader won't see the assignement.


texture2D text;
float i;
// NO.

float i;
texture2D text;
//ok


I sent email to microsoft, who did never answer.
I do not know, how to recognize if set a resource with VS, PS or GS functions?

Share this post


Link to post
Share on other sites
Quote:
Original post by XVincentX
For example, textures MUST be ever the last places variables, else PixelShader won't see the assignement.


You could be right, but are you really sure because even the BasicHLSL10 demo breaks this 'rule'

Share this post


Link to post
Share on other sites
Does that mean I should just forget about using the ID3D10Effect framework?

Do most games uses the ID3D10Effect framework? or do they manage the VS, PS, GS and State manually?

Share this post


Link to post
Share on other sites
Unless you run into some really nasty bug then maybe sticking to Effect framework would be worthwhile to ease development. It seems a decent abstraction of the shader pipeline and if you design your code with its removal in mind then it should be possible to write your own shader control later, this is an approach I am taking.

Share this post


Link to post
Share on other sites
The ID3D10Effect framework it's the worse interface i've ever seen in all the DirectX SDK of the world.

ID3DXEffect of D3D9 worked, was better and had the simple function SetValue that simply with a void*...anyway...

Forget about it if you do not want to spend 30-40 min to understand why your shdaer does not work (like me)

Share this post


Link to post
Share on other sites

This topic is 3295 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