I would like some guidance on how to best parallelize this loop. I've played 
around with the parallel: macro, and using spawn, but haven't gotten a working 
solution yet. It isn't entirely clear what the best approach should be:
    
    
    for i,face in faces:  #face is a path to an image file
        var width,height,channels:int
        #loads and decodes jpgs/pngs from disk returning a seq[byte]
        let data = stbi.load(face,width,height,channels,stbi.Default)
        if data != nil and data.len != 0:
            let target = (GL_TEXTURE_CUBE_MAP_POSITIVE_X.int+i).TexImageTarget
            #sets up opengl texture
            glTexImage2D(target.GLenum,
                         level.GLint,
                         internalFormat.GLint,
                         width.GLsizei,
                         height.GLsizei,
                         0,
                         format.GLenum,
                         pixelType.GLenum,
                         data[0].unsafeAddr)  #error on this when using 
parallel:
        else:
            echo "Failure to Load Cubemap Image"
    

When I try to just use the parallel: macro I get: Error: cannot prove: 0 <= 
len(data) + -1 (bounds check)

I also experimented with spawn but wasn't clear on how to use that well. 

Reply via email to