Skip to content
Permalink
Browse files

Merge pull request #8238 from lioncash/video-stats

VideoCommon/Statistics: Minor cleanup changes
  • Loading branch information...
stenzek committed Jul 11, 2019
2 parents 8d8d103 + 9c24565 commit 4c649d1a5d92ccb1cb106861d60d744b92188524
@@ -50,7 +50,7 @@ static void UpdateConstantBuffer(ID3D11Buffer* const buffer, const void* data, u
memcpy(map.pData, data, data_size);
D3D::context->Unmap(buffer, 0);

ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
}

static ComPtr<ID3D11ShaderResourceView>
@@ -166,7 +166,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff

*out_offset = m_texel_buffer_offset / elem_size;
std::memcpy(static_cast<u8*>(sr.pData) + m_texel_buffer_offset, data, data_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
m_texel_buffer_offset += data_size;

D3D::context->Unmap(m_texel_buffer.Get(), 0);
@@ -194,7 +194,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
std::memcpy(static_cast<u8*>(sr.pData) + m_texel_buffer_offset, data, data_size);
std::memcpy(static_cast<u8*>(sr.pData) + m_texel_buffer_offset + palette_byte_offset,
palette_data, palette_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, palette_byte_offset + palette_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, palette_byte_offset + palette_size);
*out_offset = m_texel_buffer_offset / elem_size;
*out_palette_offset = (m_texel_buffer_offset + palette_byte_offset) / palette_elem_size;
m_texel_buffer_offset += palette_byte_offset + palette_size;
@@ -251,8 +251,8 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in

m_buffer_cursor = cursor + totalBufferSize;

ADDSTAT(stats.thisFrame.bytesVertexStreamed, vertexBufferSize);
ADDSTAT(stats.thisFrame.bytesIndexStreamed, indexBufferSize);
ADDSTAT(g_stats.this_frame.bytes_vertex_streamed, vertexBufferSize);
ADDSTAT(g_stats.this_frame.bytes_index_streamed, indexBufferSize);

D3D::stateman->SetVertexBuffer(m_buffers[m_current_buffer].Get(), vertex_stride, 0);
D3D::stateman->SetIndexBuffer(m_buffers[m_current_buffer].Get());
@@ -112,8 +112,8 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in
m_vertex_stream_buffer.CommitMemory(vertex_data_size);
m_index_stream_buffer.CommitMemory(index_data_size);

ADDSTAT(stats.thisFrame.bytesVertexStreamed, static_cast<int>(vertex_data_size));
ADDSTAT(stats.thisFrame.bytesIndexStreamed, static_cast<int>(index_data_size));
ADDSTAT(g_stats.this_frame.bytes_vertex_streamed, static_cast<int>(vertex_data_size));
ADDSTAT(g_stats.this_frame.bytes_index_streamed, static_cast<int>(index_data_size));

Renderer::GetInstance()->SetVertexBuffer(m_vertex_stream_buffer.GetGPUPointer(), vertex_stride,
m_vertex_stream_buffer.GetSize());
@@ -137,7 +137,7 @@ void VertexManager::UpdateVertexShaderConstants()
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), &VertexShaderManager::constants,
sizeof(VertexShaderConstants));
m_uniform_stream_buffer.CommitMemory(sizeof(VertexShaderConstants));
ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(VertexShaderConstants));
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(VertexShaderConstants));
VertexShaderManager::dirty = false;
}

@@ -150,7 +150,7 @@ void VertexManager::UpdateGeometryShaderConstants()
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), &GeometryShaderManager::constants,
sizeof(GeometryShaderConstants));
m_uniform_stream_buffer.CommitMemory(sizeof(GeometryShaderConstants));
ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(GeometryShaderConstants));
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(GeometryShaderConstants));
GeometryShaderManager::dirty = false;
}

@@ -163,7 +163,7 @@ void VertexManager::UpdatePixelShaderConstants()
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), &PixelShaderManager::constants,
sizeof(PixelShaderConstants));
m_uniform_stream_buffer.CommitMemory(sizeof(PixelShaderConstants));
ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(PixelShaderConstants));
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(PixelShaderConstants));
PixelShaderManager::dirty = false;
}

@@ -227,7 +227,7 @@ void VertexManager::UploadAllConstants()

// Finally, flush buffer memory after copying
m_uniform_stream_buffer.CommitMemory(allocation_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, allocation_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, allocation_size);

// Clear dirty flags
VertexShaderManager::dirty = false;
@@ -250,7 +250,7 @@ void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size)
Renderer::GetInstance()->SetConstantBuffer(2, m_uniform_stream_buffer.GetCurrentGPUPointer());
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer(), data, data_size);
m_uniform_stream_buffer.CommitMemory(data_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
}

bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format,
@@ -275,7 +275,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
std::memcpy(m_texel_stream_buffer.GetCurrentHostPointer(), data, data_size);
*out_offset = static_cast<u32>(m_texel_stream_buffer.GetCurrentOffset()) / elem_size;
m_texel_stream_buffer.CommitMemory(data_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
Renderer::GetInstance()->SetTextureDescriptor(0, m_texel_buffer_views[format].cpu_handle);
return true;
}
@@ -312,7 +312,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
palette_elem_size;

m_texel_stream_buffer.CommitMemory(palette_byte_offset + palette_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, palette_byte_offset + palette_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, palette_byte_offset + palette_size);
Renderer::GetInstance()->SetTextureDescriptor(0, m_texel_buffer_views[format].cpu_handle);
Renderer::GetInstance()->SetTextureDescriptor(1, m_texel_buffer_views[palette_format].cpu_handle);
return true;
@@ -158,7 +158,7 @@ void SHADER::Bind() const
{
if (CurrentProgram != glprogid)
{
INCSTAT(stats.thisFrame.numShaderChanges);
INCSTAT(g_stats.this_frame.num_shader_changes);
glUseProgram(glprogid);
CurrentProgram = glprogid;
}
@@ -248,7 +248,7 @@ void ProgramShaderCache::UploadConstants()
VertexShaderManager::dirty = false;
GeometryShaderManager::dirty = false;

ADDSTAT(stats.thisFrame.bytesUniformStreamed, s_ubo_buffer_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, s_ubo_buffer_size);
}
}

@@ -264,7 +264,7 @@ void ProgramShaderCache::UploadConstants(const void* data, u32 data_size)
for (u32 index = 1; index <= 3; index++)
glBindBufferRange(GL_UNIFORM_BUFFER, index, s_buffer->m_buffer, buffer.second, data_size);

ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
}

bool ProgramShaderCache::CompileComputeShader(SHADER& shader, const std::string& code)
@@ -105,7 +105,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
const u32 elem_size = GetTexelBufferElementSize(format);
const auto dst = m_texel_buffer->Map(data_size, elem_size);
std::memcpy(dst.first, data, data_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
*out_offset = dst.second / elem_size;
m_texel_buffer->Unmap(data_size);

@@ -130,7 +130,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
const u32 palette_byte_offset = Common::AlignUp(data_size, palette_elem_size);
std::memcpy(dst.first, data, data_size);
std::memcpy(dst.first + palette_byte_offset, palette_data, palette_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, palette_byte_offset + palette_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, palette_byte_offset + palette_size);
*out_offset = dst.second / elem_size;
*out_palette_offset = (dst.second + palette_byte_offset) / palette_elem_size;
m_texel_buffer->Unmap(palette_byte_offset + palette_size);
@@ -181,8 +181,8 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in
m_vertex_buffer->Unmap(vertex_data_size);
m_index_buffer->Unmap(index_data_size);

ADDSTAT(stats.thisFrame.bytesVertexStreamed, vertex_data_size);
ADDSTAT(stats.thisFrame.bytesIndexStreamed, index_data_size);
ADDSTAT(g_stats.this_frame.bytes_vertex_streamed, vertex_data_size);
ADDSTAT(g_stats.this_frame.bytes_index_streamed, index_data_size);
}

void VertexManager::UploadUniforms()
@@ -221,7 +221,7 @@ static void ClipTriangle(int* indices, int* numIndices)
POLY_CLIP(CLIP_POS_Z_BIT, 0, 0, 0, 1);
POLY_CLIP(CLIP_NEG_Z_BIT, 0, 0, 1, 1);

INCSTAT(stats.thisFrame.numTrianglesClipped);
INCSTAT(g_stats.this_frame.num_triangles_clipped);

// transform the poly in inlist into triangles
indices[0] = inlist[0];
@@ -288,7 +288,7 @@ static void ClipLine(int* indices)

void ProcessTriangle(OutputVertexData* v0, OutputVertexData* v1, OutputVertexData* v2)
{
INCSTAT(stats.thisFrame.numTrianglesIn)
INCSTAT(g_stats.this_frame.num_triangles_in)

bool backface;

@@ -410,7 +410,7 @@ bool CullTest(const OutputVertexData* v0, const OutputVertexData* v1, const Outp

if (mask)
{
INCSTAT(stats.thisFrame.numTrianglesRejected)
INCSTAT(g_stats.this_frame.num_triangles_rejected)
return false;
}

@@ -430,13 +430,13 @@ bool CullTest(const OutputVertexData* v0, const OutputVertexData* v1, const Outp

if ((bpmem.genMode.cullmode & 1) && !backface) // cull frontfacing
{
INCSTAT(stats.thisFrame.numTrianglesCulled)
INCSTAT(g_stats.this_frame.num_triangles_culled)
return false;
}

if ((bpmem.genMode.cullmode & 2) && backface) // cull backfacing
{
INCSTAT(stats.thisFrame.numTrianglesCulled)
INCSTAT(g_stats.this_frame.num_triangles_culled)
return false;
}

@@ -106,7 +106,7 @@ void DumpActiveTextures()
{
SaveTexture(StringFromFormat("%star%i_ind%i_map%i_mip%i.png",
File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
stats.thisFrame.numDrawnObjects, stageNum, texmap, mip),
g_stats.this_frame.num_drawn_objects, stageNum, texmap, mip),
texmap, mip);
}
}
@@ -124,7 +124,7 @@ void DumpActiveTextures()
{
SaveTexture(StringFromFormat("%star%i_stage%i_map%i_mip%i.png",
File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
stats.thisFrame.numDrawnObjects, stageNum, texmap, mip),
g_stats.this_frame.num_drawn_objects, stageNum, texmap, mip),
texmap, mip);
}
}
@@ -191,32 +191,38 @@ void CopyTempBuffer(s16 x, s16 y, int bufferBase, int subBuffer, const char* nam

void OnObjectBegin()
{
if (g_ActiveConfig.bDumpTextures && stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
if (g_ActiveConfig.bDumpTextures &&
g_stats.this_frame.num_drawn_objects >= g_ActiveConfig.drawStart &&
g_stats.this_frame.num_drawn_objects < g_ActiveConfig.drawEnd)
{
DumpActiveTextures();
}
}

void OnObjectEnd()
{
if (g_ActiveConfig.bDumpObjects && stats.thisFrame.numDrawnObjects >= g_ActiveConfig.drawStart &&
stats.thisFrame.numDrawnObjects < g_ActiveConfig.drawEnd)
if (g_ActiveConfig.bDumpObjects &&
g_stats.this_frame.num_drawn_objects >= g_ActiveConfig.drawStart &&
g_stats.this_frame.num_drawn_objects < g_ActiveConfig.drawEnd)
{
DumpEfb(StringFromFormat("%sobject%i.png", File::GetUserPath(D_DUMPOBJECTS_IDX).c_str(),
stats.thisFrame.numDrawnObjects));
g_stats.this_frame.num_drawn_objects));
}

for (int i = 0; i < NUM_OBJECT_BUFFERS; i++)
{
if (DrawnToBuffer[i])
{
DrawnToBuffer[i] = false;
std::string filename =
StringFromFormat("%sobject%i_%s(%i).png", File::GetUserPath(D_DUMPOBJECTS_IDX).c_str(),
stats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]);
std::string filename = StringFromFormat(
"%sobject%i_%s(%i).png", File::GetUserPath(D_DUMPOBJECTS_IDX).c_str(),
g_stats.this_frame.num_drawn_objects, ObjectBufferName[i], i - BufferBase[i]);

TextureToPng((u8*)ObjectBuffer[i], EFB_WIDTH * 4, filename, EFB_WIDTH, EFB_HEIGHT, true);
memset(ObjectBuffer[i], 0, EFB_WIDTH * EFB_HEIGHT * sizeof(u32));
}
}

stats.thisFrame.numDrawnObjects++;
g_stats.this_frame.num_drawn_objects++;
}
} // namespace DebugUtil
@@ -72,7 +72,7 @@ void SetTevReg(int reg, int comp, s16 color)

static void Draw(s32 x, s32 y, s32 xi, s32 yi)
{
INCSTAT(stats.thisFrame.rasterizedPixels);
INCSTAT(g_stats.this_frame.rasterized_pixels);

float dx = vertexOffsetX + (float)(x - vertex0X);
float dy = vertexOffsetY + (float)(y - vertex0Y);
@@ -267,7 +267,7 @@ static void BuildBlock(s32 blockX, s32 blockY)
void DrawTriangleFrontFace(const OutputVertexData* v0, const OutputVertexData* v1,
const OutputVertexData* v2)
{
INCSTAT(stats.thisFrame.numTrianglesDrawn);
INCSTAT(g_stats.this_frame.num_triangles_drawn);

// adapted from http://devmaster.net/posts/6145/advanced-rasterization

@@ -91,7 +91,7 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
// assemble and rasterize the primitive
m_setup_unit.SetupVertex();

INCSTAT(stats.thisFrame.numVerticesLoaded)
INCSTAT(g_stats.this_frame.num_vertices_loaded)
}

DebugUtil::OnObjectEnd();
@@ -568,7 +568,7 @@ void Tev::Draw()
ASSERT(Position[0] >= 0 && Position[0] < EFB_WIDTH);
ASSERT(Position[1] >= 0 && Position[1] < EFB_HEIGHT);

INCSTAT(stats.thisFrame.tevPixelsIn);
INCSTAT(g_stats.this_frame.tev_pixels_in);

// initial color values
for (int i = 0; i < 4; i++)
@@ -869,7 +869,7 @@ void Tev::Draw()
}
#endif

