Skip to content

Commit

Permalink
Added GetGraphVisualizationFile function in the entire pipeline of Ga…
Browse files Browse the repository at this point in the history
…pid.
  • Loading branch information
elviscapiaq authored and bjoeris committed Jan 2, 2019
1 parent 55f73cd commit 5e0bcc9
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/gapit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ go_library(
"dump_shaders.go",
"export_replay.go",
"flags.go",
"graph_visualization.go",
"inputs.go",
"main.go",
"memory.go",
Expand Down
6 changes: 6 additions & 0 deletions cmd/gapit/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,10 @@ type (
Gapir GapirFlags
Out string `help:"output file to save the profiling result"`
}

GraphVisualizationFlags struct {
Gapis GapisFlags
Gapir GapirFlags
Out string `help:"path to Save Dot File"`
}
)
72 changes: 72 additions & 0 deletions cmd/gapit/graph_visualization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright (C) 2018 Google Inc.
//
// 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 main

import (
"context"
"flag"
"github.com/google/gapid/core/app"
"github.com/google/gapid/core/log"
"io/ioutil"
"path/filepath"
)

type graph_visualizationVerb struct{ GraphVisualizationFlags }

func init() {
verb := &graph_visualizationVerb{}
app.AddVerb(&app.Verb{
Name: "graph_visualization",
ShortHelp: "Get and Write graph-visualization file from capture",
Action: verb,
})
}

func (verb *graph_visualizationVerb) Run(ctx context.Context, flags flag.FlagSet) error {
if flags.NArg() != 1 {
app.Usage(ctx, "Exactly one gfx capture file expected, got %d", flags.NArg())
return nil
}

capturePath, err := filepath.Abs(flags.Arg(0))
if err != nil {
return log.Errf(ctx, err, "Finding file: %v", flags.Arg(0))
}

client, err := getGapis(ctx, verb.Gapis, verb.Gapir)
if err != nil {
return log.Err(ctx, err, "Failed to connect to the GAPIS server")
}
defer client.Close()

capture, err := client.LoadCapture(ctx, capturePath)
if err != nil {
return log.Errf(ctx, err, "LoadCapture(%v)", capturePath)
}

graphVisualizationFile, err := client.GetGraphVisualizationFile(ctx, capture)
if err != nil {
return log.Errf(ctx, err, "ExportCapture(%v)", capture)
}

graphVisualizationName := verb.Out
if graphVisualizationName == "" {
graphVisualizationName = "graph_visualizatione.dot"
}
if err := ioutil.WriteFile(graphVisualizationName, []byte(graphVisualizationFile), 0666); err != nil {
return log.Errf(ctx, err, "Writing file: %v", graphVisualizationName)
}
return nil
}
13 changes: 13 additions & 0 deletions gapis/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,16 @@ func (c *client) GetTimestamps(ctx context.Context, capture *path.Capture, devic
}
return res, nil
}

