Material::getParamStruct not finding param


#1

I have a cbuffer in a shader, and I’m trying to get a handle to a struct within that cbuffer. I get a warning - “Material doesn’t have a parameter named xxx”. I’m able to use getParamFloat to get a handle to a float in that cbuffer, but not the struct version.

I’m also having problems setting values for arrays within a cbuffer (using the setVecX with an array index), which prompted me to try the struct version in the first place. I get a warning that says the size of the array is 1 when i try to set any index higher than 0, regardless of what size i set in the shader.


#2

What platform and render backend is this happening on?


#3

Also, if you could you post the shader that’s having the problem, or at least a snippet in question.


#4

Platform is Windows 10. Using whatever the default render backend is – I compiled from source using the compiling instructions on github, using Visual Studio 2017.

I made a copy of the standard Diffuse.bsl shader and added a struct and a cbuffer:

     struct TestStruct
     {
	float4 p;
     };

cbuffer TestBuffer
{
	TestStruct testStruct;
	float testFloat = 15.0;
	float2 testArray[4];
}

I can access testFloat from C++ and set/get the value.

For the struct, I get a warning “Material doesn’t have a parameter named testStruct” using material->getParamStruct(“testStruct”);

For the array, I can set the 0 element with material->setVec2(“testArray”, v, 0), but any non-zero index gives me a warning: “Array index out of range. Provided index was 1 but array length is 1”. Looping through the array in the shader, the 0 element is what i set it as in C++, but the rest are zeroed out.


#5

Thanks, I’ve identified the issue. I should have a fix available in a matter of few days.


#6

Great, thanks for the help!


#7

I’ve submitted a fix on master - arrays and structs should now both work. With structs be careful to respect the padding & alignment as expected by the render backend, as it might not be the same as of your compiler.