| 
									
										
										
										
											2015-05-24 06:32:32 +02:00
										 |  |  | // Copyright 2012 Dolphin Emulator Project
 | 
					
						
							|  |  |  | // Licensed under GPLv2+
 | 
					
						
							|  |  |  | // Refer to the license.txt file included.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-10 13:54:46 -05:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2012-06-17 13:58:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-20 21:49:49 -05:00
										 |  |  | #include <memory>
 | 
					
						
							| 
									
										
										
										
											2014-02-17 05:18:15 -05:00
										 |  |  | #include "Common/CommonTypes.h"
 | 
					
						
							| 
									
										
										
										
											2012-06-17 13:58:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum PerfQueryType | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   PQ_ZCOMP_INPUT_ZCOMPLOC = 0, | 
					
						
							|  |  |  |   PQ_ZCOMP_OUTPUT_ZCOMPLOC, | 
					
						
							|  |  |  |   PQ_ZCOMP_INPUT, | 
					
						
							|  |  |  |   PQ_ZCOMP_OUTPUT, | 
					
						
							|  |  |  |   PQ_BLEND_INPUT, | 
					
						
							|  |  |  |   PQ_EFB_COPY_CLOCKS, | 
					
						
							|  |  |  |   PQ_NUM_MEMBERS | 
					
						
							| 
									
										
										
										
											2012-06-17 13:58:29 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum PerfQueryGroup | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   PQG_ZCOMP_ZCOMPLOC, | 
					
						
							|  |  |  |   PQG_ZCOMP, | 
					
						
							|  |  |  |   PQG_EFB_COPY_CLOCKS, | 
					
						
							|  |  |  |   PQG_NUM_MEMBERS, | 
					
						
							| 
									
										
										
										
											2012-06-17 13:58:29 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class PerfQueryBase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   PerfQueryBase() : m_query_count(0) {} | 
					
						
							|  |  |  |   virtual ~PerfQueryBase() {} | 
					
						
							|  |  |  |   // Checks if performance queries are enabled in the gameini configuration.
 | 
					
						
							|  |  |  |   // NOTE: Called from CPU+GPU thread
 | 
					
						
							|  |  |  |   static bool ShouldEmulate(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Begin querying the specified value for the following host GPU commands
 | 
					
						
							|  |  |  |   virtual void EnableQuery(PerfQueryGroup type) {} | 
					
						
							|  |  |  |   // Stop querying the specified value for the following host GPU commands
 | 
					
						
							|  |  |  |   virtual void DisableQuery(PerfQueryGroup type) {} | 
					
						
							|  |  |  |   // Reset query counters to zero and drop any pending queries
 | 
					
						
							|  |  |  |   virtual void ResetQuery() {} | 
					
						
							|  |  |  |   // Return the measured value for the specified query type
 | 
					
						
							|  |  |  |   // NOTE: Called from CPU thread
 | 
					
						
							|  |  |  |   virtual u32 GetQueryResult(PerfQueryType type) { return 0; } | 
					
						
							|  |  |  |   // Request the value of any pending queries - causes a pipeline flush and thus should be used
 | 
					
						
							|  |  |  |   // carefully!
 | 
					
						
							|  |  |  |   virtual void FlushResults() {} | 
					
						
							|  |  |  |   // True if there are no further pending query results
 | 
					
						
							|  |  |  |   // NOTE: Called from CPU thread
 | 
					
						
							|  |  |  |   virtual bool IsFlushed() const { return true; } | 
					
						
							| 
									
										
										
										
											2015-04-15 19:22:16 -04:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2016-06-24 10:43:46 +02:00
										 |  |  |   // TODO: sloppy
 | 
					
						
							|  |  |  |   volatile u32 m_query_count; | 
					
						
							|  |  |  |   volatile u32 m_results[PQG_NUM_MEMBERS]; | 
					
						
							| 
									
										
										
										
											2012-06-17 13:58:29 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-20 21:49:49 -05:00
										 |  |  | extern std::unique_ptr<PerfQueryBase> g_perf_query; |