diff --git a/OpenJPOG/Source/States/ARootState.cpp b/OpenJPOG/Source/States/ARootState.cpp index 5c4bc46..4bfca82 100644 --- a/OpenJPOG/Source/States/ARootState.cpp +++ b/OpenJPOG/Source/States/ARootState.cpp @@ -65,11 +65,11 @@ TBOOL ARootState::RemoveChild() ARootState& ARootState::GetCurrent() { - ARootState i; - for (i = *this; i.m_pChild != TNULL; i = *i.m_pChild) { - if (i.m_pChild == TNULL) { - return i; + ARootState* i; + for (i = this; i->m_pChild != TNULL; i = i->m_pChild) { + if (i->m_pChild == TNULL) { + return *i; } } - return i; + return *i; } diff --git a/Toshi/Include/TKernel/TFreeList.h b/Toshi/Include/TKernel/TFreeList.h index 500321d..f1ba899 100644 --- a/Toshi/Include/TKernel/TFreeList.h +++ b/Toshi/Include/TKernel/TFreeList.h @@ -2,6 +2,19 @@ #include "TMemory.h" +#define DECLARE_FREELIST(class_name) \ +public: \ +static TPVOID TOSHI_API operator new(TUINT s, TPVOID mem) { return mem; } \ +static TPVOID TOSHI_API operator new(TUINT s) { return ms_oFreeList.New(s); } \ +static TPVOID TOSHI_API operator new(TUINT s, TPCHAR mem, TINT unk) { return ms_oFreeList.New(s); } \ +static void TOSHI_API operator delete(void* ptr) { ms_oFreeList.Delete(ptr); } \ +static Toshi::TFreeList& TOSHI_API GetFreeList() {return ms_oFreeList;} \ +\ +private: static Toshi::TFreeList ms_oFreeList; + +#define IMPLEMENT_FREELIST(class_name, InitialSize, GrowSize) \ +Toshi::TFreeList class_name::ms_oFreeList = Toshi::TFreeList(sizeof(class_name), InitialSize, GrowSize, TNULL); + TOSHI_NAMESPACE_BEGIN class TKERNELINTERFACE_EXPORTS TFreeList diff --git a/Toshi/Include/TKernel/TNodeTree.h b/Toshi/Include/TKernel/TNodeTree.h index 5b48aa1..78d4fb3 100644 --- a/Toshi/Include/TKernel/TNodeTree.h +++ b/Toshi/Include/TKernel/TNodeTree.h @@ -22,7 +22,7 @@ class TNodeTree m_Next = (T*)this; m_Prev = (T*)this; m_Parent = TNULL; - m_Attached = TNULL; + m_Child = TNULL; } public: @@ -37,14 +37,14 @@ class TNodeTree T* Next() const { return m_Next; } T* Prev() const { return m_Prev; } TNodeTree* GetTree() const { return m_Tree; } - T* Attached() const { return m_Attached; } + T* Child() const { return m_Child; } protected: TNodeTree* m_Tree; T* m_Next; T* m_Prev; T* m_Parent; - T* m_Attached; + T* m_Child; }; public: @@ -74,7 +74,7 @@ class TNodeTree Remove(*a_pSourceNode, TFALSE); // Get the first attached to parent node - T* firstAttached = parentNode->Attached(); + T* firstAttached = parentNode->Child(); if (firstAttached != TNULL) { @@ -90,7 +90,7 @@ class TNodeTree else { // Attach node as the first one - parentNode->m_Attached = a_pSourceNode; + parentNode->m_Child = a_pSourceNode; } a_pSourceNode->m_Tree = this; @@ -147,7 +147,7 @@ class TNodeTree if (flag) { - T* attachedNode = node.Attached(); + T* attachedNode = node.Child(); while (attachedNode != TNULL) { @@ -164,9 +164,9 @@ class TNodeTree if (nodeParent != TNULL) { // If it's the first attached to the root node, set it to next or just remove - if (nodeParent->Attached() == &node) + if (nodeParent->Child() == &node) { - nodeParent->m_Attached = (node.Next() != &node) ? node.Next() : TNULL; + nodeParent->m_Child = (node.Next() != &node) ? node.Next() : TNULL; } node.m_Parent = TNULL; @@ -191,9 +191,9 @@ class TNodeTree { T* next = (node->Next() != node) ? node->Next() : TNULL; - if (node->Attached() != TNULL) + if (node->Child() != TNULL) { - DeleteRecurse(node->Attached()); + DeleteRecurse(node->Child()); } if (node->GetTree() == this) @@ -208,16 +208,16 @@ class TNodeTree if (nodeParent != TNULL) { // If it's the first attached to the root node, set it to next or just remove - if (nodeParent->Attached() == node) + if (nodeParent->Child() == node) { - nodeParent->m_Attached = (node->Next() != node) ? node->Next() : TNULL; + nodeParent->m_Child = (node->Next() != node) ? node->Next() : TNULL; } node->m_Parent = TNULL; } node->m_Prev->m_Parent = node->m_Next; - node->m_Next->m_Attached = node->m_Prev; + node->m_Next->m_Child = node->m_Prev; node->m_Next = node; node->m_Prev = node; node->m_Tree = TNULL; @@ -230,13 +230,13 @@ class TNodeTree void DeleteAll() { - T* node = GetRoot()->Attached(); + T* node = GetRoot()->Child(); while (node != TNULL) { Remove(node, TFALSE); DeleteRecurse(node); - node = GetRoot()->Attached(); + node = GetRoot()->Child(); } TASSERT(Count() == 0); @@ -247,9 +247,9 @@ class TNodeTree return TSTATICCAST(T*, &m_Root); } - T* AttachedToRoot() + T* ChildOfRoot() { - return m_Root.Attached(); + return m_Root.Child(); } size_t Count() const diff --git a/Toshi/Include/TRender/TRenderInterface.h b/Toshi/Include/TRender/TRenderInterface.h index d3c9c8a..531dfcc 100644 --- a/Toshi/Include/TRender/TRenderInterface.h +++ b/Toshi/Include/TRender/TRenderInterface.h @@ -14,6 +14,8 @@ class TRENDERINTERFACE_EXPORTS TRenderInterface : public TObject DECLARE_DYNAMIC(TRenderInterface) public: + + enum FLAG { FLAG_DIRTY = BITFIELD(0), diff --git a/Toshi/Include/TRender/TResource.h b/Toshi/Include/TRender/TResource.h index 15c2a44..7c006c0 100644 --- a/Toshi/Include/TRender/TResource.h +++ b/Toshi/Include/TRender/TResource.h @@ -13,6 +13,9 @@ class TRENDERINTERFACE_EXPORTS TResource : public TObject, public TNodeTree 0x30 + TVertexFactoryResourceInterface* m_pFactory; // 0x30 + TUSHORT m_usFlags; // 0x34 + TUSHORT m_usMaxVertices; // 0x36 + TUSHORT m_usNumVertices; // 0x38 + TUINT m_uiLockCount; // 0x3A +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRenderD3D/TD3DVertexBlockResource.h b/Toshi/Include/TRenderD3D/TD3DVertexBlockResource.h new file mode 100644 index 0000000..f738408 --- /dev/null +++ b/Toshi/Include/TRenderD3D/TD3DVertexBlockResource.h @@ -0,0 +1,47 @@ +#pragma once +#include "TRender/TResource.h" +#include "TKernel/TFreeList.h" +#include "TRender/TVertexFactoryResourceInterface.h" +#include + +TOSHI_NAMESPACE_BEGIN + +class TVertexPoolResource; +class TVertexFactoryResource; + +class TVertexBlockResource : public TResource +{ + DECLARE_DYNAMIC(TVertexBlockResource) + DECLARE_FREELIST(TVertexBlockResource) + +public: + + struct HALBuffer + { + HALBuffer(); + + TUINT uiNumStreams; + TUSHORT uiVertexOffset; + IDirect3DVertexBuffer8* apVertexBuffers[TVertexFactoryFormat::MAX_NUM_STREAMS]; + }; + + TBOOL Create(TVertexFactoryResource* a_pFactory, TUSHORT a_uiMaxVertices, TUINT a_uiFlags); + + TBOOL AttachPool(TVertexPoolResource* a_pPool); + TBOOL CanFit(TVertexPoolResource* a_pPoolResource); + + TVertexFactoryResourceInterface* GetFactory() { return m_pFactory; } + TUINT GetFlags() { return m_uiFlags; } + +private: + TVertexFactoryResourceInterface* m_pFactory; // 0x30 + TUINT m_uiFlags; // 0x34 + TUSHORT m_uiMaxVertices; + TUINT m_uiOffset; + TUINT m_uiVerticesUsed; + TUINT m_uiLockCount; + TUINT m_Unk1; + HALBuffer m_HALBuffer; +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRenderD3D/TD3DVertexFactoryResource.h b/Toshi/Include/TRenderD3D/TD3DVertexFactoryResource.h new file mode 100644 index 0000000..9815c9d --- /dev/null +++ b/Toshi/Include/TRenderD3D/TD3DVertexFactoryResource.h @@ -0,0 +1,20 @@ +#pragma once + +#include "TRender/TVertexFactoryResourceInterface.h" +#include "TD3DVertexPoolResource.h" +#include "TD3DVertexBlockResource.h" + +TOSHI_NAMESPACE_BEGIN + +class TVertexFactoryResource : public TVertexFactoryResourceInterface +{ + DECLARE_DYNAMIC(TVertexFactoryResource) + +public: + virtual TVertexPoolResourceInterface* CreatePoolResource(TUSHORT a_uiMaxStaticVertices, TUINT a_uiFlags); + + TVertexBlockResource* FindBlockResource(TVertexPoolResource* a_pResource); + TVertexBlockResource* CreateBlockResource(TUSHORT a_uiMaxVertices, TUINT a_uiFlags); +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Include/TRenderD3D/TD3DVertexPoolResource.h b/Toshi/Include/TRenderD3D/TD3DVertexPoolResource.h new file mode 100644 index 0000000..34f5a18 --- /dev/null +++ b/Toshi/Include/TRenderD3D/TD3DVertexPoolResource.h @@ -0,0 +1,23 @@ +#pragma once + +#include "TRender/TVertexPoolResourceInterface.h" + + +TOSHI_NAMESPACE_BEGIN + +class TVertexPoolResource : public TVertexPoolResourceInterface +{ + DECLARE_DYNAMIC(TVertexPoolResource) + + friend class TVertexFactoryResource; + +protected: + virtual TBOOL Validate() override; + virtual void Invalidate() override; + virtual void OnDestroy() override; + virtual TBOOL Lock(LockBuffer* a_pLockBuffer) override; + virtual void Unlock(TUSHORT a_uiNewNumVertices) override; + virtual TBOOL Create(TVertexFactoryResourceInterface* a_pFactory, TUINT a_uiMaxVertices, TUINT a_uiFlags) override; +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/Toshi/Source/TKernel/TScheduler.cpp b/Toshi/Source/TKernel/TScheduler.cpp index 0b03025..124c621 100644 --- a/Toshi/Source/TKernel/TScheduler.cpp +++ b/Toshi/Source/TKernel/TScheduler.cpp @@ -61,8 +61,8 @@ void TScheduler::Update() m_fCurrentTimeDelta = 0.0f; } - DestroyDyingTasks(m_oTaskTree.AttachedToRoot()); - UpdateActiveTasks(m_oTaskTree.AttachedToRoot()); + DestroyDyingTasks(m_oTaskTree.ChildOfRoot()); + UpdateActiveTasks(m_oTaskTree.ChildOfRoot()); } void TScheduler::DestroyDyingTasks(TTask* a_pTask) @@ -107,7 +107,7 @@ void TScheduler::UpdateActiveTasks(TTask* a_pTask) void TScheduler::DestroyAllTasks() { - TTask* pAttached = m_oTaskTree.AttachedToRoot(); + TTask* pAttached = m_oTaskTree.ChildOfRoot(); if (pAttached) { DestroyTask(*pAttached); DeleteTaskAtomic(pAttached); diff --git a/Toshi/Source/TRender/TRenderInterface.cpp b/Toshi/Source/TRender/TRenderInterface.cpp index 09c96bf..f2066ef 100644 --- a/Toshi/Source/TRender/TRenderInterface.cpp +++ b/Toshi/Source/TRender/TRenderInterface.cpp @@ -45,8 +45,24 @@ TBOOL TRenderInterface::CreateSystemResources() TBOOL bRes = TFALSE; m_aSysResources[SYSRESOURCE_VFACTORIES] = CreateResource(&TGetClass(TNullResource), "VFactories", TNULL); - //m_aSysResources[SYSRESOURCE_VFSYSSVNDUV1] = CreateResource(TFindClass(TVertexFactoryResource, TNULL), "VFSYSSVNDUV1", GetSystemResource(SYSRESOURCE_VFACTORIES)); - //TVALIDADDRESS(m_aSysResources[SYSRESOURCE_VFSYSSVNDUV1]); + + m_aSysResources[SYSRESOURCE_VFSYSSVNDUV1] = CreateResource(TFindClass(TVertexFactoryResource, TNULL), "VFSYSSVNDUV1", GetSystemResource(SYSRESOURCE_VFACTORIES)); + TVALIDADDRESS(m_aSysResources[SYSRESOURCE_VFSYSSVNDUV1]); + TVertexFactoryFormat vertexFormat; + vertexFormat.m_uiNumStreams = 1; + vertexFormat.m_aStreamFormats[0].m_uiVertexSize = 24; + vertexFormat.m_aStreamFormats[0].m_uiUnk = 0; + bRes = static_cast(GetSystemResource(SYSRESOURCE_VFSYSSVNDUV1))->Create(&vertexFormat, 11000, 0); + TASSERT(TTRUE == bRes); + + m_aSysResources[SYSRESOURCE_VFSKIN] = CreateResource(TFindClass(TVertexFactoryResource, TNULL), "VFSKIN", GetSystemResource(SYSRESOURCE_VFACTORIES)); + TVALIDADDRESS(m_aSysResources[SYSRESOURCE_VFSKIN]); + TVertexFactoryFormat vertexFormat; + vertexFormat.m_uiNumStreams = 1; + vertexFormat.m_aStreamFormats[0].m_uiVertexSize = 40; + vertexFormat.m_aStreamFormats[0].m_uiUnk = 0; + bRes = static_cast(GetSystemResource(SYSRESOURCE_VFSKIN))->Create(&vertexFormat, 11000, 0); + TASSERT(TTRUE == bRes); m_aSysResources[SYSRESOURCE_TEXTUREFACTORY] = CreateResource(TFindClass(TTextureFactoryHAL, TNULL), "TextureFactory", TNULL); bRes = m_aSysResources[SYSRESOURCE_TEXTUREFACTORY]->Create(); diff --git a/Toshi/Source/TRender/TResource.cpp b/Toshi/Source/TRender/TResource.cpp index 56a095d..3e4d7a7 100644 --- a/Toshi/Source/TRender/TResource.cpp +++ b/Toshi/Source/TRender/TResource.cpp @@ -21,6 +21,18 @@ TBOOL TResource::Validate() return TTRUE; } +void TResource::Invalidate() +{ +} + +void TResource::DestroyResource() +{ +} + +void TResource::OnDestroy() +{ +} + void TResource::SetParent(TResource* a_pParent) { TASSERT((TNULL == a_pParent) || (TTRUE == IsDying()) || (TFALSE == a_pParent->IsDying())); @@ -50,3 +62,41 @@ void TResource::SetName(TPCCHAR a_strName) TASSERT(TSystem::StringLength(a_strName)<=MAXNAMELEN); TSystem::StringCopy(m_szName, a_strName, -1); } + +TBOOL Recurse(TResource::t_RecurseCb a_pCallback, TResource* a_pResource, TBOOL a_bFlag, TPVOID a_pUserData) +{ + TResource* pResource = a_pResource; + + while (pResource) { + TResource* pNext = pResource->Next(); + + if (pNext == a_pResource || pNext == pResource || !a_bFlag) { + pNext = TNULL; + } + + if (!a_pCallback(pResource, a_pUserData)) { + return TFALSE; + } + + auto pAttached = pResource->Child(); + if (pAttached && !Recurse(a_pCallback, pResource, TTRUE, a_pUserData)) { + return TFALSE; + } + + pResource = pNext; + } + + return TTRUE; +} + +void TResource::RecurseSimple(t_RecurseCb a_pfnCallback, TResource* a_pResource, TPVOID a_pUserData) +{ + TASSERT(TNULL != GetTree()); + TASSERT(TNULL != a_pfnCallback); + if (a_pResource) { + Recurse(a_pfnCallback, a_pResource, TFALSE, a_pUserData); + } + else { + Recurse(a_pfnCallback, Child(), TTRUE, a_pUserData); + } +} diff --git a/Toshi/Source/TRender/TVertexFactoryResourceInterface.cpp b/Toshi/Source/TRender/TVertexFactoryResourceInterface.cpp index 55a831e..f4a4e32 100644 --- a/Toshi/Source/TRender/TVertexFactoryResourceInterface.cpp +++ b/Toshi/Source/TRender/TVertexFactoryResourceInterface.cpp @@ -11,6 +11,10 @@ TVertexFactoryResourceInterface::TVertexFactoryResourceInterface() m_uiFlags = 0; } +TVertexFactoryResourceInterface::TVertexFactoryResourceInterface() +{ +} + TBOOL TVertexFactoryResourceInterface::Create(TVertexFactoryFormat* a_pVertexFormat, TUSHORT a_uiMaxStaticVertices, TUINT a_uiFlags) { TVALIDADDRESS(a_pVertexFormat); diff --git a/Toshi/Source/TRender/TVertexPoolResourceInterface.cpp b/Toshi/Source/TRender/TVertexPoolResourceInterface.cpp new file mode 100644 index 0000000..66c34d0 --- /dev/null +++ b/Toshi/Source/TRender/TVertexPoolResourceInterface.cpp @@ -0,0 +1,54 @@ +#include "TVertexPoolResourceInterface.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNAMIC(TVertexPoolResourceInterface, TResource) + +TVertexPoolResourceInterface::LockBuffer::LockBuffer() +{ + uiNumStreams = 0; + uiOffset = 0; + apStreams[0] = TNULL; + apStreams[1] = TNULL; + apStreams[2] = TNULL; + apStreams[3] = TNULL; + apStreams[4] = TNULL; + apStreams[5] = TNULL; + apStreams[6] = TNULL; + apStreams[7] = TNULL; +} + +TVertexPoolResourceInterface::TVertexPoolResourceInterface() +{ + m_pFactory = TNULL; + m_usFlags = 0; + m_usMaxVertices = 0; + m_usNumVertices = 0; + m_uiLockCount = 0; +} + +void TVertexPoolResourceInterface::OnDestroy() +{ + TASSERT(0==m_uiLockCount); + m_pFactory->m_uiNumCreatedVertexPools--; + TResource::OnDestroy(); +} + +TBOOL TVertexPoolResourceInterface::Lock(LockBuffer* a_pLockBuffer) +{ + return TBOOL(); +} + +void TVertexPoolResourceInterface::Unlock(TUSHORT a_uiNewNumVertices) +{ +} + +TBOOL TVertexPoolResourceInterface::Create(TVertexFactoryResourceInterface* a_pFactory, TUINT a_uiMaxVertices, TUINT a_uiFlags) +{ + m_pFactory = a_pFactory; + m_usMaxVertices = a_uiMaxVertices; + m_usFlags = a_uiFlags; + return TResource::Create(); +} + + diff --git a/Toshi/Source/TRenderD3D/TD3DVertexBlockResource.cpp b/Toshi/Source/TRenderD3D/TD3DVertexBlockResource.cpp new file mode 100644 index 0000000..45f44f8 --- /dev/null +++ b/Toshi/Source/TRenderD3D/TD3DVertexBlockResource.cpp @@ -0,0 +1,42 @@ +#include "TRenderD3D/TD3DVertexBlockResource.h" +#include "TRenderD3D/TD3DVertexPoolResource.h" +#include "TRenderD3D/TD3DVertexFactoryResource.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNAMIC(TVertexBlockResource, TResource) +IMPLEMENT_FREELIST(TVertexBlockResource, 0, 8) + +TBOOL TVertexBlockResource::CanFit(TVertexPoolResource* a_pPoolResource) +{ + if (GetFlags() & 1 && a_pPoolResource->GetFlags() & 1) + { + return m_uiMaxVertices >= a_pPoolResource->GetNumVertices() + m_uiVerticesUsed; + } + + return TFALSE; +} + +TBOOL TVertexBlockResource::AttachPool(TVertexPoolResource* a_pPool) +{ + TVALIDADDRESS(a_pPool); + + m_uiVerticesUsed += a_pPool->GetNumVertices(); + a_pPool->SetParent(this); + + if (m_uiFlags & 1) { + Invalidate(); + } + + return TTRUE; +} + +TBOOL TVertexBlockResource::Create(TVertexFactoryResource* a_pFactory, TUSHORT a_uiMaxVertices, TUINT a_uiFlags) +{ + TASSERT(TFALSE == IsCreated()); + TVALIDADDRESS(a_pFactory); + m_pFactory = a_pFactory; + m_uiMaxVertices = a_uiMaxVertices; + m_uiFlags = a_uiFlags; + return TResource::Create(); +} diff --git a/Toshi/Source/TRenderD3D/TD3DVertexFactoryResource.cpp b/Toshi/Source/TRenderD3D/TD3DVertexFactoryResource.cpp new file mode 100644 index 0000000..fcb35fc --- /dev/null +++ b/Toshi/Source/TRenderD3D/TD3DVertexFactoryResource.cpp @@ -0,0 +1,63 @@ +#include "TRenderD3D/TD3DVertexFactoryResource.h" +#include "TRender/TRenderInterface.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNCREATE(TVertexFactoryResource, TVertexFactoryResourceInterface) + +TVertexPoolResourceInterface* TVertexFactoryResource::CreatePoolResource(TUSHORT a_uiMaxStaticVertices, TUINT a_uiFlags) +{ + TVertexPoolResource* pVertexPool = TSTATICCAST( + TVertexPoolResource*, + GetRenderer()->CreateResource(&TGetClass(TVertexPoolResource), TNULL, this) + ); + + TVALIDADDRESS(pVertexPool); + + pVertexPool->Create(this, a_uiMaxStaticVertices, a_uiFlags); + return pVertexPool; +} + +struct CallbackStruct +{ + TVertexBlockResource* m_pBlock; + TVertexPoolResource* m_pPool; +}; + +static TBOOL CallBack(TResource* a_pResource, TPVOID a_pUserData) +{ + CallbackStruct* pStruct = TSTATICCAST(CallbackStruct*, a_pUserData); + TVertexBlockResource* pBlockResource = TSTATICCAST(TVertexBlockResource*, a_pResource); + + if (a_pResource->IsA(TGetClass(TVertexBlockResource))) { + + if (pBlockResource->CanFit(pStruct->m_pPool) && !pBlockResource->IsDying()) { + pStruct->m_pBlock = pBlockResource; + return TFALSE; + } + } + + return TTRUE; +} + +TVertexBlockResource* TVertexFactoryResource::FindBlockResource(TVertexPoolResource* a_pResource) +{ + CallbackStruct result = { TNULL, a_pResource }; + if (a_pResource->GetFlags() & 2) { + return TNULL; + } + RecurseSimple(CallBack, this, &result); +} + +TVertexBlockResource* TVertexFactoryResource::CreateBlockResource(TUSHORT a_uiMaxVertices, TUINT a_uiFlags) +{ + TVertexBlockResource* pVertexBlock = TSTATICCAST( + TVertexBlockResource*, + GetRenderer()->CreateResource(&TGetClass(TVertexBlockResource), TNULL, this) + ); + + TVALIDADDRESS(pVertexBlock); + + pVertexBlock->Create(this, a_uiMaxVertices, a_uiFlags); + return pVertexBlock; +} diff --git a/Toshi/Source/TRenderD3D/TD3DVertexPoolResource.cpp b/Toshi/Source/TRenderD3D/TD3DVertexPoolResource.cpp new file mode 100644 index 0000000..a424185 --- /dev/null +++ b/Toshi/Source/TRenderD3D/TD3DVertexPoolResource.cpp @@ -0,0 +1,75 @@ +#include "TRenderD3D/TD3DVertexPoolResource.h" +#include "TRenderD3D/TD3DVertexBlockResource.h" +#include "TRenderD3D/TD3DVertexFactoryResource.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNCREATE(TVertexPoolResource, TVertexPoolResourceInterface) + +TBOOL TVertexPoolResource::Validate() +{ + if (IsValid()) { + return TTRUE; + } + + TVertexFactoryResource* pFactory = TSTATICCAST(TVertexFactoryResource*, GetFactory()); + TVertexBlockResource* pVertexBlock = pFactory->FindBlockResource(this); + + if (!pVertexBlock) + { + TUINT32 uiFlags; + TUSHORT uiNumVerts; + + TUINT8 uiUnk1 = GetFlags() & 7; + + if (uiUnk1 == 1) { + uiNumVerts = pFactory->GetMaxStaticVertices(); + TASSERT(GetNumVertices() <= uiNumVerts); + uiFlags = 1; + } + else if (uiUnk1 == 2) { + uiNumVerts = GetMaxVertices(); + uiFlags = 2; + } + else { + if (uiUnk1 != 4) { + return TFALSE; + } + + uiNumVerts = GetMaxVertices(); + uiFlags = 4; + } + + pVertexBlock = pFactory->CreateBlockResource(uiNumVerts, uiFlags); + TVALIDADDRESS(pVertexBlock); + + if (!pVertexBlock) { + return TFALSE; + } + } + + pVertexBlock->AttachPool(this); + return TResource::Validate(); +} + +void TVertexPoolResource::Invalidate() +{ +} + +void TVertexPoolResource::OnDestroy() +{ +} + +TBOOL TVertexPoolResource::Lock(LockBuffer* a_pLockBuffer) +{ + return TBOOL(); +} + +void TVertexPoolResource::Unlock(TUSHORT a_uiNewNumVertices) +{ +} + +TBOOL TVertexPoolResource::Create(TVertexFactoryResourceInterface* a_pFactory, TUINT a_uiMaxVertices, TUINT a_uiFlags) +{ + return TBOOL(); +}