public void SetupCounters() { if (Configuration.AMDGPUPerf == false) { return; } uint count; var status = GPUPerfAPI.GPA.GPA_GetNumCounters(out count); Console.WriteLine("Got " + count + " performance counters"); counters = new AMDGPUCounter[count]; for (uint i = 0; i < count; ++i) { GPUPerfAPI.GPA_Type type; GPUPerfAPI.GPA_Usage_Type usage; string description; string name; GPUPerfAPI.GPA.GPA_GetCounterDataType(i, out type); GPUPerfAPI.GPA.GPA_GetCounterDescription(i, out description); GPUPerfAPI.GPA.GPA_GetCounterName(i, out name); GPUPerfAPI.GPA.GPA_GetCounterUsageType(i, out usage); counters[i] = new AMDGPUCounter(i, type, usage, name, description); dictionary[name] = counters[i]; Console.WriteLine(counters[i].ToString()); } Console.WriteLine("----"); // All are GPA_TYPE_FLOAT64 // GPA_USAGE_TYPE_MILLISECONDS GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["GPUTime"].Index); // GPA_USAGE_TYPE_PERCENTAGE GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["GPUBusy"].Index); //GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["TessellatorBusy"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["ShaderBusy"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["ShaderBusyVS"].Index); //GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["ShaderBusyHS"].Index); //GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["ShaderBusyDS"].Index); //GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["ShaderBusyGS"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["ShaderBusyPS"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["PSTexBusy"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["PSExportStalls"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["PSTexInstCount"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["PSPixelsIn"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["PSPixelsOut"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["HiZQuadsCulled"].Index); GPUPerfAPI.GPA.GPA_EnableCounter(dictionary["ZUnitStalled"].Index); GPUPerfAPI.GPA.GPA_GetPassCount(out requiredPassCount); Console.WriteLine("NumPasses = " + requiredPassCount); }
public void GetSessionResults(uint sessionId) { if (Configuration.AMDGPUPerf == false) { return; } uint sampleCount = 0; GPUPerfAPI.GPA.GPA_GetSampleCount(sessionId, out sampleCount); for (uint sample = 0; sample < sampleCount; ++sample) { uint counterCount; GPUPerfAPI.GPA.GPA_GetEnabledCount(out counterCount); for (uint j = 0; j < counterCount; ++j) { uint index; GPUPerfAPI.GPA.GPA_GetEnabledIndex(j, out index); AMDGPUCounter counter = counters[index]; GPUPerfAPI.GPA.GPA_GetSampleFloat64(sessionId, sample, index, out counter.DoubleValue); } } }