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 --gpu option to optimizer #1218

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
10 changes: 9 additions & 1 deletion USAGE_desktop_D3D12.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ gfxrecon-optimize.exe - Produce new captures with enhanced performance character
For D3D12, the optimizer will improve DXR replay performance and remove unused PSOs (for all captures)

Usage:
gfxrecon-optimize.exe [-h | --help] [--version] [--d3d12-pso-removal] [--dxr] <input-file> <output-file>
gfxrecon-optimize.exe [-h | --help] [--version] [--d3d12-pso-removal] [--dxr] [--gpu <index>] <input-file> <output-file>

Required arguments:
<input-file> The path to input GFXReconstruct capture file to be processed.
Expand All @@ -417,6 +417,10 @@ Optional arguments:
--version Print version information and exit.
--d3d12-pso-removal D3D12-only: Remove creation of unreferenced PSOs.
--dxr D3D12-only: Optimize for DXR replay.
--gpu <index> D3D12-only: Use the specified device for the optimizer replay, where index is the zero-based index to the array
of physical devices returned by vkEnumeratePhysicalDevices or the optimizer replay may fail if the specified
device is not compatible with the IDXGIFactory1::EnumAdapters1. The optimizer replay may fail if the specified
device is not compatible with the original capture devices.

Note: running without optional arguments will instruct the optimizer to detect API and run all available optimizations.
```
Expand Down Expand Up @@ -461,6 +465,10 @@ Required arguments:
Optional arguments:
--d3d12-pso-removal D3D12-only: Remove creation of unreferenced PSOs.
--dxr D3D12-only: Optimize for DXR replay.
--gpu <index> D3D12-only: Use the specified device for the optimizer replay, where index is the zero-based index to the array
of physical devices returned by vkEnumeratePhysicalDevices or The optimizer replay may fail if the specified
device is not compatible with the IDXGIFactory1::EnumAdapters1. The optimizer replay may fail if the specified
device is not compatible with the original capture devices.

Note: running without optional arguments will instruct the optimizer to detect API and run all available optimizations.
```
Expand Down
2 changes: 2 additions & 0 deletions framework/decode/dx12_optimize_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct Dx12OptimizationOptions
bool remove_redundant_psos{ false };
bool optimize_resource_values{ false };
bool optimize_resource_values_experimental{ false };

int32_t override_gpu_index{ -1 };
};

