Skip to content
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

Add wait before present option #1146

Merged
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
6 changes: 5 additions & 1 deletion USAGE_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ usage: gfxrecon.py replay [-h] [--push-file LOCAL_FILE] [--version] [--pause-fra
[--measurement-file DEVICE_FILE] [--quit-after-measurement-range]
[--flush-measurement-range] [-m MODE]
[--swapchain MODE] [--use-captured-swapchain-indices]
[--use-colorspace-fallback]
[--use-colorspace-fallback] [--wait-before-present]
[file]

Launch the replay tool.
Expand Down Expand Up @@ -973,6 +973,10 @@ optional arguments:
--sgfr FRAME-RANGES, --skip-get-fence-ranges FRAME-RANGES
Frame ranges where --sgfs applies. Default is all frames
(forwarded to replay tool)
--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
9 changes: 6 additions & 3 deletions USAGE_desktop_Vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,13 @@ gfxrecon-replay [-h | --help] [--version] [--gpu <index>]
[--surface-index <N>] [--remove-unsupported] [--validate]
[-m <mode> | --memory-translation <mode>]
[--fwo <x,y> | --force-windowed-origin <x,y>]
[--use-captured-swapchain-indices]
[--swapchain MODE] [--use-captured-swapchain-indices]
[--mfr|--measurement-frame-range <start-frame>-<end-frame>]
[--measurement-file <file>] [--quit-after-measurement-range]
[--flush-measurement-range]
[--log-level <level>] [--log-file <file>] [--log-debugview]
[--no-debug-popup] <file>
[--use-colorspace-fallback]
[--no-debug-popup] [--use-colorspace-fallback]
[--wait-before-present] <file>

Required arguments:
<file> Path to the capture file to replay.
Expand Down Expand Up @@ -695,6 +694,10 @@ Optional arguments:
--sgfr <frame-ranges>
Frame ranges where --sgfs applies. The format is:
<frame-start-1>-<frame-end-1>[,<frame-start-1>-<frame-end-1>]*
--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 @@ -93,6 +93,7 @@ def CreateReplayParser():
parser.add_argument('--flush-inside-measurement-range', action='store_true', default=False, help='If this is specified the replayer will flush and wait for all current GPU work to finish at end of each frame inside the measurement range. (forwarded to replay tool)')
parser.add_argument('--sgfs', '--skip-get-fence-status', metavar='STATUS', default=0, help='Specify behaviour to skip calls to vkWaitForFences and vkGetFenceStatus. Default is 0 - No skip (forwarded to replay tool)')
parser.add_argument('--sgfr', '--skip-get-fence-ranges', metavar='FRAME-RANGES', default='', help='Frame ranges where --sgfs applies. Default is all frames (forwarded to replay tool)')
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('--swapchain', metavar='MODE', choices=['virtual', 'captured', 'offscreen'], help='Choose a swapchain mode to replay. Available modes are: virtual, captured, offscreen (forwarded to replay tool)')
parser.add_argument('--vssb', '--virtual-swapchain-skip-blit', action='store_true', default=False, help='Skip blit to real swapchain to gain performance during replay.')
Expand Down Expand Up @@ -217,6 +218,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
6 changes: 6 additions & 0 deletions framework/decode/vulkan_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6143,6 +6143,12 @@ VulkanReplayConsumerBase::OverrideQueuePresentKHR(PFN_vkQueuePresentKHR
modified_present_info.pImageIndices = modified_image_indices_.data();
}

if (options_.wait_before_present)
{
VkDevice device = MapHandle<DeviceInfo>(queue_info->parent_id, &VulkanObjectInfoTable::GetDeviceInfo);
GetDeviceTable(device)->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 @@ -71,6 +71,7 @@ struct VulkanReplayOptions : public ReplayOptions
std::string replace_dir;
SkipGetFenceStatus skip_get_fence_status{ SkipGetFenceStatus::NoSkip };
std::vector<util::UintRange> skip_get_fence_ranges;
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 @@ -32,7 +32,7 @@ const char kOptions[] =
"screenshot-all,--onhb|--omit-null-hardware-buffers,--qamr|--quit-after-measurement-range,--fmr|--flush-"
"measurement-range,--flush-inside-measurement-range,--vssb|--virtual-swapchain-skip-blit,--use-captured-swapchain-"
"indices,--dcp,--discard-cached-psos,--use-colorspace-fallback,--use-cached-psos,--dx12-override-object-names,--"
"offscreen-swapchain-frame-boundary";
"offscreen-swapchain-frame-boundary,--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 @@ -255,6 +255,10 @@ static void PrintUsage(const char* exe_name)
GFXRECON_WRITE_CONSOLE(" --sgfr <frame-ranges>");
GFXRECON_WRITE_CONSOLE(" \t\tFrame ranges where --sgfs applies. The format is:");
GFXRECON_WRITE_CONSOLE(" \t\t\t<frame-start-1>-<frame-end-1>[,<frame-start-1>-<frame-end-1>]*");
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
5 changes: 5 additions & 0 deletions tools/tool_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const char kExpandFlagsOption[] = "--expand-flags";
const char kFilePerFrameOption[] = "--file-per-frame";
const char kSkipGetFenceStatus[] = "--skip-get-fence-status";
const char kSkipGetFenceRanges[] = "--skip-get-fence-ranges";
const char kWaitBeforePresent[] = "--wait-before-present";
#if defined(WIN32)
const char kDxTwoPassReplay[] = "--dx12-two-pass-replay";
const char kDxOverrideObjectNames[] = "--dx12-override-object-names";
Expand Down Expand Up @@ -957,6 +958,10 @@ GetVulkanReplayOptions(const gfxrecon::util::ArgumentParser& arg_parse
replay_options.skip_get_fence_ranges =
gfxrecon::util::GetUintRanges(skip_get_fence_ranges.c_str(), "skip-get-fence-ranges");
}
if (arg_parser.IsOptionSet(kWaitBeforePresent))
{
replay_options.wait_before_present = true;
}

return replay_options;
}
Expand Down
Loading