summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2023-09-03 18:29:00 -0400
committerGitHub <noreply@github.com>2023-09-03 18:29:00 -0400
commit900439ea0d3cfdfae259890a94dfc383103f1bad (patch)
tree3bba0bfc72346aee1301dcc3f118098c48ae7881 /Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp
parent6f6eb73667d461073b44f993c00095c30ac35414 (diff)
parent62fee2f3b60c84b27efbb0792e3695bbe812ac1a (diff)
Merge pull request #12102 from iwubcode/cubemap_custom_texture
VideoCommon: add ability to load cube maps into custom texture data
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))