I have a MTLBuffer attached to my fragment shader and data format of this MTLBuffer is an struct which has an array of another struct and a count variable as given below
struct Data{//has some vector variables};
Struct Lights {
Int light_count;
Data light_data[10]; };
I just populate 1 light data in the mtlbuffer means mtlbuffer is not fully populated . So in this case, fragment function becomes too slow if I change array size of light_data to 1 and then fragment shader becomes fast.
Another thing if I populate mtlbuffer fully and access light_data in for loop in my fragment function then again it becomes too slow.
Does anybody have any idea why this problem is there? and please tell me any solution to make fragment function fast ? or should I format my Lights struct in different way so that fragment function can access it fast.