Skip to content

Commit

Permalink
Add wait before present option
Browse files Browse the repository at this point in the history
Force wait on completion of queue operations for all queues before calling Present.
This is needed for accurate acquisition of instrumentation data on some platforms.

Change-Id: Ie5c07df95ad4420ed516f6f59c719d91887fa73a
  • Loading branch information
bartosz-muszarski-arm committed Jun 12, 2023
1 parent efc2dc8 commit 0b71233
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions USAGE_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ usage: gfxrecon.py replay [-h] [--push-file LOCAL_FILE] [--version] [--pause-fra
[--screenshot-prefix PREFIX] [--sfa] [--opcd]
[--surface-index N] [--sync] [--remove-unsupported]
[-m MODE] [--use-captured-swapchain-indices]
[--wait-before-present]
[file]
Launch the replay tool.
Expand Down Expand Up @@ -773,6 +774,10 @@ optional arguments:
setup for replay. The default without this option is to use a Virtual Swapchain
of images which match the swapchain in effect at capture time and which are
copied to the underlying swapchain of the implementation being replayed on.
--wait-before-present
Force wait on completion of queue operations for all queues
before calling Present. This is needed for accurate acquisition
of instrumentation data on some platforms.
```

The command will force-stop an active replay process before starting the replay
Expand Down
6 changes: 5 additions & 1 deletion USAGE_desktop_Vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ gfxrecon-replay [-h | --help] [--version] [--gpu <index>]
[-m <mode> | --memory-translation <mode>]
[--use-captured-swapchain-indices]
[--log-level <level>] [--log-file <file>] [--log-debugview]
[--api <api>] [--no-debug-popup] <file>
[--api <api>] [--no-debug-popup] [--wait-before-present] <file>
Required arguments:
<file> Path to the capture file to replay.
Expand Down Expand Up @@ -470,6 +470,10 @@ Optional arguments:
setup for replay. The default without this option is to use a Virtual Swapchain
of images which match the swapchain in effect at capture time and which are
copied to the underlying swapchain of the implementation being replayed on.
--wait-before-present
Force wait on completion of queue operations for all queues
before calling Present. This is needed for accurate acquisition
of instrumentation data on some platforms.
```

### Key Controls
Expand Down
4 changes: 4 additions & 0 deletions android/scripts/gfxrecon.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ 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-captured-swapchain-indices', action='store_true', default=False, help='Use the swapchain indices stored in the capture directly on the swapchain setup for replay. The default without this option is to use a Virtual Swapchain of images which match the swapchain in effect at capture time and which are copied to the underlying swapchain of the implementation being replayed on.')
parser.add_argument('--wait-before-present', action='store_true', default=False, help='Force wait on completion of queue operations for all queues before calling Present. This is needed for accurate acquisition of instrumentation data on some platforms.')

parser.add_argument('-m', '--memory-translation', metavar='MODE', choices=['none', 'remap', 'realign', 'rebind'], help='Enable memory translation for replay on GPUs with memory types that are not compatible with the capture GPU\'s memory types. Available modes are: none, remap, realign, rebind (forwarded to replay tool)')
parser.add_argument('file', nargs='?', help='File on device to play (forwarded to replay tool)')
Expand Down Expand Up @@ -146,6 +147,9 @@ def MakeExtrasString(args):
arg_list.append('-m')
arg_list.append('{}'.format(args.memory_translation))

if args.wait_before_present:
arg_list.append('--wait-before-present')

if args.file:
arg_list.append(args.file)
elif not args.version:
Expand Down
7 changes: 7 additions & 0 deletions framework/decode/vulkan_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5522,6 +5522,13 @@ VulkanReplayConsumerBase::OverrideQueuePresentKHR(PFN_vkQueuePresentKHR
modified_present_info.pImageIndices = modified_image_indices_.data();
}

if (options_.wait_before_present)
{
format::HandleId device_handle = queue_info->parent_id;
VkDevice device = MapHandle<DeviceInfo>(device_handle, &VulkanObjectInfoTable::GetDeviceInfo);
GetDeviceTable((const void*)device_handle)->DeviceWaitIdle(device);
}

// Only attempt to find imported or shadow semaphores if we know at least one around.
if ((!have_imported_semaphores_) && (shadow_semaphores_.empty()) && (modified_present_info.swapchainCount != 0))
{
Expand Down
1 change: 1 addition & 0 deletions framework/decode/vulkan_replay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct VulkanReplayOptions : public ReplayOptions
std::string screenshot_dir;
std::string screenshot_file_prefix{ kDefaultScreenshotFilePrefix };
std::string replace_dir;
bool wait_before_present{ false };
};

GFXRECON_END_NAMESPACE(decode)
Expand Down
6 changes: 5 additions & 1 deletion tools/replay/replay_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const char kOptions[] =
"opcd|--omit-pipeline-cache-data,--remove-unsupported,--validate,--debug-device-lost,--create-dummy-allocations,--"
"screenshot-all,--onhb|--omit-null-hardware-buffers,--qamr|--quit-after-measurement-"
"range,--fmr|--flush-measurement-range,--use-captured-swapchain-indices,--dcp,--discard-cached-psos,"
"--dx12-override-object-names";
"--dx12-override-object-names,--wait-before-present";
const char kArguments[] =
"--log-level,--log-file,--gpu,--gpu-group,--pause-frame,--wsi,--surface-index,-m|--memory-translation,"
"--replace-shaders,--screenshots,--denied-messages,--allowed-messages,--screenshot-format,--"
Expand Down Expand Up @@ -196,6 +196,10 @@ static void PrintUsage(const char* exe_name)
GFXRECON_WRITE_CONSOLE(" \t\treturned by vkEnumeratePhysicalDeviceGroups. Replay may fail");
GFXRECON_WRITE_CONSOLE(" \t\tif the specified device group is not compatible with the");
GFXRECON_WRITE_CONSOLE(" \t\toriginal capture device group.");
GFXRECON_WRITE_CONSOLE(" --wait-before-present");
GFXRECON_WRITE_CONSOLE(" \t\tForce wait on completion of queue operations for all queues");
GFXRECON_WRITE_CONSOLE(" \t\tbefore calling Present. This is needed for accurate acquisition");
GFXRECON_WRITE_CONSOLE(" \t\tof instrumentation data on some platforms.");

#if defined(WIN32)
GFXRECON_WRITE_CONSOLE("")
Expand Down
7 changes: 7 additions & 0 deletions tools/tool_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ const char kFormatArgument[] = "--format";
const char kIncludeBinariesOption[] = "--include-binaries";
const char kExpandFlagsOption[] = "--expand-flags";
const char kFilePerFrameOption[] = "--file-per-frame";
const char kWaitBeforePresent[] = "--wait-before-present";

#if defined(WIN32)
const char kApiFamilyOption[] = "--api";
const char kDxTwoPassReplay[] = "--dx12-two-pass-replay";
Expand Down Expand Up @@ -785,6 +787,11 @@ GetVulkanReplayOptions(const gfxrecon::util::ArgumentParser& arg_parse
replay_options.surface_index = std::stoi(surface_index);
}

if (arg_parser.IsOptionSet(kWaitBeforePresent))
{
replay_options.wait_before_present = true;
}

return replay_options;
}

Expand Down

0 comments on commit 0b71233

Please sign in to comment.