summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureCacheBase.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/TextureCacheBase.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/TextureCacheBase.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp23
1 files changed, 15 insertions, 8 deletions
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<u32>(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<u32>(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<u32>(asset->m_levels.size()));
+ level_index < std::min(texLevels, static_cast<u32>(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);
}