| 109 | } |
| 110 | |
| 111 | void GpuTimer::resolve() |
| 112 | { |
| 113 | if (mStatus == Status::Idle) |
| 114 | { |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | if (mStatus == Status::Begin) |
| 119 | { |
| 120 | FALCOR_THROW("GpuTimer::resolve() was called but the GpuTimer::end() wasn't called."); |
| 121 | } |
| 122 | |
| 123 | FALCOR_ASSERT(mStatus == Status::End); |
| 124 | |
| 125 | // TODO: The code here is inefficient as it resolves each timer individually. |
| 126 | // This should be batched across all active timers and results copied into a single staging buffer once per frame instead. |
| 127 | |
| 128 | // Resolve timestamps into buffer. |
| 129 | auto encoder = mpDevice->getRenderContext()->getLowLevelData()->getResourceCommandEncoder(); |
| 130 | |
| 131 | encoder->resolveQuery(mpDevice->getTimestampQueryHeap()->getGfxQueryPool(), mStart, 2, mpResolveBuffer->getGfxBufferResource(), 0); |
| 132 | |
| 133 | // Copy resolved timestamps to staging buffer for readback. This inserts the necessary barriers. |
| 134 | mpDevice->getRenderContext()->copyResource(mpResolveStagingBuffer.get(), mpResolveBuffer.get()); |
| 135 | |
| 136 | mDataPending = true; |
| 137 | mStatus = Status::Idle; |
| 138 | } |
| 139 | |
| 140 | double GpuTimer::getElapsedTime() |
| 141 | { |
no test coverage detected