diff options
| author | Dave Parks <davep@lindenlab.com> | 2023-03-07 09:39:50 -0600 | 
|---|---|---|
| committer | Dave Parks <davep@lindenlab.com> | 2023-03-07 09:39:50 -0600 | 
| commit | dd17170abb08cb4ec8ebc8c7e5f38d3ad1519538 (patch) | |
| tree | 1ecbcab7e68354b01632843a9c8777a1c435fd3c | |
| parent | b9b913a60ada97fc61bf2176e443dc72c8359ccb (diff) | |
| parent | c51f8b82482f7bd8c45ccc65733dd5d5eef2f076 (diff) | |
Merge branch 'DRTVWR-559' of github.com:secondlife/viewer into DRTVWR-559
| -rw-r--r-- | indra/llcommon/llerror.h | 2 | ||||
| -rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 3 | ||||
| -rw-r--r-- | indra/newview/llface.cpp | 120 | 
3 files changed, 80 insertions, 45 deletions
| diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index d06c0e2132..b7dec3cb7f 100644 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -82,9 +82,11 @@ const int LL_ERR_NOERR = 0;  #ifdef SHOW_ASSERT  #define llassert(func)			llassert_always_msg(func, #func) +#define llassert_msg(func, msg)	llassert_always_msg(func, msg)  #define llverify(func)			llassert_always_msg(func, #func)  #else  #define llassert(func) +#define llassert_msg(func, msg)  #define llverify(func)			do {if (func) {}} while(0)  #endif diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 9fb5eef3a2..e5e6882ba1 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1363,7 +1363,8 @@ void LLVertexBuffer::setBuffer()      U32 data_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask;      // this Vertex Buffer must provide all necessary attributes for currently bound shader -    llassert((data_mask & mTypeMask) == data_mask); +    llassert_msg((data_mask & mTypeMask) == data_mask, +        "Attribute mask mismatch! mTypeMask should be a superset of data_mask.  data_mask: 0x" << std::hex << data_mask << " mTypeMask: 0x" << mTypeMask << std::dec);      if (sGLRenderBuffer != mGLBuffer)      { diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index d05e367c12..87abb06285 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -1322,39 +1322,75 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  		}  	} + +    LLMaterial* mat = tep->getMaterialParams().get(); +    LLGLTFMaterial* gltf_mat = tep->getGLTFRenderMaterial(); +  	F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0; -	bool do_xform = false; -	if (rebuild_tcoord) -	{ -		if (tep) -		{ -			r  = tep->getRotation(); -			os = tep->mOffsetS; -			ot = tep->mOffsetT; -			ms = tep->mScaleS; -			mt = tep->mScaleT; -			cos_ang = cos(r); -			sin_ang = sin(r); - -			if (cos_ang != 1.f ||  -				sin_ang != 0.f || -				os != 0.f || -				ot != 0.f || -				ms != 1.f || -				mt != 1.f) -			{ -				do_xform = true; -			} -			else -			{ -				do_xform = false; -			}	 -		} -		else -		{ -			do_xform = false; -		} -	} + +    constexpr S32 XFORM_NONE = 0; +    constexpr S32 XFORM_BLINNPHONG_COLOR = 1; +    constexpr S32 XFORM_BLINNPHONG_NORMAL = 1 << 1; +    constexpr S32 XFORM_BLINNPHONG_SPECULAR = 1 << 2; + +    S32 xforms = XFORM_NONE; +    // For GLTF, transforms will be applied later +    if (rebuild_tcoord && tep && !gltf_mat) +    { +        r  = tep->getRotation(); +        os = tep->mOffsetS; +        ot = tep->mOffsetT; +        ms = tep->mScaleS; +        mt = tep->mScaleT; +        cos_ang = cos(r); +        sin_ang = sin(r); + +        if (cos_ang != 1.f || +            sin_ang != 0.f || +            os != 0.f || +            ot != 0.f || +            ms != 1.f || +            mt != 1.f) +        { +            xforms |= XFORM_BLINNPHONG_COLOR; +        } +        if (mat) +        { +            F32 r_norm = 0, os_norm = 0, ot_norm = 0, ms_norm = 0, mt_norm = 0, cos_ang_norm = 0, sin_ang_norm = 0; +            mat->getNormalOffset(os_norm, ot_norm); +            mat->getNormalRepeat(ms_norm, mt_norm); +            r_norm = mat->getNormalRotation(); +            cos_ang_norm = cos(r_norm); +            sin_ang_norm = sin(r_norm); +            if (cos_ang_norm != 1.f || +                sin_ang_norm != 0.f || +                os_norm != 0.f || +                ot_norm != 0.f || +                ms_norm != 1.f || +                mt_norm != 1.f) +            { +                xforms |= XFORM_BLINNPHONG_NORMAL; +            } +        } +        if (mat) +        { +            F32 r_spec = 0, os_spec = 0, ot_spec = 0, ms_spec = 0, mt_spec = 0, cos_ang_spec = 0, sin_ang_spec = 0; +            mat->getSpecularOffset(os_spec, ot_spec); +            mat->getSpecularRepeat(ms_spec, mt_spec); +            r_spec = mat->getSpecularRotation(); +            cos_ang_spec = cos(r_spec); +            sin_ang_spec = sin(r_spec); +            if (cos_ang_spec != 1.f || +                sin_ang_spec != 0.f || +                os_spec != 0.f || +                ot_spec != 0.f || +                ms_spec != 1.f || +                mt_spec != 1.f) +            { +                xforms |= XFORM_BLINNPHONG_SPECULAR; +            } +        } +    }      const LLMeshSkinInfo* skin = nullptr;      LLMatrix4a mat_vert; @@ -1495,7 +1531,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  					sin_ang = 0.f;  					ms = mt = 1.f; -					do_xform = false; +                    xforms = XFORM_NONE;  				}  				if (getVirtualSize() >= MIN_TEX_ANIM_SIZE) // || isState(LLFace::RIGGED)) @@ -1507,15 +1543,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  			LLVector4a scalea;  			scalea.load3(scale.mV); -			LLMaterial* mat = tep->getMaterialParams().get(); -            LLGLTFMaterial* gltf_mat = tep->getGLTFRenderMaterial(); - -            if (gltf_mat) -            { -                // Transforms will be applied later -                do_xform = false; -            } -  			bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1);  			if ((mat || gltf_mat) && !do_bump) @@ -1536,7 +1563,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,                      LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("getGeometryVolume - texgen");  					if (!do_tex_mat)  					{ -						if (!do_xform) +						if (xforms == XFORM_NONE)  						{                              LL_PROFILE_ZONE_NAMED_CATEGORY_FACE("ggv - texgen 1");  							S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF; @@ -1615,7 +1642,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  							*tex_coords0++ = tc;	  						}  					} -					else if (do_xform) +					else if (xforms != XFORM_NONE)  					{  						for (S32 i = 0; i < num_vertices; i++)  						{	 @@ -1662,12 +1689,15 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  				for (U32 ch = 0; ch < 3; ++ch)  				{ +                    S32 xform_channel = XFORM_NONE;  					switch (ch)  					{  						case 0:  +                            xform_channel = XFORM_BLINNPHONG_COLOR;  							mVertexBuffer->getTexCoord0Strider(dst, mGeomIndex, mGeomCount);   							break;  						case 1: +                            xform_channel = XFORM_BLINNPHONG_NORMAL;  							if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))  							{  								mVertexBuffer->getTexCoord1Strider(dst, mGeomIndex, mGeomCount); @@ -1688,6 +1718,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  							}  							break;  						case 2: +                            xform_channel = XFORM_BLINNPHONG_SPECULAR;  							if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD2))  							{  								mVertexBuffer->getTexCoord2Strider(dst, mGeomIndex, mGeomCount); @@ -1707,6 +1738,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,  							}  							break;  					} +                    const bool do_xform = (xforms & xform_channel) != XFORM_NONE;                      for (S32 i = 0; i < num_vertices; i++) | 
