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

Initial support for D3D11 #1698

Open
wants to merge 54 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
730b740
Generate globally unique anon union names
dgraves Jul 26, 2024
76919d1
DX11 encode code generation
dgraves Jul 26, 2024
0bbf75d
Update codegen for anon structs
dgraves Jul 26, 2024
58cff1b
Add DX11 bitfield entry
dgraves Jul 26, 2024
065f8ae
DX11 decode code generation
dgraves Jul 26, 2024
a91b50a
Add DX11 enums to codegen bits list
dgraves Jul 26, 2024
06fb7cc
Add DX11 API call IDs
dgraves Jul 26, 2024
d2cb319
Add d3d11.lib to linker input
dgraves Jul 26, 2024
0c17377
DX11 encoding utility code
dgraves Jul 26, 2024
1e60ef3
Custom DX11 encode/decode routines
dgraves Jul 26, 2024
bd788a1
DX11 decoding utility code
roberto-c Jul 26, 2024
ece0afd
Allocate output data for replay
dgraves Jul 26, 2024
9b23284
Add replay support for output string parameters
dgraves Jul 26, 2024
b696048
Add codegen inout parameter support
dgraves Jul 26, 2024
6fc9fe8
Support D3D 'result_bytebuffer' case
dgraves Jul 26, 2024
699df68
Add generated DX11 code
dgraves Jul 26, 2024
723faee
Gen AddObject for non HRESULT case
dgraves Jul 26, 2024
18298d3
Add d3d11.dll proxy
dgraves Jul 26, 2024
af92a59
Enable D3D11 API decoding
dgraves Jul 26, 2024
c56a68d
Initial resource tracking
dgraves Jul 26, 2024
d6abf2e
Add replay support for mapped memory updates
dgraves Jul 26, 2024
ce73160
Add ID3D11DeviceContext::GetData replay override
dgraves Jul 26, 2024
2a34189
Add DX 11.3 support
dgraves Jul 26, 2024
75b12da
Add DX 11.4 support
dgraves Jul 26, 2024
a3c89cc
Add custom d3d11 object wrapper for ID3D11Resource
dgraves Jul 26, 2024
8990592
Adjust variable length output array sizes
dgraves Jul 26, 2024
1e449ff
Update codegen for arrays of COM pointers
dgraves Jul 26, 2024
92e8d61
Prevent array size null pointer dereference
dgraves Jul 26, 2024
f72c73c
Add d3d11on12 support
dgraves Jul 26, 2024
eaef443
Add unique codegen names for replay object info
dgraves Jul 26, 2024
813e378
Adjust discard mapped memory case
dgraves Jul 26, 2024
88e539e
Adjust exteral object/IUnknown handling
dgraves Jul 26, 2024
559ccff
Make D3D11 view hold internal resource ref
dgraves Jul 26, 2024
290ed17
Add -1 count check to debug assert
dgraves Jul 26, 2024
87e4beb
Update swap chain handling for D3D11
dgraves Jul 26, 2024
9fa53c4
Handle D3D11 MipLevels = 0 texture creation case
dgraves Jul 26, 2024
55a756b
Handle uncommon map discard cases
dgraves Jul 26, 2024
31ebc23
Add swapchain init for CreateDeviceAndSwapChain
dgraves Jul 26, 2024
376c517
Enable debug layer for D3D11
dgraves Jul 26, 2024
386d2e6
Support aligned copies for mapped texture updates
dgraves Jul 26, 2024
6de279a
Add DX11 screenshot support
dgraves Jul 26, 2024
e0348ce
Keep persistent memory in table for DX11
dgraves Jul 26, 2024
9608828
Custom ID3D11Device::CheckFeatureSupport routines
dgraves Jul 26, 2024
7a34447
Per-write metadata API ID specification
dgraves Jul 26, 2024
486f589
DX11 support for gfxrecon-info
dgraves Jul 26, 2024
c9ac977
Custom decoder for CheckFeatureSupport data param
dgraves Jul 26, 2024
08def37
Adjust system DLL loading
dgraves Jul 26, 2024
d6b1e43
Fix ResizeBuffers replay with width/height = 0
dgraves Jul 26, 2024
eae9eb0
Fix gfxrecon-info ResizeBuffers usage
dgraves Jul 26, 2024
b540828
Enable debug markers for DX11 replay
dgraves Jul 26, 2024
b2e1be0
Handle UpdateSubresource data pointer adjustment
dgraves Jul 26, 2024
734320b
Fix DX11 compressed tex1d/3d subresource size calc
dgraves Jul 26, 2024
c0ef127
DX11 deferred context memory tracking optimization
dgraves Jul 26, 2024
5a2c4fe
Make IDXGISwapChain buffer cast conditional
dgraves Jul 26, 2024
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
1 change: 1 addition & 0 deletions framework/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ target_sources(gfxrecon_decode
${CMAKE_CURRENT_LIST_DIR}/info_consumer.h
${CMAKE_CURRENT_LIST_DIR}/info_decoder.h
${CMAKE_CURRENT_LIST_DIR}/info_decoder.cpp
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx_feature_data_decoder.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx_replay_options.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_optimize_options.h>
$<$<BOOL:${D3D12_SUPPORT}>:${CMAKE_CURRENT_LIST_DIR}/dx12_object_info.h>
Expand Down
585 changes: 585 additions & 0 deletions framework/decode/custom_dx12_struct_decoders.cpp

Large diffs are not rendered by default.

169 changes: 169 additions & 0 deletions framework/decode/custom_dx12_struct_decoders.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
** Copyright (c) 2021 LunarG, Inc.
** Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -31,6 +32,7 @@
#include "util/defines.h"

#include <d3d12.h>
#include <d3d11.h>

GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(decode)
Expand Down Expand Up @@ -298,6 +300,173 @@ struct Decoded_D3D12_SAMPLER_DESC2
PointerDecoder<float> FloatBorderColor;
};

