Browse Source

If backbuffer is multisampled, use a screen buffer for deferred rendering. Note: this wastes performance, so it is better to disable multisampling instead.
Ensure correct fill mode when executing renderpath commands.

Lasse Öörni 13 years ago
parent
commit
ffc3d433a1
1 changed files with 8 additions and 10 deletions
  1. 8 10
      Engine/Graphics/View.cpp

+ 8 - 10
Engine/Graphics/View.cpp

@@ -430,7 +430,7 @@ void View::Render()
     // Actually update geometry data now
     // Actually update geometry data now
     UpdateGeometries();
     UpdateGeometries();
     
     
-    // Allocate screen buffers for post-processing and blitting as necessary
+    // Allocate screen buffers as necessary
     AllocateScreenBuffers();
     AllocateScreenBuffers();
     
     
     // Initialize screenbuffer indices to use for read and write (pingponging)
     // Initialize screenbuffer indices to use for read and write (pingponging)
@@ -450,8 +450,6 @@ void View::Render()
     if (camera_->GetAutoAspectRatio())
     if (camera_->GetAutoAspectRatio())
         camera_->SetAspectRatio((float)(viewSize_.x_) / (float)(viewSize_.y_));
         camera_->SetAspectRatio((float)(viewSize_.x_) / (float)(viewSize_.y_));
     
     
-    graphics_->SetColorWrite(true);
-    
     // Bind the face selection and indirection cube maps for point light shadows
     // Bind the face selection and indirection cube maps for point light shadows
     if (renderer_->GetDrawShadows())
     if (renderer_->GetDrawShadows())
     {
     {
@@ -1143,8 +1141,6 @@ void View::ExecuteRenderPathCommands()
         }
         }
     }
     }
     
     
-    graphics_->SetFillMode(camera_->GetFillMode());
-    
     {
     {
         PROFILE(RenderCommands);
         PROFILE(RenderCommands);
         
         
@@ -1229,6 +1225,7 @@ void View::ExecuteRenderPathCommands()
                     
                     
                     SetRenderTargets(command);
                     SetRenderTargets(command);
                     SetTextures(command);
                     SetTextures(command);
+                    graphics_->SetFillMode(camera_->GetFillMode());
                     batchQueues_[command.pass_].Draw(this, command.useScissor_, command.markToStencil_);
                     batchQueues_[command.pass_].Draw(this, command.useScissor_, command.markToStencil_);
                 }
                 }
                 break;
                 break;
@@ -1258,10 +1255,10 @@ void View::ExecuteRenderPathCommands()
                         {
                         {
                             RenderShadowMap(*i);
                             RenderShadowMap(*i);
                             SetRenderTargets(command);
                             SetRenderTargets(command);
-                            graphics_->SetFillMode(camera_->GetFillMode());
                         }
                         }
                         
                         
                         SetTextures(command);
                         SetTextures(command);
+                        graphics_->SetFillMode(camera_->GetFillMode());
                         i->litBatches_.Draw(i->light_, this);
                         i->litBatches_.Draw(i->light_, this);
                     }
                     }
                     
                     
@@ -1310,10 +1307,6 @@ void View::ExecuteRenderPathCommands()
     graphics_->SetDepthStencil(depthStencil_);
     graphics_->SetDepthStencil(depthStencil_);
     graphics_->SetViewport(viewRect_);
     graphics_->SetViewport(viewRect_);
     graphics_->SetFillMode(FILL_SOLID);
     graphics_->SetFillMode(FILL_SOLID);
-    
-    // Resolve multisampled backbuffer now if necessary
-    //if (resolve)
-    //    graphics_->ResolveToTexture(screenBuffers_[0], viewRect_);
 }
 }
 
 
 void View::SetRenderTargets(const RenderPathCommand& command)
 void View::SetRenderTargets(const RenderPathCommand& command)
@@ -1344,6 +1337,7 @@ void View::SetRenderTargets(const RenderPathCommand& command)
     
     
     graphics_->SetDepthStencil(currentDepthStencil_);
     graphics_->SetDepthStencil(currentDepthStencil_);
     graphics_->SetViewport(viewRect_);
     graphics_->SetViewport(viewRect_);
+    graphics_->SetColorWrite(true);
 }
 }
 
 
 void View::SetTextures(const RenderPathCommand& command)
 void View::SetTextures(const RenderPathCommand& command)
@@ -1466,6 +1460,9 @@ void View::AllocateScreenBuffers()
         Graphics::GetRGBAFormat())))
         Graphics::GetRGBAFormat())))
         neededBuffers = 1;
         neededBuffers = 1;
     #endif
     #endif
+    // If backbuffer is antialiased when using deferred rendering, need to reserve a buffer
+    if (deferred_ && !renderTarget_ && graphics_->GetMultiSample() > 1)
+        neededBuffers = 1;
     
     
     unsigned format = Graphics::GetRGBFormat();
     unsigned format = Graphics::GetRGBFormat();
     #ifdef USE_OPENGL
     #ifdef USE_OPENGL
@@ -2388,6 +2385,7 @@ void View::SetupLightVolumeBatch(Batch& batch)
     graphics_->SetBlendMode(BLEND_ADD);
     graphics_->SetBlendMode(BLEND_ADD);
     graphics_->SetDepthBias(0.0f, 0.0f);
     graphics_->SetDepthBias(0.0f, 0.0f);
     graphics_->SetDepthWrite(false);
     graphics_->SetDepthWrite(false);
+    graphics_->SetFillMode(FILL_SOLID);
     
     
     if (type != LIGHT_DIRECTIONAL)
     if (type != LIGHT_DIRECTIONAL)
     {
     {