//------------------------------------------------------------------------------
// RecordSpan
//------------------------------------------------------------------------------
void ManualRecorder::RecordSpan(const collector::Span& span) noexcept try {
  if (disabled_) {
    dropped_spans_++;
    options_.metrics_observer->OnSpansDropped(1);
    return;
  }

  auto max_buffered_spans = options_.max_buffered_spans.value();
  if (builder_.num_pending_spans() >= max_buffered_spans) {
    // If there's no report in flight, flush the recoder. We can only get
    // here if max_buffered_spans was dynamically decreased.
    //
    // Otherwise, drop the span.
    if (!IsReportInProgress()) {
      FlushOne();
    } else {
      dropped_spans_++;
      options_.metrics_observer->OnSpansDropped(1);
      return;
    }
  }
  builder_.AddSpan(span);
  if (builder_.num_pending_spans() >= max_buffered_spans) {
    FlushOne();
  }
} catch (const std::exception& e) {
  logger_.Error("Failed to record span: ", e.what());
}
Exemple #2
0
void PerfQuery::EnableQuery(PerfQueryGroup type)
{
	if (!ShouldEmulate())
		return;

	// Is this sane?
	if (m_query_count > ArraySize(m_query_buffer) / 2)
		WeakFlush();

	if (ArraySize(m_query_buffer) == m_query_count)
	{
		// TODO
		FlushOne();
		ERROR_LOG(VIDEO, "Flushed query buffer early!");
	}

	// start query
	if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
	{
		auto& entry = m_query_buffer[(m_query_read_pos + m_query_count) % ArraySize(m_query_buffer)];

		D3D::context->Begin(entry.query);
		entry.query_type = type;

		++m_query_count;
	}
}
//------------------------------------------------------------------------------
// FlushWithTimeout
//------------------------------------------------------------------------------
bool ManualRecorder::FlushWithTimeout(
    std::chrono::system_clock::duration /*timeout*/) noexcept {
  if (disabled_) {
    return false;
  }
  return FlushOne();
}
Exemple #4
0
// TODO: could selectively flush things, but I don't think that will do much
void PerfQuery::FlushResults()
{
    if (!ShouldEmulate())
		return;
	while (!IsFlushed())
		FlushOne();
}
Exemple #5
0
void PerfQuery::EnableQuery(PerfQueryGroup type)
{
  if (m_query_count > m_query_buffer.size() / 2)
    WeakFlush();

  // all queries already used?
  if (m_query_buffer.size() == m_query_count)
  {
    FlushOne();
    // WARN_LOG(VIDEO, "Flushed query buffer early!");
  }

  if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
  {
    size_t index = (m_query_read_pos + m_query_count) % m_query_buffer.size();
    auto& entry = m_query_buffer[index];

    D3D::current_command_list->BeginQuery(m_query_heap, D3D12_QUERY_TYPE_OCCLUSION,
                                          static_cast<UINT>(index));
    entry.query_type = type;
    entry.fence_value = -1;

    ++m_query_count;
  }
}
Exemple #6
0
void PerfQuery::EnableQuery(PerfQueryGroup type)
{
    if (!ShouldEmulate())
        return;

    // Is this sane?
    if (m_query_count > ArraySize(m_query_buffer) / 2)
        WeakFlush();

    if (ArraySize(m_query_buffer) == m_query_count)
    {
        FlushOne();
        //ERROR_LOG(VIDEO, "Flushed query buffer early!");
    }

    // start query
    if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
    {
        auto& entry = m_query_buffer[(m_query_read_pos + m_query_count) % ArraySize(m_query_buffer)];

        glBeginQuery(GL_SAMPLES_PASSED, entry.query_id);
        entry.query_type = type;

        ++m_query_count;
    }
}
Exemple #7
0
void PerfQuery::WeakFlush()
{
  UINT64 completed_fence = m_tracking_fence->GetCompletedValue();

  while (!IsFlushed())
  {
    ActiveQuery& entry = m_query_buffer[m_query_read_pos];
    if (entry.fence_value > completed_fence)
      break;

    FlushOne();
  }
}
void PerfQueryGLESNV::WeakFlush()
{
	while (!IsFlushed())
	{
		auto& entry = m_query_buffer[m_query_read_pos];

		GLuint result = GL_FALSE;
		glGetOcclusionQueryuivNV(entry.query_id, GL_PIXEL_COUNT_AVAILABLE_NV, &result);

		if (GL_TRUE == result)
		{
			FlushOne();
		}
		else
		{
			break;
		}
	}
}
void PerfQueryGL::WeakFlush()
{
	while (!IsFlushed())
	{
		auto& entry = m_query_buffer[m_query_read_pos];

		GLuint result = GL_FALSE;
		glGetQueryObjectuiv(entry.query_id, GL_QUERY_RESULT_AVAILABLE, &result);

		if (GL_TRUE == result)
		{
			FlushOne();
		}
		else
		{
			break;
		}
	}
}
void PerfQueryGL::EnableQuery(PerfQueryGroup type)
{
	// Is this sane?
	if (m_query_count > m_query_buffer.size() / 2)
		WeakFlush();

	if (m_query_buffer.size() == m_query_count)
	{
		FlushOne();
		//ERROR_LOG(VIDEO, "Flushed query buffer early!");
	}

	// start query
	if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
	{
		auto& entry = m_query_buffer[(m_query_read_pos + m_query_count) % m_query_buffer.size()];

		glBeginQuery(m_query_type, entry.query_id);
		entry.query_type = type;

		++m_query_count;
	}
}
Exemple #11
0
void PerfQuery::EnableQuery(PerfQueryGroup type)
{
	// Is this sane?
	if (m_query_count > m_query_buffer.size() / 2)
		WeakFlush();

	if (m_query_buffer.size() == m_query_count)
	{
		FlushOne();
		//ERROR_LOG(VIDEO, "Flushed query buffer early!");
	}

	// start query
	if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
	{
		auto& entry = m_query_buffer[(m_query_read_pos + m_query_count) % m_query_buffer.size()];

		glBeginQuery(GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL ? GL_SAMPLES_PASSED : GL_ANY_SAMPLES_PASSED, entry.query_id);
		entry.query_type = type;

		++m_query_count;
	}
}
// TODO: could selectively flush things, but I don't think that will do much
void PerfQueryGLESNV::FlushResults()
{
	while (!IsFlushed())
		FlushOne();
}