Skip to content

Commit

Permalink
Ignore frames from FrameBoundaryAndroid
Browse files Browse the repository at this point in the history
During capture by seting debug.gfxrecon.ignore_frame_boundary_android to
true/1.
During replay with --screenshot-ignore-FrameBoundaryANDROID.
  • Loading branch information
panos-lunarg committed Feb 11, 2025
1 parent 7716e6b commit bbff806
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 65 deletions.
4 changes: 4 additions & 0 deletions android/scripts/gfxrecon.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def CreateReplayParser():
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('--quit-after-frame', metavar='FRAME', help='Specify a frame after which replay will terminate.')
parser.add_argument('--screenshot-ignore-FrameBoundaryANDROID', action='store_true', default=False, help='If set, frames switced with vkFrameBoundANDROID will be ignored from the screenshot handler.')

return parser

Expand Down Expand Up @@ -334,6 +335,9 @@ def MakeExtrasString(args):
arg_list.append('--quit-after-frame')
arg_list.append('{}'.format(args.quit_after_frame))

if args.screenshot_ignore_FrameBoundaryANDROID:
arg_list.append('--screenshot-ignore-FrameBoundaryANDROID')

if args.file:
arg_list.append(args.file)
elif not args.version:
Expand Down
1 change: 1 addition & 0 deletions framework/decode/replay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct ReplayOptions
std::string screenshot_dir;
std::string screenshot_file_prefix{ kDefaultScreenshotFilePrefix };
uint32_t screenshot_width, screenshot_height;
bool screenshot_ignore_frameBoundaryAndroid{ false };
int32_t num_pipeline_creation_jobs{ 0 };
std::string asset_file_path;
std::string dump_resources_output_dir;
Expand Down
2 changes: 1 addition & 1 deletion framework/decode/vulkan_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8875,7 +8875,7 @@ void VulkanReplayConsumerBase::OverrideFrameBoundaryANDROID(PFN_vkFrameBoundaryA
VkSemaphore semaphore = semaphore_info ? semaphore_info->handle : VK_NULL_HANDLE;
VkImage image = image_info ? image_info->handle : VK_NULL_HANDLE;

if (screenshot_handler_ != nullptr)
if (screenshot_handler_ != nullptr && !options_.screenshot_ignore_frameBoundaryAndroid)
{
decode::BeginInjectedCommands();

Expand Down
3 changes: 2 additions & 1 deletion framework/encode/api_capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ApiCaptureManager
uint32_t GetCurrentFrame() const { return common_manager_->GetCurrentFrame(); }
CommonCaptureManager::CaptureMode GetCaptureMode() const { return common_manager_->GetCaptureMode(); }
void SetCaptureMode(CommonCaptureManager::CaptureMode mode) { common_manager_->SetCaptureMode(mode); }
bool GetDebugLayerSetting() const { return common_manager_->GetDebugLayerSetting(); }
bool GetDebugLayerSetting() const { return common_manager_->GetDebugLayerSetting(); }
bool GetDebugDeviceLostSetting() const { return common_manager_->GetDebugDeviceLostSetting(); }
bool GetDisableDxrSetting() const { return common_manager_->GetDisableDxrSetting(); }
auto GetAccelStructPaddingSetting() const { return common_manager_->GetAccelStructPaddingSetting(); }
Expand Down Expand Up @@ -234,6 +234,7 @@ class ApiCaptureManager
auto GetTrimDrawCalls() const { return common_manager_->GetTrimDrawCalls(); }
bool GetUseAssetFile() const { return common_manager_->GetUseAssetFile(); }
CommandWriter* GetCommandWriter() { return common_manager_->GetCommandWriter(); }
bool GetIgnoreFrameBoundaryAndroid() const { return common_manager_->GetIgnoreFrameBoundaryAndroid(); }

protected:
const format::ApiFamilyId api_family_;
Expand Down
4 changes: 3 additions & 1 deletion framework/encode/capture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ bool CommonCaptureManager::Initialize(format::ApiFamilyId api_
allow_pipeline_compile_required_ = trace_settings.allow_pipeline_compile_required;
force_fifo_present_mode_ = trace_settings.force_fifo_present_mode;
use_asset_file_ = trace_settings.use_asset_file;
ignore_frame_boundary_android_ = trace_settings.ignore_frame_boundary_android;

rv_annotation_info_.gpuva_mask = trace_settings.rv_anotation_info.gpuva_mask;
rv_annotation_info_.descriptor_mask = trace_settings.rv_anotation_info.descriptor_mask;
Expand Down Expand Up @@ -1629,7 +1630,8 @@ CaptureFileOutputStream::CaptureFileOutputStream(CommonCaptureManager* capture_m
const std::string& filename,
size_t buffer_size,
bool append) :
FileOutputStream(filename, buffer_size, append), capture_manager_(capture_manager)
FileOutputStream(filename, buffer_size, append),
capture_manager_(capture_manager)
{}

bool CaptureFileOutputStream::Write(const void* data, size_t len)
Expand Down
4 changes: 3 additions & 1 deletion framework/encode/capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class CommonCaptureManager
auto GetTrimDrawCalls() const { return trim_draw_calls_; }
auto GetQueueSubmitCount() const { return queue_submit_count_; }
bool GetUseAssetFile() const { return use_asset_file_; }
bool GetIgnoreFrameBoundaryAndroid() const { return ignore_frame_boundary_android_; }

util::Compressor* GetCompressor() { return compressor_.get(); }
std::mutex& GetMappedMemoryLock() { return mapped_memory_lock_; }
Expand Down Expand Up @@ -290,7 +291,7 @@ class CommonCaptureManager

template <size_t N>
void CombineAndWriteToFile(const std::pair<const void*, size_t> (&buffers)[N],
util::FileOutputStream* file_stream = nullptr)
util::FileOutputStream* file_stream = nullptr)
{
file_stream ? file_stream->CombineAndWrite<N>(buffers, GetThreadData()->GetScratchBuffer())
: file_stream_->CombineAndWrite<N>(buffers, GetThreadData()->GetScratchBuffer());
Expand Down Expand Up @@ -390,6 +391,7 @@ class CommonCaptureManager
bool write_assets_;
bool previous_write_assets_;
bool write_state_files_;
bool ignore_frame_boundary_android_;

struct
{
Expand Down
11 changes: 11 additions & 0 deletions framework/encode/capture_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ GFXRECON_BEGIN_NAMESPACE(encode)
#define RV_ANNOTATION_DESCRIPTOR_UPPER "RV_ANNOTATION_DESCRIPTOR"
#define FORCE_FIFO_PRESENT_MODE_LOWER "force_fifo_present_mode"
#define FORCE_FIFO_PRESENT_MODE_UPPER "FORCE_FIFO_PRESENT_MODE"
#define IGNORE_FRAME_BOUNDARY_ANDROID_LOWER "ignore_frame_boundary_android"
#define IGNORE_FRAME_BOUNDARY_ANDROID_UPPER "IGNORE_FRAME_BOUNDARY_ANDROID"

#if defined(__ANDROID__)
// Android Properties
Expand Down Expand Up @@ -200,6 +202,7 @@ const char kAnnotationRandEnvVar[] = GFXRECON_ENV_VAR_
const char kAnnotationGPUVAEnvVar[] = GFXRECON_ENV_VAR_PREFIX RV_ANNOTATION_GPUVA_LOWER;
const char kAnnotationDescriptorEnvVar[] = GFXRECON_ENV_VAR_PREFIX RV_ANNOTATION_DESCRIPTOR_LOWER;
const char kForceFifoPresentModeEnvVar[] = GFXRECON_ENV_VAR_PREFIX FORCE_FIFO_PRESENT_MODE_LOWER;
const char kIgnoreFrameBoundaryAndroidEnvVar[] = GFXRECON_ENV_VAR_PREFIX IGNORE_FRAME_BOUNDARY_ANDROID_LOWER;

#else
// Desktop environment settings
Expand Down Expand Up @@ -255,6 +258,7 @@ const char kAnnotationRandEnvVar[] = GFXRECON_ENV_VAR_
const char kAnnotationGPUVAEnvVar[] = GFXRECON_ENV_VAR_PREFIX RV_ANNOTATION_GPUVA_UPPER;
const char kAnnotationDescriptorEnvVar[] = GFXRECON_ENV_VAR_PREFIX RV_ANNOTATION_DESCRIPTOR_UPPER;
const char kForceFifoPresentModeEnvVar[] = GFXRECON_ENV_VAR_PREFIX FORCE_FIFO_PRESENT_MODE_UPPER;
const char kIgnoreFrameBoundaryAndroidEnvVar[] = GFXRECON_ENV_VAR_PREFIX IGNORE_FRAME_BOUNDARY_ANDROID_UPPER;

#endif

Expand Down Expand Up @@ -309,6 +313,7 @@ const std::string kOptionKeyAnnotationRand = std::stri
const std::string kOptionKeyAnnotationGPUVA = std::string(kSettingsFilter) + std::string(RV_ANNOTATION_GPUVA_LOWER);
const std::string kOptionKeyAnnotationDescriptor = std::string(kSettingsFilter) + std::string(RV_ANNOTATION_DESCRIPTOR_LOWER);
const std::string kOptionForceFifoPresentModeEnvVar = std::string(kSettingsFilter) + std::string(FORCE_FIFO_PRESENT_MODE_LOWER);
const std::string kOptionIgnoreFrameBoundaryAndroid = std::string(kSettingsFilter) + std::string(IGNORE_FRAME_BOUNDARY_ANDROID_LOWER);

#if defined(GFXRECON_ENABLE_LZ4_COMPRESSION)
const format::CompressionType kDefaultCompressionType = format::CompressionType::kLz4;
Expand Down Expand Up @@ -478,6 +483,8 @@ void CaptureSettings::LoadOptionsEnvVar(OptionsMap* options)
LoadSingleOptionEnvVar(options, kAnnotationGPUVAEnvVar, kOptionKeyAnnotationGPUVA);
LoadSingleOptionEnvVar(options, kAnnotationDescriptorEnvVar, kOptionKeyAnnotationDescriptor);
LoadSingleOptionEnvVar(options, kForceFifoPresentModeEnvVar, kOptionForceFifoPresentModeEnvVar);

LoadSingleOptionEnvVar(options, kIgnoreFrameBoundaryAndroidEnvVar, kOptionIgnoreFrameBoundaryAndroid);
}

void CaptureSettings::LoadOptionsFile(OptionsMap* options)
Expand Down Expand Up @@ -691,6 +698,10 @@ void CaptureSettings::ProcessOptions(OptionsMap* options, CaptureSettings* setti
settings->trace_settings_.rv_anotation_info.descriptor_mask);
settings->trace_settings_.force_fifo_present_mode = ParseBoolString(
FindOption(options, kOptionForceFifoPresentModeEnvVar), settings->trace_settings_.force_fifo_present_mode);

settings->trace_settings_.ignore_frame_boundary_android =
ParseBoolString(FindOption(options, kOptionIgnoreFrameBoundaryAndroid),
settings->trace_settings_.ignore_frame_boundary_android);
}

void CaptureSettings::ProcessLogOptions(OptionsMap* options, CaptureSettings* settings)
Expand Down
1 change: 1 addition & 0 deletions framework/encode/capture_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class CaptureSettings
bool quit_after_frame_ranges{ false };
bool force_fifo_present_mode{ true };
bool use_asset_file{ false };
bool ignore_frame_boundary_android{ false };

// An optimization for the page_guard memory tracking mode that eliminates the need for shadow memory by
// overriding vkAllocateMemory so that all host visible allocations use the external memory extension with a
Expand Down
15 changes: 6 additions & 9 deletions framework/encode/vulkan_capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,10 @@ class VulkanCaptureManager : public ApiCaptureManager
VkSemaphore semaphore,
VkImage image)
{
EndFrame(current_lock);
if (!common_manager_->GetIgnoreFrameBoundaryAndroid())
{
EndFrame(current_lock);
}
}

void PostProcess_vkCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer,
Expand Down Expand Up @@ -1544,15 +1547,9 @@ class VulkanCaptureManager : public ApiCaptureManager

virtual ~VulkanCaptureManager() {}

virtual void CreateStateTracker() override
{
state_tracker_ = std::make_unique<VulkanStateTracker>();
}
virtual void CreateStateTracker() override { state_tracker_ = std::make_unique<VulkanStateTracker>(); }

virtual void DestroyStateTracker() override
{
state_tracker_ = nullptr;
}
virtual void DestroyStateTracker() override { state_tracker_ = nullptr; }

virtual void WriteTrackedState(util::FileOutputStream* file_stream, util::ThreadData* thread_data) override;

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 @@ -36,7 +36,8 @@ const char kOptions[] =
"--dump-resources-dump-depth-attachment,--dump-"
"resources-dump-vertex-index-buffers,--dump-resources-json-output-per-command,--dump-resources-dump-immutable-"
"resources,--dump-resources-dump-all-image-subresources,--dump-resources-dump-raw-images,--dump-resources-dump-"
"separate-alpha,--pbi-all,--preload-measurement-range, --add-new-pipeline-caches";
"separate-alpha,--pbi-all,--preload-measurement-range, --add-new-pipeline-caches,"
"--screenshot-ignore-FrameBoundaryANDROID";
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 @@ -345,6 +346,9 @@ static void PrintUsage(const char* exe_name)
GFXRECON_WRITE_CONSOLE(" \t\twhen it encounters a pipeline created without cache. This option can");
GFXRECON_WRITE_CONSOLE(" \t\tbe used in coordination with `--save-pipeline-cache` and");
GFXRECON_WRITE_CONSOLE(" \t\t`--load-pipeline-cache`.");
GFXRECON_WRITE_CONSOLE(" --screenshot-ignore-FrameBoundaryANDROID");
GFXRECON_WRITE_CONSOLE(" \t\tIf set, frames switced with vkFrameBoundANDROID will be ignored from");
GFXRECON_WRITE_CONSOLE(" \t\tthe screenshot handler.");
#if defined(WIN32)
GFXRECON_WRITE_CONSOLE("")
GFXRECON_WRITE_CONSOLE("D3D12 only:")
Expand Down
Loading

0 comments on commit bbff806

Please sign in to comment.