Skip to content

Commit

Permalink
only compile D3D12 into convert if D3D12_SUPPORT is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
bradgrantham-lunarg committed Aug 29, 2024
1 parent 1198516 commit 9af9b1c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/convert/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
#include "generated/generated_vulkan_json_consumer.h"
#include "decode/marker_json_consumer.h"
#include "decode/metadata_json_consumer.h"
#if defined(D3D12_SUPPORT)
#include "generated/generated_dx12_json_consumer.h"
#endif

using gfxrecon::util::JsonFormat;
using VulkanJsonConsumer = gfxrecon::decode::MetadataJsonConsumer<
gfxrecon::decode::MarkerJsonConsumer<gfxrecon::decode::VulkanExportJsonConsumer>>;
#if defined(D3D12_SUPPORT)
using Dx12JsonConsumer =
gfxrecon::decode::MetadataJsonConsumer<gfxrecon::decode::MarkerJsonConsumer<gfxrecon::decode::Dx12JsonConsumer>>;
#endif
const char kOptions[] = "-h|--help,--version,--no-debug-popup,--file-per-frame,--include-binaries,--expand-flags";

const char kArguments[] = "--output,--format";
Expand Down Expand Up @@ -171,6 +175,17 @@ int main(int argc, const char** argv)

gfxrecon::decode::FileProcessor file_processor;

#ifndef D3D12_SUPPORT
bool detected_d3d12 = false;
bool detected_vulkan = false;
gfxrecon::decode::DetectAPIs(input_filename, detected_d3d12, detected_vulkan);

if (detected_d3d12)
{
GFXRECON_LOG_INFO("Capture file contains D3D12 content but gfxrecon-convert is not compiled with D3D12 support.");
goto exit;
}
#endif
if (file_per_frame && output_to_stdout)
{
GFXRECON_LOG_WARNING("Outputting a file per frame is not consistent with outputting to stdout.");
Expand Down Expand Up @@ -235,6 +250,8 @@ int main(int argc, const char** argv)
json_consumer.Initialize(&json_writer, vulkan_version);
json_writer.StartStream(&out_stream);

// If CONVERT_EXPERIMENTAL_D3D12 was set, then add DX12 consumer/decoder
#ifdef D3D12_SUPPORT
Dx12JsonConsumer dx12_json_consumer;
gfxrecon::decode::Dx12Decoder dx12_decoder;

Expand All @@ -243,6 +260,7 @@ int main(int argc, const char** argv)
auto dx12_json_flags = output_format == JsonFormat::JSON ? gfxrecon::util::kToString_Formatted
: gfxrecon::util::kToString_Unformatted;
dx12_json_consumer.Initialize(&json_writer);
#endif

while (success)
{
Expand All @@ -268,7 +286,10 @@ int main(int argc, const char** argv)
}
}
json_consumer.Destroy();
// If CONVERT_EXPERIMENTAL_D3D12 was set, then cleanup DX12 consumer
#ifdef D3D12_SUPPORT
dx12_json_consumer.Destroy();
#endif
if (!output_to_stdout)
{
gfxrecon::util::platform::FileClose(out_file_handle);
Expand Down

0 comments on commit 9af9b1c

Please sign in to comment.