Skip to content

Timeline layer: Update AS build/update in viewer #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ build*
# Data files and build outputs
*.gputl
*.log
*.metadata
*.perfetto
*.so

Expand Down
10 changes: 9 additions & 1 deletion lglpy/timeline/data/processed_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,16 @@ def __init__(
# Populate common data
super().__init__(event, metadata)

# We cannot get specific subtypes from the layer, as one API call can
# contain a mixture of subtypes and is ambiguous. Instead we infer it
# from the Perfetto stage data generated by the driver which is
# subtype-specific, with multiple workloads per Vulkan command if
# the command contains multiple subtypes.
assert metadata.subtype == 'Unknown'
assert event.stage is not None
self.build_type = GPUStageID.get_ui_name(event.stage)

# We must have metadata so no need to check
self.build_type = metadata.subtype
self.primitive_count = metadata.primitive_count

def get_long_label(self) -> str:
Expand Down
79 changes: 50 additions & 29 deletions lglpy/timeline/data/raw_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,27 @@ class GPUStageID(enum.IntEnum):
FRAGMENT: Fragment shaders from a render pass.
BINNING: Binning subset of vertex shaders from a render pass.
MAIN: Main phase vertex and fragment shaders from a render pass.
IMAGE_TRANSFER: Transfers writing an image output.
TRACE_RAYS: Ray tracing pipeline dispatch.
AS_TRANSFER: Transfer writing to/from an acceleration structure.
BUFFER_TRANSFER: Transfer writing a buffer output.
ASBUILD: Acceleration structure build.
IMAGE_TRANSFER: Transfers writing an image output.
AS_BUILD_FAST_BUILD: Acceleration structure build with fast_build.
AS_BUILD_FAST_TRACE: Acceleration structure build with fast_trace.
AS_BUILD_UPDATE: Acceleration structure build with update.
'''
COMPUTE = 0
ADVANCED_GEOMETRY = 1
VERTEX = 2
FRAGMENT = 3
BINNING = 4
MAIN = 5
IMAGE_TRANSFER = 6
BUFFER_TRANSFER = 7
ASBUILD = 8
TRACE_RAYS = 6
AS_TRANSFER = 7
BUFFER_TRANSFER = 8
IMAGE_TRANSFER = 9
AS_BUILD_FAST_BUILD = 10
AS_BUILD_FAST_TRACE = 11
AS_BUILD_UPDATE = 12

@classmethod
def get_ui_name(cls, stage_id) -> str:
Expand All @@ -123,9 +131,13 @@ def get_ui_name(cls, stage_id) -> str:
cls.FRAGMENT: 'Fragment',
cls.BINNING: 'Binning',
cls.MAIN: 'Main',
cls.IMAGE_TRANSFER: 'Image transfer',
cls.TRACE_RAYS: 'Trace rays',
cls.AS_TRANSFER: 'AS transfer',
cls.BUFFER_TRANSFER: 'Buffer transfer',
cls.ASBUILD: 'Acceleration structure build',
cls.IMAGE_TRANSFER: 'Image transfer',
cls.AS_BUILD_FAST_BUILD: 'AS build (fast build)',
cls.AS_BUILD_FAST_TRACE: 'AS build (fast trace)',
cls.AS_BUILD_UPDATE: 'AS build (update)'
}

return human_names[stage_id]
Expand Down Expand Up @@ -580,30 +592,39 @@ class PerfettoConfig:
'''
# Known Perfetto streams and their remapped names
STREAM_REMAP = {
"compute": GPUStreamID.COMPUTE,
"non-fragment": GPUStreamID.NONFRAGMENT,
"fragment": GPUStreamID.FRAGMENT,
"binning": GPUStreamID.BINNING,
"main": GPUStreamID.MAIN,
"transfer": GPUStreamID.TRANSFER
'compute': GPUStreamID.COMPUTE,
'vertex': GPUStreamID.NONFRAGMENT,
'non-fragment': GPUStreamID.NONFRAGMENT,
'fragment': GPUStreamID.FRAGMENT,
'binning': GPUStreamID.BINNING,
'main': GPUStreamID.MAIN,
'transfer': GPUStreamID.TRANSFER
}

# Known Perfetto render stages and their remapped names
STAGE_REMAP = {
"clear image": GPUStageID.IMAGE_TRANSFER,
"copy image": GPUStageID.IMAGE_TRANSFER,
"blit image": GPUStageID.IMAGE_TRANSFER,
"generate mipmap": GPUStageID.IMAGE_TRANSFER,
"copy buffer": GPUStageID.BUFFER_TRANSFER,
"fill buffer": GPUStageID.BUFFER_TRANSFER,
"compute": GPUStageID.COMPUTE,
"advanced geometry": GPUStageID.ADVANCED_GEOMETRY,
"vertex": GPUStageID.VERTEX,
"fragment": GPUStageID.FRAGMENT,
"binning": GPUStageID.BINNING,
"main": GPUStageID.MAIN,
"acceleration structure 'fast build' build": GPUStageID.ASBUILD,
"acceleration structure 'fast trace' build": GPUStageID.ASBUILD,
'clear image': GPUStageID.IMAGE_TRANSFER,
'copy image': GPUStageID.IMAGE_TRANSFER,
'blit image': GPUStageID.IMAGE_TRANSFER,
'resolve image': GPUStageID.IMAGE_TRANSFER,
'generate mipmap': GPUStageID.IMAGE_TRANSFER,
'copy buffer': GPUStageID.BUFFER_TRANSFER,
'fill buffer': GPUStageID.BUFFER_TRANSFER,
'copy query': GPUStageID.BUFFER_TRANSFER,
'compute': GPUStageID.COMPUTE,
'trace_rays': GPUStageID.TRACE_RAYS,
'advanced geometry': GPUStageID.ADVANCED_GEOMETRY,
'vertex': GPUStageID.VERTEX,
'fragment': GPUStageID.FRAGMENT,
'binning': GPUStageID.BINNING,
'main': GPUStageID.MAIN,
"acceleration structure 'fast build' build":
GPUStageID.AS_BUILD_FAST_BUILD,
"acceleration structure 'fast trace' build":
GPUStageID.AS_BUILD_FAST_TRACE,
'acceleration structure copy to memory': GPUStageID.AS_TRANSFER,
'acceleration structure copy from memory': GPUStageID.AS_TRANSFER,
'acceleration structure update': GPUStageID.BUFFER_TRANSFER
}

def __init__(self):
Expand Down Expand Up @@ -731,7 +752,7 @@ def replace_interned_stage(self, event: RenderstageEvent) -> None:

# Interned ID does not exist
else:
assert False, "Stage IID not found"
assert False, 'ERROR: Unknown stage interned data ID'


class RawTrace:
Expand Down Expand Up @@ -863,7 +884,7 @@ def load_perfetto_from_file(
for event in trace_events:
event.start_time -= start_time

# Also ensure that "queued time" does not show as running
# Also ensure that queued time does not show as running
if event.stream not in streams:
streams[event.stream] = [event]
continue
Expand Down