From 29216ac5e725254c48711737f5c22d2ad3e5e4a2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 23 Sep 2013 13:43:01 -0700 Subject: [PATCH 1/2] MAINT-3179 fix bad indexing of position info generating false alarms on range checks, issue with free of data now allocated contig with positions instead, and added copious amounts of llwarns to error return sites so 'invalid element' will be a reason to read the log and not a tease. --- indra/llmath/llvolume.cpp | 6 ++++-- indra/llprimitive/llmodel.cpp | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index de960e5d95..2b865b4a8e 100755 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -4827,13 +4827,15 @@ void LLVolumeFace::optimize(F32 angle_cutoff) if (angle_cutoff > 1.f && !mNormals) { - ll_aligned_free_16(new_face.mNormals); + // Now alloc'd with positions + //ll_aligned_free_16(new_face.mNormals); new_face.mNormals = NULL; } if (!mTexCoords) { - ll_aligned_free_16(new_face.mTexCoords); + // Now alloc'd with positions + //ll_aligned_free_16(new_face.mTexCoords); new_face.mTexCoords = NULL; } diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 37f0bfcbb8..34e0483a83 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -166,6 +166,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if ( !get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source) || !pos_source ) { + llwarns << "Could not find dom sources for basic geo data; invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -201,6 +202,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (((i + pos_offset) > index_count) || ((idx[i+pos_offset]*3+2) > vertex_count)) { + llwarns << "Out of range index data; invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -210,6 +212,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (!cv.getPosition().isFinite3()) { + llwarns << "Nan positional data, invalid model." << llendl; return LLModel::BAD_ELEMENT; } } @@ -222,6 +225,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (((i + tc_offset) > index_count) || ((idx[i+tc_offset]*2+1) > tc_count)) { + llwarns << "Out of range TC indices." << llendl; return LLModel::BAD_ELEMENT; } @@ -242,6 +246,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa if (((i + norm_offset) > index_count) || ((idx[i+norm_offset]*3+2) > norm_count)) { + llwarns << "Found out of range norm indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -380,6 +385,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (!get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source)) { + llwarns << "Could not get DOM sources for basic geo data, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -430,9 +436,10 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac { // guard against model data specifiying out of range indices or verts // - if (((i + pos_offset) > index_count) - || ((idx[i+pos_offset]*3+2) > vertex_count)) + if (((cur_idx + pos_offset) > index_count) + || ((idx[cur_idx+pos_offset]*3+2) > vertex_count)) { + llwarns << "Out of range position indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -455,6 +462,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (((cur_idx + tc_offset) > index_count) || ((idx[cur_idx+tc_offset]*2+1) > tc_count)) { + llwarns << "Out of range TC indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -475,6 +483,7 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector& fac if (((cur_idx + norm_offset) > index_count) || ((idx[cur_idx+norm_offset]*3+2) > norm_count)) { + llwarns << "Out of range norm indices, invalid model." << llendl; return LLModel::BAD_ELEMENT; } @@ -653,6 +662,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domVertices* vertices = (domVertices*) elem.cast(); if (!vertices) { + llwarns << "Could not find vertex source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } domInputLocal_Array& v_inp = vertices->getInput_array(); @@ -666,6 +676,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domSource* src = (domSource*) elem.cast(); if (!src) { + llwarns << "Could not find DOM source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } v = &(src->getFloat_array()->getValue()); @@ -681,6 +692,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domSource* src = (domSource*) elem.cast(); if (!src) { + llwarns << "Could not find DOM source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } n = &(src->getFloat_array()->getValue()); @@ -693,6 +705,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector& fac domSource* src = (domSource*) elem.cast(); if (!src) { + llwarns << "Could not find DOM source, invalid model." << llendl; return LLModel::BAD_ELEMENT; } t = &(src->getFloat_array()->getValue()); From 71e986b0597341f9fcfb28f71bfbc46d65f08d88 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 23 Sep 2013 14:49:10 -0700 Subject: [PATCH 2/2] NORSPEC-285 fix merge error with attenuation on alpha masquerading as this norspec from wayback --- indra/llrender/llrender.cpp | 6 +++--- indra/newview/pipeline.cpp | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index aa94110f4d..0ac30b4d63 100755 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -832,8 +832,8 @@ LLLightState::LLLightState(S32 index) : mIndex(index), mEnabled(false), mConstantAtten(1.f), - mLinearAtten(1.f), - mQuadraticAtten(1.f), + mLinearAtten(0.f), + mQuadraticAtten(0.f), mSpotExponent(0.f), mSpotCutoff(180.f) { @@ -1150,7 +1150,7 @@ void LLRender::syncLightState() position[i] = light->mPosition; direction[i] = light->mSpotDirection; - attenuation[i].set(1.f/light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[3]); + attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[3]); diffuse[i].set(light->mDiffuse.mV); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 9f808776ec..b0c73d0304 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -122,6 +122,10 @@ //#define DEBUG_INDICES #endif +// Expensive and currently broken +// +#define MATERIALS_IN_REFLECTIONS 0 + bool gShiftFrame = false; //cached settings @@ -8477,6 +8481,7 @@ void LLPipeline::renderDeferredLighting() } gDeferredSunProgram.uniform3fv(sOffset, slice, offset); + gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight()); { LLGLDisable blend(GL_BLEND);