2021-04-30 23:59:24 -06:00
|
|
|
// Copyright 2021 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-04-30 23:59:24 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <optional>
|
2024-04-13 10:29:52 -06:00
|
|
|
#include <span>
|
2021-04-30 23:59:24 -06:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
|
|
|
enum class TextureFormat;
|
|
|
|
enum class TLUTFormat;
|
|
|
|
|
|
|
|
class TextureInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static TextureInfo FromStage(u32 stage);
|
2024-04-13 10:29:52 -06:00
|
|
|
TextureInfo(u32 stage, std::span<const u8> data, std::span<const u8> tlut_data, u32 address,
|
2022-03-05 13:52:02 -07:00
|
|
|
TextureFormat texture_format, TLUTFormat tlut_format, u32 width, u32 height,
|
2024-04-13 10:29:52 -06:00
|
|
|
bool from_tmem, std::span<const u8> tmem_odd, std::span<const u8> tmem_even,
|
2022-03-05 13:52:02 -07:00
|
|
|
std::optional<u32> mip_count);
|
2021-04-30 23:59:24 -06:00
|
|
|
|
|
|
|
struct NameDetails
|
|
|
|
{
|
|
|
|
std::string base_name;
|
2021-05-14 17:17:08 -06:00
|
|
|
std::string texture_name;
|
2021-04-30 23:59:24 -06:00
|
|
|
std::string tlut_name;
|
|
|
|
std::string format_name;
|
|
|
|
|
2021-05-14 17:17:08 -06:00
|
|
|
std::string GetFullName() const;
|
2021-04-30 23:59:24 -06:00
|
|
|
};
|
2022-03-05 13:52:02 -07:00
|
|
|
NameDetails CalculateTextureName() const;
|
2021-04-30 23:59:24 -06:00
|
|
|
|
2024-04-13 10:29:52 -06:00
|
|
|
bool IsDataValid() const;
|
|
|
|
|
2021-04-30 23:59:24 -06:00
|
|
|
const u8* GetData() const;
|
|
|
|
const u8* GetTlutAddress() const;
|
|
|
|
|
|
|
|
u32 GetRawAddress() const;
|
|
|
|
|
|
|
|
bool IsFromTmem() const;
|
|
|
|
const u8* GetTmemOddAddress() const;
|
|
|
|
|
|
|
|
TextureFormat GetTextureFormat() const;
|
|
|
|
TLUTFormat GetTlutFormat() const;
|
|
|
|
|
|
|
|
std::optional<u32> GetPaletteSize() const;
|
|
|
|
u32 GetTextureSize() const;
|
|
|
|
|
|
|
|
u32 GetBlockWidth() const;
|
|
|
|
u32 GetBlockHeight() const;
|
|
|
|
|
|
|
|
u32 GetExpandedWidth() const;
|
|
|
|
u32 GetExpandedHeight() const;
|
|
|
|
|
|
|
|
u32 GetRawWidth() const;
|
|
|
|
u32 GetRawHeight() const;
|
|
|
|
|
2022-03-05 13:52:02 -07:00
|
|
|
u32 GetStage() const;
|
|
|
|
|
2021-04-30 23:59:24 -06:00
|
|
|
class MipLevel
|
|
|
|
{
|
|
|
|
public:
|
2024-04-13 10:29:52 -06:00
|
|
|
MipLevel(u32 level, const TextureInfo& parent, bool from_tmem, std::span<const u8>* src_data,
|
|
|
|
std::span<const u8>* tmem_even, std::span<const u8>* tmem_odd);
|
2021-04-30 23:59:24 -06:00
|
|
|
|
2024-04-13 10:29:52 -06:00
|
|
|
bool IsDataValid() const;
|
2021-04-30 23:59:24 -06:00
|
|
|
|
2024-04-13 10:29:52 -06:00
|
|
|
const u8* GetData() const;
|
2021-04-30 23:59:24 -06:00
|
|
|
u32 GetTextureSize() const;
|
|
|
|
|
|
|
|
u32 GetExpandedWidth() const;
|
|
|
|
u32 GetExpandedHeight() const;
|
|
|
|
|
|
|
|
u32 GetRawWidth() const;
|
|
|
|
u32 GetRawHeight() const;
|
|
|
|
|
|
|
|
private:
|
2024-04-13 10:29:52 -06:00
|
|
|
bool m_data_valid;
|
|
|
|
|
2021-04-30 23:59:24 -06:00
|
|
|
const u8* m_ptr;
|
|
|
|
|
|
|
|
u32 m_texture_size = 0;
|
|
|
|
|
|
|
|
u32 m_expanded_width;
|
|
|
|
u32 m_raw_width;
|
|
|
|
|
|
|
|
u32 m_expanded_height;
|
|
|
|
u32 m_raw_height;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool HasMipMaps() const;
|
|
|
|
u32 GetLevelCount() const;
|
|
|
|
const MipLevel* GetMipMapLevel(u32 level) const;
|
|
|
|
u32 GetFullLevelSize() const;
|
|
|
|
|
|
|
|
static constexpr std::string_view format_prefix{"tex1_"};
|
|
|
|
|
|
|
|
private:
|
|
|
|
const u8* m_ptr;
|
|
|
|
const u8* m_tlut_ptr;
|
|
|
|
|
|
|
|
u32 m_address;
|
|
|
|
|
2024-04-13 10:29:52 -06:00
|
|
|
bool m_data_valid;
|
|
|
|
|
2021-04-30 23:59:24 -06:00
|
|
|
bool m_from_tmem;
|
|
|
|
const u8* m_tmem_odd;
|
|
|
|
|
|
|
|
TextureFormat m_texture_format;
|
|
|
|
TLUTFormat m_tlut_format;
|
|
|
|
|
2021-05-21 17:52:13 -06:00
|
|
|
bool m_mipmaps_enabled = false;
|
2021-04-30 23:59:24 -06:00
|
|
|
std::vector<MipLevel> m_mip_levels;
|
|
|
|
|
|
|
|
u32 m_texture_size = 0;
|
|
|
|
std::optional<u32> m_palette_size;
|
|
|
|
|
|
|
|
u32 m_block_width;
|
|
|
|
u32 m_expanded_width;
|
|
|
|
u32 m_raw_width;
|
|
|
|
|
|
|
|
u32 m_block_height;
|
|
|
|
u32 m_expanded_height;
|
|
|
|
u32 m_raw_height;
|
2022-03-05 13:52:02 -07:00
|
|
|
|
|
|
|
u32 m_stage;
|
2021-04-30 23:59:24 -06:00
|
|
|
};
|