GPU: Add host/hardware stats
This commit is contained in:
@ -513,6 +513,8 @@ void D3D11Device::CopyTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u32 d
|
||||
|
||||
src11->CommitClear(m_context.Get());
|
||||
|
||||
s_stats.num_copies++;
|
||||
|
||||
const CD3D11_BOX src_box(static_cast<LONG>(src_x), static_cast<LONG>(src_y), 0, static_cast<LONG>(src_x + width),
|
||||
static_cast<LONG>(src_y + height), 1);
|
||||
m_context->CopySubresourceRegion(dst11->GetD3DTexture(), D3D11CalcSubresource(dst_level, dst_layer, dst->GetLevels()),
|
||||
@ -531,6 +533,8 @@ void D3D11Device::ResolveTextureRegion(GPUTexture* dst, u32 dst_x, u32 dst_y, u3
|
||||
DebugAssert((dst_y + height) <= dst->GetMipHeight(dst_level));
|
||||
DebugAssert(!dst->IsMultisampled() && src->IsMultisampled());
|
||||
|
||||
s_stats.num_copies++;
|
||||
|
||||
// DX11 can't resolve partial rects.
|
||||
Assert(src_x == 0 && src_y == 0 && width == src->GetWidth() && height == src->GetHeight() && dst_x == 0 &&
|
||||
dst_y == 0 && width == dst->GetMipWidth(dst_level) && height == dst->GetMipHeight(dst_level));
|
||||
@ -635,6 +639,7 @@ bool D3D11Device::BeginPresent(bool skip_present)
|
||||
static constexpr float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
m_context->ClearRenderTargetView(m_swap_chain_rtv.Get(), clear_color);
|
||||
m_context->OMSetRenderTargets(1, m_swap_chain_rtv.GetAddressOf(), nullptr);
|
||||
s_stats.num_render_passes++;
|
||||
m_num_current_render_targets = 0;
|
||||
std::memset(m_current_render_targets.data(), 0, sizeof(m_current_render_targets));
|
||||
m_current_depth_target = nullptr;
|
||||
@ -852,7 +857,9 @@ void D3D11Device::MapVertexBuffer(u32 vertex_size, u32 vertex_count, void** map_
|
||||
|
||||
void D3D11Device::UnmapVertexBuffer(u32 vertex_size, u32 vertex_count)
|
||||
{
|
||||
m_vertex_buffer.Unmap(m_context.Get(), vertex_size * vertex_count);
|
||||
const u32 upload_size = vertex_size * vertex_count;
|
||||
s_stats.buffer_streamed += upload_size;
|
||||
m_vertex_buffer.Unmap(m_context.Get(), upload_size);
|
||||
}
|
||||
|
||||
void D3D11Device::MapIndexBuffer(u32 index_count, DrawIndex** map_ptr, u32* map_space, u32* map_base_index)
|
||||
@ -865,6 +872,7 @@ void D3D11Device::MapIndexBuffer(u32 index_count, DrawIndex** map_ptr, u32* map_
|
||||
|
||||
void D3D11Device::UnmapIndexBuffer(u32 used_index_count)
|
||||
{
|
||||
s_stats.buffer_streamed += sizeof(DrawIndex) * used_index_count;
|
||||
m_index_buffer.Unmap(m_context.Get(), sizeof(DrawIndex) * used_index_count);
|
||||
}
|
||||
|
||||
@ -874,6 +882,7 @@ void D3D11Device::PushUniformBuffer(const void* data, u32 data_size)
|
||||
const auto res = m_uniform_buffer.Map(m_context.Get(), UNIFORM_BUFFER_ALIGNMENT, used_space);
|
||||
std::memcpy(res.pointer, data, data_size);
|
||||
m_uniform_buffer.Unmap(m_context.Get(), data_size);
|
||||
s_stats.buffer_streamed += data_size;
|
||||
|
||||
const UINT first_constant = (res.index_aligned * UNIFORM_BUFFER_ALIGNMENT) / 16u;
|
||||
const UINT num_constants = (used_space * UNIFORM_BUFFER_ALIGNMENT) / 16u;
|
||||
@ -895,6 +904,8 @@ void D3D11Device::UnmapUniformBuffer(u32 size)
|
||||
const UINT num_constants = used_space / 16u;
|
||||
|
||||
m_uniform_buffer.Unmap(m_context.Get(), used_space);
|
||||
s_stats.buffer_streamed += size;
|
||||
|
||||
m_context->VSSetConstantBuffers1(0, 1, m_uniform_buffer.GetD3DBufferArray(), &first_constant, &num_constants);
|
||||
m_context->PSSetConstantBuffers1(0, 1, m_uniform_buffer.GetD3DBufferArray(), &first_constant, &num_constants);
|
||||
}
|
||||
@ -944,6 +955,7 @@ void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTextu
|
||||
if (!changed)
|
||||
return;
|
||||
|
||||
s_stats.num_render_passes++;
|
||||
m_context->OMSetRenderTargets(num_rts, rtvs, ds ? static_cast<D3D11Texture*>(ds)->GetD3DDSV() : nullptr);
|
||||
}
|
||||
|
||||
@ -1035,10 +1047,12 @@ void D3D11Device::SetScissor(s32 x, s32 y, s32 width, s32 height)
|
||||
|
||||
void D3D11Device::Draw(u32 vertex_count, u32 base_vertex)
|
||||
{
|
||||
s_stats.num_draws++;
|
||||
m_context->Draw(vertex_count, base_vertex);
|
||||
}
|
||||
|
||||
void D3D11Device::DrawIndexed(u32 index_count, u32 base_index, u32 base_vertex)
|
||||
{
|
||||
s_stats.num_draws++;
|
||||
m_context->DrawIndexed(index_count, base_index, base_vertex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user