mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-20 09:11:40 +00:00
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
This commit is contained in:
parent
5e5887a378
commit
62fee2f3b6
8 changed files with 225 additions and 118 deletions
|
@ -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 levels, create one to pass into LoadPNGTexture
|
||||
if (data->m_levels.empty())
|
||||
data->m_levels.push_back({});
|
||||
// If we have no slices, create one
|
||||
if (data->m_slices.empty())
|
||||
data->m_slices.push_back({});
|
||||
|
||||
if (!LoadPNGTexture(&data->m_levels[0], PathToString(asset_path)))
|
||||
auto& slice = data->m_slices[0];
|
||||
// If we have no levels, create one to pass into LoadPNGTexture
|
||||
if (slice.m_levels.empty())
|
||||
slice.m_levels.push_back({});
|
||||
|
||||
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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue