From 490f3698119382db4e9c3bd6fd2e772c1888827d Mon Sep 17 00:00:00 2001 From: LHoG <1476261+lhog@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:50:07 +0100 Subject: [PATCH] Renames before type changes: ScopedMatricesMemAlloc -> ScopedTransformMemAlloc MatrixUploader -> TransformsUploader MatricesMemStorage -> TransformsMemStorage matAlloc -> traAlloc matrixUploader -> transformsUploader matricesMemStorage -> transformsMemStorage --- rts/Game/Game.cpp | 6 +- rts/Lua/LuaVBOImpl.cpp | 6 +- rts/Rendering/Common/ModelDrawer.h | 4 +- rts/Rendering/Common/ModelDrawerData.h | 14 ++--- rts/Rendering/Models/3DModel.cpp | 4 +- rts/Rendering/Models/3DModel.h | 10 ++-- rts/Rendering/Models/3DModelVAO.cpp | 18 +++--- rts/Rendering/Models/IModelParser.cpp | 2 +- rts/Rendering/Models/ModelsMemStorage.cpp | 4 +- rts/Rendering/Models/ModelsMemStorage.h | 46 +++++++-------- rts/Rendering/ModelsDataUploader.cpp | 68 +++++++++++------------ rts/Rendering/ModelsDataUploader.h | 4 +- rts/System/SpringApp.cpp | 2 +- 13 files changed, 94 insertions(+), 94 deletions(-) diff --git a/rts/Game/Game.cpp b/rts/Game/Game.cpp index 25ffce47c3..331608c51a 100644 --- a/rts/Game/Game.cpp +++ b/rts/Game/Game.cpp @@ -736,7 +736,7 @@ void CGame::PreLoadRendering() geometricObjects = new CGeometricObjects(); // load components that need to exist before PostLoadSimulation - matrixUploader.Init(); + transformsUploader.Init(); modelsUniformsUploader.Init(); worldDrawer.InitPre(); } @@ -997,7 +997,7 @@ void CGame::KillRendering() icon::iconHandler.Kill(); spring::SafeDelete(geometricObjects); worldDrawer.Kill(); - matrixUploader.Kill(); + transformsUploader.Kill(); modelsUniformsUploader.Kill(); } @@ -1470,7 +1470,7 @@ bool CGame::UpdateUnsynced(const spring_time currentTime) shadowHandler.Update(); { worldDrawer.Update(newSimFrame); - matrixUploader.Update(); + transformsUploader.Update(); modelsUniformsUploader.Update(); } diff --git a/rts/Lua/LuaVBOImpl.cpp b/rts/Lua/LuaVBOImpl.cpp index 8f13e3148c..b344666be6 100644 --- a/rts/Lua/LuaVBOImpl.cpp +++ b/rts/Lua/LuaVBOImpl.cpp @@ -986,7 +986,7 @@ SInstanceData LuaVBOImpl::InstanceDataFromGetData(int id, int attrID, uint8_t de uint32_t teamID = defTeamID; const TObj* obj = LuaUtils::SolIdToObject(id, __func__); - const uint32_t matOffset = static_cast(matrixUploader.GetElemOffset(obj)); + const uint32_t matOffset = static_cast(transformsUploader.GetElemOffset(obj)); const uint32_t uniIndex = static_cast(modelsUniformsStorage.GetObjOffset(obj)); //doesn't need to exist for defs and model. Don't check for validity if (matOffset == ~0u) { @@ -1003,11 +1003,11 @@ SInstanceData LuaVBOImpl::InstanceDataFromGetData(int id, int attrID, uint8_t de size_t bposeIndex = 0; if constexpr (std::is_same::value) { numPieces = static_cast(obj->numPieces); - bposeIndex = matrixUploader.GetElemOffset(obj); + bposeIndex = transformsUploader.GetElemOffset(obj); } else { numPieces = static_cast(obj->model->numPieces); - bposeIndex = matrixUploader.GetElemOffset(obj->model); + bposeIndex = transformsUploader.GetElemOffset(obj->model); } return SInstanceData(matOffset, teamID, drawFlags, numPieces, uniIndex, bposeIndex); diff --git a/rts/Rendering/Common/ModelDrawer.h b/rts/Rendering/Common/ModelDrawer.h index ef4c036341..bbb1c60e3f 100644 --- a/rts/Rendering/Common/ModelDrawer.h +++ b/rts/Rendering/Common/ModelDrawer.h @@ -21,7 +21,7 @@ namespace GL { struct GeometryBuffer; } template class ScopedModelDrawerImpl; -class ScopedMatricesMemAlloc; +class ScopedTransformMemAlloc; static constexpr const char* ModelDrawerNames[ModelDrawerTypes::MODEL_DRAWER_CNT] = { @@ -110,7 +110,7 @@ class CModelDrawerBase : public CModelDrawerConcept { static bool CanDrawDeferred() { return modelDrawerState->CanDrawDeferred(); } static bool SetTeamColor(int team, const float alpha = 1.0f) { return modelDrawerState->SetTeamColor(team, alpha); } static void SetNanoColor(const float4& color) { modelDrawerState->SetNanoColor(color); } - static const ScopedMatricesMemAlloc& GetMatricesMemAlloc(const ObjType* o) { return const_cast(modelDrawerData)->GetObjectMatricesMemAlloc(o); } + static const ScopedTransformMemAlloc& GetMatricesMemAlloc(const ObjType* o) { return const_cast(modelDrawerData)->GetObjectTransformMemAlloc(o); } public: virtual void Update() const = 0; // Draw* diff --git a/rts/Rendering/Common/ModelDrawerData.h b/rts/Rendering/Common/ModelDrawerData.h index f08801e0e6..b7939519af 100644 --- a/rts/Rendering/Common/ModelDrawerData.h +++ b/rts/Rendering/Common/ModelDrawerData.h @@ -69,18 +69,18 @@ class CModelDrawerDataBase : public CModelDrawerDataConcept void ClearPreviousDrawFlags() { for (auto object : unsortedObjects) object->previousDrawFlag = 0; } - const ScopedMatricesMemAlloc& GetObjectMatricesMemAlloc(const T* o) const { + const ScopedTransformMemAlloc& GetObjectTransformMemAlloc(const T* o) const { const auto it = matricesMemAllocs.find(const_cast(o)); - return (it != matricesMemAllocs.end()) ? it->second : ScopedMatricesMemAlloc::Dummy(); + return (it != matricesMemAllocs.end()) ? it->second : ScopedTransformMemAlloc::Dummy(); } - ScopedMatricesMemAlloc& GetObjectMatricesMemAlloc(const T* o) { return matricesMemAllocs[const_cast(o)]; } + ScopedTransformMemAlloc& GetObjectTransformMemAlloc(const T* o) { return matricesMemAllocs[const_cast(o)]; } private: static constexpr int MMA_SIZE0 = 2 << 16; protected: std::array, MODELTYPE_CNT> modelRenderers; std::vector unsortedObjects; - std::unordered_map matricesMemAllocs; + std::unordered_map matricesMemAllocs; bool& mtModelDrawer; }; @@ -126,7 +126,7 @@ inline void CModelDrawerDataBase::AddObject(const T* co, bool add) unsortedObjects.emplace_back(o); const uint32_t numMatrices = (o->model ? o->model->numPieces : 0) + 1u; - matricesMemAllocs.emplace(o, ScopedMatricesMemAlloc(numMatrices)); + matricesMemAllocs.emplace(o, ScopedTransformMemAlloc(numMatrices)); modelsUniformsStorage.GetObjOffset(co); } @@ -157,10 +157,10 @@ inline void CModelDrawerDataBase::UpdateObject(const T* co, bool init) template inline void CModelDrawerDataBase::UpdateObjectSMMA(const T* o) { - ScopedMatricesMemAlloc& smma = GetObjectMatricesMemAlloc(o); + ScopedTransformMemAlloc& smma = GetObjectTransformMemAlloc(o); const auto tmNew = o->GetTransformMatrix(); - const auto& tmOld = const_cast(smma)[0]; + const auto& tmOld = const_cast(smma)[0]; // from one point it doesn't worth the comparison, cause units usually move // but having not updated smma[0] allows for longer solid no-update areas in ModelsUniformsUploader::UpdateDerived() diff --git a/rts/Rendering/Models/3DModel.cpp b/rts/Rendering/Models/3DModel.cpp index 8f1af8d3b9..a9cf6e924a 100644 --- a/rts/Rendering/Models/3DModel.cpp +++ b/rts/Rendering/Models/3DModel.cpp @@ -763,13 +763,13 @@ void S3DModel::SetPieceMatrices() // use this occasion and copy bpose matrices for (size_t i = 0; i < pieceObjects.size(); ++i) { const auto* po = pieceObjects[i]; - matAlloc[0 + i] = po->bposeTransform.ToMatrix(); + traAlloc[0 + i] = po->bposeTransform.ToMatrix(); } // use this occasion and copy inverse bpose matrices // store them right after all bind pose matrices for (size_t i = 0; i < pieceObjects.size(); ++i) { const auto* po = pieceObjects[i]; - matAlloc[numPieces + i] = po->bposeInvTransform.ToMatrix(); + traAlloc[numPieces + i] = po->bposeInvTransform.ToMatrix(); } } diff --git a/rts/Rendering/Models/3DModel.h b/rts/Rendering/Models/3DModel.h index d35cb7e168..1c8005de3c 100644 --- a/rts/Rendering/Models/3DModel.h +++ b/rts/Rendering/Models/3DModel.h @@ -271,7 +271,7 @@ struct S3DModel , loadStatus(NOTLOADED) , uploaded(false) - , matAlloc(ScopedMatricesMemAlloc()) + , traAlloc(ScopedTransformMemAlloc()) {} S3DModel(const S3DModel& m) = delete; @@ -307,7 +307,7 @@ struct S3DModel loadStatus = m.loadStatus; uploaded = m.uploaded; - std::swap(matAlloc, m.matAlloc); + std::swap(traAlloc, m.traAlloc); return *this; } @@ -342,7 +342,7 @@ struct S3DModel // force mutex just in case this is called from modelLoader.ProcessVertices() // TODO: pass to S3DModel if it is created from LoadModel(ST) or from ProcessVertices(MT) - matAlloc = ScopedMatricesMemAlloc(2 * numPieces); + traAlloc = ScopedTransformMemAlloc(2 * numPieces); std::vector stack = { root }; @@ -368,7 +368,7 @@ struct S3DModel float3 CalcDrawMidPos() const { return ((maxs + mins) * 0.5f); } float3 GetDrawMidPos() const { return relMidPos; } - const ScopedMatricesMemAlloc& GetMatAlloc() const { return matAlloc; } + const ScopedTransformMemAlloc& GetMatAlloc() const { return traAlloc; } public: std::string name; std::array texs; @@ -395,7 +395,7 @@ struct S3DModel LoadStatus loadStatus; bool uploaded; private: - ScopedMatricesMemAlloc matAlloc; + ScopedTransformMemAlloc traAlloc; }; diff --git a/rts/Rendering/Models/3DModelVAO.cpp b/rts/Rendering/Models/3DModelVAO.cpp index 757379b6c3..0e9f1835bf 100644 --- a/rts/Rendering/Models/3DModelVAO.cpp +++ b/rts/Rendering/Models/3DModelVAO.cpp @@ -287,8 +287,8 @@ template bool S3DModelVAO::AddToSubmissionImpl(const TObj* obj, uint32_t indexStart, uint32_t indexCount, uint8_t teamID, uint8_t drawFlags) { RECOIL_DETAILED_TRACY_ZONE; - const auto matIndex = matrixUploader.GetElemOffset(obj); - if (matIndex == MatricesMemStorage::INVALID_INDEX) + const auto matIndex = transformsUploader.GetElemOffset(obj); + if (matIndex == TransformsMemStorage::INVALID_INDEX) return false; const auto uniIndex = modelsUniformsStorage.GetObjOffset(obj); //doesn't need to exist for defs and models. Don't check for validity @@ -297,14 +297,14 @@ bool S3DModelVAO::AddToSubmissionImpl(const TObj* obj, uint32_t indexStart, uint size_t bposeIndex = 0; if constexpr (std::is_same::value) { numPieces = static_cast(obj->numPieces); - bposeIndex = matrixUploader.GetElemOffset(obj); + bposeIndex = transformsUploader.GetElemOffset(obj); } else { numPieces = static_cast(obj->model->numPieces); - bposeIndex = matrixUploader.GetElemOffset(obj->model); + bposeIndex = transformsUploader.GetElemOffset(obj->model); } - if (bposeIndex == MatricesMemStorage::INVALID_INDEX) + if (bposeIndex == TransformsMemStorage::INVALID_INDEX) return false; auto& modelInstanceData = modelDataToInstance[SIndexAndCount{ indexStart, indexCount }]; @@ -414,8 +414,8 @@ template bool S3DModelVAO::SubmitImmediatelyImpl(const TObj* obj, uint32_t indexStart, uint32_t indexCount, uint8_t teamID, uint8_t drawFlags, GLenum mode, bool bindUnbind) { RECOIL_DETAILED_TRACY_ZONE; - std::size_t matIndex = matrixUploader.GetElemOffset(obj); - if (matIndex == MatricesMemStorage::INVALID_INDEX) + std::size_t matIndex = transformsUploader.GetElemOffset(obj); + if (matIndex == TransformsMemStorage::INVALID_INDEX) return false; const auto uniIndex = modelsUniformsStorage.GetObjOffset(obj); //doesn't need to exist for defs. Don't check for validity @@ -424,11 +424,11 @@ bool S3DModelVAO::SubmitImmediatelyImpl(const TObj* obj, uint32_t indexStart, ui size_t bposeIndex = 0; if constexpr (std::is_same::value) { numPieces = static_cast(obj->numPieces); - bposeIndex = matrixUploader.GetElemOffset(obj); + bposeIndex = transformsUploader.GetElemOffset(obj); } else { numPieces = static_cast(obj->model->numPieces); - bposeIndex = matrixUploader.GetElemOffset(obj->model); + bposeIndex = transformsUploader.GetElemOffset(obj->model); } SInstanceData instanceData(static_cast(matIndex), teamID, drawFlags, numPieces, uniIndex, bposeIndex); diff --git a/rts/Rendering/Models/IModelParser.cpp b/rts/Rendering/Models/IModelParser.cpp index 92861d6f83..048ad9d27d 100644 --- a/rts/Rendering/Models/IModelParser.cpp +++ b/rts/Rendering/Models/IModelParser.cpp @@ -97,7 +97,7 @@ static void LoadDummyModel(S3DModel& model) model.numPieces = 1; // give it one empty piece model.AddPiece(g3DOParser.AllocPiece()); - model.FlattenPieceTree(model.GetRootPiece()); //useless except for setting up matAlloc + model.FlattenPieceTree(model.GetRootPiece()); //useless except for setting up traAlloc model.GetRootPiece()->SetCollisionVolume(CollisionVolume('b', 'z', -UpVector, ZeroVector)); model.loadStatus = S3DModel::LoadStatus::LOADED; } diff --git a/rts/Rendering/Models/ModelsMemStorage.cpp b/rts/Rendering/Models/ModelsMemStorage.cpp index c8ffe4242b..3b4c633e7a 100644 --- a/rts/Rendering/Models/ModelsMemStorage.cpp +++ b/rts/Rendering/Models/ModelsMemStorage.cpp @@ -3,7 +3,7 @@ #include "System/Misc/TracyDefs.h" -MatricesMemStorage matricesMemStorage; +TransformsMemStorage transformsMemStorage; ModelsUniformsStorage modelsUniformsStorage; ModelsUniformsStorage::ModelsUniformsStorage() @@ -49,7 +49,7 @@ ModelUniformData& ModelsUniformsStorage::GetObjUniformsArray(const CWorldObject* return storage[offset]; } -void MatricesMemStorage::SetAllDirty() +void TransformsMemStorage::SetAllDirty() { RECOIL_DETAILED_TRACY_ZONE; assert(Threading::IsMainThread()); diff --git a/rts/Rendering/Models/ModelsMemStorage.h b/rts/Rendering/Models/ModelsMemStorage.h index f58ada71e9..f91df4db1c 100644 --- a/rts/Rendering/Models/ModelsMemStorage.h +++ b/rts/Rendering/Models/ModelsMemStorage.h @@ -13,9 +13,9 @@ #include "Sim/Misc/GlobalConstants.h" #include "Sim/Objects/SolidObjectDef.h" -class MatricesMemStorage : public StablePosAllocator { +class TransformsMemStorage : public StablePosAllocator { public: - explicit MatricesMemStorage() + explicit TransformsMemStorage() : StablePosAllocator(INIT_NUM_ELEMS) , dirtyMap(INIT_NUM_ELEMS, BUFFERING) {} @@ -68,31 +68,31 @@ class MatricesMemStorage : public StablePosAllocator { static constexpr int INIT_NUM_ELEMS = 1 << 16u; }; -extern MatricesMemStorage matricesMemStorage; +extern TransformsMemStorage transformsMemStorage; //////////////////////////////////////////////////////////////////// -class ScopedMatricesMemAlloc { +class ScopedTransformMemAlloc { public: - ScopedMatricesMemAlloc() : ScopedMatricesMemAlloc(0u) {}; - ScopedMatricesMemAlloc(std::size_t numElems_) + ScopedTransformMemAlloc() : ScopedTransformMemAlloc(0u) {}; + ScopedTransformMemAlloc(std::size_t numElems_) : numElems{numElems_} { - firstElem = matricesMemStorage.Allocate(numElems); + firstElem = transformsMemStorage.Allocate(numElems); } - ScopedMatricesMemAlloc(const ScopedMatricesMemAlloc&) = delete; - ScopedMatricesMemAlloc(ScopedMatricesMemAlloc&& smma) noexcept { *this = std::move(smma); } + ScopedTransformMemAlloc(const ScopedTransformMemAlloc&) = delete; + ScopedTransformMemAlloc(ScopedTransformMemAlloc&& smma) noexcept { *this = std::move(smma); } - ~ScopedMatricesMemAlloc() { - if (firstElem == MatricesMemStorage::INVALID_INDEX) + ~ScopedTransformMemAlloc() { + if (firstElem == TransformsMemStorage::INVALID_INDEX) return; - matricesMemStorage.Free(firstElem, numElems, &CMatrix44f::Zero()); + transformsMemStorage.Free(firstElem, numElems, &CMatrix44f::Zero()); } - bool Valid() const { return firstElem != MatricesMemStorage::INVALID_INDEX; } + bool Valid() const { return firstElem != TransformsMemStorage::INVALID_INDEX; } std::size_t GetOffset(bool assertInvalid = true) const { if (assertInvalid) assert(Valid()); @@ -100,8 +100,8 @@ class ScopedMatricesMemAlloc { return firstElem; } - ScopedMatricesMemAlloc& operator= (const ScopedMatricesMemAlloc&) = delete; - ScopedMatricesMemAlloc& operator= (ScopedMatricesMemAlloc&& smma) noexcept { + ScopedTransformMemAlloc& operator= (const ScopedTransformMemAlloc&) = delete; + ScopedTransformMemAlloc& operator= (ScopedTransformMemAlloc&& smma) noexcept { //swap to prevent dealloc on dying object, yet enable destructor to do its thing on valid object std::swap(firstElem, smma.firstElem); std::swap(numElems , smma.numElems ); @@ -110,26 +110,26 @@ class ScopedMatricesMemAlloc { } const CMatrix44f& operator[](std::size_t offset) const { - assert(firstElem != MatricesMemStorage::INVALID_INDEX); + assert(firstElem != TransformsMemStorage::INVALID_INDEX); assert(offset >= 0 && offset < numElems); - return matricesMemStorage[firstElem + offset]; + return transformsMemStorage[firstElem + offset]; } CMatrix44f& operator[](std::size_t offset) { - assert(firstElem != MatricesMemStorage::INVALID_INDEX); + assert(firstElem != TransformsMemStorage::INVALID_INDEX); assert(offset >= 0 && offset < numElems); - matricesMemStorage.GetDirtyMap().at(firstElem + offset) = MatricesMemStorage::BUFFERING; - return matricesMemStorage[firstElem + offset]; + transformsMemStorage.GetDirtyMap().at(firstElem + offset) = TransformsMemStorage::BUFFERING; + return transformsMemStorage[firstElem + offset]; } public: - static const ScopedMatricesMemAlloc& Dummy() { - static ScopedMatricesMemAlloc dummy; + static const ScopedTransformMemAlloc& Dummy() { + static ScopedTransformMemAlloc dummy; return dummy; }; private: - std::size_t firstElem = MatricesMemStorage::INVALID_INDEX; + std::size_t firstElem = TransformsMemStorage::INVALID_INDEX; std::size_t numElems = 0u; }; diff --git a/rts/Rendering/ModelsDataUploader.cpp b/rts/Rendering/ModelsDataUploader.cpp index e2992663e6..813099fe81 100644 --- a/rts/Rendering/ModelsDataUploader.cpp +++ b/rts/Rendering/ModelsDataUploader.cpp @@ -104,7 +104,7 @@ std::size_t TypedStorageBufferUploader::GetProjectileElemOffset(int3 return GetElemOffsetImpl(projectileHandler.GetProjectileBySyncedID(syncedProjectileID)); } -void MatrixUploader::InitDerived() +void TransformsUploader::InitDerived() { if (!globalRendering->haveGL4) return; @@ -113,17 +113,17 @@ void MatrixUploader::InitDerived() ? IStreamBufferConcept::Types::SB_PERSISTENTMAP : IStreamBufferConcept::Types::SB_BUFFERSUBDATA; - InitImpl(MATRIX_SSBO_BINDING_IDX, ELEM_COUNT0, ELEM_COUNTI, sbType, true, MatricesMemStorage::BUFFERING); + InitImpl(MATRIX_SSBO_BINDING_IDX, ELEM_COUNT0, ELEM_COUNTI, sbType, true, TransformsMemStorage::BUFFERING); if (ssbo->GetBufferImplementation() == IStreamBufferConcept::Types::SB_PERSISTENTMAP && !ssbo->IsValid()) { // some potatoe driver overestimated its support for SB_PERSISTENTMAP // Redo with good old SB_BUFFERSUBDATA LOG_L(L_ERROR, "[MatrixUploader::%s] OpenGL reported persistent mapping to be available, but initial mapping of buffer failed. Falling back.", __func__); KillImpl(); - InitImpl(MATRIX_SSBO_BINDING_IDX, ELEM_COUNT0, ELEM_COUNTI, IStreamBufferConcept::Types::SB_BUFFERSUBDATA, true, MatricesMemStorage::BUFFERING); + InitImpl(MATRIX_SSBO_BINDING_IDX, ELEM_COUNT0, ELEM_COUNTI, IStreamBufferConcept::Types::SB_BUFFERSUBDATA, true, TransformsMemStorage::BUFFERING); } } -void MatrixUploader::KillDerived() +void TransformsUploader::KillDerived() { if (!globalRendering->haveGL4) return; @@ -131,7 +131,7 @@ void MatrixUploader::KillDerived() KillImpl(); } -void MatrixUploader::UpdateDerived() +void TransformsUploader::UpdateDerived() { if (!globalRendering->haveGL4) return; @@ -143,7 +143,7 @@ void MatrixUploader::UpdateDerived() //resize const uint32_t elemCount = GetElemsCount(); - const uint32_t storageElemCount = matricesMemStorage.GetSize(); + const uint32_t storageElemCount = transformsMemStorage.GetSize(); if (storageElemCount > elemCount) { const uint32_t newElemCount = AlignUp(storageElemCount, elemCountIncr); LOG_L(L_DEBUG, "[%s::%s] sizing SSBO %s. New elements count = %u, elemCount = %u, storageElemCount = %u", className, __func__, "up", newElemCount, elemCount, storageElemCount); @@ -152,22 +152,22 @@ void MatrixUploader::UpdateDerived() if (ssbo->GetBufferImplementation() == IStreamBufferConcept::Types::SB_PERSISTENTMAP && !ssbo->IsValid()) { LOG_L(L_ERROR, "[MatrixUploader::%s] OpenGL reported persistent mapping to be available, but mapping of buffer of %u size failed. Falling back.", __func__, uint32_t(newElemCount * sizeof(CMatrix44f))); KillImpl(); - InitImpl(MATRIX_SSBO_BINDING_IDX, newElemCount, ELEM_COUNTI, IStreamBufferConcept::Types::SB_BUFFERSUBDATA, true, MatricesMemStorage::BUFFERING); + InitImpl(MATRIX_SSBO_BINDING_IDX, newElemCount, ELEM_COUNTI, IStreamBufferConcept::Types::SB_BUFFERSUBDATA, true, TransformsMemStorage::BUFFERING); } - matricesMemStorage.SetAllDirty(); //Resize doesn't copy the data + transformsMemStorage.SetAllDirty(); //Resize doesn't copy the data } //update on the GPU - const CMatrix44f* clientPtr = matricesMemStorage.GetData().data(); + const CMatrix44f* clientPtr = transformsMemStorage.GetData().data(); constexpr bool ENABLE_UPLOAD_OPTIMIZATION = true; if (ssbo->GetBufferImplementation() == IStreamBufferConcept::Types::SB_PERSISTENTMAP && ENABLE_UPLOAD_OPTIMIZATION) { - const auto stt = matricesMemStorage.GetDirtyMap().begin(); - const auto fin = matricesMemStorage.GetDirtyMap().end(); + const auto stt = transformsMemStorage.GetDirtyMap().begin(); + const auto fin = transformsMemStorage.GetDirtyMap().end(); - auto beg = matricesMemStorage.GetDirtyMap().begin(); - auto end = matricesMemStorage.GetDirtyMap().begin(); + auto beg = transformsMemStorage.GetDirtyMap().begin(); + auto end = transformsMemStorage.GetDirtyMap().begin(); static const auto dirtyPred = [](uint8_t m) -> bool { return m > 0u; }; while (beg != fin) { @@ -189,7 +189,7 @@ void MatrixUploader::UpdateDerived() } } else { - const CMatrix44f* clientPtr = matricesMemStorage.GetData().data(); + const CMatrix44f* clientPtr = transformsMemStorage.GetData().data(); CMatrix44f* mappedPtr = ssbo->Map(clientPtr, 0, storageElemCount); if (!ssbo->HasClientPtr()) @@ -201,90 +201,90 @@ void MatrixUploader::UpdateDerived() ssbo->SwapBuffer(); } -std::size_t MatrixUploader::GetDefElemOffsetImpl(const S3DModel* model) const +std::size_t TransformsUploader::GetDefElemOffsetImpl(const S3DModel* model) const { if (model == nullptr) { LOG_L(L_ERROR, "[%s::%s] Supplied nullptr S3DModel", className, __func__); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } return model->GetMatAlloc().GetOffset(false); } -std::size_t MatrixUploader::GetDefElemOffsetImpl(const UnitDef* def) const +std::size_t TransformsUploader::GetDefElemOffsetImpl(const UnitDef* def) const { if (def == nullptr) { LOG_L(L_ERROR, "[%s::%s] Supplied nullptr UnitDef", className, __func__); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } return GetDefElemOffsetImpl(def->LoadModel()); } -std::size_t MatrixUploader::GetDefElemOffsetImpl(const FeatureDef* def) const +std::size_t TransformsUploader::GetDefElemOffsetImpl(const FeatureDef* def) const { if (def == nullptr) { LOG_L(L_ERROR, "[%s::%s] Supplied nullptr FeatureDef", className, __func__); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } return GetDefElemOffsetImpl(def->LoadModel()); } -std::size_t MatrixUploader::GetElemOffsetImpl(const CUnit* unit) const +std::size_t TransformsUploader::GetElemOffsetImpl(const CUnit* unit) const { if (unit == nullptr) { LOG_L(L_ERROR, "[%s::%s] Supplied nullptr CUnit", className, __func__); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } - if (std::size_t offset = CUnitDrawer::GetMatricesMemAlloc(unit).GetOffset(false); offset != MatricesMemStorage::INVALID_INDEX) { + if (std::size_t offset = CUnitDrawer::GetMatricesMemAlloc(unit).GetOffset(false); offset != TransformsMemStorage::INVALID_INDEX) { return offset; } LOG_L(L_ERROR, "[%s::%s] Supplied invalid CUnit (id:%d)", className, __func__, unit->id); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } -std::size_t MatrixUploader::GetElemOffsetImpl(const CFeature* feature) const +std::size_t TransformsUploader::GetElemOffsetImpl(const CFeature* feature) const { if (feature == nullptr) { LOG_L(L_ERROR, "[%s::%s] Supplied nullptr CFeature", className, __func__); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } - if (std::size_t offset = CFeatureDrawer::GetMatricesMemAlloc(feature).GetOffset(false); offset != MatricesMemStorage::INVALID_INDEX) { + if (std::size_t offset = CFeatureDrawer::GetMatricesMemAlloc(feature).GetOffset(false); offset != TransformsMemStorage::INVALID_INDEX) { return offset; } LOG_L(L_ERROR, "[%s::%s] Supplied invalid CFeature (id:%d)", className, __func__, feature->id); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } -std::size_t MatrixUploader::GetElemOffsetImpl(const CProjectile* p) const +std::size_t TransformsUploader::GetElemOffsetImpl(const CProjectile* p) const { if (p == nullptr) { LOG_L(L_ERROR, "[%s::%s] Supplied nullptr CProjectile", className, __func__); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } if (!p->synced) { LOG_L(L_ERROR, "[%s::%s] Supplied non-synced CProjectile (id:%d)", className, __func__, p->id); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } if (!p->weapon || !p->piece) { LOG_L(L_ERROR, "[%s::%s] Supplied non-weapon or non-piece CProjectile (id:%d)", className, __func__, p->id); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } /* - if (std::size_t offset = p->GetMatAlloc().GetOffset(false); offset != MatricesMemStorage::INVALID_INDEX) { + if (std::size_t offset = p->GetMatAlloc().GetOffset(false); offset != TransformsMemStorage::INVALID_INDEX) { return offset; } */ LOG_L(L_ERROR, "[%s::%s] Supplied invalid CProjectile (id:%d)", className, __func__, p->id); - return MatricesMemStorage::INVALID_INDEX; + return TransformsMemStorage::INVALID_INDEX; } void ModelsUniformsUploader::InitDerived() diff --git a/rts/Rendering/ModelsDataUploader.h b/rts/Rendering/ModelsDataUploader.h index 6e335b0045..9646ff56cc 100644 --- a/rts/Rendering/ModelsDataUploader.h +++ b/rts/Rendering/ModelsDataUploader.h @@ -69,7 +69,7 @@ class TypedStorageBufferUploader { std::unique_ptr> ssbo; }; -class MatrixUploader : public TypedStorageBufferUploader { +class TransformsUploader : public TypedStorageBufferUploader { public: void InitDerived(); void KillDerived(); @@ -105,5 +105,5 @@ class ModelsUniformsUploader : public TypedStorageBufferUploaderResetState(); ENTER_SYNCED_CODE();