I have this program :
for (int i = 0; i < STEPS; ++i)
{
context->CSSetShader(computeShader, NULL, 0);
ID3D11UnorderedAccessView *aUAViews[1] = {bufferOut_UAV};
context->CSSetUnorderedAccessViews(0, 1, aUAViews, NULL);
context->Dispatch(32, 32, 1);
in[i] = t.GetTime();
if (i == STEPS / 2)
{
context->End(pEventQuery);
while( context->GetData( pEventQuery, NULL, 0, 0 ) == S_FALSE ) {}
}
}
double out = t.GetTime();
context->End(pEventQuery);
while( context->GetData( pEventQuery, NULL, 0, 0 ) == S_FALSE ) {}
First while iteration last only 26 ms, while second 46 ms?
Just in case the shader:
RWStructuredBuffer<float> Output : register(u0);
[numthreads(GROUP_SIZE_X, GROUP_SIZE_Y, 1)]
void arrayTest(uint3 DTid : SV_DispatchThreadID)
{
float i = DTid.x * 32 + DTid.y;
Output[i] = 0;
for (int k = 0; k < 100; ++k)
{
Output[i] += sqrt(i + k);
}
}
but i don't think it should take different time at every start.
interesting what if I comment out line ''if (i == STEPS / 2)'' both halves take nearly the same time.
EDIT: as far as i can see for now, it is decause of cashing