mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-21 03:54:57 +00:00
VideoCommon: add render target asset
This commit is contained in:
parent
f1059921ae
commit
733bae981f
2 changed files with 74 additions and 0 deletions
43
Source/Core/VideoCommon/Assets/RenderTargetAsset.cpp
Normal file
43
Source/Core/VideoCommon/Assets/RenderTargetAsset.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2025 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "VideoCommon/Assets/RenderTargetAsset.h"
|
||||
|
||||
#include "Common/EnumUtils.h"
|
||||
#include "Common/JsonUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
|
||||
namespace VideoCommon
|
||||
{
|
||||
bool RenderTargetData::FromJson(const CustomAssetLibrary::AssetID& asset_id,
|
||||
const picojson::object& json, RenderTargetData* data)
|
||||
{
|
||||
data->m_texture_format = AbstractTextureFormat::RGBA8;
|
||||
// TODO: parse format
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderTargetData::ToJson(picojson::object* obj, const RenderTargetData& data)
|
||||
{
|
||||
if (!obj) [[unlikely]]
|
||||
return;
|
||||
|
||||
auto& json_obj = *obj;
|
||||
json_obj.emplace("format", static_cast<double>(data.m_texture_format));
|
||||
}
|
||||
|
||||
CustomAssetLibrary::LoadInfo
|
||||
RenderTargetAsset::LoadImpl(const CustomAssetLibrary::AssetID& asset_id)
|
||||
{
|
||||
auto potential_data = std::make_shared<RenderTargetData>();
|
||||
const auto loaded_info = m_owning_library->LoadRenderTarget(asset_id, potential_data.get());
|
||||
if (loaded_info.m_bytes_loaded == 0)
|
||||
return {};
|
||||
{
|
||||
std::lock_guard lk(m_data_lock);
|
||||
m_loaded = true;
|
||||
m_data = std::move(potential_data);
|
||||
}
|
||||
return loaded_info;
|
||||
}
|
||||
} // namespace VideoCommon
|
31
Source/Core/VideoCommon/Assets/RenderTargetAsset.h
Normal file
31
Source/Core/VideoCommon/Assets/RenderTargetAsset.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2025 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <picojson.h>
|
||||
|
||||
#include "VideoCommon/Assets/CustomAsset.h"
|
||||
#include "VideoCommon/RenderState.h"
|
||||
#include "VideoCommon/TextureConfig.h"
|
||||
|
||||
namespace VideoCommon
|
||||
{
|
||||
struct RenderTargetData
|
||||
{
|
||||
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
|
||||
RenderTargetData* data);
|
||||
static void ToJson(picojson::object* obj, const RenderTargetData& data);
|
||||
AbstractTextureFormat m_texture_format;
|
||||
SamplerState m_sampler;
|
||||
};
|
||||
|
||||
class RenderTargetAsset final : public CustomLoadableAsset<RenderTargetData>
|
||||
{
|
||||
public:
|
||||
using CustomLoadableAsset::CustomLoadableAsset;
|
||||
|
||||
private:
|
||||
CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) override;
|
||||
};
|
||||
} // namespace VideoCommon
|
Loading…
Add table
Reference in a new issue