mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-08 02:25:56 +00:00
render target asset
This commit is contained in:
parent
82b183df53
commit
145b8bb20f
2 changed files with 16 additions and 5 deletions
|
@ -12,8 +12,11 @@ namespace VideoCommon
|
||||||
bool RenderTargetData::FromJson(const CustomAssetLibrary::AssetID& asset_id,
|
bool RenderTargetData::FromJson(const CustomAssetLibrary::AssetID& asset_id,
|
||||||
const picojson::object& json, RenderTargetData* data)
|
const picojson::object& json, RenderTargetData* data)
|
||||||
{
|
{
|
||||||
data->m_texture_format = AbstractTextureFormat::RGBA8;
|
data->texture_format = AbstractTextureFormat::RGBA8;
|
||||||
// TODO: parse format
|
// TODO: parse format
|
||||||
|
data->height = ReadNumericFromJson<u16>(json, "height").value_or(0);
|
||||||
|
data->width = ReadNumericFromJson<u16>(json, "width").value_or(0);
|
||||||
|
data->type = static_cast<AbstractTextureType>(ReadNumericFromJson<u64>(json, "type").value_or(0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +26,11 @@ void RenderTargetData::ToJson(picojson::object* obj, const RenderTargetData& dat
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto& json_obj = *obj;
|
auto& json_obj = *obj;
|
||||||
json_obj.emplace("format", static_cast<double>(data.m_texture_format));
|
json_obj.emplace("format", static_cast<double>(data.texture_format));
|
||||||
|
json_obj.emplace("height", static_cast<double>(data.height));
|
||||||
|
json_obj.emplace("width", static_cast<double>(data.width));
|
||||||
|
json_obj.emplace("type", static_cast<double>(data.type));
|
||||||
|
// TODO: sampler...
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomAssetLibrary::LoadInfo
|
CustomAssetLibrary::LoadInfo
|
||||||
|
@ -31,7 +38,7 @@ RenderTargetAsset::LoadImpl(const CustomAssetLibrary::AssetID& asset_id)
|
||||||
{
|
{
|
||||||
auto potential_data = std::make_shared<RenderTargetData>();
|
auto potential_data = std::make_shared<RenderTargetData>();
|
||||||
const auto loaded_info = m_owning_library->LoadRenderTarget(asset_id, potential_data.get());
|
const auto loaded_info = m_owning_library->LoadRenderTarget(asset_id, potential_data.get());
|
||||||
if (loaded_info.m_bytes_loaded == 0)
|
if (loaded_info.bytes_loaded == 0)
|
||||||
return {};
|
return {};
|
||||||
{
|
{
|
||||||
std::lock_guard lk(m_data_lock);
|
std::lock_guard lk(m_data_lock);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <picojson.h>
|
#include <picojson.h>
|
||||||
|
|
||||||
|
#include "Common/CommonTypes.h"
|
||||||
#include "VideoCommon/Assets/CustomAsset.h"
|
#include "VideoCommon/Assets/CustomAsset.h"
|
||||||
#include "VideoCommon/RenderState.h"
|
#include "VideoCommon/RenderState.h"
|
||||||
#include "VideoCommon/TextureConfig.h"
|
#include "VideoCommon/TextureConfig.h"
|
||||||
|
@ -16,8 +17,11 @@ struct RenderTargetData
|
||||||
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
|
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
|
||||||
RenderTargetData* data);
|
RenderTargetData* data);
|
||||||
static void ToJson(picojson::object* obj, const RenderTargetData& data);
|
static void ToJson(picojson::object* obj, const RenderTargetData& data);
|
||||||
AbstractTextureFormat m_texture_format;
|
AbstractTextureFormat texture_format;
|
||||||
SamplerState m_sampler;
|
SamplerState sampler;
|
||||||
|
u16 width;
|
||||||
|
u16 height;
|
||||||
|
AbstractTextureType type = AbstractTextureType::Texture_2D;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderTargetAsset final : public CustomLoadableAsset<RenderTargetData>
|
class RenderTargetAsset final : public CustomLoadableAsset<RenderTargetData>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue