diff --git a/USAGE_android.md b/USAGE_android.md index cbd49cfb7..cfa94b91d 100644 --- a/USAGE_android.md +++ b/USAGE_android.md @@ -327,6 +327,7 @@ option values. | Page guard unblock SIGSEGV | debug.gfxrecon.page_guard_unblock_sigsegv | BOOL | When the `page_guard` memory tracking mode is enabled and in the case that SIGSEGV has been marked as blocked in thread's signal mask, setting this enviroment variable to `true` will forcibly re-enable the signal in the thread's signal mask. Default is `false` | | Page guard signal handler watcher | debug.gfxrecon.page_guard_signal_handler_watcher | BOOL | When the `page_guard` memory tracking mode is enabled, setting this enviroment variable to `true` will spawn a thread which will periodically reinstall the `SIGSEGV` handler if it has been replaced by the application being traced. Default is `false` | | Page guard signal handler watcher max restores | debug.gfxrecon.page_guard_signal_handler_watcher_max_restores | INTEGER | Sets the number of times the watcher will attempt to restore the signal handler. Setting it to a negative value will make the watcher thread run indefinitely. Default is `1` | +| Force FIFO present mode | debug.gfxrecon.force_fifo_present_mode | BOOL | When the `force_fifo_present_mode` is enabled, force all present modes in vkGetPhysicalDeviceSurfacePresentModesKHR to VK_PRESENT_MODE_FIFO_KHR, app present mode is set in vkCreateSwapchain to VK_PRESENT_MODE_FIFO_KHR. Otherwise the original present mode will be used. Default is: `true` | #### Settings File diff --git a/framework/encode/capture_manager.cpp b/framework/encode/capture_manager.cpp index ca9c99fa7..bbe876cbd 100644 --- a/framework/encode/capture_manager.cpp +++ b/framework/encode/capture_manager.cpp @@ -308,6 +308,7 @@ bool CommonCaptureManager::Initialize(format::ApiFamilyId api_ force_command_serialization_ = trace_settings.force_command_serialization; queue_zero_only_ = trace_settings.queue_zero_only; allow_pipeline_compile_required_ = trace_settings.allow_pipeline_compile_required; + force_fifo_present_mode_ = trace_settings.force_fifo_present_mode; rv_annotation_info_.gpuva_mask = trace_settings.rv_anotation_info.gpuva_mask; rv_annotation_info_.descriptor_mask = trace_settings.rv_anotation_info.descriptor_mask; @@ -1404,6 +1405,11 @@ void CommonCaptureManager::WriteCaptureOptions(std::string& operation_annotation buffer += "\n \"queue-zero-only\": "; buffer += queue_zero_only_ ? "true," : "false,"; } + if (force_fifo_present_mode_ != default_settings.force_fifo_present_mode) + { + buffer += "\n \"force-fifo-present-mode\": "; + buffer += force_fifo_present_mode_ ? "true," : "false,"; + } if (buffer.empty()) { diff --git a/framework/encode/capture_manager.h b/framework/encode/capture_manager.h index c30710ce1..583b5036d 100644 --- a/framework/encode/capture_manager.h +++ b/framework/encode/capture_manager.h @@ -256,6 +256,7 @@ class CommonCaptureManager bool GetDebugDeviceLostSetting() const { return debug_device_lost_; } bool GetDisableDxrSetting() const { return disable_dxr_; } auto GetAccelStructPaddingSetting() const { return accel_struct_padding_; } + bool GetForceFifoPresentModeSetting() const { return force_fifo_present_mode_; } util::Compressor* GetCompressor() { return compressor_.get(); } std::mutex& GetMappedMemoryLock() { return mapped_memory_lock_; } @@ -380,6 +381,7 @@ class CommonCaptureManager bool queue_zero_only_; bool allow_pipeline_compile_required_; bool quit_after_frame_ranges_; + bool force_fifo_present_mode_; struct { diff --git a/framework/encode/capture_settings.cpp b/framework/encode/capture_settings.cpp index 90f18e13d..fd1989721 100644 --- a/framework/encode/capture_settings.cpp +++ b/framework/encode/capture_settings.cpp @@ -134,6 +134,8 @@ GFXRECON_BEGIN_NAMESPACE(encode) #define RV_ANNOTATION_GPUVA_UPPER "RV_ANNOTATION_GPUVA" #define RV_ANNOTATION_DESCRIPTOR_LOWER "rv_annotation_descriptor" #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" #if defined(__ANDROID__) // Android Properties @@ -187,6 +189,7 @@ const char kAnnotationExperimentalEnvVar[] = GFXRECON_ENV_VAR_ const char kAnnotationRandEnvVar[] = GFXRECON_ENV_VAR_PREFIX RV_ANNOTATION_RAND_LOWER; 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; #else // Desktop environment settings @@ -239,6 +242,7 @@ const char kAnnotationExperimentalEnvVar[] = GFXRECON_ENV_VAR_ const char kAnnotationRandEnvVar[] = GFXRECON_ENV_VAR_PREFIX RV_ANNOTATION_RAND_UPPER; 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; #endif @@ -290,6 +294,7 @@ const std::string kOptionKeyAnnotationExperimental = std::stri const std::string kOptionKeyAnnotationRand = std::string(kSettingsFilter) + std::string(RV_ANNOTATION_RAND_LOWER); 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); #if defined(GFXRECON_ENABLE_LZ4_COMPRESSION) const format::CompressionType kDefaultCompressionType = format::CompressionType::kLz4; @@ -445,6 +450,7 @@ void CaptureSettings::LoadOptionsEnvVar(OptionsMap* options) LoadSingleOptionEnvVar(options, kAnnotationRandEnvVar, kOptionKeyAnnotationRand); LoadSingleOptionEnvVar(options, kAnnotationGPUVAEnvVar, kOptionKeyAnnotationGPUVA); LoadSingleOptionEnvVar(options, kAnnotationDescriptorEnvVar, kOptionKeyAnnotationDescriptor); + LoadSingleOptionEnvVar(options, kForceFifoPresentModeEnvVar, kOptionForceFifoPresentModeEnvVar); } void CaptureSettings::LoadOptionsFile(OptionsMap* options) @@ -616,6 +622,8 @@ void CaptureSettings::ProcessOptions(OptionsMap* options, CaptureSettings* setti settings->trace_settings_.rv_anotation_info.descriptor_mask = ParseUnsignedInteger16String(FindOption(options, kOptionKeyAnnotationDescriptor), 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); } void CaptureSettings::ProcessLogOptions(OptionsMap* options, CaptureSettings* settings) diff --git a/framework/encode/capture_settings.h b/framework/encode/capture_settings.h index 28dc72e02..6224ae898 100644 --- a/framework/encode/capture_settings.h +++ b/framework/encode/capture_settings.h @@ -118,6 +118,7 @@ class CaptureSettings bool queue_zero_only{ false }; bool allow_pipeline_compile_required{ false }; bool quit_after_frame_ranges{ false }; + bool force_fifo_present_mode{ true }; // 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 diff --git a/framework/encode/vulkan_capture_manager.cpp b/framework/encode/vulkan_capture_manager.cpp index f25d8a38d..dcb797589 100644 --- a/framework/encode/vulkan_capture_manager.cpp +++ b/framework/encode/vulkan_capture_manager.cpp @@ -2682,9 +2682,17 @@ void VulkanCaptureManager::OverrideGetPhysicalDeviceSurfacePresentModesKHR(uint3 { assert((pPresentModeCount != nullptr) && (pPresentModes != nullptr)); - for (uint32_t i = 0; i < (*pPresentModeCount); ++i) + if (common_manager_->GetForceFifoPresentModeSetting()) { - pPresentModes[i] = VK_PRESENT_MODE_FIFO_KHR; + GFXRECON_LOG_WARNING_ONCE( + "Force all present modes in vkGetPhysicalDeviceSurfacePresentModesKHR to VK_PRESENT_MODE_FIFO_KHR. " + "The application will use VK_PRESENT_MODE_FIFO_KHR present mode in vkCreateSwapchainKHR, which may " + "cause an unknown crash if the application does not use VK_PRESENT_MODE_FIFO_KHR present mode"); + + for (uint32_t i = 0; i < (*pPresentModeCount); ++i) + { + pPresentModes[i] = VK_PRESENT_MODE_FIFO_KHR; + } } } #endif