Integrate-like function in shader

Hello, i am at the very very beginning of shader programming and was wondering if it’s possible to create a “spreadable” integrate-like function in shader.

The idea was to get a random spread of static values from a dynamic buffer and then upadate each slice by adding the initial value after each “iteration”.
I am using SV_InstanceID in vertex shader to get the current instance id.

I have been trying a couple of solutions but none of them have worked.
Any suggestion is welcome, thank you

use compute shader for that so you can read and write to the destination resource at the same time. so you can do if the layer connected to a Renderer (DX11 Buffer)

RWStructuredBuffer[SV_DispatchThreadID.x](SV_DispatchThreadID.x) += stuff;

or if the layer connected to a Renderer (DX11 TempTarget)

RWTexture2D<float>[SV_DispatchThreadID.xy](SV_DispatchThreadID.xy) += stuff;

note that in case of RWTexture2D you can write to RGBA so

RWTexture2D<float4>

textures too but you can only read from single component read/write textures so

RWTexture2D<float>

but you can read or sample all components from a readonly texture of course so

Texture2D<float4>.

Ok thank you very much for your help, i’m not quite into compute shaders yet but i will keep this into consideration.
Do you think it will be possible to do it in vertex shader if i consider to store those values in a new array/spread instead of reading and writing from/to the same source?