Skip to content

Commit

Permalink
Reorganize common options
Browse files Browse the repository at this point in the history
Move replay options around that are shared between multiple
replay paths.

For layered API support.
  • Loading branch information
jzulauf-lunarg committed Oct 31, 2024
1 parent fe0b46d commit a08a7ca
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 44 deletions.
8 changes: 1 addition & 7 deletions framework/decode/dx_replay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@ struct DxReplayOptions : public ReplayOptions
bool override_object_names{ false };
bool enable_dump_resources{ false };
DumpResourcesTarget dump_resources_target{};

util::ScreenshotFormat screenshot_format{ util::ScreenshotFormat::kBmp };
std::vector<ScreenshotRange> screenshot_ranges;
std::string screenshot_dir;
std::string screenshot_file_prefix{ kDefaultScreenshotFilePrefix };
std::string replace_dir;
int32_t memory_usage{ kDefaultBatchingMemoryUsage };
int32_t memory_usage{ kDefaultBatchingMemoryUsage };
};

GFXRECON_END_NAMESPACE(decode)
Expand Down
49 changes: 28 additions & 21 deletions framework/decode/replay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,34 @@ struct ScreenshotRange

struct ReplayOptions
{
bool enable_validation_layer{ false };
bool sync_queue_submissions{ false };
bool enable_debug_device_lost{ false };
bool create_dummy_allocations{ false };
bool omit_null_hardware_buffers{ false };
bool quit_after_measurement_frame_range{ false };
bool flush_measurement_frame_range{ false };
bool flush_inside_measurement_range{ false };
bool force_windowed{ false };
uint32_t windowed_width{ 0 };
uint32_t windowed_height{ 0 };
bool force_windowed_origin{ false };
int32_t window_topleft_x{ 0 };
int32_t window_topleft_y{ 0 };
int32_t override_gpu_index{ -1 };
std::string capture_filename;
bool enable_print_block_info{ false };
int64_t block_index_from{ -1 };
int64_t block_index_to{ -1 };
int32_t num_pipeline_creation_jobs{ 0 };
std::string asset_file_path;
bool enable_validation_layer{ false };
bool sync_queue_submissions{ false };
bool enable_debug_device_lost{ false };
bool create_dummy_allocations{ false };
bool omit_null_hardware_buffers{ false };
bool quit_after_measurement_frame_range{ false };
bool flush_measurement_frame_range{ false };
bool flush_inside_measurement_range{ false };
bool force_windowed{ false };
uint32_t windowed_width{ 0 };
uint32_t windowed_height{ 0 };
bool force_windowed_origin{ false };
int32_t window_topleft_x{ 0 };
int32_t window_topleft_y{ 0 };
int32_t override_gpu_index{ -1 };
std::string capture_filename;
bool enable_print_block_info{ false };
int64_t block_index_from{ -1 };
int64_t block_index_to{ -1 };
bool skip_failed_allocations{ false };
bool remove_unsupported_features{ false };
util::ScreenshotFormat screenshot_format{ util::ScreenshotFormat::kBmp };
std::vector<ScreenshotRange> screenshot_ranges;
std::string screenshot_dir;
std::string screenshot_file_prefix{ kDefaultScreenshotFilePrefix };
uint32_t screenshot_width, screenshot_height;
int32_t num_pipeline_creation_jobs{ 0 };
std::string asset_file_path;
};

GFXRECON_END_NAMESPACE(decode)
Expand Down
16 changes: 8 additions & 8 deletions framework/decode/vulkan_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5794,7 +5794,7 @@ VkResult VulkanReplayConsumerBase::OverrideCreateShaderModule(
(pShaderModule != nullptr) && !pShaderModule->IsNull());

