-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Graph Visualization: Added the data structure for graph visualization,
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
1 parent
aa4e4d9
commit 1236ebb
Showing
9 changed files
with
421 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.