|
25 | 25 | #include <algorithm>
|
26 | 26 | #include <iterator>
|
27 | 27 | #include "driver/ihv/amd/amd_counters.h"
|
| 28 | +#include "driver/ihv/arm/arm_counters.h" |
28 | 29 | #include "driver/ihv/intel/intel_gl_counters.h"
|
29 | 30 | #include "gl_driver.h"
|
30 | 31 | #include "gl_replay.h"
|
@@ -65,6 +66,11 @@ rdcarray<GPUCounter> GLReplay::EnumerateCounters()
|
65 | 66 | ret.append(m_pIntelCounters->GetPublicCounterIds());
|
66 | 67 | }
|
67 | 68 |
|
| 69 | + if(m_pARMCounters) |
| 70 | + { |
| 71 | + ret.append(m_pARMCounters->GetPublicCounterIds()); |
| 72 | + } |
| 73 | + |
68 | 74 | return ret;
|
69 | 75 | }
|
70 | 76 |
|
@@ -96,6 +102,11 @@ CounterDescription GLReplay::DescribeCounter(GPUCounter counterID)
|
96 | 102 | }
|
97 | 103 | }
|
98 | 104 |
|
| 105 | + if(IsARMCounter(counterID) && m_pARMCounters) |
| 106 | + { |
| 107 | + return m_pARMCounters->GetCounterDescription(counterID); |
| 108 | + } |
| 109 | + |
99 | 110 | // FFBA5548-FBF8-405D-BA18-F0329DA370A0
|
100 | 111 | desc.uuid.words[0] = 0xFFBA5548;
|
101 | 112 | desc.uuid.words[1] = 0xFBF8405D;
|
@@ -461,6 +472,84 @@ rdcarray<CounterResult> GLReplay::FetchCountersIntel(const rdcarray<GPUCounter>
|
461 | 472 | return ret;
|
462 | 473 | }
|
463 | 474 |
|
| 475 | +void GLReplay::FillTimersARM(uint32_t *eventStartID, uint32_t *sampleIndex, |
| 476 | + rdcarray<uint32_t> *eventIDs, const DrawcallDescription &drawnode) |
| 477 | +{ |
| 478 | + if(drawnode.children.empty()) |
| 479 | + return; |
| 480 | + |
| 481 | + for(size_t i = 0; i < drawnode.children.size(); i++) |
| 482 | + { |
| 483 | + const DrawcallDescription &d = drawnode.children[i]; |
| 484 | + |
| 485 | + FillTimersARM(eventStartID, sampleIndex, eventIDs, drawnode.children[i]); |
| 486 | + |
| 487 | + if(d.events.empty()) |
| 488 | + continue; |
| 489 | + |
| 490 | + eventIDs->push_back(d.eventId); |
| 491 | + |
| 492 | + m_pDriver->ReplayLog(*eventStartID, d.eventId, eReplay_WithoutDraw); |
| 493 | + |
| 494 | + m_pARMCounters->BeginSample(d.eventId); |
| 495 | + |
| 496 | + m_pDriver->ReplayLog(*eventStartID, d.eventId, eReplay_OnlyDraw); |
| 497 | + |
| 498 | + // wait for the GPU to process all commands |
| 499 | + GLsync sync = GL.glFenceSync(eGL_SYNC_GPU_COMMANDS_COMPLETE, 0); |
| 500 | + GL.glClientWaitSync(sync, eGL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); |
| 501 | + |
| 502 | + m_pARMCounters->EndSample(); |
| 503 | + |
| 504 | + GL.glDeleteSync(sync); |
| 505 | + |
| 506 | + *eventStartID = d.eventId + 1; |
| 507 | + ++*sampleIndex; |
| 508 | + } |
| 509 | +} |
| 510 | + |
| 511 | +rdcarray<CounterResult> GLReplay::FetchCountersARM(const rdcarray<GPUCounter> &counters) |
| 512 | +{ |
| 513 | + m_pARMCounters->DisableAllCounters(); |
| 514 | + |
| 515 | + // enable counters it needs |
| 516 | + for(size_t i = 0; i < counters.size(); i++) |
| 517 | + { |
| 518 | + // This function is only called internally, and violating this assertion means our |
| 519 | + // caller has invoked this method incorrectly |
| 520 | + RDCASSERT(IsARMCounter(counters[i])); |
| 521 | + m_pARMCounters->EnableCounter(counters[i]); |
| 522 | + } |
| 523 | + |
| 524 | + uint32_t passCount = m_pARMCounters->GetPassCount(); |
| 525 | + |
| 526 | + uint32_t sampleIndex = 0; |
| 527 | + |
| 528 | + rdcarray<uint32_t> eventIDs; |
| 529 | + |
| 530 | + m_pDriver->ReplayMarkers(false); |
| 531 | + |
| 532 | + for(uint32_t p = 0; p < passCount; p++) |
| 533 | + { |
| 534 | + m_pARMCounters->BeginPass(p); |
| 535 | + |
| 536 | + uint32_t eventStartID = 0; |
| 537 | + |
| 538 | + sampleIndex = 0; |
| 539 | + |
| 540 | + eventIDs.clear(); |
| 541 | + |
| 542 | + FillTimersARM(&eventStartID, &sampleIndex, &eventIDs, m_pDriver->GetRootDraw()); |
| 543 | + |
| 544 | + m_pARMCounters->EndPass(); |
| 545 | + } |
| 546 | + m_pDriver->ReplayMarkers(true); |
| 547 | + |
| 548 | + rdcarray<CounterResult> ret = m_pARMCounters->GetCounterData(eventIDs, counters); |
| 549 | + |
| 550 | + return ret; |
| 551 | +} |
| 552 | + |
464 | 553 | rdcarray<CounterResult> GLReplay::FetchCounters(const rdcarray<GPUCounter> &allCounters)
|
465 | 554 | {
|
466 | 555 | rdcarray<CounterResult> ret;
|
@@ -503,6 +592,16 @@ rdcarray<CounterResult> GLReplay::FetchCounters(const rdcarray<GPUCounter> &allC
|
503 | 592 | }
|
504 | 593 | }
|
505 | 594 |
|
| 595 | + if(m_pARMCounters) |
| 596 | + { |
| 597 | + rdcarray<GPUCounter> armCounters; |
| 598 | + std::copy_if(allCounters.begin(), allCounters.end(), std::back_inserter(armCounters), |
| 599 | + [](const GPUCounter &c) { return IsARMCounter(c); }); |
| 600 | + |
| 601 | + if(!armCounters.empty()) |
| 602 | + ret = FetchCountersARM(armCounters); |
| 603 | + } |
| 604 | + |
506 | 605 | if(counters.empty())
|
507 | 606 | {
|
508 | 607 | return ret;
|
|
0 commit comments