2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CTEXTURE
|
|
|
|
#define _CTEXTURE
|
2022-07-02 05:30:04 +00:00
|
|
|
|
2023-10-17 18:26:21 +00:00
|
|
|
#include "dolphin/gx/GXEnum.h"
|
2022-07-02 05:30:04 +00:00
|
|
|
#include "types.h"
|
|
|
|
|
2022-12-03 21:31:54 +00:00
|
|
|
#include "Kyoto/CARAMToken.hpp"
|
|
|
|
#include "rstl/single_ptr.hpp"
|
2022-08-30 22:48:44 +00:00
|
|
|
|
2022-12-03 21:31:54 +00:00
|
|
|
#include <dolphin/gx.h>
|
|
|
|
|
2023-10-17 18:26:21 +00:00
|
|
|
class CResFactory;
|
2022-12-03 21:31:54 +00:00
|
|
|
class CDvdRequest;
|
2022-09-13 04:26:54 +00:00
|
|
|
class CInputStream;
|
2022-12-03 21:31:54 +00:00
|
|
|
class CGraphicsPalette;
|
2022-09-13 04:26:54 +00:00
|
|
|
|
2022-12-01 16:11:09 +00:00
|
|
|
enum ETexelFormat {
|
|
|
|
kTF_Invalid = -1,
|
|
|
|
kTF_I4 = 0,
|
|
|
|
kTF_I8 = 1,
|
|
|
|
kTF_IA4 = 2,
|
|
|
|
kTF_IA8 = 3,
|
|
|
|
kTF_C4 = 4,
|
|
|
|
kTF_C8 = 5,
|
|
|
|
kTF_C14X2 = 6,
|
|
|
|
kTF_RGB565 = 7,
|
|
|
|
kTF_RGB5A3 = 8,
|
|
|
|
kTF_RGBA8 = 9,
|
|
|
|
kTF_CMPR = 10,
|
|
|
|
};
|
|
|
|
|
2022-07-02 05:30:04 +00:00
|
|
|
class CTexture {
|
|
|
|
public:
|
2022-12-03 21:31:54 +00:00
|
|
|
class CDumpedBitmapDataReloader {
|
|
|
|
int x0_;
|
|
|
|
uint x4_;
|
|
|
|
int x8_;
|
|
|
|
uint xc_;
|
|
|
|
bool x10_;
|
|
|
|
rstl::single_ptr< CDvdRequest > x14_;
|
|
|
|
rstl::single_ptr< uchar > x18_;
|
2023-10-17 18:26:21 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CDumpedBitmapDataReloader(uint unk1, uint unk2, bool unk3);
|
|
|
|
|
|
|
|
void BeginReloadBitmapData(CResFactory& factory);
|
|
|
|
void* TryBuildReloadedBitmapData(CResFactory& factory);
|
|
|
|
int GetStatus() const { return x0_; }
|
|
|
|
const bool GetX10() const { return x10_; }
|
2022-12-03 21:31:54 +00:00
|
|
|
};
|
|
|
|
|
2022-07-02 05:30:04 +00:00
|
|
|
enum EClampMode {
|
2022-10-17 02:33:08 +00:00
|
|
|
kCM_Clamp,
|
|
|
|
kCM_Repeat,
|
|
|
|
kCM_Mirror,
|
2022-07-02 05:30:04 +00:00
|
|
|
};
|
2022-09-13 04:26:54 +00:00
|
|
|
enum EAutoMipmap {
|
|
|
|
kAM_Zero,
|
|
|
|
};
|
|
|
|
enum EBlackKey {
|
|
|
|
kBK_Zero,
|
|
|
|
};
|
|
|
|
|
2022-12-01 16:11:09 +00:00
|
|
|
CTexture(ETexelFormat fmt, short w, short h, int mips);
|
2022-09-13 04:26:54 +00:00
|
|
|
CTexture(CInputStream& stream, EAutoMipmap mip, EBlackKey bk);
|
2022-12-01 16:11:09 +00:00
|
|
|
~CTexture();
|
2022-12-03 21:31:54 +00:00
|
|
|
|
2022-12-01 16:11:09 +00:00
|
|
|
// Used in certain destructors
|
2023-10-17 18:26:21 +00:00
|
|
|
void fn_8030E10C();
|
|
|
|
void LoadMipLevel(int, GXTexMapID tex, EClampMode) const;
|
2022-07-02 05:30:04 +00:00
|
|
|
void Load(GXTexMapID texMapId, EClampMode clampMode) const;
|
2023-10-17 18:26:21 +00:00
|
|
|
bool HasPalette() const { return IsCITextureFormat(mTexelFormat); }
|
|
|
|
const void* GetConstBitMapData(const int mip) const;
|
|
|
|
void* GetBitMapData(int);
|
2022-12-03 21:31:54 +00:00
|
|
|
ETexelFormat GetTexelFormat() const { return mTexelFormat; }
|
2023-10-17 18:26:21 +00:00
|
|
|
const short GetWidth() const { return mWidth; }
|
|
|
|
const short GetHeight() const { return mHeight; }
|
2022-12-03 21:31:54 +00:00
|
|
|
void* Lock() {
|
|
|
|
mLocked = true;
|
|
|
|
return GetBitMapData(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MakeSwappable() const;
|
|
|
|
void CountMemory() const;
|
|
|
|
void UncountMemory() const;
|
|
|
|
void SetFlag1(bool b) { mLocked = b; }
|
2023-10-17 18:26:21 +00:00
|
|
|
void MangleMipmap(int mip);
|
|
|
|
const char GetBitsPerPixel() const { return mBitsPerPixel; }
|
|
|
|
void UnloadBitmapData(uint unk) const;
|
|
|
|
bool TryReloadBitmapData(CResFactory& factory) const;
|
|
|
|
int fn_8030F088() const;
|
|
|
|
bool LoadToMRAM() const;
|
|
|
|
bool LoadToARAM() const;
|
|
|
|
bool IsARAMTransferInProgress() const;
|
|
|
|
static int TexelFormatBitsPerPixel(ETexelFormat fmt);
|
|
|
|
void InitBitmapBuffers(const ETexelFormat fmt, const short w, const short h, const int mips);
|
|
|
|
void InitTextureObjects();
|
|
|
|
void UnLock();
|
2022-12-03 21:31:54 +00:00
|
|
|
|
|
|
|
static void InvalidateTexmap(GXTexMapID id);
|
2023-10-17 18:26:21 +00:00
|
|
|
static bool IsCITextureFormat(ETexelFormat fmt) {
|
|
|
|
return fmt == kTF_C4 ? true : fmt == kTF_C8 ? true : fmt == kTF_C14X2 ? true : false;
|
|
|
|
}
|
2022-12-03 21:31:54 +00:00
|
|
|
|
2023-10-17 18:26:21 +00:00
|
|
|
static void SetMangleMipmaps(bool v) { sMangleMips = true; }
|
|
|
|
static const bool GetMangleMipmaps() { return sMangleMips; }
|
2022-12-03 21:31:54 +00:00
|
|
|
static int sCurrentFrameCount;
|
|
|
|
static int sTotalAllocatedMemory;
|
|
|
|
static bool sMangleMips;
|
2022-10-09 05:13:17 +00:00
|
|
|
|
2022-09-13 04:26:54 +00:00
|
|
|
private:
|
2023-10-17 18:26:21 +00:00
|
|
|
ETexelFormat mTexelFormat;
|
2022-10-09 05:37:23 +00:00
|
|
|
short mWidth;
|
|
|
|
short mHeight;
|
2023-10-17 18:26:21 +00:00
|
|
|
char mNumMips;
|
|
|
|
char mBitsPerPixel;
|
2022-12-03 21:31:54 +00:00
|
|
|
bool mLocked : 1;
|
2023-10-17 18:26:21 +00:00
|
|
|
mutable bool mCanLoadPalette : 1;
|
2022-12-03 21:31:54 +00:00
|
|
|
bool mIsPowerOfTwo : 1;
|
|
|
|
mutable bool mNoSwap : 1;
|
|
|
|
mutable bool mCounted : 1;
|
2023-10-17 18:26:21 +00:00
|
|
|
mutable bool mCanLoadObj : 1;
|
2022-12-03 21:31:54 +00:00
|
|
|
uint mMemoryAllocated;
|
|
|
|
rstl::single_ptr< CGraphicsPalette > mGraphicsPalette;
|
2023-10-17 18:26:21 +00:00
|
|
|
mutable rstl::single_ptr< CDumpedBitmapDataReloader > mBitmapReloader;
|
|
|
|
GXTexFmt mNativeFormat;
|
|
|
|
GXCITexFmt mNativeCIFormat;
|
|
|
|
mutable GXTexObj mTexObj;
|
|
|
|
mutable EClampMode mClampMode;
|
|
|
|
mutable CARAMToken mARAMToken;
|
|
|
|
mutable uint mFrameAllocated;
|
2022-07-02 05:30:04 +00:00
|
|
|
};
|
2022-12-01 16:25:05 +00:00
|
|
|
CHECK_SIZEOF(CTexture, 0x68)
|
2022-07-02 05:30:04 +00:00
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CTEXTURE
|