summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureCacheBase.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/TextureCacheBase.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/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 3df1d7f51c..fa677bf1b5 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -1640,10 +1640,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;
+ }
}
}
}
@@ -1679,6 +1682,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,
@@ -1697,12 +1703,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);
@@ -1711,11 +1717,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);
}