diff options
| author | Brad Linden <brad@lindenlab.com> | 2024-06-11 15:39:48 -0700 | 
|---|---|---|
| committer | Brad Linden <brad@lindenlab.com> | 2024-06-11 15:39:48 -0700 | 
| commit | a7b0f9391146b42dd5cd5f47f845de81bfdb6820 (patch) | |
| tree | 4d0e499b14abe28434de8f9cc97a50fa92e0d6e0 | |
| parent | 7c42711ca3a4e67b95473aa5129dce5ff19bea15 (diff) | |
Fixed signed/unsigned warnings after they got enabled in the maint-A merge
| -rw-r--r-- | indra/llmath/llvolumeoctree.h | 2 | ||||
| -rw-r--r-- | indra/newview/gltf/accessor.cpp | 5 | ||||
| -rw-r--r-- | indra/newview/gltf/animation.cpp | 11 | ||||
| -rw-r--r-- | indra/newview/gltf/primitive.cpp | 19 | ||||
| -rw-r--r-- | indra/newview/gltfscenemanager.cpp | 11 | ||||
| -rw-r--r-- | indra/newview/lldynamictexture.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/llheroprobemanager.cpp | 10 | ||||
| -rw-r--r-- | indra/newview/llvocache.cpp | 3 | 
8 files changed, 36 insertions, 29 deletions
diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index 838e1d3db0..05d45f7b5f 100644 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -186,7 +186,7 @@ public:              llassert(!branch->isLeaf()); // Empty leaf          } -        for (S32 i = 0; i < branch->getChildCount(); ++i) +        for (U32 i = 0; i < branch->getChildCount(); ++i)          {  //stretch by child extents              LLVolumeOctreeListener* child = (LLVolumeOctreeListener*)branch->getChild(i)->getListener(0);              min.setMin(min, child->mExtents[0]); diff --git a/indra/newview/gltf/accessor.cpp b/indra/newview/gltf/accessor.cpp index 9f1cb0c1cd..2ef9237f2d 100644 --- a/indra/newview/gltf/accessor.cpp +++ b/indra/newview/gltf/accessor.cpp @@ -108,7 +108,8 @@ void Buffer::erase(Asset& asset, S32 offset, S32 length)      mData.erase(mData.begin() + offset, mData.begin() + offset + length); -    mByteLength = mData.size(); +    llassert(mData.size() <= size_t(INT_MAX)); +    mByteLength = S32(mData.size());      for (BufferView& view : asset.mBufferViews)      { @@ -141,7 +142,7 @@ bool Buffer::prep(Asset& asset)          }          mData.resize(mByteLength); -        if (!file.read((U8*)mData.data(), mData.size())) +        if (!file.read((U8*)mData.data(), mByteLength))          {              LL_WARNS("GLTF") << "Failed to load buffer data from asset: " << id << LL_ENDL;              return false; diff --git a/indra/newview/gltf/animation.cpp b/indra/newview/gltf/animation.cpp index 45e9e1ddef..8f53c28539 100644 --- a/indra/newview/gltf/animation.cpp +++ b/indra/newview/gltf/animation.cpp @@ -189,16 +189,15 @@ void Animation::Sampler::getFrameInfo(Asset& asset, F32 time, U32& frameIndex, F      if (mFrameTimes.size() > 1)      { +        llassert(mFrameTimes.size() <= size_t(U32_MAX)); +        frameIndex = U32(mFrameTimes.size()) - 2; +        t = 1.f; +          if (time > mMaxTime)          { -            frameIndex = mFrameTimes.size() - 2; -            t = 1.0f;              return;          } -        frameIndex = mFrameTimes.size() - 2; -        t = 1.f; -          for (U32 i = 0; i < mFrameTimes.size() - 1; i++)          {              if (time >= mFrameTimes[i] && time < mFrameTimes[i + 1]) @@ -382,7 +381,7 @@ void Skin::uploadMatrixPalette(Asset& asset)          glGenBuffers(1, &mUBO);      } -    U32 joint_count = llmin(max_joints, mJoints.size()); +    size_t joint_count = llmin<size_t>(max_joints, mJoints.size());      std::vector<mat4> t_mp; diff --git a/indra/newview/gltf/primitive.cpp b/indra/newview/gltf/primitive.cpp index bc333aff69..197ffb68e8 100644 --- a/indra/newview/gltf/primitive.cpp +++ b/indra/newview/gltf/primitive.cpp @@ -55,7 +55,7 @@ struct MikktMesh      bool copy(const Primitive* prim)      {          bool indexed = !prim->mIndexArray.empty(); -        U32 vert_count = indexed ? prim->mIndexArray.size() : prim->mPositions.size(); +        auto vert_count = indexed ? prim->mIndexArray.size() : prim->mPositions.size();          if (prim->mMode != Primitive::Mode::TRIANGLES)          { @@ -85,7 +85,7 @@ struct MikktMesh              j.resize(vert_count);          } -        for (int i = 0; i < vert_count; ++i) +        for (U32 i = 0; i < vert_count; ++i)          {              U32 idx = indexed ? prim->mIndexArray[i] : i; @@ -110,8 +110,8 @@ struct MikktMesh      void genNormals()      { -        U32 tri_count = p.size() / 3; -        for (U32 i = 0; i < tri_count; ++i) +        size_t tri_count = p.size() / 3; +        for (size_t i = 0; i < tri_count; ++i)          {              LLVector3 v0 = p[i * 3];              LLVector3 v1 = p[i * 3 + 1]; @@ -166,7 +166,7 @@ struct MikktMesh              prim->mWeights.resize(vert_count);              prim->mJoints.resize(vert_count);          } -         +          prim->mIndexArray.resize(remap.size());          for (int i = 0; i < remap.size(); ++i) @@ -411,7 +411,10 @@ bool Primitive::prep(Asset& asset)      }      mVertexBuffer = new LLVertexBuffer(mask); -    mVertexBuffer->allocateBuffer(mPositions.size(), mIndexArray.size() * 2); // double the size of the index buffer for 32-bit indices +    // we store these buffer sizes as S32 elsewhere +    llassert(mPositions.size() <= size_t(S32_MAX)); +    llassert(mIndexArray.size() <= size_t(S32_MAX / 2)); +    mVertexBuffer->allocateBuffer(U32(mPositions.size()), U32(mIndexArray.size() * 2)); // double the size of the index buffer for 32-bit indices      mVertexBuffer->setBuffer();      mVertexBuffer->setPositionData(mPositions.data()); @@ -619,8 +622,8 @@ const LLVolumeTriangle* Primitive::lineSegmentIntersect(const LLVector4a& start,      face.mTangents = mTangents.data();      face.mIndices = nullptr; // unreferenced -    face.mNumIndices = mIndexArray.size(); -    face.mNumVertices = mPositions.size(); +    face.mNumIndices = S32(mIndexArray.size()); +    face.mNumVertices = S32(mPositions.size());      LLOctreeTriangleRayIntersect intersect(start, dir, &face, &closest_t, intersection, tex_coord, normal, tangent_out);      intersect.traverse(mOctree); diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index d7eb605489..b948b2e2d6 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -244,7 +244,8 @@ void GLTFSceneManager::uploadSelection()                          LLFileSystem cache(assetId, LLAssetType::AT_GLTF_BIN, LLFileSystem::WRITE);                          auto& data = mUploadingAsset->mBuffers[idx].mData; -                        cache.write((const U8*)data.data(), data.size()); +                        llassert(data.size() <= size_t(S32_MAX)); +                        cache.write((const U8 *) data.data(), S32(data.size()));                      }                  };  #if GLTF_SIM_SUPPORT @@ -399,8 +400,9 @@ void GLTFSceneManager::onGLTFLoadComplete(const LLUUID& id, LLAssetType::EType a          {              LLFileSystem file(id, asset_type, LLFileSystem::READ);              std::string data; -            data.resize(file.getSize()); -            file.read((U8*)data.data(), data.size()); +            S32 file_size = file.getSize(); +            data.resize(file_size); +            file.read((U8*)data.data(), file_size);              boost::json::value json = boost::json::parse(data); @@ -479,7 +481,8 @@ void GLTFSceneManager::update()                              LLFileSystem cache(assetId, LLAssetType::AT_GLTF, LLFileSystem::WRITE);                              LL_INFOS("GLTF") << "Uploaded GLTF json: " << assetId << LL_ENDL; -                            cache.write((const U8 *) buffer.c_str(), buffer.size()); +                            llassert(buffer.size() <= size_t(S32_MAX)); +                            cache.write((const U8 *) buffer.c_str(), S32(buffer.size()));                              mUploadingAsset = nullptr;                          } diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index 739f85d4e6..fe6cd4e37d 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -217,8 +217,8 @@ bool LLViewerDynamicTexture::updateAllInstances()              LLViewerDynamicTexture *dynamicTexture = *iter;              if (dynamicTexture->needsRender())              { -                llassert(dynamicTexture->getFullWidth() <= LLPipeline::MAX_BAKE_WIDTH); -                llassert(dynamicTexture->getFullHeight() <= LLPipeline::MAX_BAKE_WIDTH); +                llassert(dynamicTexture->getFullWidth() <= S32(LLPipeline::MAX_BAKE_WIDTH)); +                llassert(dynamicTexture->getFullHeight() <= S32(LLPipeline::MAX_BAKE_WIDTH));                  glClear(GL_DEPTH_BUFFER_BIT); diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 83c7b8a354..f544b70329 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -101,7 +101,7 @@ void LLHeroProbeManager::update()          U32 count = log2((F32)res) + 0.5f;          mMipChain.resize(count); -        for (int i = 0; i < count; ++i) +        for (U32 i = 0; i < count; ++i)          {              mMipChain[i].allocate(res, res, GL_RGBA16F);              res /= 2; @@ -198,7 +198,7 @@ void LLHeroProbeManager::update()                  mFaceUpdateList[i] = ceilf(cube_facing * gPipeline.RenderHeroProbeConservativeUpdateMultiplier);                  } -             +              mProbes[0]->mOrigin = probe_pos;          }          else @@ -359,7 +359,8 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face, bool              res /= 2; -            S32 mip = i - (mMipChain.size() - mips); +            llassert(mMipChain.size() <= size_t(S32_MAX)); +            GLint mip = i - (S32(mMipChain.size()) - mips);              if (mip >= 0)              { @@ -487,7 +488,8 @@ void LLHeroProbeManager::updateUniforms()          mHeroData.heroSphere.mV[3] = mProbes[0]->mRadius;      } -    mHeroData.heroMipCount = mMipChain.size(); +    llassert(mMipChain.size() <= size_t(S32_MAX)); +    mHeroData.heroMipCount = S32(mMipChain.size());  }  void LLHeroProbeManager::renderDebug() diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 5f68051d10..7bbdd83a7f 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -1937,9 +1937,8 @@ void LLVOCache::writeGenericExtrasToCache(U64 handle, const LLUUID& id, const LL      LLViewerRegion* pRegion = LLWorld::getInstance()->getRegionFromHandle(handle);      U32 num_entries = 0; -    U32 inmem_entries = 0;      U32 skipped = 0; -    inmem_entries = cache_extras_entry_map.size(); +    size_t inmem_entries = cache_extras_entry_map.size();      for (auto [local_id, entry] : cache_extras_entry_map)      {          // Only write out GLTFOverrides that we can actually apply again on import.  | 
