Repeatedly read colour of rendertarget within shader

Good day people,

I’m trying to implement some fairly complex shader which calculates a 2D shadowmap based on a 2D occlusionmap using raytracing.

For this, I’ve got a shader which aims draws to an Nx1 rendertexture. The shader executes a relatively large loop for each pixels, stepping over the occlusionmap and returning the distance if it steps on an occluder. As a result the shader draws an Nx1 texture with the length of each ray. This shader is working.
However, because of the compiler target I can only do 64 steps in the shader loop at a time. The problem is that I need to somehow implement more steps.

Main question

Now I was thinking it might be possible to do more steps in multiple shader calls. The idea was that the shader reads the distance stored on the previous call and then starts the iteration from there. The problem is that this requires me to read from the rendertarget within the shader, and I can not get this to work. I have tried passing the rendertarget as a texture as follows:

graphics.SetRenderTarget(LosRaycastMap);

graphics.Clear(Color.White); 

for (int i = 0; i < losRaycastSetting.RayStepIterations; i++)
{
    LosRaycastEffect.Parameters["xTexture"].SetValue(LosRaycastMap);
    LosRaycastEffect.CurrentTechnique.Passes[0].Apply();
    Quad.Render();
}

graphics.SetRenderTarget(null);

Quad.Render uses DrawIndexedPrimitives to draw vertices with UVs at the texture corners. Then in the shader I sample xTexture with

Texture2D xTexture;
sampler TextureSampler : register (s0) = sampler_state { Texture = <xTexture>; };

// ...
float4 rayCast64(VertexShaderOutput input) : COLOR0
{
    float startDepth = tex2D(TextureSampler, input.TexCoords.x).r;
}

This seems to always return 0.
Is this at all possible? Is there an alternative I am overlooking?

Many thanks.

Reference

Full shader code for reference:

struct VertexShaderInput
{
    float4 Position : POSITION0;
    float2 TexCoords: TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float2 TexCoords: TEXCOORD0;
};

VertexShaderOutput mainVS(in VertexShaderInput input)
{
    VertexShaderOutput output = (VertexShaderOutput)0;

    output.Position = input.Position;
    output.TexCoords = input.TexCoords;

    return output;
}

const float M_TAU = 6.28318530717958647692528676655900577;

Texture2D xTexture;
sampler TextureSampler : register (s0) = sampler_state { Texture = <xTexture>; };

Texture2D occlusionMap;
sampler occlusionSampler = sampler_state { Texture = <occlusionMap>; };

float2 center;
float bias;
float rayStepSize;

// rayCast 64 stepsll
float4 rayCast64(VertexShaderOutput input) : COLOR0
{
    // Init step as unit vector in direction of cast
    float theta = input.TexCoords.x * M_TAU;
    float2 step = float2(cos(theta), sin(theta));

    // Init coord using result from possible previous cast as starting point
    float2 coord = center + step*tex2D(TextureSampler, input.TexCoords.x).r;

    // Set step to appropriate size
    step *= rayStepSize;

    // Step 64 times along ray or until occluder found
    [unroll(64)]
    while (tex2D(occlusionSampler, coord).r > bias) {
        coord += step;
    }

    // store the resulting length
    return length(coord - center);
}

technique rayCast64
{
    pass Pass1
    {
        VertexShader = compile vs_4_0_level_9_1 mainVS();
        PixelShader = compile ps_4_0_level_9_3 rayCast64();
    }
}

I manged to fix this by using two rendertargets like a swapchain:

                    graphics.SetRenderTarget(LosRaycastMap[0]);

                    graphics.Clear(Color.Black); // init texture as black (all rays start at 0)

                    LosRaycastEffect.CurrentTechnique = LosRaycastEffect.Techniques["rayCast64"];

                    for (int i = 0; i < losRaycastSetting.RayStepIterations; i++)
                    {
                        // swap buffers
                        RenderTarget2D temp = LosRaycastMap[0];
                        LosRaycastMap[0] = LosRaycastMap[1];
                        LosRaycastMap[1] = temp;

                        graphics.SetRenderTarget(LosRaycastMap[0]);
                        LosRaycastEffect.Parameters["xTexture"].SetValue(LosRaycastMap[1]);
                        LosRaycastEffect.CurrentTechnique.Passes[0].Apply();
                        Quad.Render();

                    }