| // Copyright (C) 2016 The Android Open Source Project |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| package scheduler |
| |
| import ( |
| "android.googlesource.com/platform/tools/gpu/framework/log" |
| "android.googlesource.com/platform/tools/gpu/gapid/robot/build" |
| "android.googlesource.com/platform/tools/gpu/gapid/robot/job" |
| "android.googlesource.com/platform/tools/gpu/gapid/robot/monitor" |
| "android.googlesource.com/platform/tools/gpu/gapid/robot/trace" |
| ) |
| |
| func (s schedule) getTraceTargetTools(ctx log.Context) *build.ToolSet { |
| ctx = ctx.V("Target", s.worker.Target) |
| tools := s.pkg.FindTools(ctx, s.data.FindDevice(s.worker.Target)) |
| if tools == nil { |
| return nil |
| } |
| if tools.Interceptor == "" { |
| return nil |
| } |
| if tools.Gapii == "" { |
| return nil |
| } |
| if tools.VulkanTraceLayer == "" { |
| return nil |
| } |
| return tools |
| } |
| |
| func (s schedule) doTrace(ctx log.Context, subj *monitor.Subject) error { |
| if !s.worker.Supports(job.Trace) { |
| return nil |
| } |
| ctx = ctx.Enter("Trace") |
| ctx = ctx.V("Package", s.pkg.Id) |
| hostTools := s.getHostTools(ctx) |
| targetTools := s.getTraceTargetTools(ctx) |
| if hostTools == nil || targetTools == nil { |
| return nil |
| } |
| input := &trace.Input{ |
| Subject: subj.Id, |
| Gapit: hostTools.Gapit, |
| Interceptor: targetTools.Interceptor, |
| Gapii: targetTools.Gapii, |
| VulkanLayer: targetTools.VulkanTraceLayer, |
| } |
| action := &trace.Action{ |
| Input: input, |
| Host: s.worker.Host, |
| Target: s.worker.Target, |
| } |
| if _, found := s.data.Traces.FindOrCreate(ctx, action); found { |
| return nil |
| } |
| // TODO: we just ignore the error right now, what should we do? |
| go s.managers.Trace.Do(ctx, action.Target, input) |
| return nil |
| } |