From 145b8bb20f0eaa76c5536c0ed4179ff1e7977ac0 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sun, 3 Aug 2025 16:45:46 -0500 Subject: [PATCH] render target asset --- .../Core/VideoCommon/Assets/RenderTargetAsset.cpp | 13 ++++++++++--- Source/Core/VideoCommon/Assets/RenderTargetAsset.h | 8 ++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Source/Core/VideoCommon/Assets/RenderTargetAsset.cpp b/Source/Core/VideoCommon/Assets/RenderTargetAsset.cpp index 149af22ba3..1fd6bf5048 100644 --- a/Source/Core/VideoCommon/Assets/RenderTargetAsset.cpp +++ b/Source/Core/VideoCommon/Assets/RenderTargetAsset.cpp @@ -12,8 +12,11 @@ namespace VideoCommon bool RenderTargetData::FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json, RenderTargetData* data) { - data->m_texture_format = AbstractTextureFormat::RGBA8; + data->texture_format = AbstractTextureFormat::RGBA8; // TODO: parse format + data->height = ReadNumericFromJson(json, "height").value_or(0); + data->width = ReadNumericFromJson(json, "width").value_or(0); + data->type = static_cast(ReadNumericFromJson(json, "type").value_or(0)); return true; } @@ -23,7 +26,11 @@ void RenderTargetData::ToJson(picojson::object* obj, const RenderTargetData& dat return; auto& json_obj = *obj; - json_obj.emplace("format", static_cast(data.m_texture_format)); + json_obj.emplace("format", static_cast(data.texture_format)); + json_obj.emplace("height", static_cast(data.height)); + json_obj.emplace("width", static_cast(data.width)); + json_obj.emplace("type", static_cast(data.type)); + // TODO: sampler... } CustomAssetLibrary::LoadInfo @@ -31,7 +38,7 @@ RenderTargetAsset::LoadImpl(const CustomAssetLibrary::AssetID& asset_id) { auto potential_data = std::make_shared(); 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 {}; { std::lock_guard lk(m_data_lock); diff --git a/Source/Core/VideoCommon/Assets/RenderTargetAsset.h b/Source/Core/VideoCommon/Assets/RenderTargetAsset.h index 94a28e354b..efe3f5f410 100644 --- a/Source/Core/VideoCommon/Assets/RenderTargetAsset.h +++ b/Source/Core/VideoCommon/Assets/RenderTargetAsset.h @@ -5,6 +5,7 @@ #include +#include "Common/CommonTypes.h" #include "VideoCommon/Assets/CustomAsset.h" #include "VideoCommon/RenderState.h" #include "VideoCommon/TextureConfig.h" @@ -16,8 +17,11 @@ 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; + AbstractTextureFormat texture_format; + SamplerState sampler; + u16 width; + u16 height; + AbstractTextureType type = AbstractTextureType::Texture_2D; }; class RenderTargetAsset final : public CustomLoadableAsset