vsg StatsCounter

📅 发布时间:2026/7/13 9:25:18 👁️ 浏览次数:
vsg StatsCounter
材质https://cloud.tencent.com/developer/article/2599321classStatsCounter:publicvsg::Visitor{public:uint64_ttriangles0;uint64_tvertices0;uint64_tindices0;uint64_tdrawCalls0;VkPrimitiveTopology topologyVK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;voidreset(){triangles0;vertices0;indices0;drawCalls0;}voidapply(vsg::Nodenode)override{node.traverse(*this);}voidapply(vsg::BindGraphicsPipelinebind)override{autopipelinebind.pipeline;for(autos:pipeline-pipelineStates){if(ss-is_compatible(typeid(vsg::InputAssemblyState))){autoinputAssemblyStates-castvsg::InputAssemblyState();topologyinputAssemblyState-topology;break;}}bind.traverse(*this);}uint64_tcalcTriangles(uint32_tcount){switch(topology){caseVK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:returncount/3;caseVK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:caseVK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:returncount3?count-2:0;caseVK_PRIMITIVE_TOPOLOGY_LINE_LIST:caseVK_PRIMITIVE_TOPOLOGY_LINE_STRIP:caseVK_PRIMITIVE_TOPOLOGY_POINT_LIST:return0;default:return0;}}voidapply(vsg::Drawdraw)override{drawCalls;verticesdraw.vertexCount;trianglescalcTriangles(draw.vertexCount);}voidapply(vsg::DrawIndexeddraw)override{drawCalls;indicesdraw.indexCount;trianglescalcTriangles(draw.indexCount);}voidapply(vsg::VertexIndexDrawdraw)override{drawCalls;indicesdraw.indexCount;trianglescalcTriangles(draw.indexCount);}};