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

Started by
4 comments, last by XVincentX 15 years, 4 months ago
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?
Advertisement
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?
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'
Innovation not reiterationIf at any point I look as if I know what I'm doing don't worry it was probably an accident.
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?
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.
Innovation not reiterationIf at any point I look as if I know what I'm doing don't worry it was probably an accident.
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)

This topic is closed to new replies.

Advertisement