VideoCommon: rename GameTextureAsset into TextureAsset and make it only contain CustomTextureData. Move validation and load logic to individual functions

This commit is contained in:
iwubcode
2025-05-17 12:20:33 -05:00
parent 2ae43324cb
commit d8ea31ca46
12 changed files with 337 additions and 297 deletions

View File

@ -13,11 +13,11 @@
namespace VideoCommon
{
struct TextureData
struct TextureAndSamplerData
{
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json,
TextureData* data);
static void ToJson(picojson::object* obj, const TextureData& data);
TextureAndSamplerData* data);
static void ToJson(picojson::object* obj, const TextureAndSamplerData& data);
enum class Type
{
Type_Undefined,
@ -30,23 +30,19 @@ struct TextureData
SamplerState m_sampler;
};
class GameTextureAsset final : public CustomLoadableAsset<TextureData>
class TextureAsset final : public CustomLoadableAsset<CustomTextureData>
{
public:
using CustomLoadableAsset::CustomLoadableAsset;
// Validates that the game texture matches the native dimensions provided
// Callees are expected to call this once the data is loaded
bool Validate(u32 native_width, u32 native_height) const;
private:
CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) override;
};
} // namespace VideoCommon
template <>
struct fmt::formatter<VideoCommon::TextureData::Type>
: EnumFormatter<VideoCommon::TextureData::Type::Type_Max>
struct fmt::formatter<VideoCommon::TextureAndSamplerData::Type>
: EnumFormatter<VideoCommon::TextureAndSamplerData::Type::Type_Max>
{
constexpr formatter() : EnumFormatter({"Undefined", "Texture2D", "TextureCube"}) {}
};