From 62fee2f3b60c84b27efbb0792e3695bbe812ac1a Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sun, 13 Aug 2023 16:09:45 -0500 Subject: 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 --- Source/Core/VideoCommon/TextureCacheBase.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 37dadba967..2e9bbd976a 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1639,10 +1639,13 @@ RcTcacheEntry TextureCacheBase::GetTexture(const int textureCacheSafetyColorSamp auto data = asset->GetData(); if (data) { - if (!data->m_levels.empty()) + if (!data->m_slices.empty()) { - height = data->m_levels[0].height; - width = data->m_levels[0].width; + if (!data->m_slices[0].m_levels.empty()) + { + height = data->m_slices[0].m_levels[0].height; + width = data->m_slices[0].m_levels[0].width; + } } } } @@ -1678,6 +1681,9 @@ RcTcacheEntry TextureCacheBase::GetTexture(const int textureCacheSafetyColorSamp return entry; } +// Note: the following function assumes all CustomTextureData has a single slice. This is verified +// with the 'GameTexture::Validate' function after the data is loaded. Only a single slice is +// expected because each texture is loaded into a texture array RcTcacheEntry TextureCacheBase::CreateTextureEntry( const TextureCreationInfo& creation_info, const TextureInfo& texture_info, const int safety_color_sample_size, @@ -1696,12 +1702,12 @@ RcTcacheEntry TextureCacheBase::CreateTextureEntry( const auto calculate_max_levels = [&]() { const auto max_element = std::max_element( assets_data.begin(), assets_data.end(), [](const auto& lhs, const auto& rhs) { - return lhs->m_levels.size() < rhs->m_levels.size(); + return lhs->m_slices[0].m_levels.size() < rhs->m_slices[0].m_levels.size(); }); - return max_element->get()->m_levels.size(); + return max_element->get()->m_slices[0].m_levels.size(); }; const u32 texLevels = no_mips ? 1 : (u32)calculate_max_levels(); - const auto& first_level = assets_data[0]->m_levels[0]; + const auto& first_level = assets_data[0]->m_slices[0].m_levels[0]; const TextureConfig config(first_level.width, first_level.height, texLevels, static_cast(assets_data.size()), 1, first_level.format, 0); entry = AllocateCacheEntry(config); @@ -1710,11 +1716,12 @@ RcTcacheEntry TextureCacheBase::CreateTextureEntry( for (u32 data_index = 0; data_index < static_cast(assets_data.size()); data_index++) { const auto asset = assets_data[data_index]; + const auto& slice = asset->m_slices[0]; for (u32 level_index = 0; - level_index < std::min(texLevels, static_cast(asset->m_levels.size())); + level_index < std::min(texLevels, static_cast(slice.m_levels.size())); ++level_index) { - const auto& level = asset->m_levels[level_index]; + const auto& level = slice.m_levels[level_index]; entry->texture->Load(level_index, level.width, level.height, level.row_length, level.data.data(), level.data.size(), data_index); } -- cgit v1.2.3