Browse Source

Removed the "view texture" abstraction, which is unnecessary now, as all deferred renderpaths write directly to the destination rendertarget. Fixes #166.

Lasse Öörni 12 years ago
parent
commit
782c3ac54e

+ 1 - 16
Source/Engine/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -1371,7 +1371,7 @@ void Graphics::SetTexture(unsigned index, Texture* texture)
     // Check if texture is currently bound as a rendertarget. In that case, use its backup texture, or blank if not defined
     if (texture)
     {
-        if (texture == viewTexture_ || (renderTargets_[0] && renderTargets_[0]->GetParentTexture() == texture))
+        if (renderTargets_[0] && renderTargets_[0]->GetParentTexture() == texture)
             texture = texture->GetBackupTexture();
     }
     
@@ -1566,20 +1566,6 @@ void Graphics::SetDepthStencil(Texture2D* texture)
     SetDepthStencil(depthStencil);
 }
 
-void Graphics::SetViewTexture(Texture* texture)
-{
-    viewTexture_ = texture;
-    
-    if (viewTexture_)
-    {
-        for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
-        {
-            if (textures_[i] == viewTexture_)
-                SetTexture(i, textures_[i]->GetBackupTexture());
-        }
-    }
-}
-
 void Graphics::SetViewport(const IntRect& rect)
 {
     IntVector2 size = GetRenderTargetDimensions();
@@ -2582,7 +2568,6 @@ void Graphics::ResetCachedState()
     
     depthStencil_ = 0;
     impl_->depthStencilSurface_ = 0;
-    viewTexture_ = 0;
     viewport_ = IntRect(0, 0, width_, height_);
     impl_->sRGBWrite_ = false;
     

+ 0 - 4
Source/Engine/Graphics/Direct3D9/D3D9Graphics.h

@@ -181,8 +181,6 @@ public:
     void SetDepthStencil(RenderSurface* depthStencil);
     /// Set depth-stencil surface.
     void SetDepthStencil(Texture2D* texture);
-    /// Set view texture (deferred rendering final output rendertarget) to prevent it from being sampled.
-    void SetViewTexture(Texture* texture);
     /// Set viewport.
     void SetViewport(const IntRect& rect);
     /// Set blending mode.
@@ -513,8 +511,6 @@ private:
     RenderSurface* renderTargets_[MAX_RENDERTARGETS];
     /// Depth-stencil surface in use.
     RenderSurface* depthStencil_;
-    /// View texture.
-    Texture* viewTexture_;
     /// Viewport coordinates.
     IntRect viewport_;
     /// Texture anisotropy level.

+ 1 - 16
Source/Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -1393,7 +1393,7 @@ void Graphics::SetTexture(unsigned index, Texture* texture)
     // Check if texture is currently bound as a rendertarget. In that case, use its backup texture, or blank if not defined
     if (texture)
     {
-        if (texture == viewTexture_ || (renderTargets_[0] && renderTargets_[0]->GetParentTexture() == texture))
+        if (renderTargets_[0] && renderTargets_[0]->GetParentTexture() == texture)
             texture = texture->GetBackupTexture();
     }
     
@@ -1581,20 +1581,6 @@ void Graphics::SetDepthStencil(Texture2D* texture)
     SetDepthStencil(depthStencil);
 }
 
-void Graphics::SetViewTexture(Texture* texture)
-{
-    viewTexture_ = texture;
-    
-    if (viewTexture_)
-    {
-        for (unsigned i = 0; i < MAX_TEXTURE_UNITS; ++i)
-        {
-            if (textures_[i] == viewTexture_)
-                SetTexture(i, textures_[i]->GetBackupTexture());
-        }
-    }
-}
-
 void Graphics::SetViewport(const IntRect& rect)
 {
     if (impl_->fboDirty_)
@@ -2793,7 +2779,6 @@ void Graphics::ResetCachedState()
         renderTargets_[i] = 0;
     
     depthStencil_ = 0;
-    viewTexture_ = 0;
     viewport_ = IntRect(0, 0, 0, 0);
     indexBuffer_ = 0;
     vertexShader_ = 0;

+ 0 - 4
Source/Engine/Graphics/OpenGL/OGLGraphics.h

@@ -187,8 +187,6 @@ public:
     void SetDepthStencil(RenderSurface* depthStencil);
     /// Set depth-stencil surface.
     void SetDepthStencil(Texture2D* texture);
-    /// Set view texture (deferred rendering final output rendertarget) to prevent it from being sampled.
-    void SetViewTexture(Texture* texture);
     /// Set viewport.
     void SetViewport(const IntRect& rect);
     /// Set blending mode.
@@ -517,8 +515,6 @@ private:
     RenderSurface* renderTargets_[MAX_RENDERTARGETS];
     /// Depth-stencil surface in use.
     RenderSurface* depthStencil_;
-    /// View texture.
-    Texture* viewTexture_;
     /// Viewport coordinates.
     IntRect viewport_;
     /// Texture anisotropy level.

+ 0 - 4
Source/Engine/Graphics/View.cpp

@@ -529,11 +529,8 @@ void View::Render()
         graphics_->SetTexture(TU_INDIRECTION, renderer_->GetIndirectionCubeMap());
     }
     
-    // Set "view texture" to prevent destination texture sampling during all renderpasses
     if (renderTarget_)
     {
-        graphics_->SetViewTexture(renderTarget_->GetParentTexture());
-        
         // On OpenGL, flip the projection if rendering to a texture so that the texture can be addressed in the same way
         // as a render texture produced on Direct3D9
         #ifdef USE_OPENGL
@@ -551,7 +548,6 @@ void View::Render()
     graphics_->SetDepthBias(0.0f, 0.0f);
     graphics_->SetScissorTest(false);
     graphics_->SetStencilTest(false);
-    graphics_->SetViewTexture(0);
     graphics_->ResetStreamFrequencies();
     
     // Run framebuffer blitting if necessary