mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-09 01:28:57 +00:00
VideoCommon: add function to serialize ShaderAsset to json
This commit is contained in:
parent
d1b4c5482c
commit
b5a6225e1a
5 changed files with 104 additions and 0 deletions
26
Source/Core/Common/JsonUtil.h
Normal file
26
Source/Core/Common/JsonUtil.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2024 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <span>
|
||||
|
||||
#include <picojson.h>
|
||||
|
||||
// Ideally this would use a concept like, 'template <std::ranges::range Range>' to constrain it,
|
||||
// but unfortunately we'd need to require clang 15 for that, since the ranges library isn't
|
||||
// fully implemented until then, but this should suffice.
|
||||
|
||||
template <typename Range>
|
||||
picojson::array ToJsonArray(const Range& data)
|
||||
{
|
||||
picojson::array result;
|
||||
result.reserve(std::size(data));
|
||||
|
||||
for (const auto& value : data)
|
||||
{
|
||||
result.emplace_back(static_cast<double>(value));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue