Fragment Function(visualizeScalar): missing buffer binding at index 0 for bufferData[0] after modifying buffer

So I have changed StaticData from

Code Block
struct StaticData
{
var positions: FloatTuple
var impulses: FloatTuple
var impulseScalar: SIMD2<Float>
var offsets: SIMD2<Float>
var screenSize: SIMD2<Float>
var inkRadius: simd_float1
}


into this

Code Block
struct StaticData
{
var positions: FloatTuple
var impulses: FloatTuple
var impulseScalar: SIMD2<Float>
var offsets: SIMD2<Float>
var screenSize: SIMD2<Float>
var inkRadius: simd_float1
var red: CFloat
var green: CFloat
var blue: CFloat
}


The problem is that when I use red/green/blue in visualiseScalar it shows the error

Code Block
Fragment Function(visualizeScalar): missing buffer binding at index 0 for bufferData[0] after modifying buffer


I sincerely stuck at this. Follows code of bufferData and visualiseScalar, could be helpful probably
Code Block
fragment half4 visualizeScalar(VertexOut fragmentIn [[stage_in]], texture2d<float, access::sample> tex2d [[texture(0)]], constant BufferData &bufferData [[buffer(0)]])
{
constexpr sampler sampler2d(filter::nearest);
half4 color = half4(tex2d.sample(sampler2d, fragmentIn.textureCoorinates));
return half4(half3(bufferData.red, bufferData.green, bufferData.blue) * abs(color.xxx), 1.0);
}

That's makeBuffer line (staticData = StaticData)

Code Block
let buffer = MetalDevice.sharedInstance.device.makeBuffer(bytes: &staticData, length: bufferSize, options: .storageModeShared)!
uniformsBuffers.append(buffer)

First question to get more context.

You say tou receive error message:

Fragment Function(visualizeScalar): missing buffer binding at index 0 for bufferData[0] after modifying buffer

Is it swift code (as the tag seems to tell) ?

If so, is Function a func or yours (should be as it unusually starts with Uppercase) ?
Where is the Fragment keyword coming from ? Is it MetalKit or a 3rd party library ?

So, please provide more information (it was not either in your SO post that you replicated here)
I'm really unclear on what you're trying to do here. Is this StaticData Swift structure what you're passing in to the kernel as BufferData? If so, one big problem you will have is that because Swift doesn't guarantee any particular layout of data in a structure, it's not likely to match what the Metal shader uses for the layout. You really should specify the specify the structure in C and include it in a bridging header so your Swift code can access it. C Structs specified in a bridging header will use the layout defined by C so, if you also include that struct in your Metal shading code, the layouts will match.

That said, this wouldn't cause the error you're seeing (you'd just run into that problem after you fixed the error you're seeing).

Can you show the code where you set the buffer in the RenderCommandEncoder object, set the render state pipeline, and draw with that pipeline?
Fragment Function(visualizeScalar): missing buffer binding at index 0 for bufferData[0] after modifying buffer
 
 
Q