summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2023-08-13 16:09:45 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2023-09-02 20:20:09 -0500
commit62fee2f3b60c84b27efbb0792e3695bbe812ac1a (patch)
tree1ba80d4b42fefe1a9525dec7884938eb0c840ef1 /Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
parent5e5887a378db28324a8fc8825f21539525412e12 (diff)
VideoCommon: add loading cube maps from DDS files and loading it into our custom texture object. Custom texture object now has the concept of slices in addition to levels. Traditional custom textures have a single slice
Diffstat (limited to 'Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp')
-rw-r--r--Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
index 7a1f84ca08..99c3e9487e 100644
--- a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
+++ b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
@@ -9,7 +9,6 @@
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
-#include "VideoCommon/Assets/CustomTextureData.h"
#include "VideoCommon/Assets/MaterialAsset.h"
#include "VideoCommon/Assets/ShaderAsset.h"
@@ -34,9 +33,12 @@ std::chrono::system_clock::time_point FileTimeToSysTime(std::filesystem::file_ti
std::size_t GetAssetSize(const CustomTextureData& data)
{
std::size_t total = 0;
- for (const auto& level : data.m_levels)
+ for (const auto& slice : data.m_slices)
{
- total += level.data.size();
+ for (const auto& level : slice.m_levels)
+ {
+ total += level.data.size();
+ }
}
return total;
}
@@ -247,24 +249,32 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass
return {};
}
- if (!LoadMips(asset_path, data))
+ if (data->m_slices.empty()) [[unlikely]]
+ data->m_slices.push_back({});
+
+ if (!LoadMips(asset_path, &data->m_slices[0]))
return {};
return LoadInfo{GetAssetSize(*data), FileTimeToSysTime(last_loaded_time)};
}
else if (ext == ".png")
{
+ // If we have no slices, create one
+ if (data->m_slices.empty())
+ data->m_slices.push_back({});
+
+ auto& slice = data->m_slices[0];
// If we have no levels, create one to pass into LoadPNGTexture
- if (data->m_levels.empty())
- data->m_levels.push_back({});
+ if (slice.m_levels.empty())
+ slice.m_levels.push_back({});
- if (!LoadPNGTexture(&data->m_levels[0], PathToString(asset_path)))
+ if (!LoadPNGTexture(&slice.m_levels[0], PathToString(asset_path)))
{
ERROR_LOG_FMT(VIDEO, "Asset '{}' error - could not load png texture!", asset_id);
return {};
}
- if (!LoadMips(asset_path, data))
+ if (!LoadMips(asset_path, &slice))
return {};
return LoadInfo{GetAssetSize(*data), FileTimeToSysTime(last_loaded_time)};
@@ -282,7 +292,7 @@ void DirectFilesystemAssetLibrary::SetAssetIDMapData(const AssetID& asset_id,
}
bool DirectFilesystemAssetLibrary::LoadMips(const std::filesystem::path& asset_path,
- CustomTextureData* data)
+ CustomTextureData::ArraySlice* data)
{
if (!data) [[unlikely]]
return false;
@@ -304,7 +314,7 @@ bool DirectFilesystemAssetLibrary::LoadMips(const std::filesystem::path& asset_p
if (!File::Exists(full_path))
return true;
- VideoCommon::CustomTextureData::Level level;
+ VideoCommon::CustomTextureData::ArraySlice::Level level;
if (extension_lower == ".dds")
{
if (!LoadDDSTexture(&level, full_path, mip_level))