I have a simpler fragment shader :
struct PSResources
{
constant ConstantBufferStruct& uniforms [[ buffer(1) ]];
texture2d<float> Texture0 [[texture(0)]];
sampler GlobalSampler [[sampler(0)]];
};
fragment float4 SpritePS(VS_OUT in [[stage_in]],
device PSResources & Resources
)
{
//...
}
This only compiles under Language Version 2.0, however reflection says I have 1 input to my fragment function, the Resources "buffer" and the MTLStructType is non null, so I go into it to find 3 members, a MTLDataTypeTexture, MTLDataTypePointer and MTLDataTypeSampler. This all sounds good, but how do I get the binding points ? The MTLStructMember only has an argument index which starts from 0 and increments by 1 for each member, so for GlobalSampler the index is 2 instead of the binding point I'm looking for which is 0. Same goes for uniforms, I need the 1 but I get 0.
I know I can manually move all inputs into the parameters for the fragment function and that "fixes" the issue by having arguments be present in the MTLRenderPipelineReflection.fragmentArguments, but I enjoy having my inputs in a nice structure in case I need to pass resources to functions and having just a single function parameter is way cleaner than having a ton of arguments for all functions.