auto original_info = pCreateInfo->GetPointer();
if (original_result < 0 || options_.replace_dir.empty())
if (original_result < 0 || options_.replace_shader_dir.empty())
{
VkResult vk_res = func(
device_info->handle, original_info, GetAllocationCallbacks(pAllocator), pShaderModule->GetHandlePointer());
Expand Down Expand Up @@ -5833,7 +5833,7 @@ VkResult VulkanReplayConsumerBase::OverrideCreateShaderModule(
const size_t orig_size = original_info->codeSize;
uint64_t handle_id = *pShaderModule->GetPointer();
std::string file_name = "sh" + std::to_string(handle_id);
std::string file_path = util::filepath::Join(options_.replace_dir, file_name);
std::string file_path = util::filepath::Join(options_.replace_shader_dir, file_name);

FILE* fp = nullptr;
int32_t result = util::platform::FileOpen(&fp, file_path.c_str(), "rb");
Expand Down Expand Up @@ -9746,7 +9746,7 @@ void VulkanReplayConsumerBase::OverrideUpdateDescriptorSets(
uint64_t handle_id = pipelines[i];
std::string file_name =
"sh" + std::to_string(handle_id) + "_" + std::to_string(stage_create_info.stage);
std::string file_path = util::filepath::Join(options_.replace_dir, file_name);
std::string file_path = util::filepath::Join(options_.replace_shader_dir, file_name);

FILE* fp = nullptr;
int32_t result = util::platform::FileOpen(&fp, file_path.c_str(), "rb");
Expand Down Expand Up @@ -9794,7 +9794,7 @@ VkResult VulkanReplayConsumerBase::OverrideCreateGraphicsPipelines(
std::vector<std::unique_ptr<char[]>> replaced_file_code;
auto* maybe_replaced_create_infos = in_p_create_infos;

if (original_result >= 0 && !options_.replace_dir.empty())
if (original_result >= 0 && !options_.replace_shader_dir.empty())
{
uint32_t num_bytes = graphics::vulkan_struct_deep_copy(in_p_create_infos, create_info_count, nullptr);
create_info_data.resize(num_bytes);
Expand Down Expand Up @@ -9885,7 +9885,7 @@ VkResult VulkanReplayConsumerBase::OverrideCreateComputePipelines(
size_t orig_size = create_info->codeSize;
uint64_t handle_id = shaders[i];
std::string file_name = "sh" + std::to_string(handle_id);
std::string file_path = util::filepath::Join(options_.replace_dir, file_name);
std::string file_path = util::filepath::Join(options_.replace_shader_dir, file_name);

FILE* fp = nullptr;
int32_t result = util::platform::FileOpen(&fp, file_path.c_str(), "rb");
Expand Down Expand Up @@ -9927,7 +9927,7 @@ VkResult VulkanReplayConsumerBase::OverrideCreateShadersEXT(
std::vector<std::unique_ptr<char[]>> replaced_file_code;
auto* maybe_replaced_create_infos = in_p_create_infos;

if (original_result >= 0 && !options_.replace_dir.empty())
if (original_result >= 0 && !options_.replace_shader_dir.empty())
{
uint32_t num_bytes = graphics::vulkan_struct_deep_copy(in_p_create_infos, create_info_count, nullptr);
create_info_data.resize(num_bytes);
Expand Down Expand Up @@ -10098,7 +10098,7 @@ std::function<decode::handle_create_result_t<VkPipeline>()> VulkanReplayConsumer
auto create_infos = reinterpret_cast<VkGraphicsPipelineCreateInfo*>(create_info_data.data());

std::vector<std::unique_ptr<char[]>> replaced_file_code;
if (returnValue >= 0 && !options_.replace_dir.empty())
if (returnValue >= 0 && !options_.replace_shader_dir.empty())
{
replaced_file_code = ReplaceShaders(createInfoCount, create_infos, pipelines.data());
}
Expand Down Expand Up @@ -10233,7 +10233,7 @@ VulkanReplayConsumerBase::AsyncCreateShadersEXT(const ApiCallInfo&
auto create_infos = reinterpret_cast<VkShaderCreateInfoEXT*>(create_info_data.data());

std::vector<std::unique_ptr<char[]>> replaced_file_code;
if (returnValue >= 0 && !options_.replace_dir.empty())
if (returnValue >= 0 && !options_.replace_shader_dir.empty())
{
replaced_file_code = ReplaceShaders(createInfoCount, create_infos, shaders.data());
}
Expand Down
8 changes: 1 addition & 7 deletions framework/decode/vulkan_replay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,17 @@ static constexpr int kUnspecifiedColorAttachment = -1;
struct VulkanReplayOptions : public ReplayOptions
{
bool enable_vulkan{ true };
bool skip_failed_allocations{ false };
bool omit_pipeline_cache_data{ false };
bool remove_unsupported_features{ false };
bool use_colorspace_fallback{ false };
bool offscreen_swapchain_frame_boundary{ false };
util::SwapchainOption swapchain_option{ util::SwapchainOption::kVirtual };
bool virtual_swapchain_skip_blit{ false };
int32_t override_gpu_group_index{ -1 };
int32_t surface_index{ -1 };
CreateResourceAllocator create_resource_allocator;
util::ScreenshotFormat screenshot_format{ util::ScreenshotFormat::kBmp };
std::vector<ScreenshotRange> screenshot_ranges;
std::string screenshot_dir;
std::string screenshot_file_prefix{ kDefaultScreenshotFilePrefix };
uint32_t screenshot_width, screenshot_height;
float screenshot_scale;
std::string replace_dir;
std::string replace_shader_dir;
SkipGetFenceStatus skip_get_fence_status{ SkipGetFenceStatus::NoSkip };
std::vector<util::UintRange> skip_get_fence_ranges;
bool wait_before_present{ false };
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ GetVulkanReplayOptions(const gfxrecon::util::ArgumentParser& arg_parse
replay_options.virtual_swapchain_skip_blit = true;
}

replay_options.replace_dir = arg_parser.GetArgumentValue(kShaderReplaceArgument);
replay_options.replace_shader_dir = arg_parser.GetArgumentValue(kShaderReplaceArgument);
replay_options.create_resource_allocator =
GetCreateResourceAllocatorFunc(arg_parser, filename, replay_options, tracked_object_info_table);

Expand Down

0 comments on commit a08a7ca

Please sign in to comment.