Skip to content

Commit

Permalink
SysShader
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Jan 15, 2024
1 parent 185c3f7 commit fbc14bd
Show file tree
Hide file tree
Showing 19 changed files with 487 additions and 8 deletions.
7 changes: 5 additions & 2 deletions OpenJPOG/Source/Movie/ABINKMoviePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ TBOOL ABINKMoviePlayer::RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iDestWidth, T
return TFALSE;
}


TBOOL ABINKMoviePlayer::InitializeVideoResource()
{
TRenderInterface* renderer = g_oTheApp.GetRootTask()->GetRenderInterface();
Expand All @@ -208,10 +209,12 @@ TBOOL ABINKMoviePlayer::InitializeVideoResource()
textureFormat = TTEXTURERESOURCEFORMAT::R5G5B5A1;
textureFormatSize = 8;
}
size *= 0x10000;
size *= 256 * 256;
TPVOID buffer = tmalloc(size, TNULL, -1);
TSystem::MemSet(buffer, 0xFF, size);
factory->CreateEx(buffer, size, 256, 256, 1, textureFormat, textureFormatSize);
m_pTextures[2] = factory->CreateEx(buffer, size, 256, 256, 1, textureFormat, textureFormatSize);
m_pTextures[2]->SetAddressModeMode(TTextureResource::ADDRESSMODE_UNKNOWN3);

return TTRUE;
}

Expand Down
16 changes: 16 additions & 0 deletions Toshi/Include/TKernel/TQuaternion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "TDebug.h"

TOSHI_NAMESPACE_BEGIN

class TKERNELINTERFACE_EXPORTS TQuaternion
{
private:
TFLOAT m_fX; // 0x0
TFLOAT m_fY; // 0x4
TFLOAT m_fZ; // 0x8
TFLOAT m_fW; // 0xC
};

TOSHI_NAMESPACE_END
6 changes: 4 additions & 2 deletions Toshi/Include/TKernel/TVector2.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

TOSHI_NAMESPACE_BEGIN

class TVector2
class TKERNELINTERFACE_EXPORTS TVector2
{

private:
TFLOAT m_fX; // 0x0
TFLOAT m_fY; // 0x4
};

TOSHI_NAMESPACE_END
15 changes: 15 additions & 0 deletions Toshi/Include/TKernel/TVector3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include "TDebug.h"

TOSHI_NAMESPACE_BEGIN

class TKERNELINTERFACE_EXPORTS TVector3
{
private:
TFLOAT m_fX; // 0x0
TFLOAT m_fY; // 0x4
TFLOAT m_fZ; // 0x8
};

TOSHI_NAMESPACE_END
34 changes: 34 additions & 0 deletions Toshi/Include/TKernel/TVector4.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

#include "TDebug.h"
#include "TVector3.h"

TOSHI_NAMESPACE_BEGIN

class TKERNELINTERFACE_EXPORTS TVector4
{
public:

void Set(const TVector3& a_rVec3)
{

}

TFLOAT const& operator()(TUINT a_iIndex) const
{
return (&m_fX)[a_iIndex];
}

TFLOAT& operator()(TUINT a_iIndex)
{
return (&m_fX)[a_iIndex];
}

private:
TFLOAT m_fX; // 0x0
TFLOAT m_fY; // 0x4
TFLOAT m_fZ; // 0x8
TFLOAT m_fW; // 0xC
};

TOSHI_NAMESPACE_END
26 changes: 26 additions & 0 deletions Toshi/Include/TRender/TDBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
#include "Defines.h"

TOSHI_NAMESPACE_BEGIN

class TRENDERINTERFACE_EXPORTS TDBase
{
public:

class TRENDERINTERFACE_EXPORTS TKeyFrame
{
public:
void Get(TFLOAT& a_rTime);
};

TFLOAT GetTransDeviation() { return s_fDeltaTransDeviation; }
TFLOAT GetTransEpsilon() { return s_fDeltaTransEpsilon; }

TFLOAT SetTransDeviation(TFLOAT a_fDeltaTransDeviation) { s_fDeltaTransDeviation = a_fDeltaTransDeviation; }
TFLOAT SetTransEpsilon(TFLOAT a_fDeltaTransEpsilon) { s_fDeltaTransEpsilon = a_fDeltaTransEpsilon; }

static inline TFLOAT s_fDeltaTransDeviation = 0.05f;
static inline TFLOAT s_fDeltaTransEpsilon = 0.05f / 5.0f;
};

