Example #1
0
void D3D11Replay::FillTimersAMD(uint32_t &eventStartID, uint32_t &sampleIndex,
                                vector<uint32_t> &eventIDs, const DrawcallDescription &drawnode)
{
  if(drawnode.children.empty())
    return;

  for(size_t i = 0; i < drawnode.children.size(); i++)
  {
    const DrawcallDescription &d = drawnode.children[i];

    FillTimersAMD(eventStartID, sampleIndex, eventIDs, drawnode.children[i]);

    if(d.events.empty())
      continue;

    eventIDs.push_back(d.eventId);

    m_pDevice->ReplayLog(eventStartID, d.eventId, eReplay_WithoutDraw);

    SerializeImmediateContext();

    m_pAMDCounters->BeginSample(sampleIndex);

    m_pDevice->ReplayLog(eventStartID, d.eventId, eReplay_OnlyDraw);

    m_pAMDCounters->EndSample();

    eventStartID = d.eventId + 1;
    sampleIndex++;
  }
}
Example #2
0
void D3D11DebugManager::FillTimersAMD(uint32_t &eventStartID, uint32_t &sampleIndex,
                                      vector<uint32_t> &eventIDs, const DrawcallTreeNode &drawnode)
{
  if(drawnode.children.empty())
    return;

  for(size_t i = 0; i < drawnode.children.size(); i++)
  {
    const DrawcallDescription &d = drawnode.children[i].draw;

    FillTimersAMD(eventStartID, sampleIndex, eventIDs, drawnode.children[i]);

    if(d.events.count == 0)
      continue;

    eventIDs.push_back(d.eventID);

    m_WrappedDevice->ReplayLog(eventStartID, d.eventID, eReplay_WithoutDraw);

    m_pImmediateContext->Flush();

    m_pAMDCounters->BeginSample(sampleIndex);

    m_WrappedDevice->ReplayLog(eventStartID, d.eventID, eReplay_OnlyDraw);

    m_pAMDCounters->EndSample();

    eventStartID = d.eventID + 1;
    sampleIndex++;
  }
}
Example #3
0
vector<CounterResult> D3D11Replay::FetchCountersAMD(const vector<GPUCounter> &counters)
{
  vector<CounterResult> ret;

  m_pAMDCounters->DisableAllCounters();

  // enable counters it needs
  for(size_t i = 0; i < counters.size(); i++)
  {
    // This function is only called internally, and violating this assertion means our
    // caller has invoked this method incorrectly
    RDCASSERT(IsAMDCounter(counters[i]));
    m_pAMDCounters->EnableCounter(counters[i]);
  }

  uint32_t sessionID = m_pAMDCounters->BeginSession();

  uint32_t passCount = m_pAMDCounters->GetPassCount();

  uint32_t sampleIndex = 0;

  vector<uint32_t> eventIDs;

  for(uint32_t p = 0; p < passCount; p++)
  {
    m_pAMDCounters->BeginPass();

    uint32_t eventStartID = 0;

    sampleIndex = 0;

    eventIDs.clear();

    FillTimersAMD(eventStartID, sampleIndex, eventIDs, m_pImmediateContext->GetRootDraw());

    m_pAMDCounters->EndPass();
  }

  m_pAMDCounters->EndSesssion();

  return m_pAMDCounters->GetCounterData(sessionID, sampleIndex, eventIDs, counters);
}
Example #4
0
vector<CounterResult> D3D11DebugManager::FetchCountersAMD(const vector<GPUCounter> &counters)
{
  vector<CounterResult> ret;

  m_pAMDCounters->DisableAllCounters();

  // enable counters it needs
  for(size_t i = 0; i < counters.size(); i++)
  {
    // This function is only called internally, and violating this assertion means our
    // caller has invoked this method incorrectly
    RDCASSERT((counters[i] >= (GPUCounter::FirstAMD)) && (counters[i] < (GPUCounter::FirstIntel)));
    m_pAMDCounters->EnableCounter(counters[i]);
  }

  uint32_t sessionID = m_pAMDCounters->BeginSession();

  uint32_t passCount = m_pAMDCounters->GetPassCount();

  uint32_t sampleIndex = 0;

  vector<uint32_t> eventIDs;

  for(uint32_t p = 0; p < passCount; p++)
  {
    m_pAMDCounters->BeginPass();

    uint32_t eventStartID = 0;

    sampleIndex = 0;

    eventIDs.clear();

    FillTimersAMD(eventStartID, sampleIndex, eventIDs, m_WrappedContext->GetRootDraw());

    m_pAMDCounters->EndPass();
  }

  m_pAMDCounters->EndSesssion();

  bool isReady = false;

  do
  {
    isReady = m_pAMDCounters->IsSessionReady(sessionID);
  } while(!isReady);

  for(uint32_t s = 0; s < sampleIndex; s++)
  {
    for(size_t c = 0; c < counters.size(); c++)
    {
      const CounterDescription desc = m_pAMDCounters->GetCounterDescription(counters[c]);

      switch(desc.resultType)
      {
        case CompType::UInt:
        {
          if(desc.resultByteWidth == sizeof(uint32_t))
          {
            uint32_t value = m_pAMDCounters->GetSampleUint32(sessionID, s, counters[c]);

            if(desc.unit == CounterUnit::Percentage)
            {
              value = RDCCLAMP(value, 0U, 100U);
            }

            ret.push_back(CounterResult(eventIDs[s], counters[c], value));
          }
          else if(desc.resultByteWidth == sizeof(uint64_t))
          {
            uint64_t value = m_pAMDCounters->GetSampleUint64(sessionID, s, counters[c]);

            if(desc.unit == CounterUnit::Percentage)
            {
              value = RDCCLAMP(value, 0ULL, 100ULL);
            }

            ret.push_back(

                CounterResult(eventIDs[s], counters[c], value));
          }
          else
          {
            RDCERR("Unexpected byte width %u", desc.resultByteWidth);
          }
        }
        break;
        case CompType::Float:
        {
          float value = m_pAMDCounters->GetSampleFloat32(sessionID, s, counters[c]);

          if(desc.unit == CounterUnit::Percentage)
          {
            value = RDCCLAMP(value, 0.0f, 100.0f);
          }

          ret.push_back(CounterResult(eventIDs[s], counters[c], value));
        }
        break;
        case CompType::Double:
        {
          double value = m_pAMDCounters->GetSampleFloat64(sessionID, s, counters[c]);

          if(desc.unit == CounterUnit::Percentage)
          {
            value = RDCCLAMP(value, 0.0, 100.0);
          }

          ret.push_back(CounterResult(eventIDs[s], counters[c], value));
        }
        break;
        default: RDCASSERT(0); break;
      };
    }
  }

  return ret;
}