From a51d6a6dddc99b91a19025988a3e91bb2bc02acb Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 23 May 2013 21:07:01 +0200 Subject: [PATCH] add new statistics for gpu buffer streaming --- Source/Core/VideoCommon/Src/Statistics.cpp | 3 +++ Source/Core/VideoCommon/Src/Statistics.h | 4 ++++ Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp | 2 ++ Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp | 3 +++ Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp | 2 ++ Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp | 2 ++ Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp | 2 ++ Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp | 3 +++ 8 files changed, 21 insertions(+) diff --git a/Source/Core/VideoCommon/Src/Statistics.cpp b/Source/Core/VideoCommon/Src/Statistics.cpp index 3dcd281b7f..0c69499355 100644 --- a/Source/Core/VideoCommon/Src/Statistics.cpp +++ b/Source/Core/VideoCommon/Src/Statistics.cpp @@ -55,6 +55,9 @@ char *Statistics::ToString(char *ptr) ptr+=sprintf(ptr,"CP loads (DL): %i\n",stats.thisFrame.numCPLoadsInDL); ptr+=sprintf(ptr,"BP loads: %i\n",stats.thisFrame.numBPLoads); ptr+=sprintf(ptr,"BP loads (DL): %i\n",stats.thisFrame.numBPLoadsInDL); + ptr+=sprintf(ptr,"Vertex streamed: %i kB\n",stats.thisFrame.bytesVertexStreamed/1024); + ptr+=sprintf(ptr,"Index streamed: %i kB\n",stats.thisFrame.bytesIndexStreamed/1024); + ptr+=sprintf(ptr,"Uniform streamed: %i kB\n",stats.thisFrame.bytesUniformStreamed/1024); ptr+=sprintf(ptr,"Vertex Loaders: %i\n",stats.numVertexLoaders); std::string text1; diff --git a/Source/Core/VideoCommon/Src/Statistics.h b/Source/Core/VideoCommon/Src/Statistics.h index cb8a3afdc5..a7976651a5 100644 --- a/Source/Core/VideoCommon/Src/Statistics.h +++ b/Source/Core/VideoCommon/Src/Statistics.h @@ -60,6 +60,10 @@ struct Statistics int numBufferSplits; int numDListsCalled; + + int bytesVertexStreamed; + int bytesIndexStreamed; + int bytesUniformStreamed; }; ThisFrame thisFrame; void ResetFrame(); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp index bc5004d0c2..a2bdd360c2 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp @@ -345,6 +345,8 @@ ID3D11Buffer* &PixelShaderCache::GetConstantBuffer() memcpy(map.pData, psconstants, sizeof(psconstants)); D3D::context->Unmap(pscbuf, 0); pscbufchanged = false; + + ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(psconstants)); } return pscbuf; } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp index 1f2a662b53..46161e25a5 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexManager.cpp @@ -128,6 +128,9 @@ void VertexManager::PrepareDrawBuffers() memcpy((u16*)map.pData + m_point_draw_index, GetPointIndexBuffer(), sizeof(u16) * IndexGenerator::GetPointindexLen()); D3D::context->Unmap(m_index_buffers[m_current_index_buffer], 0); m_index_buffer_cursor += iCount; + + ADDSTAT(stats.thisFrame.bytesVertexStreamed, vSize); + ADDSTAT(stats.thisFrame.bytesIndexStreamed, iCount*sizeof(u16)); } static const float LINE_PT_TEX_OFFSETS[8] = { diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp index ade8d7697c..267f7c9642 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp @@ -50,6 +50,8 @@ ID3D11Buffer* &VertexShaderCache::GetConstantBuffer() memcpy(map.pData, vsconstants, sizeof(vsconstants)); D3D::context->Unmap(vscbuf, 0); vscbufchanged = false; + + ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(vsconstants)); } return vscbuf; } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index 348f2d89a2..e0592b12e0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -197,6 +197,8 @@ void VertexManager::PrepareDrawBuffers(u32 stride) D3D::SetIndices(m_index_buffers[m_current_index_buffer]); } + ADDSTAT(stats.thisFrame.bytesVertexStreamed, datasize); + ADDSTAT(stats.thisFrame.bytesIndexStreamed, IndexDataSize); } void VertexManager::DrawVertexBuffer(int stride) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index 1c85177352..2df1f47760 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -171,6 +171,8 @@ void ProgramShaderCache::UploadConstants() glBindBufferRange(GL_UNIFORM_BUFFER, 1, s_buffer->getBuffer(), offset, s_ps_data_size); glBindBufferRange(GL_UNIFORM_BUFFER, 2, s_buffer->getBuffer(), offset + s_vs_data_offset, s_vs_data_size); s_ubo_dirty = false; + + ADDSTAT(stats.thisFrame.bytesUniformStreamed, s_ubo_buffer_size); } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index 6e1590c1c6..59ea68504b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -104,6 +104,9 @@ void VertexManager::PrepareDrawBuffers(u32 stride) { s_offset[2] = s_indexBuffer->Upload((u8*)GetPointIndexBuffer(), point_index_size * sizeof(u16)); } + + ADDSTAT(stats.thisFrame.bytesVertexStreamed, vertex_data_size); + ADDSTAT(stats.thisFrame.bytesIndexStreamed, index_size); } void VertexManager::Draw(u32 stride)