0
\$\begingroup\$

I have a vs_2_0 shader like this:

struct ConstantBuffer
{
    float4 diffuse;
    float4 specular
};

shared uniform ConstantBuffer g_cb : app_constantBuffer;

void PS(out float4 Color: COLOR0)
{
    Color = g_cb.diffuse;
}

The above example is simple, the constant buffer only stores two 4 component colors. I want to set the constant buffer before binding the pixel shader. I do not want to use the ID3DXEffect interface.

The IDirect3D9Device interface only provides methods for setting primitive types...I want to set the entire struct at one time. Is this possible?

\$\endgroup\$
1
\$\begingroup\$

D3D9 doesn't support constant buffers but all uniforms are placed into one global "constant buffer". You can set multiple float4 constants at once with IDirect3DDevice9::SetPixelShaderConstantF() by passing the number of constants as the last argument.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.