Sorting

I am trying to write a fragment shader that sorts a part of a texture. Each thread is responsible for sorting a part. Perhaps this is not the most efficient way, but this is how I need to do it now. I wrote the following code, which works with a data set and fails with another (I think the shader halts with no output).

 minDepth=100000.0;
    minEpoint=float(count)+10.0;

    for(int j=0;j<2*count;j++) //to find min
    {

        EpointIndexGlobal = 2*offset+j;

        EpointIndexGlobalX=EpointIndexGlobal%EpointsNumSqrt;
        EpointIndexGlobalY=EpointIndexGlobal/EpointsNumSqrt;


        info = texelFetch(TmpEpointsImage, ivec2(int(EpointIndexGlobalX),int(EpointIndexGlobalY)),0);

        Depth=info.x;
        Epoint=info.z;

        if(lessThan(Depth,Epoint,minDepth,minEpoint) && greaterThan(Depth,Epoint,lastDepth,lastEpoint))
        {
            minDepth=Depth;
            minEpoint=Epoint;
            minInfo=info;
        }

    }

    EpointIndexGlobal = 2*offset+i;
    EpointIndexGlobalX=EpointIndexGlobal%EpointsNumSqrt;
    EpointIndexGlobalY=EpointIndexGlobal/EpointsNumSqrt;

    imageStore(EpointsImage,  ivec2(EpointIndexGlobalX,EpointIndexGlobalY), minInfo);

    lastDepth=minDepth;
    lastEpoint=minEpoint;

}

I read vec4 values from tmpEpointsImage and sort in EpointsImage. Sorting is performed according to two values. Does anyone know what is the problem?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.