Sign in to follow this  

Weird behavior on Timestamp query heap for GTX 1080

This topic is 415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey Guys,

 

I have encountered a weird situation where my GPU profiler report some negative time duration only on machines with GTX 1080. The GPU profiler I write is very standard one with Timestamp query heap, and map/unmap once every frame when copying data out. It work properly on GTX680m, GTX980. However when I run it with my latest machine with GTX1080 I got some negative time duration. It seems like graphic driver reordered some of my EndQuery calls on cmdlist (I am not sure whether that is even possible...)

 

I have also found that when I run it with visual studio graphic debug, the bug just disappeared, everything is back to normal.... So I can't use VSGD to confirm whether my cmdlist EndQuery call get reordered or not.

 

The driver I use is uptodate. Does anyone happened to encounter similar things? or any suggestion on where I probably got it wrong?

 

Thanks

Share this post


Link to post
Share on other sites

Does setting SetStablePowerState(TRUE) affect your results at all?

The GPU profiler I write is very standard one with Timestamp query heap, and map/unmap once every frame when copying data out.

Do you use ResolveQueryData to copy the timestamps into a buffer and then map that buffer?

How do you synchronize this so that the GPU isn't accessing the buffer while the CPU has it mapped?

Share this post


Link to post
Share on other sites

Here is the relevant code.

void
GPU_Profiler::ProcessAndReadback(CommandContext& EngineContext)
{
    Graphics::g_cmdListMngr.WaitForFence(m_fence);

    HRESULT hr;
    D3D12_RANGE range;
    range.Begin = 0;
    range.End = MAX_TIMER_COUNT * 2 * sizeof(uint64_t);
    V(m_readbackBuffer->Map(
        0, &range, reinterpret_cast<void**>(&m_timeStampBuffer)));
    memcpy(m_timeStampBufferCopy, m_timeStampBuffer,
        m_timerCount * 2 * sizeof(uint64_t));
    D3D12_RANGE EmptyRange = {};
    m_readbackBuffer->Unmap(0, &EmptyRange);
    
    ....

    {
        EngineContext.PIXEndEvent();
        EngineContext.InsertTimeStamp(m_queryHeap, 1);
        EngineContext.ResolveTimeStamps(
            m_readbackBuffer, m_queryHeap, 2 * m_timerCount);
        EngineContext.PIXBeginEvent(L"Frame Start");
        EngineContext.InsertTimeStamp(m_queryHeap, 0);
    }
    m_fence = EngineContext.Flush();
}
 

So the first and second element in queryHeap is for frame begin/end time stamp.

Thanks in advance for any suggestions

 

Share this post


Link to post
Share on other sites

Does setting SetStablePowerState(TRUE) affect your results at all?

The GPU profiler I write is very standard one with Timestamp query heap, and map/unmap once every frame when copying data out.

How do you synchronize this so that the GPU isn't accessing the heap while the CPU has it mapped?

 

Thanks for such a prompt reply

I use fence to guard it, as shown in the code. I just tried SetStablePowerState(TRUE) it doesn't help...

Share this post


Link to post
Share on other sites

This topic is 415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this