TOSHI_NAMESPACE_END
2 changes: 2 additions & 0 deletions Toshi/Include/TRender/TTextureFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class TRENDERINTERFACE_EXPORTS TTextureFactory : public TResource

TTextureResource* FindTexture(TPCCHAR a_szName);

void DeregisterTexture(TTextureResource* a_pTexture);

protected:

TUINT HashName(TPCCHAR a_szName);
Expand Down
39 changes: 38 additions & 1 deletion Toshi/Include/TRender/TTextureResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,53 @@ class TRENDERINTERFACE_EXPORTS TTextureResource : public TResource

public:

enum ADDRESSMODE
{
ADDRESSMODE_UNKNOWN,
ADDRESSMODE_UNKNOWN2,
ADDRESSMODE_UNKNOWN3,
};

struct LOCKSTATE
{
TINT Pitch;
TPVOID pBits;
};

TTextureResource();

virtual ~TTextureResource();

virtual TUINT GetWidth() = 0;
virtual TUINT GetHeight() = 0;
virtual TBOOL Lock(LOCKSTATE& a_rLockState);
virtual void Unlock();
virtual TBOOL Create(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_eTextureFlags, TUINT a_uiWidth, TUINT a_uiHeight) = 0;
virtual TBOOL Create(TPCCHAR a_szFileName, TUINT a_eTextureFlags) = 0;
virtual TBOOL CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_uiMipmapFlags);

static TTextureResource* TOSHI_API CreateHAL(TRenderInterface* a_pRenderer, TPCCHAR a_szName, TResource* a_pResource);

public:

TTextureFactory::NameEntry* GetNameEntry() { return m_pNameEntry; }
TUINT GetCreateFlags() { return m_CreateFlags; }

ADDRESSMODE GetAddressMode()
{
return m_eAddressMode;
}

ADDRESSMODE SetAddressModeMode(ADDRESSMODE a_eAddressMode)
{
m_eAddressMode = a_eAddressMode;
return m_eAddressMode;
}

private:
TTextureFactory::NameEntry* m_pNameEntry;
ADDRESSMODE m_eAddressMode; // 0x30
TUINT m_CreateFlags; // 0x34
TTextureFactory::NameEntry* m_pNameEntry; // 0x38
};

TOSHI_NAMESPACE_END
21 changes: 21 additions & 0 deletions Toshi/Include/TRenderD3D/TTextureResourceD3D.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
#pragma once
#include "TRender/TTextureResource.h"
#include "Defines.h"
#include "TKernel/TFreeList.h"
#include <d3dx8tex.h>

TOSHI_NAMESPACE_BEGIN

class TRENDERINTERFACED3D_EXPORTS TTextureResourceHAL : public TTextureResource
{
DECLARE_DYNAMIC(TTextureResourceHAL)
DECLARE_FREELIST(TTextureResourceHAL)

enum MIPMAPFLAGS
{
MIPMAPFLAGS_DISABLED = BITFIELD(0)
};

public:

virtual ~TTextureResourceHAL() = default;

virtual TBOOL Validate() override;
virtual void Invalidate() override;

virtual TUINT GetWidth() override;
virtual TUINT GetHeight() override;
virtual TBOOL Lock(TTextureResource::LOCKSTATE& a_rLockState) override;
virtual void Unlock() override;
virtual TBOOL Create(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_eTextureFlags, TUINT a_uiWidth, TUINT a_uiHeight) override;
virtual TBOOL Create(TPCCHAR a_szFileName, TUINT a_eTextureFlags) override;
virtual TBOOL CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_uiMipmapFlags) override;
Expand All @@ -27,9 +40,17 @@ class TRENDERINTERFACED3D_EXPORTS TTextureResourceHAL : public TTextureResource
TBOOL CreateFromMemoryDDS(TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiLevels, TPVOID a_pData);
TBOOL CreateFromMemory4444(TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiLevels, TPVOID a_pData);

