Skip to content

Commit

Permalink
Better D3D12 Convert to JSON (#1362)
Browse files Browse the repository at this point in the history
A new DX12 consumer and struct and enum conversion functions that use the nlohmann JSON library.
Deleted the old "ASCII" string concatenating equivalents.

* JsonWriter Class that both Vulkan and DX12 Consumers write JSON through.
  * Moved Annotation Handling to JsonWriter
* More metadata blocks supported.
* More binary blobs dumped to files on the side.
* Convert Masks to Binary for D3D12
  Convert masks which don't have enums defining possible bit values into
  binary numbers encoded in strings using the same format as C++14
  binary literals.
* JSON Output of Marker Block types for DX12 Consumer
* Improved DX12 Enum To String
* OutputStream Write std::string_view
  Writing string views lets it write literal C-strings without
  specifying the length and also std::strings.
* FileOutputStream Additions
  * Reset() to change to a new file.
  * FileNoLockOutputStream derived for when the destination
    file needs no thread locking to syncronize access.
* Renamed vulkan_json_util.h to json_util.h and moved from decode to util
* Use in String Streams or out, not in/out in several places.

    🫳
    🎤 

---------

Co-authored-by: bradgrantham-lunarg <50641407+bradgrantham-lunarg@users.noreply.github.com>
  • Loading branch information
andrew-lunarg and bradgrantham-lunarg authored Dec 1, 2023
1 parent be08673 commit 548080b
Show file tree
Hide file tree
Showing 86 changed files with 31,066 additions and 29,079 deletions.
33 changes: 18 additions & 15 deletions framework/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ target_sources(gfxrecon_decode
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/custom_dx12_struct_decoders.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/custom_dx12_struct_object_mappers.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/custom_dx12_struct_object_mappers.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/custom_dx12_ascii_consumer.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/custom_dx12_ascii_consumer.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/custom_dx12_to_string.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/custom_dx12_to_string.cpp>
${CMAKE_CURRENT_LIST_DIR}/custom_vulkan_struct_handle_mappers.h
${CMAKE_CURRENT_LIST_DIR}/custom_vulkan_struct_handle_mappers.cpp
${CMAKE_CURRENT_LIST_DIR}/custom_vulkan_struct_to_json.h
Expand All @@ -66,6 +62,10 @@ target_sources(gfxrecon_decode
${CMAKE_CURRENT_LIST_DIR}/file_transformer.h
${CMAKE_CURRENT_LIST_DIR}/file_transformer.cpp
${CMAKE_CURRENT_LIST_DIR}/handle_pointer_decoder.h
${CMAKE_CURRENT_LIST_DIR}/json_writer.h
${CMAKE_CURRENT_LIST_DIR}/json_writer.cpp
${CMAKE_CURRENT_LIST_DIR}/decode_json_util.h
${CMAKE_CURRENT_LIST_DIR}/decode_json_util.cpp
${CMAKE_CURRENT_LIST_DIR}/pnext_node.h
${CMAKE_CURRENT_LIST_DIR}/pnext_typed_node.h
${CMAKE_CURRENT_LIST_DIR}/pointer_decoder_base.h
Expand Down Expand Up @@ -113,8 +113,8 @@ target_sources(gfxrecon_decode
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_experimental_resource_value_tracker.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_resource_value_mapper.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_resource_value_mapper.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_ascii_consumer_base.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_ascii_consumer_base.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_json_consumer_base.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_json_consumer_base.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_object_mapping_util.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_object_mapping_util.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_enum_util.h>
Expand All @@ -132,8 +132,10 @@ target_sources(gfxrecon_decode
${CMAKE_CURRENT_LIST_DIR}/vulkan_default_allocator.cpp
${CMAKE_CURRENT_LIST_DIR}/vulkan_captured_swapchain.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_captured_swapchain.cpp
${CMAKE_CURRENT_LIST_DIR}/vulkan_export_json_consumer_base.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_export_json_consumer_base.cpp
${CMAKE_CURRENT_LIST_DIR}/vulkan_json_consumer_base.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_json_consumer_base.cpp
${CMAKE_CURRENT_LIST_DIR}/marker_json_consumer.h
${CMAKE_CURRENT_LIST_DIR}/metadata_json_consumer.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_enum_util.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_feature_util.h
${CMAKE_CURRENT_LIST_DIR}/vulkan_feature_util.cpp
Expand Down Expand Up @@ -176,8 +178,8 @@ target_sources(gfxrecon_decode
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_decoder.cpp
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_enum_to_json.h
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_enum_to_json.cpp
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_export_json_consumer.h
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_export_json_consumer.cpp
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_json_consumer.h
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_json_consumer.cpp
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_feature_util.cpp
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_referenced_resource_consumer.h
${CMAKE_SOURCE_DIR}/framework/generated/generated_vulkan_referenced_resource_consumer.cpp
Expand All @@ -200,15 +202,16 @@ target_sources(gfxrecon_decode
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_consumer.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_replay_consumer.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_replay_consumer.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_ascii_consumer.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_ascii_consumer.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_json_consumer.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_json_consumer.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_enum_to_string.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_enum_to_string.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_struct_to_string.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_struct_to_string.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_struct_object_mappers.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_struct_object_mappers.cpp>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_call_id_to_string.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_enum_to_json.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_struct_decoders_to_json.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_struct_decoders_to_json.cpp>
)

if (${GFXRECON_AGS_SUPPORT_FINAL})
Expand All @@ -228,7 +231,7 @@ endif()
if (MSVC)
# These files may fail to compile with VS2017 and older, requiring the default section limit of 2^16 to be increased.
set_source_files_properties(${CMAKE_SOURCE_DIR}/framework/generated/generated_decode_pnext_struct.cpp PROPERTIES COMPILE_FLAGS /bigobj)
set_source_files_properties(${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_ascii_consumer.cpp PROPERTIES COMPILE_FLAGS /bigobj)
set_source_files_properties(${CMAKE_SOURCE_DIR}/framework/generated/generated_dx12_json_consumer.cpp PROPERTIES COMPILE_FLAGS /bigobj)
set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/test/main.cpp PROPERTIES COMPILE_FLAGS /bigobj)
if (MSVC_VERSION LESS 1920)
set_source_files_properties(${CMAKE_SOURCE_DIR}/framework/generated/generated_decode_pnext_struct.cpp PROPERTIES COMPILE_FLAGS /bigobj)
Expand Down
Loading

0 comments on commit 548080b

Please sign in to comment.