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 ags to convert tool #1211

Closed
Closed
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
2 changes: 2 additions & 0 deletions framework/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ target_sources(gfxrecon_decode
${CMAKE_CURRENT_LIST_DIR}/custom_ags_consumer_base.h
${CMAKE_CURRENT_LIST_DIR}/custom_ags_replay_consumer.h
${CMAKE_CURRENT_LIST_DIR}/custom_ags_replay_consumer.cpp
${CMAKE_CURRENT_LIST_DIR}/custom_ags_ascii_consumer.h
${CMAKE_CURRENT_LIST_DIR}/custom_ags_ascii_consumer.cpp
${CMAKE_CURRENT_LIST_DIR}/ags_detection_consumer.h
)
endif()
Expand Down
669 changes: 669 additions & 0 deletions framework/decode/custom_ags_ascii_consumer.cpp

Large diffs are not rendered by default.

677 changes: 677 additions & 0 deletions framework/decode/custom_ags_ascii_consumer.h

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions framework/decode/custom_ags_consumer_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class AgsConsumerBase
AGSContext* context,
format::HandleId object_id,
const char* data) = 0;

void SetCurrentBlockIndex(uint64_t index) { current_block_index_ = index; }

protected:
uint64_t current_block_index_{ 0 };
};

GFXRECON_END_NAMESPACE(decode)
Expand Down
8 changes: 8 additions & 0 deletions framework/decode/custom_ags_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ bool AgsDecoder::SupportsApiCall(format::ApiCallId call_id)
return (family_id == format::ApiFamilyId::ApiFamily_AGS);
}

void AgsDecoder::SetCurrentBlockIndex(uint64_t block_index)
{
for (auto consumer : consumers_)
{
consumer->SetCurrentBlockIndex(block_index);
}
}

void AgsDecoder::DecodeFunctionCall(format::ApiCallId call_id,
const ApiCallInfo& call_info,
const uint8_t* parameter_buffer,
Expand Down
2 changes: 1 addition & 1 deletion framework/decode/custom_ags_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class AgsDecoder : public ApiDecoder
const uint8_t* data) override
{}

virtual void SetCurrentBlockIndex(uint64_t block_index) override {}
virtual void SetCurrentBlockIndex(uint64_t block_index) override;

virtual void DecodeFunctionCall(format::ApiCallId call_id,
const ApiCallInfo& call_options,
Expand Down
4 changes: 2 additions & 2 deletions framework/decode/dx12_ascii_consumer_base.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
** Copyright (c) 2021-2023 LunarG, Inc.
** Copyright (c) 2023 Advanced Micro Devices, 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 @@ -100,7 +101,7 @@ class Dx12AsciiConsumerBase : public Dx12Consumer
[&](std::stringstream& strStrm)
{
// Output the API call index
FieldToString(strStrm, true, "index", to_string_flags_, tabCount, tabSize, ToString(api_call_count_++, to_string_flags_, tabCount, tabSize));
FieldToString(strStrm, true, "index", to_string_flags_, tabCount, tabSize, ToString(GetCurrentBlockIndex(), to_string_flags_, tabCount, tabSize));

// Output the method/function name
assert(writeApiCallToFileInfo.pFunctionName);
Expand Down Expand Up @@ -145,7 +146,6 @@ class Dx12AsciiConsumerBase : public Dx12Consumer
private:
FILE* file_{ nullptr };
std::string filename_;
uint64_t api_call_count_{ 0 };
};

GFXRECON_END_NAMESPACE(decode)
Expand Down
3 changes: 2 additions & 1 deletion framework/decode/dx12_consumer_base.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
** Copyright (c) 2021 LunarG, Inc.
** Copyright (c) 2021-2023 LunarG, Inc.
** Copyright (c) 2023 Advanced Micro Devices, 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
4 changes: 1 addition & 3 deletions framework/decode/file_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const uint32_t kFirstFrame = 0;
FileProcessor::FileProcessor() :
file_header_{}, file_descriptor_(nullptr), current_frame_number_(kFirstFrame), bytes_read_(0),
error_state_(kErrorInvalidFileDescriptor), annotation_handler_(nullptr), compressor_(nullptr), block_index_(0),
api_call_index_(0), block_limit_(0), capture_uses_frame_markers_(false), first_frame_(kFirstFrame + 1)
block_limit_(0), capture_uses_frame_markers_(false), first_frame_(kFirstFrame + 1)
{}

FileProcessor::FileProcessor(uint64_t block_limit) : FileProcessor()
Expand Down Expand Up @@ -651,8 +651,6 @@ bool FileProcessor::ProcessMethodCall(const format::BlockHeader& block_header, f
DecodeAllocator::End();
}
}

++api_call_index_;
}
}
else
Expand Down
19 changes: 18 additions & 1 deletion tools/convert/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
** Copyright (c) 2018-2023 Valve Corporation
** Copyright (c) 2018-2023 LunarG, Inc.
** Copyright (c) 2020 Advanced Micro Devices, Inc.
** Copyright (c) 2020-2023 Advanced Micro Devices, Inc.
**
** 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 +31,11 @@
#include "generated/generated_vulkan_export_json_consumer.h"
#if defined(CONVERT_EXPERIMENTAL_D3D12)
#include "generated/generated_dx12_ascii_consumer.h"
#ifdef GFXRECON_AGS_SUPPORT
#include "decode/custom_ags_consumer_base.h"
#include "decode/custom_ags_decoder.h"
#include "decode/custom_ags_ascii_consumer.h"
#endif // GFXRECON_AGS_SUPPORT
#endif

using gfxrecon::decode::JsonFormat;
Expand Down Expand Up @@ -270,6 +275,18 @@ int main(int argc, const char** argv)
auto dx12_json_flags = output_format == JsonFormat::JSON ? gfxrecon::util::kToString_Formatted
: gfxrecon::util::kToString_Unformatted;
dx12_ascii_consumer.Initialize(out_file_handle, dx12_json_flags);

#ifdef GFXRECON_AGS_SUPPORT
gfxrecon::decode::AgsAsciiConsumer ags_ascii_consumer;
ags_ascii_consumer.Initialize(out_file_handle, dx12_json_flags);

gfxrecon::decode::AgsDecoder ags_decoder;

ags_decoder.AddConsumer(&ags_ascii_consumer);

file_processor.AddDecoder(&ags_decoder);
#endif // GFXRECON_AGS_SUPPORT

#endif

while (success)
Expand Down