Skip to content

Commit

Permalink
Response to changes requested
Browse files Browse the repository at this point in the history
Added GetGraphVisualizationFile function in the entire pipeline of Gapid.
  • Loading branch information
elviscapiaq authored and bjoeris committed Jan 2, 2019
1 parent 5e0bcc9 commit ef4bedc
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 97 deletions.
2 changes: 1 addition & 1 deletion cmd/gapit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ go_library(
"benchmark.go",
"commands.go",
"common.go",
"create_graph_visualization.go",
"devices.go",
"dump.go",
"dump_fbo.go",
Expand All @@ -29,7 +30,6 @@ go_library(
"dump_shaders.go",
"export_replay.go",
"flags.go",
"graph_visualization.go",
"inputs.go",
"main.go",
"memory.go",
Expand Down
74 changes: 74 additions & 0 deletions cmd/gapit/create_graph_visualization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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"
"os"
)

type createGraphVisualizationVerb struct{ CreateGraphVisualizationFlags }

func init() {
verb := &createGraphVisualizationVerb{}
app.AddVerb(&app.Verb{
Name: "create_graph_visualization",
ShortHelp: "Create graph visualization file from capture",
Action: verb,
})
}

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

client, capture, err := getGapisAndLoadCapture(ctx, verb.Gapis, GapirFlags{}, flags.Arg(0), CaptureFileFlags{})
if err != nil {
return err
}
defer client.Close()

log.I(ctx, "Creating graph visualization file from capture id: %s", capture.ID)

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

filePath := verb.Out
if filePath == "" {
filePath = "graph_visualization.dot"
}

_, err = os.Stat(filePath)
if os.IsNotExist(err) {
file, err := os.Create(filePath)
if err != nil {
log.Errf(ctx, err, "Creating file (%v)", filePath)
}
defer file.Close()
}

if err := ioutil.WriteFile(filePath, []byte(graphVisualization), 0666); err != nil {
return log.Errf(ctx, err, "Writing file: %v", filePath)
}
return nil
}
5 changes: 2 additions & 3 deletions cmd/gapit/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ type (
Out string `help:"output file to save the profiling result"`
}

GraphVisualizationFlags struct {
CreateGraphVisualizationFlags struct {
Gapis GapisFlags
Gapir GapirFlags
Out string `help:"path to Save Dot File"`
Out string `help:"path to save graph visualization"`
}
)
72 changes: 0 additions & 72 deletions cmd/gapit/graph_visualization.go

This file was deleted.

6 changes: 3 additions & 3 deletions gapis/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ 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{
func (c *client) GetGraphVisualization(ctx context.Context, capture *path.Capture) (string, error) {
res, err := c.client.GetGraphVisualization(ctx, &service.GraphVisualizationRequest{
Capture: capture,
})
if err != nil {
Expand All @@ -495,5 +495,5 @@ func (c *client) GetGraphVisualizationFile(ctx context.Context, capture *path.Ca
if err := res.GetError(); err != nil {
return "", err.Get()
}
return res.GetGraphVisualizationFile(), nil
return res.GetGraphVisualization(), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ go_library(
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",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +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.

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) {
func GetGraphVisualizationFromCapture(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
Expand Down
8 changes: 4 additions & 4 deletions gapis/server/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,13 @@ 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) {
func (s *grpcServer) GetGraphVisualization(ctx xctx.Context, req *service.GraphVisualizationRequest) (*service.GraphVisualizationResponse, error) {
defer s.inRPC()()
graphVisualizationFile, err := s.handler.GetGraphVisualizationFile(s.bindCtx(ctx), req.Capture)
graphVisualization, err := s.handler.GetGraphVisualization(s.bindCtx(ctx), req.Capture)
if err := service.NewError(err); err != nil {
return &service.GraphVisualizationFileResponse{Res: &service.GraphVisualizationFileResponse_Error{Error: err}}, nil
return &service.GraphVisualizationResponse{Res: &service.GraphVisualizationResponse_Error{Error: err}}, nil
}
return &service.GraphVisualizationFileResponse{Res: &service.GraphVisualizationFileResponse_GraphVisualizationFile{GraphVisualizationFile: graphVisualizationFile}}, nil
return &service.GraphVisualizationResponse{Res: &service.GraphVisualizationResponse_GraphVisualization{GraphVisualization: graphVisualization}}, nil
}

func (s *grpcServer) GetDevices(ctx xctx.Context, req *service.GetDevicesRequest) (*service.GetDevicesResponse, error) {
Expand Down
10 changes: 6 additions & 4 deletions gapis/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +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")
func (s *server) GetGraphVisualization(ctx context.Context, p *path.Capture) (string, error) {
ctx = status.Start(ctx, "RPC GetGraphVisualization")
defer status.Finish(ctx)
ctx = log.Enter(ctx, "GetGraphVisualization")
c, err := capture.ResolveFromPath(ctx, p)
if err != nil {
return "", err
}
graphVisualizationFile, err := graph_visualization.GetGraphVisualizationFileFromCapture(ctx, c)
graphVisualization, err := graph_visualization.GetGraphVisualizationFromCapture(ctx, c)
if err != nil {
return "", err
}
return graphVisualizationFile, nil
return graphVisualization, nil
}

func (s *server) GetDevices(ctx context.Context) ([]*path.Device, error) {
Expand Down
2 changes: 1 addition & 1 deletion gapis/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ 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)
GetGraphVisualization(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.
Expand Down
10 changes: 5 additions & 5 deletions gapis/service/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ message DCECaptureResponse {
}
}

message GraphVisualizationFileRequest {
message GraphVisualizationRequest {
path.Capture capture = 1;
}
message GraphVisualizationFileResponse {
message GraphVisualizationResponse {
oneof res {
string graphVisualizationFile = 1;
string graphVisualization = 1;
Error error = 2;
}
}
Expand Down Expand Up @@ -563,8 +563,8 @@ service Gapid {
rpc DCECapture(DCECaptureRequest) returns (DCECaptureResponse) {
}

rpc GetGraphVisualizationFile(GraphVisualizationFileRequest)
returns (GraphVisualizationFileResponse) {
rpc GetGraphVisualization(GraphVisualizationRequest)
returns (GraphVisualizationResponse) {
}
// GetDevices returns the full list of replay devices avaliable to the server.
// These include local replay devices and any connected Android devices.
Expand Down

0 comments on commit ef4bedc

Please sign in to comment.