Changeset 3007


Ignore:
Timestamp:
10/06/08 15:50:50 (16 years ago)
Author:
mattausch
Message:

improving performance

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3006 r3007  
    611611         
    612612 
    613         FrameBufferObject::Release(); 
    614613        cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    615614 
     
    617616        glDisable(GL_TEXTURE_2D); 
    618617        glDisable(GL_LIGHTING); 
     618        glDisable(GL_BLEND); 
    619619 
    620620        glPushAttrib(GL_VIEWPORT_BIT); 
     
    631631        glPushMatrix(); 
    632632        glLoadIdentity(); 
     633 
     634        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    633635 
    634636        if (shadowMap) 
     
    663665 
    664666                ComputeToneParameters(fbo, light, imageKey, whiteLum, middleGrey); 
    665                 ToneMap(fbo, light, imageKey, whiteLum, middleGrey); 
     667                ToneMap(fbo, imageKey, whiteLum, middleGrey); 
    666668        } 
    667669 
     
    679681        glPopAttrib(); 
    680682 
     683        FrameBufferObject::Release(); 
    681684        cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    682685} 
     
    712715        GLuint positionsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 
    713716        GLuint normalsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture(); 
     717        GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
    714718 
    715719        glPushAttrib(GL_VIEWPORT_BIT); 
     
    720724        glDrawBuffers(1, mrt + mFboIndex); 
    721725 
    722         GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
    723726        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    724727 
     728         
    725729        cgGLBindProgram(sCgSsaoProgram); 
    726730 
     
    791795 
    792796        glPopAttrib(); 
    793         FrameBufferObject::Release(); 
    794797 
    795798        PrintGLerror("ssao first pass"); 
     
    827830void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light) 
    828831{ 
     832        FrameBufferObject::Release(); 
     833 
    829834        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
    830835 
    831836        GLuint colorsTex = colorBuffer->GetTexture(); 
    832837        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    833         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     838 
     839        //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    834840        cgGLBindProgram(sCgAntiAliasingProgram); 
    835841         
     
    874880        glDrawBuffers(1, mrt + colorBufferIdx); 
    875881         
    876         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     882        //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    877883         
    878884        cgGLBindProgram(sCgDeferredProgram); 
     
    907913        cgGLDisableTextureParameter(sPositionsTexDeferredParam); 
    908914        cgGLDisableTextureParameter(sNormalsTexDeferredParam); 
    909  
    910         FrameBufferObject::Release(); 
    911915 
    912916        PrintGLerror("deferred shading"); 
     
    10161020        cgGLDisableTextureParameter(sOldIllumTexGiParam); 
    10171021 
    1018         FrameBufferObject::Release(); 
    1019  
    10201022        glPopAttrib(); 
    10211023 
     
    10701072        cgGLDisableTextureParameter(sIllumTexCombinedIllumParam); 
    10711073 
    1072         FrameBufferObject::Release(); 
    1073  
    10741074        PrintGLerror("combine"); 
    10751075} 
     
    11151115        cgGLDisableTextureParameter(sSsaoTexCombinedSsaoParam); 
    11161116         
    1117         FrameBufferObject::Release(); 
    1118  
    11191117        PrintGLerror("combine ssao"); 
    11201118} 
     
    11891187        cgGLDisableTextureParameter(sNoiseTexShadowParam); 
    11901188 
    1191         FrameBufferObject::Release(); 
    1192  
    11931189        PrintGLerror("deferred shading + shadows"); 
    11941190} 
     
    12661262 
    12671263        cgGLDisableTextureParameter(sColorsTexLogLumParam); 
    1268         FrameBufferObject::Release(); 
    12691264 
    12701265        PrintGLerror("ToneMapParams"); 
     
    12751270        //-- compute avg loglum in scene using mipmapping 
    12761271 
    1277         glBindTexture(GL_TEXTURE_2D, fbo->GetColorBuffer(colorBufferIdx)->GetTexture()); 
    1278         glGenerateMipmapEXT(GL_TEXTURE_2D); 
     1272        //glBindTexture(GL_TEXTURE_2D, fbo->GetColorBuffer(colorBufferIdx)->GetTexture()); 
     1273        //glGenerateMipmapEXT(GL_TEXTURE_2D); 
    12791274} 
    12801275 
     
    13421337 
    13431338        cgGLDisableTextureParameter(sColorsTexDownSampleParam); 
    1344         FrameBufferObject::Release(); 
    13451339 
    13461340        /*float *data = (float *)mDownSampleFbo->GetColorBuffer(0)->ReadTexture(); 
     
    13551349 
    13561350void DeferredRenderer::ToneMap(FrameBufferObject *fbo, 
    1357                                                            DirectionalLight *light, 
    13581351                                                           float imageKey,  
    13591352                                                           float whiteLum, 
     
    13641357 
    13651358        fbo->Bind(); 
    1366  
     1359#if 0 
    13671360        colorBufferIdx = 3 - colorBufferIdx; 
    13681361        glDrawBuffers(1, mrt + colorBufferIdx); 
     1362 
    13691363        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    13701364 
    13711365        cgGLBindProgram(sCgToneProgram); 
    1372          
     1366 
    13731367        cgGLSetTextureParameter(sColorsTexToneParam, colorsTex); 
    13741368        cgGLEnableTextureParameter(sColorsTexToneParam); 
     
    13801374        glColor3f(1.0f, 1.0f, 1.0f); 
    13811375 
     1376 
    13821377        glBegin(GL_QUADS); 
    13831378 
    1384         // the neighbouring texels 
    1385         const float x_offs = 1.0f / mWidth; 
    1386         const float y_offs = 1.0f / mHeight; 
    1387  
    1388         SetVertex(0, 0, x_offs, y_offs); 
    1389         SetVertex(1, 0, x_offs, y_offs); 
    1390         SetVertex(1, 1, x_offs, y_offs); 
    1391         SetVertex(0, 1, x_offs, y_offs); 
     1379        const float offs = 0.5f; 
     1380 
     1381 
     1382        glTexCoord2f(0, 0); glVertex3f(-offs, -offs, -0.5f); 
     1383        glTexCoord2f(1, 0); glVertex3f( offs, -offs, -0.5f); 
     1384        glTexCoord2f(1, 1); glVertex3f( offs,  offs, -0.5f); 
     1385        glTexCoord2f(0, 1); glVertex3f(-offs,  offs, -0.5f); 
    13921386 
    13931387        glEnd(); 
     1388#endif 
    13941389 
    13951390        cgGLDisableTextureParameter(sColorsTexToneParam); 
    1396         FrameBufferObject::Release(); 
    13971391 
    13981392        PrintGLerror("ToneMap"); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3006 r3007  
    8080        void ComputeToneParameters(FrameBufferObject *fbo, DirectionalLight *light, float &imageKey, float &whiteLum, float &middleGrey); 
    8181 
    82         void ToneMap(FrameBufferObject *fbo, DirectionalLight *light, float imageKey, float whiteLum, float middleGrey); 
     82        void ToneMap(FrameBufferObject *fbo, float imageKey, float whiteLum, float middleGrey); 
    8383 
    8484 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp

    r3005 r3007  
    88namespace CHCDemoEngine 
    99{ 
     10 
     11int FrameBufferObject::sCurrentFbo = -1; 
    1012 
    1113 
     
    337339void FrameBufferObject::Bind() const 
    338340{ 
    339         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 
     341        if (sCurrentFbo != mId) 
     342        { 
     343                sCurrentFbo = mId; 
     344                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 
     345        } 
    340346} 
    341347 
     
    344350{ 
    345351        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
     352        sCurrentFbo = -1; 
    346353} 
    347354 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h

    r3006 r3007  
    132132 
    133133        unsigned int mDepthTexId; 
     134 
     135        static int sCurrentFbo; 
    134136}; 
    135137 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r3006 r3007  
    6767        average = exp(average * 0.25f); 
    6868 
    69         float4 hcols = cols[0] + cols[1] + cols[2] + cols[3]; 
     69        float4 c = cols[0] + cols[1] + cols[2] + cols[3]; 
    7070 
    71         return hcols * 0.25f; 
    72         //return float4(average, maximum, 0.0f, cols[0].w); 
    73  
     71        return c * 0.25f; 
    7472        // Output the luminance to the render target 
    7573        //return float4(average, maximum, 0.0f, 1.0f); 
     
    8482{ 
    8583        pixel OUT; 
     84        return OUT; 
    8685        float4 color = tex2D(colors, IN.texCoord); 
    8786 
     
    113112 
    114113        pixel OUT; 
    115  
    116         float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
     114return OUT;/* 
     115        const float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
    117116 
    118117        OUT.col = color; 
     
    135134                OUT.col.w = logLumScaled; 
    136135 
    137         return OUT; 
     136        return OUT;*/ 
    138137} 
Note: See TracChangeset for help on using the changeset viewer.