diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index 0086ef9bb..77f27ae86 100644 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp @@ -270,9 +270,9 @@ void LLCubeMap::setMatrix(S32 stage) gGL.getTexUnit(stage)->activate(); } - LLVector3 x(LLVector3d(gGLModelView+0)); - LLVector3 y(LLVector3d(gGLModelView+4)); - LLVector3 z(LLVector3d(gGLModelView+8)); + LLVector3 x(gGLModelView+0); + LLVector3 y(gGLModelView+4); + LLVector3 z(gGLModelView+8); LLMatrix3 mat3; mat3.setRows(x,y,z); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 5383a278d..b05dd4a06 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -44,11 +44,12 @@ LLRender gGL; // Handy copies of last good GL matrices -F64 gGLModelView[16]; -F64 gGLLastModelView[16]; -F64 gGLLastProjection[16]; -F64 gGLProjection[16]; -S32 gGLViewport[4]; +//Would be best to migrate these to LLMatrix4a and LLVector4a, but that's too divergent right now. +LL_ALIGN_16(F32 gGLModelView[16]); +LL_ALIGN_16(F32 gGLLastModelView[16]); +LL_ALIGN_16(F32 gGLLastProjection[16]); +LL_ALIGN_16(F32 gGLProjection[16]); +LL_ALIGN_16(S32 gGLViewport[4]); U32 LLTexUnit::sWhiteTexture = 0; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 09e0f8905..1a9e6a1af 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -408,10 +408,10 @@ private: F32 mMaxAnisotropy; }; -extern F64 gGLModelView[16]; -extern F64 gGLLastModelView[16]; -extern F64 gGLLastProjection[16]; -extern F64 gGLProjection[16]; +extern F32 gGLModelView[16]; +extern F32 gGLLastModelView[16]; +extern F32 gGLLastProjection[16]; +extern F32 gGLProjection[16]; extern S32 gGLViewport[4]; extern LLRender gGL; diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index e32d1b70d..2d0e7cf97 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -462,7 +462,7 @@ void LLRenderPass::applyModelMatrix(LLDrawInfo& params) if (params.mModelMatrix != gGLLastMatrix) { gGLLastMatrix = params.mModelMatrix; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); if (params.mModelMatrix) { glMultMatrixf((GLfloat*) params.mModelMatrix->mMatrix); diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp index 835b19918..4e604e545 100644 --- a/indra/newview/lldrawpooltree.cpp +++ b/indra/newview/lldrawpooltree.cpp @@ -233,13 +233,10 @@ void LLDrawPoolTree::renderTree(BOOL selecting) } gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); //glPushMatrix(); - F32 mat[16]; - for (U32 i = 0; i < 16; i++) - mat[i] = (F32) gGLModelView[i]; - LLMatrix4 matrix(mat); + LLMatrix4 matrix(gGLModelView); // Translate to tree base HACK - adjustment in Z plants tree underground const LLVector3 &pos_agent = treep->getPositionAgent(); diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp index 9b5633872..9b8d78113 100644 --- a/indra/newview/llhudrender.cpp +++ b/indra/newview/llhudrender.cpp @@ -104,14 +104,24 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, //get the render_pos in screen space F64 winX, winY, winZ; - LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); + const LLRect& world_view_rect = gViewerWindow->getWorldViewRectRaw(); S32 viewport[4]; viewport[0] = world_view_rect.mLeft; viewport[1] = world_view_rect.mBottom; viewport[2] = world_view_rect.getWidth(); viewport[3] = world_view_rect.getHeight(); + + F64 mdlv[16]; + F64 proj[16]; + + for (U32 i = 0; i < 16; i++) + { + mdlv[i] = (F64) gGLModelView[i]; + proj[i] = (F64) gGLProjection[i]; + } + gluProject(render_pos.mV[0], render_pos.mV[1], render_pos.mV[2], - gGLModelView, gGLProjection, (GLint*) viewport, + mdlv, proj, (GLint*) viewport, &winX, &winY, &winZ); //fonts all render orthographically, set up projection`` diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 33dcf21d8..d8c4d0ced 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -4868,9 +4868,6 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**) LLSelectMgr::getInstance()->highlightObjectAndFamily(objects); } - -extern LLGLdouble gGLModelView[16]; - void LLSelectMgr::updateSilhouettes() { S32 num_sils_genned = 0; @@ -5632,13 +5629,13 @@ void LLSelectNode::renderOneWireframe(const LLColor4& color) if (drawable->isActive()) { - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); glMultMatrixf((F32*) objectp->getRenderMatrix().mMatrix); } else if (!is_hud_object) { glLoadIdentity(); - glMultMatrixd(gGLModelView); + glMultMatrixf(gGLModelView); LLVector3 trans = objectp->getRegion()->getOriginAgent(); glTranslatef(trans.mV[0], trans.mV[1], trans.mV[2]); } @@ -5721,7 +5718,7 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) if (!is_hud_object) { glLoadIdentity(); - glMultMatrixd(gGLModelView); + glMultMatrixf(gGLModelView); } diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 2bce7e36d..de3e1446d 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2911,7 +2911,7 @@ void renderRaycast(LLDrawable* drawablep) // draw intersection point glPushMatrix(); - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); LLVector3 translate = gDebugRaycastIntersection; glTranslatef(translate.mV[0], translate.mV[1], translate.mV[2]); LLCoordFrame orient; @@ -3004,7 +3004,7 @@ public: gGL.flush(); glPushMatrix(); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); renderVisibility(group, mCamera); stop_glerror(); gGLLastMatrix = NULL; diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index d58a4d0f5..2089ef3cd 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -219,8 +219,15 @@ void LLViewerCamera::calcProjection(const F32 far_distance) const void LLViewerCamera::updateFrustumPlanes(LLCamera& camera, BOOL ortho, BOOL zflip, BOOL no_hacks) { GLint* viewport = (GLint*) gGLViewport; - GLdouble* model = gGLModelView; - GLdouble* proj = gGLProjection; + F64 model[16]; + F64 proj[16]; + + for (U32 i = 0; i < 16; i++) + { + model[i] = (F64) gGLModelView[i]; + proj[i] = (F64) gGLProjection[i]; + } + GLdouble objX,objY,objZ; LLVector3 frust[8]; @@ -444,11 +451,20 @@ void LLViewerCamera::setPerspective(BOOL for_selection, // screen coordinates to the agent's region. void LLViewerCamera::projectScreenToPosAgent(const S32 screen_x, const S32 screen_y, LLVector3* pos_agent) const { - GLdouble x, y, z; + + F64 mdlv[16]; + F64 proj[16]; + + for (U32 i = 0; i < 16; i++) + { + mdlv[i] = (F64) gGLModelView[i]; + proj[i] = (F64) gGLProjection[i]; + } + gluUnProject( GLdouble(screen_x), GLdouble(screen_y), 0.0, - gGLModelView, gGLProjection, (GLint*)gGLViewport, + mdlv, proj, (GLint*)gGLViewport, &x, &y, &z ); @@ -478,15 +494,23 @@ BOOL LLViewerCamera::projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoord } } - LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); + const LLRect& world_view_rect = gViewerWindow->getWorldViewRectRaw(); S32 viewport[4]; viewport[0] = world_view_rect.mLeft; viewport[1] = world_view_rect.mBottom; viewport[2] = world_view_rect.getWidth(); viewport[3] = world_view_rect.getHeight(); + F64 mdlv[16]; + F64 proj[16]; + + for (U32 i = 0; i < 16; i++) + { + mdlv[i] = (F64) gGLModelView[i]; + proj[i] = (F64) gGLProjection[i]; + } if (GL_TRUE == gluProject(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ], - gGLModelView, gGLProjection, (GLint*)viewport, + mdlv, proj, (GLint*)viewport, &x, &y, &z)) { // convert screen coordinates to virtual UI coordinates @@ -581,16 +605,26 @@ BOOL LLViewerCamera::projectPosAgentToScreenEdge(const LLVector3 &pos_agent, in_front = FALSE; } - LLRect world_view_rect = gViewerWindow->getWorldViewRectRaw(); + const LLRect& world_view_rect = gViewerWindow->getWorldViewRectRaw(); S32 viewport[4]; viewport[0] = world_view_rect.mLeft; viewport[1] = world_view_rect.mBottom; viewport[2] = world_view_rect.getWidth(); viewport[3] = world_view_rect.getHeight(); GLdouble x, y, z; // object's window coords, GL-style + + F64 mdlv[16]; + F64 proj[16]; + + for (U32 i = 0; i < 16; i++) + { + mdlv[i] = (F64) gGLModelView[i]; + proj[i] = (F64) gGLProjection[i]; + } + if (GL_TRUE == gluProject(pos_agent.mV[VX], pos_agent.mV[VY], - pos_agent.mV[VZ], gGLModelView, - gGLProjection, (GLint*)viewport, + pos_agent.mV[VZ], mdlv, + proj, (GLint*)viewport, &x, &y, &z)) { x /= gViewerWindow->getDisplayScale().mV[VX]; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 0571badb8..7a4ad0a15 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1200,7 +1200,7 @@ void render_ui(F32 zoom_factor, int subfield, bool tiling) if (!gSnapshot) { glPushMatrix(); - glLoadMatrixd(gGLLastModelView); + glLoadMatrixf(gGLLastModelView); glh_set_current_modelview(glh_copy_matrix(gGLLastModelView)); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f67fd62d6..b68df431a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -202,13 +202,10 @@ U32 nhpo2(U32 v) return r; } -glh::matrix4f glh_copy_matrix(GLdouble* src) +glh::matrix4f glh_copy_matrix(F32* src) { glh::matrix4f ret; - for (U32 i = 0; i < 16; i++) - { - ret.m[i] = (F32) src[i]; - } + ret.set_value(src); return ret; } @@ -232,7 +229,7 @@ glh::matrix4f glh_get_last_projection() return glh_copy_matrix(gGLLastProjection); } -void glh_copy_matrix(const glh::matrix4f& src, GLdouble* dst) +void glh_copy_matrix(const glh::matrix4f& src, F32* dst) { for (U32 i = 0; i < 16; i++) { @@ -1920,11 +1917,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl glMatrixMode(GL_PROJECTION); glPushMatrix(); - glLoadMatrixd(gGLLastProjection); + glLoadMatrixf(gGLLastProjection); glMatrixMode(GL_MODELVIEW); glPushMatrix(); gGLLastMatrix = NULL; - glLoadMatrixd(gGLLastModelView); + glLoadMatrixf(gGLLastModelView); LLVertexBuffer::unbind(); @@ -3536,7 +3533,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) { occlude = FALSE; gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); LLGLSLShader::bindNoShader(); doOcclusion(camera); } @@ -3547,7 +3544,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) LLFastTimer t(LLFastTimer::FTM_POOLRENDER); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); for( S32 i = 0; i < poolp->getNumPasses(); i++ ) { @@ -3596,13 +3593,13 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) LLVertexBuffer::unbind(); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); if (occlude) { occlude = FALSE; gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); LLGLSLShader::bindNoShader(); doOcclusion(camera); } @@ -3731,7 +3728,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) LLFastTimer t(LLFastTimer::FTM_POOLRENDER); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); for( S32 i = 0; i < poolp->getNumDeferredPasses(); i++ ) { @@ -3781,7 +3778,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) } gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); gGL.setColorMask(true, false); } @@ -3814,7 +3811,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) { occlude = FALSE; gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); LLGLSLShader::bindNoShader(); doOcclusion(camera); gGL.setColorMask(true, false); @@ -3826,7 +3823,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) LLFastTimer t(LLFastTimer::FTM_POOLRENDER); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); for( S32 i = 0; i < poolp->getNumPostDeferredPasses(); i++ ) { @@ -3876,17 +3873,17 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) } gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); if (occlude) { occlude = FALSE; gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); LLGLSLShader::bindNoShader(); doOcclusion(camera); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); } } @@ -3910,7 +3907,7 @@ void LLPipeline::renderGeomShadow(LLCamera& camera) if (hasRenderType(poolp->getType()) && poolp->getNumShadowPasses() > 0) { gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); for( S32 i = 0; i < poolp->getNumShadowPasses(); i++ ) { @@ -3951,7 +3948,7 @@ void LLPipeline::renderGeomShadow(LLCamera& camera) } gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); } @@ -3982,7 +3979,7 @@ void LLPipeline::renderDebug() gGL.color4f(1,1,1,1); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); gGL.setColorMask(true, false); bool hud_only = hasRenderType(LLPipeline::RENDER_TYPE_HUD); @@ -4193,7 +4190,7 @@ void LLPipeline::renderDebug() gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); gGL.pushMatrix(); - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); gGLLastMatrix = NULL; for (LLSpatialGroup::sg_vector_t::iterator iter = mGroupQ2.begin(); iter != mGroupQ2.end(); ++iter) @@ -5797,10 +5794,10 @@ void LLPipeline::resetVertexBuffers() void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture) { assertInitialized(); - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); gGLLastMatrix = NULL; mSimplePool->pushBatches(type, mask); - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); gGLLastMatrix = NULL; } @@ -6687,7 +6684,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen { cube_map->enable(channel); cube_map->bind(); - F64* m = gGLModelView; + F32* m = gGLModelView; F32 mat[] = { m[0], m[1], m[2], @@ -8075,7 +8072,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera glLoadMatrixf(proj.m); glMatrixMode(GL_MODELVIEW); glPushMatrix(); - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); stop_glerror(); gGLLastMatrix = NULL; @@ -8138,7 +8135,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera //glCullFace(GL_BACK); gGLLastMatrix = NULL; - glLoadMatrixd(gGLModelView); + glLoadMatrixf(gGLModelView); doOcclusion(shadow_cam); if (use_shader) diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index d3fea1ff2..00c1c7f84 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -71,7 +71,7 @@ BOOL compute_min_max(LLMatrix4& box, LLVector2& min, LLVector2& max); // Shouldn bool LLRayAABB(const LLVector3 ¢er, const LLVector3 &size, const LLVector3& origin, const LLVector3& dir, LLVector3 &coord, F32 epsilon = 0); BOOL setup_hud_matrices(); // use whole screen to render hud BOOL setup_hud_matrices(const LLRect& screen_region); // specify portion of screen (in pixels) to render hud attachments from (for picking) -glh::matrix4f glh_copy_matrix(GLdouble* src); +glh::matrix4f glh_copy_matrix(F32* src); glh::matrix4f glh_get_current_modelview(); void glh_set_current_modelview(const glh::matrix4f& mat); glh::matrix4f glh_get_current_projection();