VideoBackends / VideoCommon: add type enum to dictate whether a texture is a 2D texture, a texture array, or a cube map; support 2D texture type across backends

Co-authored-by: TellowKrinkle <tellowkrinkle@gmail.com>
This commit is contained in:
iwubcode 2023-12-09 19:00:11 -06:00
parent 370474a7cb
commit 12dd15c8dd
16 changed files with 271 additions and 81 deletions

View file

@ -415,7 +415,8 @@ void TextureCacheBase::ScaleTextureCacheEntryTo(RcTcacheEntry& entry, u32 new_wi
}
const TextureConfig newconfig(new_width, new_height, 1, entry->GetNumLayers(), 1,
AbstractTextureFormat::RGBA8, AbstractTextureFlag_RenderTarget);
AbstractTextureFormat::RGBA8, AbstractTextureFlag_RenderTarget,
AbstractTextureType::Texture_2DArray);
std::optional<TexPoolEntry> new_texture = AllocateTexture(newconfig);
if (!new_texture)
{
@ -445,7 +446,8 @@ bool TextureCacheBase::CheckReadbackTexture(u32 width, u32 height, AbstractTextu
return true;
}
TextureConfig staging_config(std::max(width, 128u), std::max(height, 128u), 1, 1, 1, format, 0);
TextureConfig staging_config(std::max(width, 128u), std::max(height, 128u), 1, 1, 1, format, 0,
AbstractTextureType::Texture_2DArray);
m_readback_texture.reset();
m_readback_texture = g_gfx->CreateStagingTexture(StagingTextureType::Readback, staging_config);
return m_readback_texture != nullptr;
@ -1680,7 +1682,8 @@ RcTcacheEntry TextureCacheBase::CreateTextureEntry(
const u32 texLevels = no_mips ? 1 : (u32)calculate_max_levels();
const auto& first_level = assets_data[0]->m_texture.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);
static_cast<u32>(assets_data.size()), 1, first_level.format, 0,
AbstractTextureType::Texture_2DArray);
entry = AllocateCacheEntry(config);
if (!entry) [[unlikely]]
return entry;
@ -1710,7 +1713,8 @@ RcTcacheEntry TextureCacheBase::CreateTextureEntry(
const u32 width = texture_info.GetRawWidth();
const u32 height = texture_info.GetRawHeight();
const TextureConfig config(width, height, texLevels, 1, 1, AbstractTextureFormat::RGBA8, 0);
const TextureConfig config(width, height, texLevels, 1, 1, AbstractTextureFormat::RGBA8, 0,
AbstractTextureType::Texture_2DArray);
entry = AllocateCacheEntry(config);
if (!entry) [[unlikely]]
return entry;
@ -1896,7 +1900,8 @@ RcTcacheEntry TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height
// Create a new VRAM texture, and fill it with the data from guest RAM.
entry = AllocateCacheEntry(TextureConfig(width, height, 1, 1, 1, AbstractTextureFormat::RGBA8,
AbstractTextureFlag_RenderTarget));
AbstractTextureFlag_RenderTarget,
AbstractTextureType::Texture_2DArray));
// Compute total texture size. XFB textures aren't tiled, so this is simple.
const u32 total_size = height * stride;
@ -2357,7 +2362,8 @@ void TextureCacheBase::CopyRenderTargetToTexture(
{
// create the texture
const TextureConfig config(scaled_tex_w, scaled_tex_h, 1, g_framebuffer_manager->GetEFBLayers(),
1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_RenderTarget);
1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_RenderTarget,
AbstractTextureType::Texture_2DArray);
entry = AllocateCacheEntry(config);
if (entry)
{
@ -2842,7 +2848,8 @@ void TextureCacheBase::ReleaseToPool(TCacheEntry* entry)
bool TextureCacheBase::CreateUtilityTextures()
{
constexpr TextureConfig encoding_texture_config(
EFB_WIDTH * 4, 1024, 1, 1, 1, AbstractTextureFormat::BGRA8, AbstractTextureFlag_RenderTarget);
EFB_WIDTH * 4, 1024, 1, 1, 1, AbstractTextureFormat::BGRA8, AbstractTextureFlag_RenderTarget,
AbstractTextureType::Texture_2DArray);
m_efb_encoding_texture = g_gfx->CreateTexture(encoding_texture_config, "EFB encoding texture");
if (!m_efb_encoding_texture)
return false;
@ -2854,7 +2861,8 @@ bool TextureCacheBase::CreateUtilityTextures()
if (g_ActiveConfig.backend_info.bSupportsGPUTextureDecoding)
{
constexpr TextureConfig decoding_texture_config(
1024, 1024, 1, 1, 1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_ComputeImage);
1024, 1024, 1, 1, 1, AbstractTextureFormat::RGBA8, AbstractTextureFlag_ComputeImage,
AbstractTextureType::Texture_2DArray);
m_decoding_texture =
g_gfx->CreateTexture(decoding_texture_config, "GPU texture decoding texture");
if (!m_decoding_texture)