SH-2428 Make GCC 4.4 happy by using LLVector4a striders with LLAlphaObject subclasses -- also vectorize particle VBO updates

master
Dave Parks 2011-10-04 17:25:55 -05:00
parent c4aa8c50da
commit ae0cd901f8
10 changed files with 82 additions and 385 deletions

View File

@ -1841,6 +1841,10 @@ bool LLVertexBuffer::getVertexStrider(LLStrider<LLVector3>& strider, S32 index,
{
return VertexBufferStrider<LLVector3,TYPE_VERTEX>::get(*this, strider, index, count, map_range);
}
bool LLVertexBuffer::getVertexStrider(LLStrider<LLVector4a>& strider, S32 index, S32 count, bool map_range)
{
return VertexBufferStrider<LLVector4a,TYPE_VERTEX>::get(*this, strider, index, count, map_range);
}
bool LLVertexBuffer::getIndexStrider(LLStrider<U16>& strider, S32 index, S32 count, bool map_range)
{
return VertexBufferStrider<U16,TYPE_INDEX>::get(*this, strider, index, count, map_range);

View File

@ -222,6 +222,7 @@ public:
// setVertsNorms(verts, norms);
// vb->unmapBuffer();
bool getVertexStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getVertexStrider(LLStrider<LLVector4a>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getIndexStrider(LLStrider<U16>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getTexCoord0Strider(LLStrider<LLVector2>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getTexCoord1Strider(LLStrider<LLVector2>& strider, S32 index=0, S32 count = -1, bool map_range = false);

View File

@ -588,7 +588,6 @@ set(viewer_SOURCE_FILES
llvopartgroup.cpp
llvosky.cpp
llvosurfacepatch.cpp
llvotextbubble.cpp
llvotree.cpp
llvovolume.cpp
llvowater.cpp
@ -1145,7 +1144,6 @@ set(viewer_HEADER_FILES
llvopartgroup.h
llvosky.h
llvosurfacepatch.h
llvotextbubble.h
llvotree.h
llvotreenew.h
llvovolume.h

View File

@ -1,4 +1,4 @@
/**
/**
* @file llviewerobject.h
* @brief Description of LLViewerObject class, which is the base class for most objects in the viewer.
*
@ -811,7 +811,7 @@ public:
virtual F32 getPartSize(S32 idx);
virtual void getGeometry(S32 idx,
LLStrider<LLVector3>& verticesp,
LLStrider<LLVector4a>& verticesp,
LLStrider<LLVector3>& normalsp,
LLStrider<LLVector2>& texcoordsp,
LLStrider<LLColor4U>& colorsp,

View File

@ -464,7 +464,7 @@ void LLVOGrass::plantBlades()
}
void LLVOGrass::getGeometry(S32 idx,
LLStrider<LLVector3>& verticesp,
LLStrider<LLVector4a>& verticesp,
LLStrider<LLVector3>& normalsp,
LLStrider<LLVector2>& texcoordsp,
LLStrider<LLColor4U>& colorsp,
@ -516,21 +516,24 @@ void LLVOGrass::getGeometry(S32 idx,
position.mV[0] = mPosition.mV[VX] + x + xf;
position.mV[1] = mPosition.mV[VY] + y + yf;
position.mV[2] = mRegionp->getLand().resolveHeightRegion(position);
*verticesp++ = v1 = position + mRegionp->getOriginAgent();
*verticesp++ = v1;
v1 = position + mRegionp->getOriginAgent();
(*verticesp++).load3(v1.mV);
(*verticesp++).load3(v1.mV);
position.mV[0] += dzx;
position.mV[1] += dzy;
position.mV[2] += blade_height;
*verticesp++ = v2 = position + mRegionp->getOriginAgent();
*verticesp++ = v2;
v2 = position + mRegionp->getOriginAgent();
(*verticesp++).load3(v2.mV);
(*verticesp++).load3(v2.mV);
position.mV[0] = mPosition.mV[VX] + x - xf;
position.mV[1] = mPosition.mV[VY] + y - xf;
position.mV[2] = mRegionp->getLand().resolveHeightRegion(position);
*verticesp++ = v3 = position + mRegionp->getOriginAgent();
*verticesp++ = v3;
v3 = position + mRegionp->getOriginAgent();
(*verticesp++).load3(v3.mV);
(*verticesp++).load3(v3.mV);
LLVector3 normal1 = (v1-v2) % (v2-v3);
normal1.mV[VZ] = 0.75f;
@ -541,8 +544,9 @@ void LLVOGrass::getGeometry(S32 idx,
position.mV[0] += dzx;
position.mV[1] += dzy;
position.mV[2] += blade_height;
*verticesp++ = v1 = position + mRegionp->getOriginAgent();
*verticesp++ = v1;
v1 = position + mRegionp->getOriginAgent();
(*verticesp++).load3(v1.mV);
(*verticesp++).load3(v1.mV);
*(normalsp++) = normal1;
*(normalsp++) = normal2;

View File

@ -59,7 +59,7 @@ public:
/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
/*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
/*virtual*/ void getGeometry(S32 idx,
LLStrider<LLVector3>& verticesp,
LLStrider<LLVector4a>& verticesp,
LLStrider<LLVector3>& normalsp,
LLStrider<LLVector2>& texcoordsp,
LLStrider<LLColor4U>& colorsp,

View File

@ -274,7 +274,7 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
}
void LLVOPartGroup::getGeometry(S32 idx,
LLStrider<LLVector3>& verticesp,
LLStrider<LLVector4a>& verticesp,
LLStrider<LLVector3>& normalsp,
LLStrider<LLVector2>& texcoordsp,
LLStrider<LLColor4U>& colorsp,
@ -290,37 +290,54 @@ void LLVOPartGroup::getGeometry(S32 idx,
U32 vert_offset = mDrawable->getFace(idx)->getGeomIndex();
LLVector3 part_pos_agent(part.mPosAgent);
LLVector3 camera_agent = getCameraPosition();
LLVector3 at = part_pos_agent - camera_agent;
LLVector3 up;
LLVector3 right;
LLVector4a part_pos_agent;
part_pos_agent.load3(part.mPosAgent.mV);
LLVector4a camera_agent;
camera_agent.load3(getCameraPosition().mV);
LLVector4a at;
at.setSub(part_pos_agent, camera_agent);
LLVector4a up(0, 0, 1);
LLVector4a right;
right = at % LLVector3(0.f, 0.f, 1.f);
right.normalize();
up = right % at;
up.normalize();
right.setCross3(at, up);
right.normalize3fast();
up.setCross3(right, at);
up.normalize3fast();
if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK)
{
LLVector3 normvel = part.mVelocity;
normvel.normalize();
LLVector4a normvel;
normvel.load3(part.mVelocity.mV);
normvel.normalize3fast();
LLVector2 up_fracs;
up_fracs.mV[0] = normvel*right;
up_fracs.mV[1] = normvel*up;
up_fracs.mV[0] = normvel.dot3(right).getF32();
up_fracs.mV[1] = normvel.dot3(up).getF32();
up_fracs.normalize();
LLVector3 new_up;
LLVector3 new_right;
new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up;
new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up;
LLVector4a new_up;
LLVector4a new_right;
//new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up;
LLVector4a t = right;
t.mul(up_fracs.mV[0]);
new_up = up;
new_up.mul(up_fracs.mV[1]);
new_up.add(t);
//new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up;
t = right;
t.mul(up_fracs.mV[1]);
new_right = up;
new_right.mul(up_fracs.mV[0]);
t.sub(new_right);
up = new_up;
right = new_right;
up.normalize();
right.normalize();
right = t;
up.normalize3fast();
right.normalize3fast();
}
right *= 0.5f*part.mScale.mV[0];
up *= 0.5f*part.mScale.mV[1];
right.mul(0.5f*part.mScale.mV[0]);
up.mul(0.5f*part.mScale.mV[1]);
LLVector3 normal = -LLViewerCamera::getInstance()->getXAxis();
@ -329,14 +346,25 @@ void LLVOPartGroup::getGeometry(S32 idx,
// this works because there is actually a 4th float stored after the vertex position which is used as a texture index
// also, somebody please VECTORIZE THIS
verticesp->mV[3] = 0.f;
*verticesp++ = part_pos_agent + up - right;
verticesp->mV[3] = 0.f;
*verticesp++ = part_pos_agent - up - right;
verticesp->mV[3] = 0.f;
*verticesp++ = part_pos_agent + up + right;
verticesp->mV[3] = 0.f;
*verticesp++ = part_pos_agent - up + right;
LLVector4a ppapu;
LLVector4a ppamu;
ppapu.setAdd(part_pos_agent, up);
ppamu.setSub(part_pos_agent, up);
verticesp->setSub(ppapu, right);
(*verticesp++).getF32ptr()[3] = 0.f;
verticesp->setSub(ppamu, right);
(*verticesp++).getF32ptr()[3] = 0.f;
verticesp->setAdd(ppapu, right);
(*verticesp++).getF32ptr()[3] = 0.f;
verticesp->setAdd(ppamu, right);
(*verticesp++).getF32ptr()[3] = 0.f;
//*verticesp++ = part_pos_agent + up - right;
//*verticesp++ = part_pos_agent - up - right;
//*verticesp++ = part_pos_agent + up + right;
//*verticesp++ = part_pos_agent - up + right;
*colorsp++ = part.mColor;
*colorsp++ = part.mColor;
@ -453,7 +481,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
LLVertexBuffer* buffer = group->mVertexBuffer;
LLStrider<U16> indicesp;
LLStrider<LLVector3> verticesp;
LLStrider<LLVector4a> verticesp;
LLStrider<LLVector3> normalsp;
LLStrider<LLVector2> texcoordsp;
LLStrider<LLColor4U> colorsp;

View File

@ -60,7 +60,7 @@ public:
/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
/*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
void getGeometry(S32 idx,
LLStrider<LLVector3>& verticesp,
LLStrider<LLVector4a>& verticesp,
LLStrider<LLVector3>& normalsp,
LLStrider<LLVector2>& texcoordsp,
LLStrider<LLColor4U>& colorsp,

View File

@ -1,272 +0,0 @@
/**
* @file llvotextbubble.cpp
* @brief Viewer-object text bubble.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llvotextbubble.h"
#include "imageids.h"
#include "llviewercontrol.h"
#include "llprimitive.h"
#include "llrendersphere.h"
#include "llbox.h"
#include "lldrawable.h"
#include "llface.h"
#include "llviewertexturelist.h"
#include "llvolume.h"
#include "pipeline.h"
#include "llvector4a.h"
#include "llviewerregion.h"
LLVOTextBubble::LLVOTextBubble(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
: LLAlphaObject(id, pcode, regionp)
{
setScale(LLVector3(1.5f, 1.5f, 0.25f));
mbCanSelect = FALSE;
mLOD = MIN_LOD;
mVolumeChanged = TRUE;
setVelocity(LLVector3(0.f, 0.f, 0.75f));
LLVolumeParams volume_params;
volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_LINE);
volume_params.setBeginAndEndS(0.f, 1.f);
volume_params.setBeginAndEndT(0.f, 1.f);
volume_params.setRatio(0.25f, 0.25f);
volume_params.setShear(0.f, 0.f);
setVolume(volume_params, 0);
mColor = LLColor4(1.0f, 0.0f, 0.0f, 1.f);
S32 i;
for (i = 0; i < getNumTEs(); i++)
{
setTEColor(i, mColor);
setTETexture(i, LLUUID(IMG_DEFAULT));
}
}
LLVOTextBubble::~LLVOTextBubble()
{
}
BOOL LLVOTextBubble::isActive() const
{
return TRUE;
}
BOOL LLVOTextBubble::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
{
static LLFastTimer::DeclareTimer ftm("Text Bubble");
LLFastTimer t(ftm);
F32 dt = mUpdateTimer.getElapsedTimeF32();
// Die after a few seconds.
if (dt > 1.5f)
{
return FALSE;
}
LLViewerObject::idleUpdate(agent, world, time);
setScale(0.5f * (1.f+dt) * LLVector3(1.5f, 1.5f, 0.5f));
F32 alpha = 0.35f*dt;
LLColor4 color = mColor;
color.mV[VALPHA] -= alpha;
if (color.mV[VALPHA] <= 0.05f)
{
return FALSE;
}
S32 i;
for (i = 0; i < getNumTEs(); i++)
{
setTEColor(i, color);
setTEFullbright(i, TRUE);
}
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE);
return TRUE;
}
void LLVOTextBubble::updateTextures()
{
// Update the image levels of all textures...
for (U32 i = 0; i < getNumTEs(); i++)
{
const LLTextureEntry *te = getTE(i);
F32 texel_area_ratio = fabs(te->mScaleS * te->mScaleT);
texel_area_ratio = llclamp(texel_area_ratio, .125f, 16.f);
LLViewerTexture *imagep = getTEImage(i);
if (imagep)
{
imagep->addTextureStats(mPixelArea / texel_area_ratio);
}
}
}
LLDrawable *LLVOTextBubble::createDrawable(LLPipeline *pipeline)
{
pipeline->allocDrawable(this);
mDrawable->setLit(FALSE);
mDrawable->setRenderType(LLPipeline::RENDER_TYPE_VOLUME);
for (U32 i = 0; i < getNumTEs(); i++)
{
LLViewerTexture *imagep;
const LLTextureEntry *texture_entry = getTE(i);
imagep = LLViewerTextureManager::getFetchedTexture(texture_entry->getID());
mDrawable->addFace((LLFacePool*) NULL, imagep);
}
return mDrawable;
}
// virtual
BOOL LLVOTextBubble::setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume)
{
if (LLPrimitive::setVolume(volume_params, mLOD))
{
if (mDrawable)
{
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE);
mVolumeChanged = TRUE;
}
return TRUE;
}
return FALSE;
}
BOOL LLVOTextBubble::updateLOD()
{
return FALSE;
}
BOOL LLVOTextBubble::updateGeometry(LLDrawable *drawable)
{
if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_VOLUME)))
return TRUE;
if (mVolumeChanged)
{
LLVolumeParams volume_params = getVolume()->getParams();
setVolume(volume_params, 0);
LLPipeline::sCompiles++;
drawable->setNumFaces(getVolume()->getNumFaces(), drawable->getFace(0)->getPool(), getTEImage(0));
}
LLMatrix4 identity4;
LLMatrix3 identity3;
for (S32 i = 0; i < drawable->getNumFaces(); i++)
{
LLFace *face = drawable->getFace(i);
face->setTEOffset(i);
face->setTexture(LLViewerFetchedTexture::sSmokeImagep);
face->setState(LLFace::FULLBRIGHT);
}
mVolumeChanged = FALSE;
mDrawable->movePartition();
return TRUE;
}
void LLVOTextBubble::updateFaceSize(S32 idx)
{
LLFace* face = mDrawable->getFace(idx);
if (idx == 0 || idx == 2)
{
face->setSize(0,0);
}
else
{
const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
face->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
}
}
void LLVOTextBubble::getGeometry(S32 idx,
LLStrider<LLVector3>& verticesp,
LLStrider<LLVector3>& normalsp,
LLStrider<LLVector2>& texcoordsp,
LLStrider<LLColor4U>& colorsp,
LLStrider<U16>& indicesp)
{
if (idx == 0 || idx == 2)
{
return;
}
const LLVolumeFace& face = getVolume()->getVolumeFace(idx);
LLVector4a pos;
pos.load3(getPositionAgent().mV);
LLVector4a scale;
scale.load3(getScale().mV);
LLColor4U color = LLColor4U(getTE(idx)->getColor());
U32 offset = mDrawable->getFace(idx)->getGeomIndex();
LLVector4a* dst_pos = (LLVector4a*) verticesp.get();
LLVector4a* src_pos = (LLVector4a*) face.mPositions;
LLVector4a* dst_norm = (LLVector4a*) normalsp.get();
LLVector4a* src_norm = (LLVector4a*) face.mNormals;
LLVector2* dst_tc = (LLVector2*) texcoordsp.get();
LLVector2* src_tc = (LLVector2*) face.mTexCoords;
LLVector4a::memcpyNonAliased16((F32*) dst_norm, (F32*) src_norm, face.mNumVertices*4*sizeof(F32));
LLVector4a::memcpyNonAliased16((F32*) dst_tc, (F32*) src_tc, face.mNumVertices*2*sizeof(F32));
for (U32 i = 0; i < face.mNumVertices; i++)
{
LLVector4a t;
t.setMul(src_pos[i], scale);
dst_pos[i].setAdd(t, pos);
*colorsp++ = color;
}
for (U32 i = 0; i < face.mNumIndices; i++)
{
*indicesp++ = face.mIndices[i] + offset;
}
}
U32 LLVOTextBubble::getPartitionType() const
{
return LLViewerRegion::PARTITION_PARTICLE;
}

View File

@ -1,66 +0,0 @@
/**
* @file llvotextbubble.h
* @brief Description of LLVORock class, which a derivation of LLViewerObject
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLVOTEXTBUBBLE_H
#define LL_LLVOTEXTBUBBLE_H
#include "llviewerobject.h"
#include "llframetimer.h"
class LLVOTextBubble : public LLAlphaObject
{
public:
LLVOTextBubble(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
/*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate.
/*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
/*virtual*/ void updateTextures();
/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
/*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
/*virtual*/ BOOL updateLOD();
/*virtual*/ void updateFaceSize(S32 idx);
/*virtual*/ void getGeometry(S32 idx,
LLStrider<LLVector3>& verticesp,
LLStrider<LLVector3>& normalsp,
LLStrider<LLVector2>& texcoordsp,
LLStrider<LLColor4U>& colorsp,
LLStrider<U16>& indicesp);
virtual U32 getPartitionType() const;
LLColor4 mColor;
S32 mLOD;
BOOL mVolumeChanged;
protected:
~LLVOTextBubble();
BOOL setVolume(const LLVolumeParams &volume_params, const S32 detail, bool unique_volume = false);
LLFrameTimer mUpdateTimer;
};
#endif // LL_VO_TEXT_BUBBLE