VideoCommon: instead of using 'CustomTextureData' directly, use 'TextureData' for texture assets, this allows us to provide additional metadata for textures. Such as a sampler or type information (to distinguish cube maps)

This commit is contained in:
iwubcode
2023-09-06 00:16:26 -05:00
parent 1b7a590b4b
commit 0e8f8ea930
13 changed files with 138 additions and 93 deletions

View File

@ -6,7 +6,7 @@
#include <algorithm>
#include "Common/Logging/Log.h"
#include "VideoCommon/Assets/CustomTextureData.h"
#include "VideoCommon/Assets/TextureAsset.h"
namespace VideoCommon
{
@ -26,16 +26,26 @@ std::size_t GetAssetSize(const CustomTextureData& data)
}
} // namespace
CustomAssetLibrary::LoadInfo CustomAssetLibrary::LoadGameTexture(const AssetID& asset_id,
CustomTextureData* data)
TextureData* data)
{
const auto load_info = LoadTexture(asset_id, data);
if (load_info.m_bytes_loaded == 0)
return {};
// Note: 'LoadTexture()' ensures we have a level loaded
for (std::size_t slice_index = 0; slice_index < data->m_slices.size(); slice_index++)
if (data->m_type != TextureData::Type::Type_Texture2D)
{
auto& slice = data->m_slices[slice_index];
ERROR_LOG_FMT(
VIDEO,
"Custom asset '{}' is not a valid game texture, it is expected to be a 2d texture "
"but was a '{}'.",
asset_id, data->m_type);
return {};
}
// Note: 'LoadTexture()' ensures we have a level loaded
for (std::size_t slice_index = 0; slice_index < data->m_texture.m_slices.size(); slice_index++)
{
auto& slice = data->m_texture.m_slices[slice_index];
const auto& first_mip = slice.m_levels[0];
// Verify that each mip level is the correct size (divide by 2 each time).