Shadow mapping with multiple shadow matrices in HdStorm

Hello everyone,

i enabled shadow mapping for HDStorm, to render my custom scene index. This works well as long as i only specify one shadow matrix and therefore one shadow texture is generated.
However, as soon as i specify more than one shadow matrix to achieve a cheap way of fake cascaded shadow maps it only works, if there is no other texture bound to the USDPreview shader. If there is another texture bound, it will try to bind this to a slot, where the other shadow textures are bound and the shader won’t compile. Is this a bug or are multiple shadowmaps not yet supported by HDStorm? I am at OpenUSD 24.08, Metal HGI.

This is my shadow matrix initialization code for 4 shadow maps:

class ShadowMatrix : public HdxShadowMatrixComputation
{
public:
ShadowMatrix(GlfSimpleLight const& light)
{
GfFrustum frustum;

    int shadowWidth = 8;
    int shadowWidth2 = 50;
    int shadowWidth3 = 200;
    int shadowWidth4 = 1000;

    frustum.SetProjectionType(GfFrustum::Orthographic);
    GfVec4d pos = light.GetPosition();
    pos = pos.GetNormalized() * shadowWidth;
    frustum.SetOrthographic(-shadowWidth, shadowWidth, -shadowWidth, shadowWidth, -shadowWidth, shadowWidth);

    GfMatrix4d viewMatrix;
    viewMatrix.SetLookAt(GfVec3d(0.0, 0.0, 0.0), -GfVec3d(pos[0], pos[1], pos[2]), GfVec3d(0.0, 0.0, 1.0));

    _shadowMatrices.clear();
    _shadowMatrices.push_back(viewMatrix * frustum.ComputeProjectionMatrix());

    frustum.SetOrthographic(-shadowWidth2, shadowWidth2, -shadowWidth2, shadowWidth2, -shadowWidth2, shadowWidth2);
    _shadowMatrices.push_back(viewMatrix * frustum.ComputeProjectionMatrix());

    frustum.SetOrthographic(-shadowWidth3, shadowWidth3, -shadowWidth3, shadowWidth3, -shadowWidth3, shadowWidth3);
    _shadowMatrices.push_back(viewMatrix * frustum.ComputeProjectionMatrix());

    frustum.SetOrthographic(-shadowWidth4, shadowWidth4, -shadowWidth4, shadowWidth4, -shadowWidth4, shadowWidth4);
    _shadowMatrices.push_back(viewMatrix * frustum.ComputeProjectionMatrix());
}

}

Shader compilation error:
Warning: in _ValidateCompilation at line 212 of /pxr/imaging/hdSt/glslProgram.cpp – Failed to compile shader (POST_TESS_VERTEX_SHADER): program_source:2154:34: error: cannot assign resource locations to ‘samplerBindings’
const device MSLSamplerBindings *samplerBindings[[buffer(28)]],
^
program_source:584:9: note: attribute ‘id’ set location to 1, but minimum is 4
sampler samplerBind_diffuseColor[[id(1)]];
^ ~~~~~
program_source:2155:34: error: cannot assign resource locations to ‘textureBindings’
const device MSLTextureBindings *textureBindings[[buffer(29)]]){
^
program_source:592:18: note: attribute ‘id’ set location to 1, but minimum is 4
texture2d textureBind_diffuseColor[[id(1)]];
^ ~~~~~

Error Context:

#define bvec2 bool2
#define bvec3 bool3
#define bvec4 bool4
#define dvec2 float2 <<< ERROR!
#define dvec3 float3
#define dvec4 float4
#define dmat2 float2x2

Coding Error: in _GetDrawingProgram at line 391 of /pxr/imaging/hdSt/drawBatch.cpp – Failed to compile shader for prim /InstancedCubePrototype_x_0_y_0_z_0.