| 31 | } |
| 32 | |
| 33 | void Profiler::StartProfile(const wstring& name) |
| 34 | { |
| 35 | ProfileData& profileData = profiles[name]; |
| 36 | Assert_(profileData.QueryStarted == false); |
| 37 | Assert_(profileData.QueryFinished == false); |
| 38 | profileData.CPUProfile = false; |
| 39 | profileData.Active = true; |
| 40 | |
| 41 | if(profileData.DisjointQuery[currFrame] == NULL) |
| 42 | { |
| 43 | // Create the queries |
| 44 | D3D11_QUERY_DESC desc; |
| 45 | desc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT; |
| 46 | desc.MiscFlags = 0; |
| 47 | DXCall(device->CreateQuery(&desc, &profileData.DisjointQuery[currFrame])); |
| 48 | |
| 49 | desc.Query = D3D11_QUERY_TIMESTAMP; |
| 50 | DXCall(device->CreateQuery(&desc, &profileData.TimestampStartQuery[currFrame])); |
| 51 | DXCall(device->CreateQuery(&desc, &profileData.TimestampEndQuery[currFrame])); |
| 52 | } |
| 53 | |
| 54 | // Start a disjoint query first |
| 55 | context->Begin(profileData.DisjointQuery[currFrame]); |
| 56 | |
| 57 | // Insert the start timestamp |
| 58 | context->End(profileData.TimestampStartQuery[currFrame]); |
| 59 | |
| 60 | profileData.QueryStarted = true; |
| 61 | } |
| 62 | |
| 63 | void Profiler::EndProfile(const wstring& name) |
| 64 | { |
no test coverage detected