struct Decoded_D3D11_SUBRESOURCE_DATA
{
using struct_type = D3D11_SUBRESOURCE_DATA;

D3D11_SUBRESOURCE_DATA* decoded_value{ nullptr };
PointerDecoder<uint8_t> pSysMem;
};

struct Decoded_D3D11_BUFFER_SRV
{
using struct_type = D3D11_BUFFER_SRV;

D3D11_BUFFER_SRV* decoded_value{ nullptr };
};

struct Decoded_D3D11_SHADER_RESOURCE_VIEW_DESC
{
using struct_type = D3D11_SHADER_RESOURCE_VIEW_DESC;

D3D11_SHADER_RESOURCE_VIEW_DESC* decoded_value{ nullptr };
Decoded_D3D11_BUFFER_SRV* Buffer{ nullptr };
Decoded_D3D11_TEX1D_SRV* Texture1D{ nullptr };
Decoded_D3D11_TEX1D_ARRAY_SRV* Texture1DArray{ nullptr };
Decoded_D3D11_TEX2D_SRV* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_SRV* Texture2DArray{ nullptr };
Decoded_D3D11_TEX2DMS_SRV* Texture2DMS{ nullptr };
Decoded_D3D11_TEX2DMS_ARRAY_SRV* Texture2DMSArray{ nullptr };
Decoded_D3D11_TEX3D_SRV* Texture3D{ nullptr };
Decoded_D3D11_TEXCUBE_SRV* TextureCube{ nullptr };
Decoded_D3D11_TEXCUBE_ARRAY_SRV* TextureCubeArray{ nullptr };
Decoded_D3D11_BUFFEREX_SRV* BufferEx{ nullptr };
};

struct Decoded_D3D11_BUFFER_RTV
{
using struct_type = D3D11_BUFFER_RTV;

D3D11_BUFFER_RTV* decoded_value{ nullptr };
};

struct Decoded_D3D11_UNORDERED_ACCESS_VIEW_DESC
{
using struct_type = D3D11_UNORDERED_ACCESS_VIEW_DESC;

D3D11_UNORDERED_ACCESS_VIEW_DESC* decoded_value{ nullptr };
Decoded_D3D11_BUFFER_UAV* Buffer{ nullptr };
Decoded_D3D11_TEX1D_UAV* Texture1D{ nullptr };
Decoded_D3D11_TEX1D_ARRAY_UAV* Texture1DArray{ nullptr };
Decoded_D3D11_TEX2D_UAV* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_UAV* Texture2DArray{ nullptr };
Decoded_D3D11_TEX3D_UAV* Texture3D{ nullptr };
};

