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 Oct 3, 2024
1 parent 81ed616 commit 5b6095b
Show file tree
Hide file tree
Showing 10 changed files with 568 additions and 100 deletions.
17 changes: 17 additions & 0 deletions USAGE_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,23 @@ optional arguments:
Enables dumping of resources that are used as inputs in the commands requested for dumping
--dump-resources-dump-all-image-subresources
Enables dumping of all image sub resources (mip map levels and array layers)
--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
13 changes: 12 additions & 1 deletion USAGE_desktop_Vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,18 @@ Optional arguments:
Specify the number of asynchronous pipeline-creation jobs as integer.
If <num_jobs> is negative it will be added to the number of cpu-cores, e.g. -1 -> num_cores - 1.
Default: 0 (do not use asynchronous operations)
--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 @@ -114,6 +114,9 @@ def CreateReplayParser():
parser.add_argument('--pbi-all', action='store_true', default=False, help='Print all block information.')
parser.add_argument('--pbis', metavar='RANGES', default=False, help='Print block information between block index1 and block index2')
parser.add_argument('--pcj', '--pipeline-creation-jobs', action='store_true', default=False, help='Specify the number of pipeline-creation-jobs or background-threads.')
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)')
return parser

def MakeExtrasString(args):
Expand Down Expand Up @@ -282,6 +285,17 @@ def MakeExtrasString(args):
arg_list.append('--pcj')
arg_list.append('{}'.format(args.pcj))

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.file:
arg_list.append(args.file)
elif not args.version:
Expand Down
Loading

0 comments on commit 5b6095b

Please sign in to comment.