func (c *client) GetGraphVisualizationFile(ctx context.Context, capture *path.Capture) (string, error) {
res, err := c.client.GetGraphVisualizationFile(ctx, &service.GraphVisualizationFileRequest{
Capture: capture,
})
if err != nil {
return "", err
}
if err := res.GetError(); err != nil {
return "", err.Get()
}
return res.GetGraphVisualizationFile(), nil
}
29 changes: 29 additions & 0 deletions gapis/resolve/dependencygraph2/graph_visualization/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (C) 2018 Google Inc.
#
# 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.

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["graph_visualization.go"],
importpath = "github.com/google/gapid/gapis/resolve/dependencygraph2/graph_visualization",
visibility = ["//visibility:public"],
deps = [
"//core/log:go_default_library",
"//core/math/interval:go_default_library",
"//gapis/api:go_default_library",
"//gapis/capture:go_default_library",
"//gapis/resolve/dependencygraph2:go_default_library",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package graph_visualization

import (
"context"
"github.com/google/gapid/core/log"
"github.com/google/gapid/core/math/interval"
"github.com/google/gapid/gapis/api"
"github.com/google/gapid/gapis/capture"
"github.com/google/gapid/gapis/resolve/dependencygraph2"
)

func GetGraphVisualizationFileFromCapture(ctx context.Context, p *capture.Capture) (string, error) {

log.I(ctx, "Working on GetGraphDotFileFromCapture")
config := dependencygraph2.DependencyGraphConfig{}
dependencyGraph, err := dependencygraph2.BuildDependencyGraph(ctx, config, p, []api.Cmd{}, interval.U64RangeList{})
_ = dependencyGraph

return "OutputFile", err
}
1 change: 1 addition & 0 deletions gapis/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ go_library(
"//gapis/resolve:go_default_library",
"//gapis/resolve/dependencygraph:go_default_library",
"//gapis/resolve/dependencygraph2:go_default_library",
"//gapis/resolve/dependencygraph2/graph_visualization:go_default_library",
"//gapis/service:go_default_library",
"//gapis/service/path:go_default_library",
"//gapis/stringtable:go_default_library",
Expand Down
9 changes: 9 additions & 0 deletions gapis/server/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ func (s *grpcServer) DCECapture(ctx xctx.Context, req *service.DCECaptureRequest
return &service.DCECaptureResponse{Res: &service.DCECaptureResponse_Capture{Capture: capture}}, nil
}

func (s *grpcServer) GetGraphVisualizationFile(ctx xctx.Context, req *service.GraphVisualizationFileRequest) (*service.GraphVisualizationFileResponse, error) {
defer s.inRPC()()
graphVisualizationFile, err := s.handler.GetGraphVisualizationFile(s.bindCtx(ctx), req.Capture)
if err := service.NewError(err); err != nil {
return &service.GraphVisualizationFileResponse{Res: &service.GraphVisualizationFileResponse_Error{Error: err}}, nil
}
return &service.GraphVisualizationFileResponse{Res: &service.GraphVisualizationFileResponse_GraphVisualizationFile{GraphVisualizationFile: graphVisualizationFile}}, nil
}

func (s *grpcServer) GetDevices(ctx xctx.Context, req *service.GetDevicesRequest) (*service.GetDevicesResponse, error) {
defer s.inRPC()()
devices, err := s.handler.GetDevices(s.bindCtx(ctx))
Expand Down
14 changes: 14 additions & 0 deletions gapis/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"github.com/google/gapid/gapis/resolve"
"github.com/google/gapid/gapis/resolve/dependencygraph"
"github.com/google/gapid/gapis/resolve/dependencygraph2"
"github.com/google/gapid/gapis/resolve/dependencygraph2/graph_visualization"
"github.com/google/gapid/gapis/service"
"github.com/google/gapid/gapis/service/path"
"github.com/google/gapid/gapis/stringtable"
Expand Down Expand Up @@ -298,6 +299,19 @@ func (s *server) DCECapture(ctx context.Context, p *path.Capture, requested []*p
return trimmed, nil
}

func (s *server) GetGraphVisualizationFile(ctx context.Context, p *path.Capture) (string, error) {
ctx = log.Enter(ctx, "Inside GetGraphVisualizationFile function")
c, err := capture.ResolveFromPath(ctx, p)
if err != nil {
return "", err
}
graphVisualizationFile, err := graph_visualization.GetGraphVisualizationFileFromCapture(ctx, c)
if err != nil {
return "", err
}
return graphVisualizationFile, nil
}

func (s *server) GetDevices(ctx context.Context) ([]*path.Device, error) {
ctx = status.Start(ctx, "RPC GetDevices")
defer status.Finish(ctx)
Expand Down
2 changes: 2 additions & 0 deletions gapis/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ type Service interface {
// DCECapture returns a new capture containing only the requested commands and their dependencies.
DCECapture(ctx context.Context, capture *path.Capture, commands []*path.Command) (*path.Capture, error)

GetGraphVisualizationFile(ctx context.Context, capture *path.Capture) (string, error)

// GetDevices returns the full list of replay devices avaliable to the server.
// These include local replay devices and any connected Android devices.
// This list may change over time, as devices are connected and disconnected.
Expand Down
13 changes: 13 additions & 0 deletions gapis/service/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ message DCECaptureResponse {
}
}

message GraphVisualizationFileRequest {
path.Capture capture = 1;
}
message GraphVisualizationFileResponse {
oneof res {
string graphVisualizationFile = 1;
Error error = 2;
}
}

message GetDevicesRequest {
}
message GetDevicesResponse {
Expand Down Expand Up @@ -553,6 +563,9 @@ service Gapid {
rpc DCECapture(DCECaptureRequest) returns (DCECaptureResponse) {
}

rpc GetGraphVisualizationFile(GraphVisualizationFileRequest)
returns (GraphVisualizationFileResponse) {
}
// GetDevices returns the full list of replay devices avaliable to the server.
// These include local replay devices and any connected Android devices.
// This list may change over time, as devices are connected and disconnected.
Expand Down

0 comments on commit 5e0bcc9

Please sign in to comment.