struct Decoded_D3D11_RENDER_TARGET_VIEW_DESC
{
using struct_type = D3D11_RENDER_TARGET_VIEW_DESC;

D3D11_RENDER_TARGET_VIEW_DESC* decoded_value{ nullptr };
Decoded_D3D11_BUFFER_RTV* Buffer{ nullptr };
Decoded_D3D11_TEX1D_RTV* Texture1D{ nullptr };
Decoded_D3D11_TEX1D_ARRAY_RTV* Texture1DArray{ nullptr };
Decoded_D3D11_TEX2D_RTV* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_RTV* Texture2DArray{ nullptr };
Decoded_D3D11_TEX2DMS_RTV* Texture2DMS{ nullptr };
Decoded_D3D11_TEX2DMS_ARRAY_RTV* Texture2DMSArray{ nullptr };
Decoded_D3D11_TEX3D_RTV* Texture3D{ nullptr };
};

struct Decoded_D3D11_DEPTH_STENCIL_VIEW_DESC
{
using struct_type = D3D11_DEPTH_STENCIL_VIEW_DESC;

D3D11_DEPTH_STENCIL_VIEW_DESC* decoded_value{ nullptr };
Decoded_D3D11_TEX1D_DSV* Texture1D{ nullptr };
Decoded_D3D11_TEX1D_ARRAY_DSV* Texture1DArray{ nullptr };
Decoded_D3D11_TEX2D_DSV* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_DSV* Texture2DArray{ nullptr };
Decoded_D3D11_TEX2DMS_DSV* Texture2DMS{ nullptr };
Decoded_D3D11_TEX2DMS_ARRAY_DSV* Texture2DMSArray{ nullptr };
};

struct Decoded_D3D11_SHADER_RESOURCE_VIEW_DESC1
{
using struct_type = D3D11_SHADER_RESOURCE_VIEW_DESC1;

D3D11_SHADER_RESOURCE_VIEW_DESC1* decoded_value{ nullptr };
Decoded_D3D11_BUFFER_SRV* Buffer{ nullptr };
Decoded_D3D11_TEX1D_SRV* Texture1D{ nullptr };
Decoded_D3D11_TEX1D_ARRAY_SRV* Texture1DArray{ nullptr };
Decoded_D3D11_TEX2D_SRV1* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_SRV1* Texture2DArray{ nullptr };
Decoded_D3D11_TEX2DMS_SRV* Texture2DMS{ nullptr };
Decoded_D3D11_TEX2DMS_ARRAY_SRV* Texture2DMSArray{ nullptr };
Decoded_D3D11_TEX3D_SRV* Texture3D{ nullptr };
Decoded_D3D11_TEXCUBE_SRV* TextureCube{ nullptr };
Decoded_D3D11_TEXCUBE_ARRAY_SRV* TextureCubeArray{ nullptr };
Decoded_D3D11_BUFFEREX_SRV* BufferEx{ nullptr };
};

struct Decoded_D3D11_UNORDERED_ACCESS_VIEW_DESC1
{
using struct_type = D3D11_UNORDERED_ACCESS_VIEW_DESC1;

D3D11_UNORDERED_ACCESS_VIEW_DESC1* decoded_value{ nullptr };
Decoded_D3D11_BUFFER_UAV* Buffer{ nullptr };
Decoded_D3D11_TEX1D_UAV* Texture1D{ nullptr };
Decoded_D3D11_TEX1D_ARRAY_UAV* Texture1DArray{ nullptr };
Decoded_D3D11_TEX2D_UAV1* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_UAV1* Texture2DArray{ nullptr };
Decoded_D3D11_TEX3D_UAV* Texture3D{ nullptr };
};