GFXRECON_END_NAMESPACE(decode)
Expand Down
5 changes: 5 additions & 0 deletions scripts/gfxrecon-optimize-renamed.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ def usage():
print("Optional arguments:")
print(" --d3d12-pso-removal D3D12-only: Remove creation of unreferenced PSOs.")
print(" --dxr D3D12-only: Optimize for DXR replay.")
print(" --gpu D3D12-only: Use the specified device for the optimizer replay, where index is the zero-based index")
print(" to the array of physical devices returned by vkEnumeratePhysicalDevices or The optimizer replay")
print(" may fail if the specified device is not compatible with theIDXGIFactory1::EnumAdapters1.")
print(" The optimizer replay may fail if the specified device is not compatible with the original")
print(" capture devices.")
print()
print("Note: running without optional arguments will instruct the optimizer to detect API and run all available optimizations.")
print()
Expand Down
3 changes: 2 additions & 1 deletion tools/optimize/dx12_optimize_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ void CreateResourceValueTrackingConsumer(
application = std::make_shared<gfxrecon::application::Application>(app_string, file_processor);
application->InitializeDx12WsiContext();

// Use default replay options, except dcp.
// Use default replay options, except gpu index.
decode::DxReplayOptions dx_replay_options;
dx_replay_options.override_gpu_index = options.override_gpu_index;

// Create the replay consumer.
dx12_replay_consumer = std::make_unique<decode::Dx12ResourceValueTrackingConsumer>(
Expand Down
21 changes: 17 additions & 4 deletions tools/optimize/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ extern "C"
}
#endif

const char kOptions[] = "-h|--help,--version,--no-debug-popup,--d3d12-pso-removal,--dxr,--dxr-experimental";
const char kOptions[] = "-h|--help,--version,--no-debug-popup,--d3d12-pso-removal,--dxr,--dxr-experimental";
const char kArguments[] = "--gpu";

const char kD3d12PsoRemoval[] = "--d3d12-pso-removal";
const char kDx12OptimizeDxr[] = "--dxr";
Expand All @@ -82,8 +83,9 @@ static void PrintUsage(const char* exe_name)
"\t\t\tFor D3D12, the optimizer will improve DXR replay performance and remove unused PSOs (for all captures)");
GFXRECON_WRITE_CONSOLE("");
GFXRECON_WRITE_CONSOLE("Usage:");
GFXRECON_WRITE_CONSOLE(" %s [-h | --help] [--version] [--d3d12-pso-removal] [--dxr] <input-file> <output-file>",
app_name.c_str());
GFXRECON_WRITE_CONSOLE(
" %s [-h | --help] [--version] [--d3d12-pso-removal] [--dxr] [--gpu <index>] <input-file> <output-file>",
app_name.c_str());
GFXRECON_WRITE_CONSOLE("");
GFXRECON_WRITE_CONSOLE("Required arguments:");
GFXRECON_WRITE_CONSOLE(" <input-file>\t\tThe path to input GFXReconstruct capture file to be processed.");
Expand All @@ -99,6 +101,12 @@ static void PrintUsage(const char* exe_name)
#endif
GFXRECON_WRITE_CONSOLE(" --d3d12-pso-removal\tD3D12-only: Remove creation of unreferenced PSOs.");
GFXRECON_WRITE_CONSOLE(" --dxr\t\t\tD3D12-only: Optimize for DXR and ExecuteIndirect replay.");
GFXRECON_WRITE_CONSOLE(" --gpu <index>\t\tUse the specified device for the optimizer replay, where index");
GFXRECON_WRITE_CONSOLE(" \t\tis the zero-based index to the array of physical devices");
GFXRECON_WRITE_CONSOLE(" \t\treturned by vkEnumeratePhysicalDevices or IDXGIFactory1::EnumAdapters1.");
GFXRECON_WRITE_CONSOLE(
" \t\tThe optimizer replay may fail if the specified device is not compatible with the");
GFXRECON_WRITE_CONSOLE(" \t\toriginal capture devices.");
GFXRECON_WRITE_CONSOLE("");
GFXRECON_WRITE_CONSOLE("Note: running without optional arguments will instruct the optimizer to detect API and run "
"all available optimizations.");
Expand Down Expand Up @@ -204,7 +212,7 @@ int main(int argc, const char** argv)

gfxrecon::util::Log::Init();

gfxrecon::util::ArgumentParser arg_parser(argc, argv, kOptions, "");
gfxrecon::util::ArgumentParser arg_parser(argc, argv, kOptions, kArguments);

if (CheckOptionPrintUsage(argv[0], arg_parser) || CheckOptionPrintVersion(argv[0], arg_parser))
{
Expand Down Expand Up @@ -240,6 +248,11 @@ int main(int argc, const char** argv)
dx12_options.optimize_resource_values = arg_parser.IsOptionSet(kDx12OptimizeDxr);
dx12_options.optimize_resource_values_experimental = arg_parser.IsOptionSet(kDx12OptimizeDxrExperimental);
dx12_options.remove_redundant_psos = arg_parser.IsOptionSet(kD3d12PsoRemoval);
const auto& override_gpu = arg_parser.GetArgumentValue(kOverrideGpuArgument);
if (!override_gpu.empty())
{
dx12_options.override_gpu_index = std::stoi(override_gpu);
}

if (dx12_options.optimize_resource_values_experimental)
{
Expand Down