Skip to content

Commit

Permalink
Graph Visualization: Added the data structure for graph visualization,
Browse files Browse the repository at this point in the history
Dot and Pbtxt formats from the graph, super-nodes (hierarchies)
based on command type and graph properties. Added unit testing for
graph data structure.

Data Structure: The data structure for the graph visualization supports
efficiently operations such as: addNode, addEdge, deleteNode,
deleteEdge, etc.

Get Dot and Pbtxt formats: The dot format allows visualize static graphs
(using Graphviz and Gephi) and the Pbtxt allows visualize dynamic graphs
using TensorBoard.

Super-nodes (hierarchies): Due limits on human and TensorBoard visualization,
creating super-nodes is necessary to improve performance. Initial super-nodes
defined on command type (CommandBuffer, CommandRenderPass and CommandSubPass) and
Strongly connected components.
  • Loading branch information
elviscapiaq authored and bjoeris committed Jan 8, 2019
1 parent aa4e4d9 commit 1236ebb
Show file tree
Hide file tree
Showing 9 changed files with 421 additions and 440 deletions.
1 change: 1 addition & 0 deletions gapis/api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ go_library(
"cmd_service.go",
"context.go",
"doc.go",
"graph_visualization.go",
"labeled.go",
"memory_breakdown.go",
"mesh.go",
Expand Down
55 changes: 55 additions & 0 deletions gapis/api/graph_visualization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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 api

type Hierarchy struct {
LevelsID []int
}

func (h *Hierarchy) GetSize() int {
return len(h.LevelsID)
}

func (h *Hierarchy) GetID(level int) int {
return h.LevelsID[level-1]
}

func (h *Hierarchy) PopBack() {
if len(h.LevelsID) > 0 {
h.LevelsID = h.LevelsID[:len(h.LevelsID)-1]
}
}

func (h *Hierarchy) PushBackToResize(newSize int) {
for len(h.LevelsID) < newSize {
h.LevelsID = append(h.LevelsID, 0)
}
}

func (h *Hierarchy) PopBackToResize(newSize int) {
for len(h.LevelsID) > newSize {
h.PopBack()
}
}

func (h *Hierarchy) IncreaseIDByOne(level int) {
h.LevelsID[level-1]++
}

type GraphVisualizationAPI interface {
GetCommandLabel(currentHierarchy *Hierarchy, command Cmd) string

GetSubCommandLabel(index SubCmdIdx) string
}
1 change: 1 addition & 0 deletions gapis/api/vulkan/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ go_library(
"externs.go",
"find_issues.go",
"footprint_builder.go",
"graph_visualization.go",
"image_primer.go",
"image_primer_shaders.go",
"mem_binding_list.go",
Expand Down
103 changes: 103 additions & 0 deletions gapis/api/vulkan/graph_visualization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// 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 vulkan

import (
"fmt"
"github.com/google/gapid/gapis/api"
)

// Interface compliance test
var (
_ = api.GraphVisualizationAPI(API{})
)

const (
VK_BEGIN_COMMAND_BUFFER = "vkBeginCommandBuffer"
VK_CMD_BEGIN_RENDER_PASS = "vkCmdBeginRenderPass"
VK_CMD_NEXT_SUBPASS = "vkCmdNextSubpass"
VK_COMMAND_BUFFER = "vkCommandBuffer"
VK_RENDER_PASS = "vkRenderPass"
VK_SUBPASS = "vkSubpass"
VK_END_COMMAND_BUFFER = "vkEndCommandBuffer"
VK_CMD_END_RENDER_PASS = "vkCmdEndRenderPass"
COMMAND_BUFFER = "commandBuffer"
)

var (
beginCommands = map[string]int{
VK_BEGIN_COMMAND_BUFFER: 1,
VK_CMD_BEGIN_RENDER_PASS: 2,
VK_CMD_NEXT_SUBPASS: 3,
}
listOfCommandNames = []string{
VK_COMMAND_BUFFER,
VK_RENDER_PASS,
VK_SUBPASS,
}
endCommands = map[string]int{
VK_END_COMMAND_BUFFER: 1,
VK_CMD_END_RENDER_PASS: 2,
VK_CMD_NEXT_SUBPASS: 3,
}
)

func getCommandBuffer(command api.Cmd) string {
parameters := command.CmdParams()
for _, parameter := range parameters {
if parameter.Name == COMMAND_BUFFER {
commandBuffer := parameter.Name + fmt.Sprintf("%d", parameter.Get()) + "/"
return commandBuffer
}
}
return ""
}

func (API) GetCommandLabel(hierarchy *api.Hierarchy, command api.Cmd) string {
commandName := command.CmdName()
isEndCommand := false
if level, ok := beginCommands[commandName]; ok {
hierarchy.PushBackToResize(level + 1)
hierarchy.IncreaseIDByOne(level)
} else {
if level, ok := endCommands[commandName]; ok {
hierarchy.PopBackToResize(level + 1)
isEndCommand = true
}
}

label := getCommandBuffer(command)
for level := 1; level < hierarchy.GetSize(); level++ {
label += fmt.Sprintf("%s%d/", listOfCommandNames[level-1], hierarchy.GetID(level))
}

if level, ok := beginCommands[commandName]; ok && commandName == VK_CMD_BEGIN_RENDER_PASS {
levelForSubpass := level + 1
hierarchy.PushBackToResize(levelForSubpass + 1)
hierarchy.IncreaseIDByOne(levelForSubpass)
}
if isEndCommand {
hierarchy.PopBack()
}
return label
}

func (API) GetSubCommandLabel(index api.SubCmdIdx) string {
label := ""
for i := 1; i < len(index); i++ {
label += fmt.Sprintf("/%d", index[i])
}
return label
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ go_library(
importpath = "github.com/google/gapid/gapis/resolve/dependencygraph2/graph_visualization",
visibility = ["//visibility:public"],
deps = [
"//core/math/interval:go_default_library",
"//gapis/api:go_default_library",
"//gapis/capture:go_default_library",
"//gapis/resolve/dependencygraph2:go_default_library",
"//gapis/service/path:go_default_library",
],
)

Expand Down
Loading

0 comments on commit 1236ebb

Please sign in to comment.