struct Decoded_D3D11_RENDER_TARGET_VIEW_DESC1
{
using struct_type = D3D11_RENDER_TARGET_VIEW_DESC1;

D3D11_RENDER_TARGET_VIEW_DESC1* decoded_value{ nullptr };
Decoded_D3D11_BUFFER_RTV* Buffer{ nullptr };
Decoded_D3D11_TEX1D_RTV* Texture1D{ nullptr };
Decoded_D3D11_TEX1D_ARRAY_RTV* Texture1DArray{ nullptr };
Decoded_D3D11_TEX2D_RTV1* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_RTV1* Texture2DArray{ nullptr };
Decoded_D3D11_TEX2DMS_RTV* Texture2DMS{ nullptr };
Decoded_D3D11_TEX2DMS_ARRAY_RTV* Texture2DMSArray{ nullptr };
Decoded_D3D11_TEX3D_RTV* Texture3D{ nullptr };
};

struct Decoded_D3D11_VIDEO_COLOR
{
using struct_type = D3D11_VIDEO_COLOR;

D3D11_VIDEO_COLOR* decoded_value{ nullptr };
};

struct Decoded_D3D11_AUTHENTICATED_PROTECTION_FLAGS
{
using struct_type = D3D11_AUTHENTICATED_PROTECTION_FLAGS;

D3D11_AUTHENTICATED_PROTECTION_FLAGS* decoded_value{ nullptr };
};

struct Decoded_D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC
{
using struct_type = D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC;

D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC* decoded_value{ nullptr };
Decoded_GUID* DecodeProfile{ nullptr };
Decoded_D3D11_TEX2D_VDOV* Texture2D{ nullptr };
};

struct Decoded_D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC
{
using struct_type = D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC;

D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC* decoded_value{ nullptr };
Decoded_D3D11_TEX2D_VPIV* Texture2D{ nullptr };
};

struct Decoded_D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC
{
using struct_type = D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC;

D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC* decoded_value{ nullptr };
Decoded_D3D11_TEX2D_VPOV* Texture2D{ nullptr };
Decoded_D3D11_TEX2D_ARRAY_VPOV* Texture2DArray{ nullptr };
};

GFXRECON_END_NAMESPACE(decode)
GFXRECON_END_NAMESPACE(gfxrecon)

Expand Down
30 changes: 30 additions & 0 deletions framework/decode/custom_dx12_struct_decoders_forward.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
** Copyright (c) 2021 LunarG, Inc.
** Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -51,6 +52,21 @@ struct Decoded_D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS;
struct Decoded_D3D12_VERSIONED_DEVICE_REMOVED_EXTENDED_DATA;
struct Decoded_D3D12_RENDER_PASS_BEGINNING_ACCESS;
struct Decoded_D3D12_RENDER_PASS_ENDING_ACCESS;
struct Decoded_D3D11_SUBRESOURCE_DATA;
struct Decoded_D3D11_BUFFER_SRV;
struct Decoded_D3D11_SHADER_RESOURCE_VIEW_DESC;
struct Decoded_D3D11_BUFFER_RTV;
struct Decoded_D3D11_UNORDERED_ACCESS_VIEW_DESC;
struct Decoded_D3D11_RENDER_TARGET_VIEW_DESC;
struct Decoded_D3D11_DEPTH_STENCIL_VIEW_DESC;
struct Decoded_D3D11_SHADER_RESOURCE_VIEW_DESC1;
struct Decoded_D3D11_UNORDERED_ACCESS_VIEW_DESC1;
struct Decoded_D3D11_RENDER_TARGET_VIEW_DESC1;
struct Decoded_D3D11_VIDEO_COLOR;
struct Decoded_D3D11_AUTHENTICATED_PROTECTION_FLAGS;
struct Decoded_D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC;
struct Decoded_D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC;
struct Decoded_D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC;

