@@ -880,6 +880,10 @@ module Resources =
880880 type VertexInputStateResource ( owner : IResourceCache , key : list < obj >, prog : PipelineInfo , input : aval < Map < Symbol , VertexInputDescription >>) =
881881 inherit AbstractPointerResource< VkPipelineVertexInputStateCreateInfo>( owner, key)
882882
883+ let struct ( maxStride , minStrideAlignment ) =
884+ let limits = owner.Device.PhysicalDevice.Properties.Limits.Vertex
885+ limits.MaxInputBindingStride, limits.MinInputBindingStrideAlignment
886+
883887 override x.Update ( handle , user , token , renderToken ) =
884888 let state = input.GetValue( user, token, renderToken)
885889
@@ -889,8 +893,22 @@ module Resources =
889893 inputs |> List.map ( fun p ->
890894 let sem = Symbol.Create p.paramSemantic
891895 match Map.tryFind sem state with
892- | Some desc -> struct ( p.paramLocation, desc)
893- | None -> failf " could not get vertex input-type for %A " p
896+ | Some desc ->
897+ let stride = uint32 desc.stride
898+
899+ if stride > maxStride then
900+ failf $" stride of vertex input '{sem}' exceeds device maximum (stride is {stride}, maximum is {maxStride})"
901+
902+ if stride < minStrideAlignment then
903+ failf $" stride of vertex input '{sem}' is smaller than device minimum (stride is {stride}, minimum is {minStrideAlignment})"
904+
905+ if minStrideAlignment > 0 u && stride % minStrideAlignment <> 0 u then
906+ failf $" stride of vertex input '{sem}' is misaligned (stride is {stride}, required alignment is {minStrideAlignment})"
907+
908+ struct ( p.paramLocation, desc)
909+
910+ | None ->
911+ failf $" could not get description for vertex input '{sem}'"
894912 )
895913
896914 let inputBindings =
0 commit comments