protected:

TBOOL IsPPM(TPCCHAR a_pFileName);

public:

IDirect3DTexture8* GetD3DTexture() { return m_pD3DTexture; }

private:
TUINT m_eTextureFlags; // 0x34
TUINT m_uiLockCount; // 0x3C
TINT m_iLoadFromMemory; // 0x40
TPVOID m_pData; // 0x44
TUINT m_uiDataSize; // 0x48
Expand Down
Empty file.
65 changes: 65 additions & 0 deletions Toshi/Shaders/TSysShader/Include/Defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

#define TNULL nullptr
#define TFALSE false
#define TTRUE true
#define BITFIELD(x) (1 << x)

#if defined(TOSHI_RELEASE) || defined(TOSHI_DEBUG)
#define TOSHI_NOTFINAL
#endif

#define STRINGIFY2(X) #X
#define STRINGIFY(X) STRINGIFY2(X)

#define STRCAT2(X, Y) X##Y
#define STRCAT(X, Y) STRCAT2(X, Y)
#define STRCAT_2 CAT
#define STRCAT_3(X, Y, Z) STRCAT(X, STRCAT(Y, Z))
#define STRCAT_4(A, X, Y, Z) STRCAT(A, STRCAT_3(X, Y, Z))

#define HASFLAG(flag) (flag) != 0

#ifdef TOSHI_SKU_WINDOWS
#define TOSHI_MULTIPLATFORM(FILENAME) STRINGIFY(STRCAT_3(Win/, FILENAME, Win.h))
#endif

#ifdef TSYSSHADERD3D
#define TSYSSHADERD3D_EXPORTS __declspec(dllexport)
#else
#define TSYSSHADERD3D_EXPORTS __declspec(dllimport)
#endif

#define TOSHI_API __stdcall
#define TOSHI_CALLBACKAPI __cdecl

#define TOSHI_NAMESPACE_BEGIN namespace Toshi {
#define TOSHI_NAMESPACE_END }
#define TOSHI_NAMESPACE_USING using namespace Toshi;

#define TSTATICCAST(type, value) static_cast<type>(value)

#define _TS8(str) #str

typedef bool TBOOL;
typedef int TINT;
typedef unsigned int TUINT;
typedef unsigned int TUINT32;
typedef unsigned __int64 TUINT64;
typedef short TSHORT;
typedef unsigned short TUSHORT;
typedef wchar_t TWCHAR;
typedef wchar_t* TPWCHAR;
typedef const wchar_t* TPCWCHAR;
typedef const char* TPCCHAR;
typedef char* TPCHAR;
typedef char TCHAR;
typedef const char TCCHAR;
typedef char TINT8;
typedef unsigned char TUINT8;
typedef unsigned char TBYTE;
typedef unsigned char* TPBYTE;
typedef void* TPVOID;
typedef const void* TPCVOID;
typedef float TFLOAT;
typedef const float TCFLOAT;
17 changes: 17 additions & 0 deletions Toshi/Shaders/TSysShader/Include/TSysShader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "Defines.h"

TOSHI_NAMESPACE_BEGIN

class ASysMaterial;
class ASysMesh;

class TSYSSHADERD3D_EXPORTS TSysShader
{
public:
virtual ASysMaterial* CreateMaterial(const char* a_szName) = 0;
virtual ASysMesh* CreateMesh(const char* a_szName) = 0;
};

TOSHI_NAMESPACE_END
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions Toshi/Source/TRender/TTextureFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ TTextureResource* TTextureFactory::FindTexture(TPCCHAR a_szName)
return TNULL;
}

void TTextureFactory::DeregisterTexture(TTextureResource* a_pTexture)
{
TVALIDADDRESS(a_pTexture);

TTextureFactory::NameEntry* pList = a_pTexture->m_pNameEntry;

if (pList) {
pList->Remove();
delete pList;
}
}

TUINT TTextureFactory::HashName(TPCCHAR a_szName)
{
TUINT iHash = 0;
Expand Down
Loading

0 comments on commit fbc14bd

Please sign in to comment.