I think I still need to understand better how to use constant buffers.
I have a constant buffer with just two floats declared:
C++ struct:
struct ConstantBuffer
{
float value0;
float value1;
} g_CBData;
.
And in the Vertex Shader I'm just trying to multiply the color by the Sin() of any of these two values:
cbuffer cbPerFrame : register (b0)
{
float value0;
float value1;
};
struct VSInput
{
float3 Pos : POSITION;
float4 Col : COLOR;
};
struct VSOutput
{
float4 Pos : SV_POSITION;
float4 Col : COLOR;
};
VSOutput main( VSInput vs_in )
{
VSOutput vs_out;
vs_out.Pos = float4( vs_in.Pos, 1 );
vs_out.Col = vs_in.Col * sin( value1 ); // "value0" runs ok, "value1" causes E_INVALIDARG
return vs_out;
}
If I use "value0" everything runs well, however, if I use "value1" then I get an E_INVALIDARG when creating the VertexShader:
R = g_pDirect3D->CreateVertexShader( pVSData, vsSize, nullptr, &g_pVertexShader );
.
The weird thing is that if I don't use the sin() function (i.e. I just multiply Color * value1):
vs_out.Col = vs_in.Col * value0; // runs ok
vs_out.Col = vs_in.Col * value1; // runs ok
Then the values are read correctly.
Also I can't multiply value0 * value1, nor sum or anything between these two values.. when I do, I just get the E_INVALIDARG error.
Is there any strange rule when using the values from a constant buffer?
Thanks