Skip to content

Commit

Permalink
CombineAndWriteToFile() now takes a file output as an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
panos-lunarg committed Oct 27, 2024
1 parent 31e59f5 commit 523d403
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
23 changes: 3 additions & 20 deletions framework/encode/capture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ void CommonCaptureManager::DeactivateTrimming(std::shared_lock<ApiCallMutexT>& c
}
}

void CommonCaptureManager::WriteFileHeader()
void CommonCaptureManager::WriteFileHeader(util::FileOutputStream* file_stream)
{
std::vector<format::FileOptionPair> option_list;

Expand All @@ -1291,7 +1291,8 @@ void CommonCaptureManager::WriteFileHeader()
file_header.num_options = static_cast<uint32_t>(option_list.size());

CombineAndWriteToFile({ { &file_header, sizeof(file_header) },
{ option_list.data(), option_list.size() * sizeof(format::FileOptionPair) } });
{ option_list.data(), option_list.size() * sizeof(format::FileOptionPair) } },
file_stream);

// File header does not count as a block
assert(block_index_ > 0);
Expand All @@ -1301,24 +1302,6 @@ void CommonCaptureManager::WriteFileHeader()
thread_data->block_index_ = block_index_.load();
}

void CommonCaptureManager::WriteFileHeader(util::FileOutputStream* file_stream)
{
assert(file_stream != nullptr);

std::vector<format::FileOptionPair> option_list;

BuildOptionList(file_options_, &option_list);

format::FileHeader file_header;
file_header.fourcc = GFXRECON_FOURCC;
file_header.major_version = 0;
file_header.minor_version = 0;
file_header.num_options = static_cast<uint32_t>(option_list.size());

WriteToFile(&file_header, sizeof(file_header), file_stream);
WriteToFile(option_list.data(), option_list.size() * sizeof(format::FileOptionPair), file_stream);
}

void CommonCaptureManager::BuildOptionList(const format::EnabledOptions& enabled_options,
std::vector<format::FileOptionPair>* option_list)
{
Expand Down
9 changes: 4 additions & 5 deletions framework/encode/capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ class CommonCaptureManager
void ActivateTrimming(std::shared_lock<ApiCallMutexT>& current_lock);
void DeactivateTrimming(std::shared_lock<ApiCallMutexT>& current_lock);

void WriteFileHeader();

void WriteFileHeader(util::FileOutputStream* file_stream);
void WriteFileHeader(util::FileOutputStream* file_stream = nullptr);

void BuildOptionList(const format::EnabledOptions& enabled_options,
std::vector<format::FileOptionPair>* option_list);
Expand All @@ -307,7 +305,8 @@ class CommonCaptureManager
void WriteToFile(const void* data, size_t size, util::FileOutputStream* file_stream = nullptr);

template <size_t N>
void CombineAndWriteToFile(const std::pair<const void*, size_t> (&buffers)[N])
void CombineAndWriteToFile(const std::pair<const void*, size_t> (&buffers)[N],
util::FileOutputStream* file_stream = nullptr)
{
static_assert(N != 1, "Use WriteToFile(void*, size) when writing a single buffer.");

Expand All @@ -321,7 +320,7 @@ class CommonCaptureManager
scratch_buffer.insert(scratch_buffer.end(), data, data + size);
}

WriteToFile(scratch_buffer.data(), scratch_buffer.size());
WriteToFile(scratch_buffer.data(), scratch_buffer.size(), file_stream);
}

void IncrementBlockIndex(uint64_t blocks)
Expand Down

0 comments on commit 523d403

Please sign in to comment.