Vectorize/memory align buffers in llvolumeface WIP
parent
8919f4811a
commit
4d57cb3c09
File diff suppressed because it is too large
Load Diff
|
|
@ -40,6 +40,7 @@ class LLPathParams;
|
|||
class LLVolumeParams;
|
||||
class LLProfile;
|
||||
class LLPath;
|
||||
class LLVector4a;
|
||||
class LLVolumeFace;
|
||||
class LLVolume;
|
||||
|
||||
|
|
@ -791,6 +792,19 @@ public:
|
|||
class LLVolumeFace
|
||||
{
|
||||
public:
|
||||
class VertexData
|
||||
{
|
||||
public:
|
||||
LLVector3 mPosition;
|
||||
LLVector3 mNormal;
|
||||
LLVector3 mBinormal;
|
||||
LLVector2 mTexCoord;
|
||||
|
||||
bool operator<(const VertexData& rhs) const;
|
||||
bool operator==(const VertexData& rhs) const;
|
||||
bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
|
||||
};
|
||||
|
||||
LLVolumeFace() :
|
||||
mID(0),
|
||||
mTypeMask(0),
|
||||
|
|
@ -808,26 +822,18 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
~LLVolumeFace();
|
||||
|
||||
BOOL create(LLVolume* volume, BOOL partial_build = FALSE);
|
||||
void createBinormals();
|
||||
|
||||
void appendFace(const LLVolumeFace& face, LLMatrix4& transform, LLMatrix4& normal_tranform);
|
||||
|
||||
void resizeVertices(S32 num_verts);
|
||||
void allocateBinormals(S32 num_verts);
|
||||
void resizeIndices(S32 num_indices);
|
||||
void fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx);
|
||||
|
||||
class VertexData
|
||||
{
|
||||
public:
|
||||
LLVector3 mPosition;
|
||||
LLVector3 mNormal;
|
||||
LLVector3 mBinormal;
|
||||
LLVector2 mTexCoord;
|
||||
|
||||
bool operator<(const VertexData& rhs) const;
|
||||
bool operator==(const VertexData& rhs) const;
|
||||
bool compareNormal(const VertexData& rhs, F32 angle_cutoff) const;
|
||||
};
|
||||
|
||||
class VertexMapData : public LLVolumeFace::VertexData
|
||||
{
|
||||
|
|
@ -1051,7 +1057,8 @@ public:
|
|||
|
||||
std::ostream& operator<<(std::ostream &s, const LLVolumeParams &volume_params);
|
||||
|
||||
LLVector3 calc_binormal_from_triangle(
|
||||
void calc_binormal_from_triangle(
|
||||
LLVector4a& binormal,
|
||||
const LLVector3& pos0,
|
||||
const LLVector2& tex0,
|
||||
const LLVector3& pos1,
|
||||
|
|
@ -1060,7 +1067,7 @@ LLVector3 calc_binormal_from_triangle(
|
|||
const LLVector2& tex2);
|
||||
|
||||
BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size);
|
||||
BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir,
|
||||
BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir,
|
||||
F32* intersection_a, F32* intersection_b, F32* intersection_t, BOOL two_sided);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1201,14 +1201,14 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(LLFace* face, const LLMeshSk
|
|||
|
||||
if (!buff ||
|
||||
buff->getTypeMask() != data_mask ||
|
||||
buff->getRequestedVerts() != vol_face.mVertices.size())
|
||||
buff->getRequestedVerts() != vol_face.mNumVertices)
|
||||
{
|
||||
face->setGeomIndex(0);
|
||||
face->setIndicesIndex(0);
|
||||
face->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
|
||||
face->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
|
||||
|
||||
face->mVertexBuffer = new LLVertexBuffer(data_mask, 0);
|
||||
face->mVertexBuffer->allocateBuffer(vol_face.mVertices.size(), vol_face.mIndices.size(), true);
|
||||
face->mVertexBuffer->allocateBuffer(vol_face.mNumVertices, vol_face.mNumIndices, true);
|
||||
|
||||
U16 offset = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -928,8 +928,8 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
|||
{
|
||||
LLFastTimer t(FTM_FACE_GET_GEOM);
|
||||
const LLVolumeFace &vf = volume.getVolumeFace(f);
|
||||
S32 num_vertices = (S32)vf.mVertices.size();
|
||||
S32 num_indices = LLPipeline::sUseTriStrips ? (S32)vf.mTriStrip.size() : (S32) vf.mIndices.size();
|
||||
S32 num_vertices = (S32)vf.mNumVertices;
|
||||
S32 num_indices = (S32) vf.mNumIndices;
|
||||
|
||||
if (mVertexBuffer.notNull())
|
||||
{
|
||||
|
|
@ -1128,19 +1128,9 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
|||
if (full_rebuild)
|
||||
{
|
||||
mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
|
||||
if (LLPipeline::sUseTriStrips)
|
||||
for (U32 i = 0; i < (U32) num_indices; i++)
|
||||
{
|
||||
for (U32 i = 0; i < (U32) num_indices; i++)
|
||||
{
|
||||
*indicesp++ = vf.mTriStrip[i] + index_offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (U32 i = 0; i < (U32) num_indices; i++)
|
||||
{
|
||||
*indicesp++ = vf.mIndices[i] + index_offset;
|
||||
}
|
||||
*indicesp++ = vf.mIndices[i] + index_offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1214,28 +1204,41 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
|||
bool bake_sunlight = !getTextureEntry()->getFullbright() &&
|
||||
!mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
|
||||
|
||||
//VECTORIZE THIS
|
||||
for (S32 i = 0; i < num_vertices; i++)
|
||||
{
|
||||
LLVector3 vf_binormal;
|
||||
if (vf.mBinormals)
|
||||
{
|
||||
vf_binormal.set(vf.mBinormals+i*4);
|
||||
}
|
||||
|
||||
LLVector3 vf_normal;
|
||||
vf_normal.set(vf.mNormals+i*4);
|
||||
|
||||
LLVector3 vf_position;
|
||||
vf_position.set(vf.mPositions+i*4);
|
||||
|
||||
if (rebuild_tcoord)
|
||||
{
|
||||
LLVector2 tc = vf.mVertices[i].mTexCoord;
|
||||
LLVector2 tc(vf.mTexCoords+i*2);
|
||||
|
||||
if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
|
||||
{
|
||||
LLVector3 vec = vf.mVertices[i].mPosition;
|
||||
LLVector3 vec = vf_position;
|
||||
|
||||
vec.scaleVec(scale);
|
||||
|
||||
switch (texgen)
|
||||
{
|
||||
case LLTextureEntry::TEX_GEN_PLANAR:
|
||||
planarProjection(tc, vf.mVertices[i].mNormal, vf.mCenter, vec);
|
||||
planarProjection(tc, vf_normal, vf.mCenter, vec);
|
||||
break;
|
||||
case LLTextureEntry::TEX_GEN_SPHERICAL:
|
||||
sphericalProjection(tc, vf.mVertices[i].mNormal, vf.mCenter, vec);
|
||||
sphericalProjection(tc, vf_normal, vf.mCenter, vec);
|
||||
break;
|
||||
case LLTextureEntry::TEX_GEN_CYLINDRICAL:
|
||||
cylindricalProjection(tc, vf.mVertices[i].mNormal, vf.mCenter, vec);
|
||||
cylindricalProjection(tc, vf_normal, vf.mCenter, vec);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -1345,10 +1348,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
|||
|
||||
if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))
|
||||
{
|
||||
LLVector3 tangent = vf.mVertices[i].mBinormal % vf.mVertices[i].mNormal;
|
||||
LLVector3 tangent = vf_binormal % vf_normal;
|
||||
|
||||
LLMatrix3 tangent_to_object;
|
||||
tangent_to_object.setRows(tangent, vf.mVertices[i].mBinormal, vf.mVertices[i].mNormal);
|
||||
tangent_to_object.setRows(tangent, vf_binormal, vf_normal);
|
||||
LLVector3 binormal = binormal_dir * tangent_to_object;
|
||||
binormal = binormal * mat_normal;
|
||||
|
||||
|
|
@ -1366,12 +1369,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
|||
|
||||
if (rebuild_pos)
|
||||
{
|
||||
*vertices++ = vf.mVertices[i].mPosition * mat_vert;
|
||||
*vertices++ = vf_position * mat_vert;
|
||||
}
|
||||
|
||||
if (rebuild_normal)
|
||||
{
|
||||
LLVector3 normal = vf.mVertices[i].mNormal * mat_normal;
|
||||
LLVector3 normal = vf_normal * mat_normal;
|
||||
normal.normVec();
|
||||
|
||||
*normals++ = normal;
|
||||
|
|
@ -1379,21 +1382,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
|||
|
||||
if (rebuild_binormal)
|
||||
{
|
||||
LLVector3 binormal = vf.mVertices[i].mBinormal * mat_normal;
|
||||
LLVector3 binormal = vf_binormal * mat_normal;
|
||||
binormal.normVec();
|
||||
*binormals++ = binormal;
|
||||
}
|
||||
|
||||
if (rebuild_weights && vf.mWeights.size() > i)
|
||||
{
|
||||
*weights++ = vf.mWeights[i];
|
||||
(*weights++) = vf.mWeights[i];
|
||||
}
|
||||
|
||||
if (rebuild_color)
|
||||
{
|
||||
if (bake_sunlight)
|
||||
{
|
||||
LLVector3 normal = vf.mVertices[i].mNormal * mat_normal;
|
||||
LLVector3 normal = vf_normal * mat_normal;
|
||||
normal.normVec();
|
||||
|
||||
F32 da = normal * gPipeline.mSunDir;
|
||||
|
|
|
|||
|
|
@ -852,6 +852,7 @@ S8 LLImagePreviewSculpted::getType() const
|
|||
|
||||
void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
|
||||
{
|
||||
#if 0 //VECTORIZE THIS
|
||||
mCameraDistance = distance;
|
||||
mCameraZoom = 1.f;
|
||||
mCameraPitch = 0.f;
|
||||
|
|
@ -892,6 +893,7 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
|
|||
{
|
||||
*(index_strider++) = vf.mIndices[i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -901,7 +903,7 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
|
|||
BOOL LLImagePreviewSculpted::render()
|
||||
{
|
||||
mNeedsUpdate = FALSE;
|
||||
|
||||
#if 0 //VECTORIZE THIS
|
||||
LLGLSUIDefault def;
|
||||
LLGLDisable no_blend(GL_BLEND);
|
||||
LLGLEnable cull(GL_CULL_FACE);
|
||||
|
|
@ -959,7 +961,7 @@ BOOL LLImagePreviewSculpted::render()
|
|||
mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0);
|
||||
|
||||
gGL.popMatrix();
|
||||
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -271,6 +271,7 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
|
|||
LLVector3 upper_left = icon_position - (x_scale * 0.5f) + y_scale;
|
||||
LLVector3 upper_right = icon_position + (x_scale * 0.5f) + y_scale;
|
||||
|
||||
#if 0 //VECTORIZE THIS
|
||||
|
||||
F32 t = 0.f;
|
||||
LLVector3 dir = end-start;
|
||||
|
|
@ -284,6 +285,7 @@ BOOL LLHUDIcon::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,6 +206,8 @@ BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
|
|||
gGL.end();
|
||||
}
|
||||
|
||||
#if 0 //VECTORIZE THIS
|
||||
|
||||
LLVector3 dir = end-start;
|
||||
F32 t = 0.f;
|
||||
|
||||
|
|
@ -218,6 +220,9 @@ BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -788,13 +788,14 @@ BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)
|
|||
LLMatrix4 render_mat(vo_volume->getRenderRotation(), LLVector4(vo_volume->getRenderPosition()));
|
||||
|
||||
num_faces = volume->getNumVolumeFaces();
|
||||
//VECTORIZE THIS
|
||||
for (i = 0; i < num_faces; i++)
|
||||
{
|
||||
const LLVolumeFace& face = volume->getVolumeFace(i);
|
||||
|
||||
for (U32 v = 0; v < face.mVertices.size(); v++)
|
||||
for (U32 v = 0; v < face.mNumVertices; v++)
|
||||
{
|
||||
LLVector4 vec = LLVector4(face.mVertices[v].mPosition) * mat;
|
||||
LLVector4 vec = LLVector4(face.mPositions+v*4) * mat;
|
||||
|
||||
if (drawablep->isActive())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -640,6 +640,7 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
|
|||
position.mV[2] += blade_height;
|
||||
v[3] = v1 = position + mRegionp->getOriginAgent();
|
||||
|
||||
#if 0 //VECTORIZE THIS
|
||||
|
||||
F32 a,b,t;
|
||||
|
||||
|
|
@ -703,6 +704,7 @@ BOOL LLVOGrass::lineSegmentIntersect(const LLVector3& start, const LLVector3& en
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#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)
|
||||
|
|
@ -217,7 +218,7 @@ void LLVOTextBubble::updateFaceSize(S32 idx)
|
|||
else
|
||||
{
|
||||
const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
|
||||
face->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
|
||||
face->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -235,19 +236,37 @@ void LLVOTextBubble::getGeometry(S32 idx,
|
|||
|
||||
const LLVolumeFace& face = getVolume()->getVolumeFace(idx);
|
||||
|
||||
LLVector3 pos = getPositionAgent();
|
||||
LLVector4a pos;
|
||||
pos.load3(getPositionAgent().mV);
|
||||
|
||||
LLVector4a scale;
|
||||
scale.load3(getScale().mV);
|
||||
|
||||
LLColor4U color = LLColor4U(getTE(idx)->getColor());
|
||||
U32 offset = mDrawable->getFace(idx)->getGeomIndex();
|
||||
|
||||
for (U32 i = 0; i < face.mVertices.size(); i++)
|
||||
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);
|
||||
LLVector4a::memcpyNonAliased16((F32*) dst_tc, (F32*) src_tc, face.mNumVertices*2);
|
||||
|
||||
|
||||
for (U32 i = 0; i < face.mNumVertices; i++)
|
||||
{
|
||||
*verticesp++ = face.mVertices[i].mPosition.scaledVec(getScale()) + pos;
|
||||
*normalsp++ = face.mVertices[i].mNormal;
|
||||
*texcoordsp++ = face.mVertices[i].mTexCoord;
|
||||
LLVector4a t;
|
||||
t.setMul(src_pos[i], scale);
|
||||
dst_pos[i].setAdd(t, pos);
|
||||
*colorsp++ = color;
|
||||
}
|
||||
|
||||
for (U32 i = 0; i < face.mIndices.size(); i++)
|
||||
for (U32 i = 0; i < face.mNumIndices; i++)
|
||||
{
|
||||
*indicesp++ = face.mIndices[i] + offset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
#include "llflexibleobject.h"
|
||||
#include "llsky.h"
|
||||
#include "lltexturefetch.h"
|
||||
#include "llvector4a.h"
|
||||
#include "llviewercamera.h"
|
||||
#include "llviewertexturelist.h"
|
||||
#include "llviewerobjectlist.h"
|
||||
|
|
@ -1601,14 +1602,8 @@ void LLVOVolume::updateFaceSize(S32 idx)
|
|||
else
|
||||
{
|
||||
const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx);
|
||||
if (LLPipeline::sUseTriStrips)
|
||||
{
|
||||
facep->setSize(vol_face.mVertices.size(), vol_face.mTriStrip.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size());
|
||||
}
|
||||
facep->setSize(vol_face.mNumVertices, vol_face.mNumIndices);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1863,21 +1858,25 @@ bool LLVOVolume::hasMedia() const
|
|||
LLVector3 LLVOVolume::getApproximateFaceNormal(U8 face_id)
|
||||
{
|
||||
LLVolume* volume = getVolume();
|
||||
LLVector3 result;
|
||||
LLVector4a result;
|
||||
result.clear();
|
||||
|
||||
LLVector3 ret;
|
||||
|
||||
if (volume && face_id < volume->getNumVolumeFaces())
|
||||
{
|
||||
const LLVolumeFace& face = volume->getVolumeFace(face_id);
|
||||
for (S32 i = 0; i < (S32)face.mVertices.size(); ++i)
|
||||
for (S32 i = 0; i < (S32)face.mNumVertices; ++i)
|
||||
{
|
||||
result += face.mVertices[i].mNormal;
|
||||
result.add(*((LLVector4a*) face.mNormals+i*4));
|
||||
}
|
||||
|
||||
result = volumeDirectionToAgent(result);
|
||||
result.normVec();
|
||||
LLVector3 ret((F32*) &result.mQ);
|
||||
ret = volumeDirectionToAgent(ret);
|
||||
ret.normVec();
|
||||
}
|
||||
|
||||
return result;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void LLVOVolume::requestMediaDataUpdate(bool isNew)
|
||||
|
|
@ -3032,7 +3031,7 @@ F32 LLVOVolume::getBinRadius()
|
|||
for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i)
|
||||
{
|
||||
const LLVolumeFace& face = volume->getVolumeFace(i);
|
||||
vert_count += face.mVertices.size();
|
||||
vert_count += face.mNumVertices;
|
||||
}
|
||||
|
||||
scale = 1.f/llmax(vert_count/1024.f, 1.f);
|
||||
|
|
|
|||
Loading…
Reference in New Issue