diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llsceneview.cpp | 173 | ||||
-rw-r--r-- | indra/newview/llviewerobject.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 2 | ||||
-rwxr-xr-x | indra/newview/pipeline.cpp | 63 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 2 |
5 files changed, 221 insertions, 22 deletions
diff --git a/indra/newview/llsceneview.cpp b/indra/newview/llsceneview.cpp index 25a7373018..8e8fc9dd25 100644 --- a/indra/newview/llsceneview.cpp +++ b/indra/newview/llsceneview.cpp @@ -77,13 +77,21 @@ void LLSceneView::draw() //object sizes std::vector<F32> size[2]; + //triangle counts std::vector<S32> triangles[2]; std::vector<S32> visible_triangles[2]; - S32 total_visible_triangles[] = {0, 0}; S32 total_triangles[] = {0, 0}; + + //streaming cost + std::vector<F32> streaming_cost[2]; + F32 total_streaming[] = { 0.f, 0.f }; + //physics cost + std::vector<F32> physics_cost[2]; + F32 total_physics[] = { 0.f, 0.f }; + U32 object_count = 0; LLViewerRegion* region = gAgent.getRegion(); @@ -113,6 +121,14 @@ void LLSceneView::draw() visible_triangles[idx].push_back(visible); triangles[idx].push_back(high_triangles); + + F32 streaming = object->getStreamingCost(); + total_streaming[idx] += streaming; + streaming_cost[idx].push_back(streaming); + + F32 physics = object->getPhysicsCost(); + total_physics[idx] += physics; + physics_cost[idx].push_back(physics); } } } @@ -123,6 +139,13 @@ void LLSceneView::draw() "Attachment" }; + S32 graph_pos[4]; + + for (U32 i = 0; i < 4; ++i) + { + graph_pos[i] = new_rect.getHeight()/4*(i+1); + } + for (U32 idx = 0; idx < 2; idx++) { if (!size[idx].empty()) @@ -135,11 +158,11 @@ void LLSceneView::draw() if (idx == 0) { - size_rect = LLRect(margin, new_rect.getHeight()/2-margin*2, new_rect.getWidth()/2-margin, margin*2); + size_rect = LLRect(margin, graph_pos[0]-margin, new_rect.getWidth()/2-margin, margin*2); } else { - size_rect = LLRect(margin+new_rect.getWidth()/2, new_rect.getHeight()/2-margin*2, new_rect.getWidth()-margin, margin*2); + size_rect = LLRect(margin+new_rect.getWidth()/2, graph_pos[0]-margin, new_rect.getWidth()-margin, margin*2); } gl_rect_2d(size_rect, LLColor4::white, false); @@ -181,7 +204,7 @@ void LLSceneView::draw() gGL.end(); gGL.flush(); - std::string label = llformat("%s Object Sizes (m) -- Min: %.1f Max: %.1f Mean: %.1f Median: %.1f -- %d samples", + std::string label = llformat("%s Object Sizes (m) -- [%.1f, %.1f] Mean: %.1f Median: %.1f -- %d samples", category[idx], size_domain[0], size_domain[1], total/count, size[idx][count/2], count); LLFontGL::getFontMonospace()->renderUTF8(label, @@ -201,11 +224,11 @@ void LLSceneView::draw() LLRect tri_rect; if (idx == 0) { - tri_rect = LLRect(margin, new_rect.getHeight()-margin*2, new_rect.getWidth()/2-margin, new_rect.getHeight()/2 + margin); + tri_rect = LLRect(margin, graph_pos[1]-margin, new_rect.getWidth()/2-margin, graph_pos[0]+margin); } else { - tri_rect = LLRect(new_rect.getWidth()/2+margin, new_rect.getHeight()-margin*2, new_rect.getWidth()-margin, new_rect.getHeight()/2 + margin); + tri_rect = LLRect(new_rect.getWidth()/2+margin, graph_pos[1]-margin, new_rect.getWidth()-margin, graph_pos[0]+margin); } gl_rect_2d(tri_rect, LLColor4::white, false); @@ -256,8 +279,8 @@ void LLSceneView::draw() total_visible += tri_count; } - std::string label = llformat("%s Object Triangle Counts (Ktris) -- Min: %.2f Max: %.2f Mean: %.2f Median: %.2f (%.2f/%.2f visible) -- %d samples", - category[idx], tri_domain[0]/1024.f, tri_domain[1]/1024.f, (total/count)/1024.f, triangles[idx][count/2]/1024.f, total_visible_triangles[idx]/1024.f, total_triangles[idx]/1024.f, count); + std::string label = llformat("%s Object Triangle Counts (Ktris) -- [%.2f, %.2f] Mean: %.2f Median: %.2f Visible: %.2f/%.2f", + category[idx], tri_domain[0]/1024.f, tri_domain[1]/1024.f, (total/count)/1024.f, triangles[idx][count/2]/1024.f, total_visible_triangles[idx]/1024.f, total_triangles[idx]/1024.f); LLFontGL::getFontMonospace()->renderUTF8(label, 0 , tri_rect.mLeft, tri_rect.mTop+margin, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); @@ -265,6 +288,140 @@ void LLSceneView::draw() } } + for (U32 idx = 0; idx < 2; ++idx) + { + if (!streaming_cost[idx].empty()) + { //plot graph of streaming cost + std::sort(streaming_cost[idx].begin(), streaming_cost[idx].end()); + + ll_remove_outliers(streaming_cost[idx], 1.f); + + LLRect tri_rect; + if (idx == 0) + { + tri_rect = LLRect(margin, graph_pos[2]-margin, new_rect.getWidth()/2-margin, graph_pos[1]+margin); + } + else + { + tri_rect = LLRect(new_rect.getWidth()/2+margin, graph_pos[2]-margin, new_rect.getWidth()-margin, graph_pos[1]+margin); + } + + gl_rect_2d(tri_rect, LLColor4::white, false); + + F32 streaming_domain[] = { 65536, 0 }; + + //get domain of triangle counts + for (U32 i = 0; i < streaming_cost[idx].size(); ++i) + { + streaming_domain[0] = llmin(streaming_domain[0], streaming_cost[idx][i]); + streaming_domain[1] = llmax(streaming_domain[1], streaming_cost[idx][i]); + } + + F32 cost_range = streaming_domain[1]-streaming_domain[0]; + + U32 count = streaming_cost[idx].size(); + + F32 total = 0; + + gGL.begin(LLRender::LINE_STRIP); + //plot triangles + for (U32 i = 0; i < count; ++i) + { + F32 sc = streaming_cost[idx][i]; + total += sc; + F32 y = (F32) (sc-streaming_domain[0])/cost_range*tri_rect.getHeight()+tri_rect.mBottom; + F32 x = (F32) i / count * tri_rect.getWidth() + tri_rect.mLeft; + + gGL.vertex2f(x,y); + + if (i%4096 == 0) + { + gGL.end(); + gGL.flush(); + gGL.begin(LLRender::LINE_STRIP); + } + } + + gGL.end(); + gGL.flush(); + + std::string label = llformat("%s Object Streaming Cost -- [%.2f, %.2f] Mean: %.2f Total: %.2f", + category[idx], streaming_domain[0], streaming_domain[1], total/count, total_streaming[idx]); + + LLFontGL::getFontMonospace()->renderUTF8(label, + 0 , tri_rect.mLeft, tri_rect.mTop+margin, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + + } + } + + for (U32 idx = 0; idx < 2; ++idx) + { + if (!physics_cost[idx].empty()) + { //plot graph of physics cost + std::sort(physics_cost[idx].begin(), physics_cost[idx].end()); + + ll_remove_outliers(physics_cost[idx], 1.f); + + LLRect tri_rect; + if (idx == 0) + { + tri_rect = LLRect(margin, graph_pos[3]-margin, new_rect.getWidth()/2-margin, graph_pos[2]+margin); + } + else + { + tri_rect = LLRect(new_rect.getWidth()/2+margin, graph_pos[3]-margin, new_rect.getWidth()-margin, graph_pos[2]+margin); + } + + gl_rect_2d(tri_rect, LLColor4::white, false); + + F32 physics_domain[] = { 65536, 0 }; + + //get domain of triangle counts + for (U32 i = 0; i < physics_cost[idx].size(); ++i) + { + physics_domain[0] = llmin(physics_domain[0], physics_cost[idx][i]); + physics_domain[1] = llmax(physics_domain[1], physics_cost[idx][i]); + } + + F32 cost_range = physics_domain[1]-physics_domain[0]; + + U32 count = physics_cost[idx].size(); + + F32 total = 0; + + gGL.begin(LLRender::LINE_STRIP); + //plot triangles + for (U32 i = 0; i < count; ++i) + { + F32 pc = physics_cost[idx][i]; + total += pc; + F32 y = (F32) (pc-physics_domain[0])/cost_range*tri_rect.getHeight()+tri_rect.mBottom; + F32 x = (F32) i / count * tri_rect.getWidth() + tri_rect.mLeft; + + gGL.vertex2f(x,y); + + if (i%4096 == 0) + { + gGL.end(); + gGL.flush(); + gGL.begin(LLRender::LINE_STRIP); + } + } + + gGL.end(); + gGL.flush(); + + std::string label = llformat("%s Object Physics Cost -- [%.2f, %.2f] Mean: %.2f Total: %.2f", + category[idx], physics_domain[0], physics_domain[1], total/count, total_physics[idx]); + + LLFontGL::getFontMonospace()->renderUTF8(label, + 0 , tri_rect.mLeft, tri_rect.mTop+margin, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + + } + } + + + LLView::draw(); } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 207e15ff1a..a5b59e8281 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -240,6 +240,9 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe mState(0), mMedia(NULL), mClickAction(0), + mObjectCost(0), + mLinksetCost(0), + mPhysicsCost(0), mLinksetPhysicsCost(0.f), mCostStale(true), mPhysicsShapeUnknown(true), diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8e4e6b5b07..bde35ee33d 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3746,7 +3746,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de LLVector3 mouse_world_start = mouse_point_global; LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth; - //gDebugRaycastIntersection = mouse_world_end; + gDebugRaycastIntersection = mouse_world_end; if (start) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bf65fd123e..d18e1de60c 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -240,6 +240,16 @@ glh::matrix4f glh_get_current_projection() return glh_copy_matrix(gGLProjection);
}
+glh::matrix4f glh_get_last_modelview()
+{
+ return glh_copy_matrix(gGLLastModelView);
+}
+
+glh::matrix4f glh_get_last_projection()
+{
+ return glh_copy_matrix(gGLLastProjection);
+}
+
void glh_copy_matrix(const glh::matrix4f& src, GLdouble* dst)
{
for (U32 i = 0; i < 16; i++)
@@ -1910,7 +1920,7 @@ BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& static LLFastTimer::DeclareTimer FTM_CULL("Object Culling");
-void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip)
+void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep)
{
LLFastTimer t(FTM_CULL);
LLMemType mt_uc(LLMemType::MTYPE_PIPELINE_UPDATE_CULL);
@@ -1930,6 +1940,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl mScreen.bindTarget();
}
+ if (sUseOcclusion > 1)
+ {
+ gGL.setColorMask(false, false);
+ }
+
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadMatrixd(gGLLastProjection);
@@ -1944,10 +1959,37 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLGLDisable test(GL_ALPHA_TEST);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- if (sUseOcclusion > 1)
+
+ //setup a clip plane in projection matrix for reflection renders (prevents flickering from occlusion culling)
+ LLViewerRegion* region = gAgent.getRegion();
+ LLPlane plane;
+
+ if (planep)
{
- gGL.setColorMask(false, false);
+ plane = *planep;
}
+ else
+ {
+ if (region)
+ {
+ LLVector3 pnorm;
+ F32 height = region->getWaterHeight();
+ if (water_clip < 0)
+ { //camera is above water, clip plane points up
+ pnorm.setVec(0,0,1);
+ plane.setVec(pnorm, -height);
+ }
+ else if (water_clip > 0)
+ { //camera is below water, clip plane points down
+ pnorm = LLVector3(0,0,-1);
+ plane.setVec(pnorm, height);
+ }
+ }
+ }
+
+ glh::matrix4f modelview = glh_get_last_modelview();
+ glh::matrix4f proj = glh_get_last_projection();
+ LLGLUserClipPlane clip(plane, modelview, proj, water_clip != 0 && LLPipeline::sReflectionRender);
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
@@ -7887,18 +7929,13 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.pushRenderTypeMask();
gPipeline.andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
LLPipeline::RENDER_TYPE_WL_SKY,
+ LLPipeline::RENDER_TYPE_CLOUDS,
LLPipeline::END_RENDER_TYPES);
static LLCullResult result;
updateCull(camera, result);
stateSort(camera, result);
- andRenderTypeMask(LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::RENDER_TYPE_WL_SKY,
- LLPipeline::END_RENDER_TYPES);
-
- //bad pop here
renderGeom(camera, TRUE);
gPipeline.popRenderTypeMask();
@@ -7931,7 +7968,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLGLUserClipPlane clip_plane(plane, mat, projection);
LLGLDisable cull(GL_CULL_FACE);
- updateCull(camera, ref_result, 1);
+ updateCull(camera, ref_result, -water_clip, &plane);
stateSort(camera, ref_result);
}
@@ -7988,9 +8025,11 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) {
//clip out geometry on the same side of water as the camera
mat = glh_get_current_modelview();
- LLGLUserClipPlane clip_plane(LLPlane(-pnorm, -(pd+pad)), mat, projection);
+ LLPlane plane(-pnorm, -(pd+pad));
+
+ LLGLUserClipPlane clip_plane(plane, mat, projection);
static LLCullResult result;
- updateCull(camera, result, water_clip);
+ updateCull(camera, result, water_clip, &plane);
stateSort(camera, result);
gGL.setColorMask(true, true);
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 074c1742e2..0cf3fde562 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -208,7 +208,7 @@ public: BOOL visibleObjectsInFrustum(LLCamera& camera); BOOL getVisibleExtents(LLCamera& camera, LLVector3 &min, LLVector3& max); BOOL getVisiblePointCloud(LLCamera& camera, LLVector3 &min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir = LLVector3(0,0,0)); - void updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip = 0); //if water_clip is 0, ignore water plane, 1, cull to above plane, -1, cull to below plane + void updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip = 0, LLPlane* plane = NULL); //if water_clip is 0, ignore water plane, 1, cull to above plane, -1, cull to below plane void createObjects(F32 max_dtime); void createObject(LLViewerObject* vobj); void updateGeom(F32 max_dtime); |