예제 #1
0
u32 PerfQuery::GetQueryResult(PerfQueryType type)
{
	if (!ShouldEmulate())
		return 0;

	u32 result = 0;

	if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC)
	{
		result = m_results[PQG_ZCOMP_ZCOMPLOC];
	}
	else if (type == PQ_ZCOMP_INPUT || type == PQ_ZCOMP_OUTPUT)
	{
		result = m_results[PQG_ZCOMP];
	}
	else if (type == PQ_BLEND_INPUT)
	{
		result = m_results[PQG_ZCOMP] + m_results[PQG_ZCOMP_ZCOMPLOC];
	}
	else if (type == PQ_EFB_COPY_CLOCKS)
	{
		result = m_results[PQG_EFB_COPY_CLOCKS];
	}

	return result / 4;
}
예제 #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;
	}
}
예제 #3
0
void PerfQuery::WeakFlush()
{
	if (!ShouldEmulate())
		return;

	while (!IsFlushed())
	{
		auto& entry = m_query_buffer[m_query_read_pos];

		UINT64 result = 0;
		HRESULT hr = D3D::context->GetData(entry.query, &result, sizeof(result), D3D11_ASYNC_GETDATA_DONOTFLUSH);

		if (hr == S_OK)
		{
			// NOTE: Reported pixel metrics should be referenced to native resolution
			m_results[entry.query_type] += (u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight();

			m_query_read_pos = (m_query_read_pos + 1) % ArraySize(m_query_buffer);
			--m_query_count;
		}
		else
		{
			break;
		}
	}
}
예제 #4
0
bool PerfQuery::IsFlushed() const
{
	if (!ShouldEmulate())
		return true;

	return 0 == m_query_count;
}
예제 #5
0
// TODO: could selectively flush things, but I don't think that will do much
void PerfQuery::FlushResults()
{
    if (!ShouldEmulate())
		return;
	while (!IsFlushed())
		FlushOne();
}
예제 #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;
    }
}
예제 #7
0
void PerfQuery::DisableQuery(PerfQueryGroup type)
{
    if (!ShouldEmulate())
		return;
	// stop 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)-1) % ArraySize(m_query_buffer)];
		entry.query->Issue(D3DISSUE_END);
	}
}
예제 #8
0
void PerfQuery::DisableQuery(PerfQueryGroup type)
{
    if (!ShouldEmulate())
        return;

    // stop query
    if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
    {
        glEndQuery(GL_SAMPLES_PASSED);
    }
}
예제 #9
0
void PerfQuery::DisableQuery(PerfQueryGroup type)
{
	if (!ShouldEmulate())
		return;

	// stop 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)-1) % ArraySize(m_query_buffer)];
		D3D::context->End(entry.query);
	}
}
예제 #10
0
void PerfQuery::FlushOne()
{
    if (!ShouldEmulate())
        return;

    auto& entry = m_query_buffer[m_query_read_pos];

    GLuint result = 0;
    glGetQueryObjectuiv(entry.query_id, GL_QUERY_RESULT, &result);

    // NOTE: Reported pixel metrics should be referenced to native resolution
    m_results[entry.query_type] += (u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight();

    m_query_read_pos = (m_query_read_pos + 1) % ArraySize(m_query_buffer);
    --m_query_count;
}
예제 #11
0
void PerfQuery::FlushOne()
{
    if (!ShouldEmulate())
		return;
	auto& entry = m_query_buffer[m_query_read_pos];

	DWORD result = 0;
	HRESULT hr = S_FALSE;
	while (hr != S_OK && hr != D3DERR_DEVICELOST)
	{
		// TODO: Might cause us to be stuck in an infinite loop!
		hr = entry.query->GetData(&result, sizeof(result), D3DGETDATA_FLUSH);
	}

	// NOTE: Reported pixel metrics should be referenced to native resolution
	m_results[entry.query_type] += (u32)((u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());

	m_query_read_pos = (m_query_read_pos + 1) % ArraySize(m_query_buffer);
	--m_query_count;
}
예제 #12
0
void PerfQuery::WeakFlush()
{
    if (!ShouldEmulate())
        return;

    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;
        }
    }
}