Textured Models in Ray Tracing

Usually a ray tracer use a single compute shader to do the shading of the entire scene. Is there a way in Metal to bind arbitrary number of textures to a signle shader? An array of textures seems not a solution because it need a fixed number as its size.