size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D12_CLEAR_VALUE* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D12_RESOURCE_BARRIER* wrapper);
Expand All @@ -71,6 +87,20 @@ size_t
DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D12_VERSIONED_DEVICE_REMOVED_EXTENDED_DATA* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D12_RENDER_PASS_BEGINNING_ACCESS* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D12_RENDER_PASS_ENDING_ACCESS* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_SUBRESOURCE_DATA* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_BUFFER_SRV* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_SHADER_RESOURCE_VIEW_DESC* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_UNORDERED_ACCESS_VIEW_DESC* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_RENDER_TARGET_VIEW_DESC* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_DEPTH_STENCIL_VIEW_DESC* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_SHADER_RESOURCE_VIEW_DESC1* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_UNORDERED_ACCESS_VIEW_DESC1* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_RENDER_TARGET_VIEW_DESC1* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_VIDEO_COLOR* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_AUTHENTICATED_PROTECTION_FLAGS* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC* wrapper);
size_t DecodeStruct(const uint8_t* buffer, size_t buffer_size, Decoded_D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC* wrapper);

// Platform types.
struct Decoded_LARGE_INTEGER;
Expand Down
14 changes: 12 additions & 2 deletions framework/decode/decode_api_detection.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
** Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
** Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -29,7 +30,11 @@
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(decode)

bool DetectAPIs(const std::string& input_filename, bool& dx12_detected, bool& vulkan_detected, bool no_block_limit)
bool DetectAPIs(const std::string& input_filename,
bool& dx11_detected,
bool& dx12_detected,
bool& vulkan_detected,
bool no_block_limit)
{
dx12_detected = false;
vulkan_detected = false;
Expand Down Expand Up @@ -61,6 +66,11 @@ bool DetectAPIs(const std::string& input_filename, bool& dx12_detected, bool& vu
#endif
file_processor.ProcessAllFrames();
#if defined(D3D12_SUPPORT)
if (dx12_detection_consumer.WasD3D11APIDetected())
{
dx11_detected = true;
}

if (dx12_detection_consumer.WasD3D12APIDetected())
{
dx12_detected = true;
Expand All @@ -79,7 +89,7 @@ bool DetectAPIs(const std::string& input_filename, bool& dx12_detected, bool& vu
vulkan_detected = true;
}
}
return dx12_detected || vulkan_detected;
return dx11_detected || dx12_detected || vulkan_detected;
}

GFXRECON_END_NAMESPACE(decode)
Expand Down
2 changes: 2 additions & 0 deletions framework/decode/decode_api_detection.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
** Copyright (c) 2022 LunarG, Inc.
** Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
** Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -38,6 +39,7 @@ GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(decode)

bool DetectAPIs(const std::string& input_filename,
bool& dx11_detected,
bool& dx12_detected,
bool& vulkan_detected,
bool no_block_limit = false);
Expand Down
33 changes: 33 additions & 0 deletions framework/decode/decode_json_util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
** Copyright (c) 2022-2023 LunarG, Inc.
** Copyright (c) 2023 Valve Corporation
** Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -203,6 +204,30 @@ void HandleToJson(nlohmann::ordered_json& jdata,
}
}

template <typename THandle>
void HandleToJson(nlohmann::ordered_json& jdata,
const HandlePointerDecoder<THandle>& data,
const util::JsonOptions& options = util::JsonOptions())
{
if (data.GetPointer())
{
const auto decoded_value = data.GetPointer();
const auto length = data.GetLength();

if (data.IsArray())
{
for (size_t i = 0; i < length; ++i)
{
HandleToJson(jdata[i], decoded_value[i], options);
}
}
else if (length == 1)
{
HandleToJson(jdata, *decoded_value, options);
}
}
}

/// @brief Thunk to HandleToJson to allow the standard FieldToJson name to be
/// used for pointers and arrays where the type of the HandlePointerDecoder
/// allows the correct version to be resolved.
Expand All @@ -214,6 +239,14 @@ void FieldToJson(nlohmann::ordered_json& jdata,
HandleToJson(jdata, data, options);
}

template <typename THandle>
void FieldToJson(nlohmann::ordered_json& jdata,
const HandlePointerDecoder<THandle>& data,
const util::JsonOptions& options = util::JsonOptions())
{
HandleToJson(jdata, data, options);
}

// Same as array FieldToJson above but converts elements pointed-to to hexadecimal
template <typename DecodedType, typename OutputDecodedType = DecodedType>
void FieldToJsonAsHex(nlohmann::ordered_json& jdata,
Expand Down
Loading
Loading