INCSTAT(stats.thisFrame.tevPixelsOut);
INCSTAT(g_stats.this_frame.tev_pixels_out);
EfbInterface::IncPerfCounterQuadCount(PQ_BLEND_INPUT);

EfbInterface::BlendTev(Position[0], Position[1], output);
@@ -181,8 +181,8 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in
m_vertex_stream_buffer->CommitMemory(vertex_data_size);
m_index_stream_buffer->CommitMemory(index_data_size);

ADDSTAT(stats.thisFrame.bytesVertexStreamed, static_cast<int>(vertex_data_size));
ADDSTAT(stats.thisFrame.bytesIndexStreamed, static_cast<int>(index_data_size));
ADDSTAT(g_stats.this_frame.bytes_vertex_streamed, static_cast<int>(vertex_data_size));
ADDSTAT(g_stats.this_frame.bytes_index_streamed, static_cast<int>(index_data_size));

StateTracker::GetInstance()->SetVertexBuffer(m_vertex_stream_buffer->GetBuffer(), 0);
StateTracker::GetInstance()->SetIndexBuffer(m_index_stream_buffer->GetBuffer(), 0,
@@ -207,7 +207,7 @@ void VertexManager::UpdateVertexShaderConstants()
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), &VertexShaderManager::constants,
sizeof(VertexShaderConstants));
m_uniform_stream_buffer->CommitMemory(sizeof(VertexShaderConstants));
ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(VertexShaderConstants));
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(VertexShaderConstants));
VertexShaderManager::dirty = false;
}

@@ -222,7 +222,7 @@ void VertexManager::UpdateGeometryShaderConstants()
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), &GeometryShaderManager::constants,
sizeof(GeometryShaderConstants));
m_uniform_stream_buffer->CommitMemory(sizeof(GeometryShaderConstants));
ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(GeometryShaderConstants));
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(GeometryShaderConstants));
GeometryShaderManager::dirty = false;
}

@@ -237,7 +237,7 @@ void VertexManager::UpdatePixelShaderConstants()
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), &PixelShaderManager::constants,
sizeof(PixelShaderConstants));
m_uniform_stream_buffer->CommitMemory(sizeof(PixelShaderConstants));
ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(PixelShaderConstants));
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, sizeof(PixelShaderConstants));
PixelShaderManager::dirty = false;
}

@@ -302,7 +302,7 @@ void VertexManager::UploadAllConstants()

// Finally, flush buffer memory after copying
m_uniform_stream_buffer->CommitMemory(allocation_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, allocation_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, allocation_size);

// Clear dirty flags
VertexShaderManager::dirty = false;
@@ -324,7 +324,7 @@ void VertexManager::UploadUtilityUniforms(const void* data, u32 data_size)
m_uniform_stream_buffer->GetBuffer(), m_uniform_stream_buffer->GetCurrentOffset(), data_size);
std::memcpy(m_uniform_stream_buffer->GetCurrentHostPointer(), data, data_size);
m_uniform_stream_buffer->CommitMemory(data_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
}

bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format,
@@ -349,7 +349,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
std::memcpy(m_texel_stream_buffer->GetCurrentHostPointer(), data, data_size);
*out_offset = static_cast<u32>(m_texel_stream_buffer->GetCurrentOffset()) / elem_size;
m_texel_stream_buffer->CommitMemory(data_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, data_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, data_size);
StateTracker::GetInstance()->SetTexelBuffer(0, m_texel_buffer_views[format]);
return true;
}
@@ -386,7 +386,7 @@ bool VertexManager::UploadTexelBuffer(const void* data, u32 data_size, TexelBuff
palette_elem_size;

m_texel_stream_buffer->CommitMemory(palette_byte_offset + palette_size);
ADDSTAT(stats.thisFrame.bytesUniformStreamed, palette_byte_offset + palette_size);
ADDSTAT(g_stats.this_frame.bytes_uniform_streamed, palette_byte_offset + palette_size);
StateTracker::GetInstance()->SetTexelBuffer(0, m_texel_buffer_views[format]);
StateTracker::GetInstance()->SetTexelBuffer(1, m_texel_buffer_views[palette_format]);
return true;

0 comments on commit 4c649d1

Please sign in to comment.
You can’t perform that action at this time.