Skip to content

Commit

Permalink
Add options to save and load pipeline caches
Browse files Browse the repository at this point in the history
Add three options `--save-pipeline-cache`, `--load-pipeline-cache`
and `--add-new-pipeline-caches` to manually handle pipeline cache
creation/loading instead of using the ones saved in the capture file.

This is useful when pipeline creation is slow on the target system.
You can generate the cache once then run the trace multiple times,
or generate it on a faster device type with the same GPU and driver.

When using `--save-pipeline-cache` the contents of the pipeline
caches are written to the specified file just before their
destruction, and just before the destruction of the last bound
pipeline for caches created by `--create-new-pipeline-cache`, or at
the end of the program if no destruction occurs before.

When using `--load-pipeline-cache` the contents of the pipeline
caches are loaded just before their creation, and just before the
creation of the pipeline for caches created by
`--create-new-pipeline-cache`.

If set, allows gfxreconstruct to create new vkPipelineCache objects
when it encounters a pipeline created without cache. This option
can be used in coordination with `--save-pipeline-cache` and
`--load-pipeline-cache`.

Change-Id: I40667416efe4c88033c386f6ec5fd53a86dd58ca
  • Loading branch information
marius-pelegrin-arm committed Jan 26, 2024
1 parent 118b535 commit 655c52c
Show file tree
Hide file tree
Showing 10 changed files with 617 additions and 51 deletions.
17 changes: 17 additions & 0 deletions USAGE_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,23 @@ optional arguments:
Swap the swapchain color space if unsupported by replay device.
Check if color space is not supported by replay device and swap
to VK_COLOR_SPACE_SRGB_NONLINEAR_KHR. (forwarded to replay tool).
--save-pipeline-cache DEVICE_FILE
If set, produces pipeline caches at replay time instead
of using the one saved at capture time and save those
caches in DEVICE_FILE.
(forwarded to replay tool)
--load-pipeline-cache DEVICE_FILE
If set, loads data created by the
`--save-pipeline-cache` option in DEVICE_FILE
and uses it to create the pipelines instead of the
pipeline caches saved at capture time.
(forwarded to replay tool)
--add-new-pipeline-caches
If set, allows gfxreconstruct to create new
vkPipelineCache objects when it encounters a pipeline
created without cache. This option can be used in
coordination with `--save-pipeline-cache` and
`--load-pipeline-cache`. (forwarded to replay tool)
```

The command will force-stop an active replay process before starting the replay
Expand Down
12 changes: 12 additions & 0 deletions USAGE_desktop_Vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,18 @@ Optional arguments:
Swap the swapchain color space if unsupported by replay device.
Check if color space is not supported by replay device and
fallback to VK_COLOR_SPACE_SRGB_NONLINEAR_KHR.
--save-pipeline-cache <cache-file>
If set, produces pipeline caches at replay time instead of using
the one saved at capture time and save those caches in <cache-file>.
--load-pipeline-cache <cache-file>
If set, loads data created by the `--save-pipeline-cache`
option in <cache-file> and uses it to create the pipelines instead
of the pipeline caches saved at capture time.
--add-new-pipeline-caches
If set, allows gfxreconstruct to create new vkPipelineCache objects
when it encounters a pipeline created without cache. This option can
be used in coordination with `--save-pipeline-cache` and
`--load-pipeline-cache`.
```

### Key Controls
Expand Down
14 changes: 14 additions & 0 deletions android/scripts/gfxrecon.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def CreateReplayParser():
parser.add_argument('--validate', action='store_true', default=False, help='Enables the Khronos Vulkan validation layer (forwarded to replay tool)')
parser.add_argument('--onhb', '--omit-null-hardware-buffers', action='store_true', default=False, help='Omit Vulkan calls that would pass a NULL AHardwareBuffer* (forwarded to replay tool)')
parser.add_argument('--use-colorspace-fallback', action='store_true', default=False, help='Swap the swapchain color space if unsupported by replay device. Check if color space is not supported by replay device and swap to VK_COLOR_SPACE_SRGB_NONLINEAR_KHR. (forwarded to replay tool).')
parser.add_argument('--save-pipeline-cache', metavar='DEVICE_FILE', help='If set, produces pipeline caches at replay time instead of using the one saved at capture time and save those caches in DEVICE_FILE. (forwarded to replay tool)')
parser.add_argument('--load-pipeline-cache', metavar='DEVICE_FILE', help='If set, loads data created by the `--save-pipeline-cache` option in DEVICE_FILE and uses it to create the pipelines instead of the pipeline caches saved at capture time. (forwarded to replay tool)')
parser.add_argument('--add-new-pipeline-caches', action='store_true', default=False, help='If set, allows gfxreconstruct to create new vkPipelineCache objects when it encounters a pipeline created without cache. This option can be used in coordination with `--save-pipeline-cache` and `--load-pipeline-cache`. (forwarded to replay tool)')
parser.add_argument('--mfr', '--measurement-frame-range', metavar='START-END', help='Custom framerange to measure FPS for. This range will include the start frame but not the end frame. The measurement frame range defaults to all frames except the loading frame but can be configured for any range. If the end frame is past the last frame in the trace it will be clamped to the frame after the last (so in that case the results would include the last frame). (forwarded to replay tool)')
parser.add_argument('--measurement-file', metavar='DEVICE_FILE', help='Write measurements to a file at the specified path. Default is: \'/sdcard/gfxrecon-measurements.json\' on android and \'./gfxrecon-measurements.json\' on desktop. (forwarded to replay tool)')
parser.add_argument('--quit-after-measurement-range', action='store_true', default=False, help='If this is specified the replayer will abort when it reaches the <end_frame> specified in the --measurement-frame-range argument. (forwarded to replay tool)')
Expand Down Expand Up @@ -170,6 +173,17 @@ def MakeExtrasString(args):
if args.use_colorspace_fallback:
arg_list.append('--use-colorspace-fallback')

if args.save_pipeline_cache:
arg_list.append('--save-pipeline-cache')
arg_list.append('{}'.format(args.save_pipeline_cache))

if args.load_pipeline_cache:
arg_list.append('--load-pipeline-cache')
arg_list.append('{}'.format(args.load_pipeline_cache))

if args.add_new_pipeline_caches:
arg_list.append('--add-new-pipeline-caches')

if args.mfr:
arg_list.append('--mfr')
arg_list.append('{}'.format(args.mfr))
Expand Down
Loading

0 comments on commit 655c52c

Please sign in to comment.