Browse Source

Remove unnecessary staging texture

Josh Engebretson 8 years ago
parent
commit
4b772996a9
1 changed files with 4 additions and 79 deletions
  1. 4 79
      Source/AtomicWebView/WebTexture2D.cpp

+ 4 - 79
Source/AtomicWebView/WebTexture2D.cpp

@@ -50,12 +50,6 @@ public:
 
 
     WebTexture2DPrivate(WebTexture2D* webTexture2D)
     WebTexture2DPrivate(WebTexture2D* webTexture2D)
     {
     {
-
-#ifdef ATOMIC_D3D11
-        stagingTexture_ = 0;
-        stagingWidth_ = 0;
-        stagingHeight_ = 0;
-#endif
         webTexture2D_ = webTexture2D;
         webTexture2D_ = webTexture2D;
         graphics_ = webTexture2D->GetSubsystem<Graphics>();
         graphics_ = webTexture2D->GetSubsystem<Graphics>();
         ClearPopupRects();
         ClearPopupRects();
@@ -218,56 +212,6 @@ public:
 
 
     // Windows D3D blitting
     // Windows D3D blitting
 
 
-#ifdef ATOMIC_D3D11
-
-    void ReleaseStagingTexture()
-    {
-        if (stagingTexture_)
-        {
-            stagingTexture_->Release();
-        }
-
-        stagingTexture_ = 0;
-        stagingWidth_ = 0;
-        stagingHeight_ = 0;
-    }
-
-    void UpdateStagingTexture()
-    {
-        if (stagingTexture_)
-        {
-            ReleaseStagingTexture();
-        }
-
-        D3D11_TEXTURE2D_DESC textureDesc;
-        memset(&textureDesc, 0, sizeof textureDesc);
-
-        textureDesc.Width = (UINT)webTexture2D_->GetWidth();
-        textureDesc.Height = (UINT)webTexture2D_->GetHeight();
-        textureDesc.MipLevels = 1;
-        textureDesc.ArraySize = 1;
-        textureDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
-        textureDesc.SampleDesc.Count = 1;
-        textureDesc.SampleDesc.Quality = 0;
-        textureDesc.Usage = D3D11_USAGE_DEFAULT;
-
-        HRESULT hr = graphics_->GetImpl()->GetDevice()->CreateTexture2D(&textureDesc, nullptr, &stagingTexture_);
-
-        if (!SUCCEEDED(hr))
-        {
-            stagingTexture_ = 0;
-            return;
-        }
-
-        stagingWidth_ = webTexture2D_->GetWidth();
-        stagingHeight_ = webTexture2D_->GetHeight();
-
-    }
-
-
-#endif
-
-
     void D3DBlit(const IntRect& dstRect, unsigned char* src, unsigned srcStride, bool discard = false)
     void D3DBlit(const IntRect& dstRect, unsigned char* src, unsigned srcStride, bool discard = false)
     {
     {
 
 
@@ -278,10 +222,8 @@ public:
             return;
             return;
         }
         }
 
 
-        if (!stagingTexture_ || (stagingWidth_ != webTexture2D_->GetWidth()) || (stagingHeight_ != webTexture2D_->GetHeight()))        
-        {
+        if ((dstRect.left_ + dstRect.Width() > webTexture2D_->GetWidth()) || (dstRect.top_ + dstRect.Height() > webTexture2D_->GetHeight()))
             return;
             return;
-        }
                 
                 
         D3D11_BOX box;
         D3D11_BOX box;
         box.left = dstRect.left_;
         box.left = dstRect.left_;
@@ -291,13 +233,7 @@ public:
         box.front = 0;
         box.front = 0;
         box.back = 1;
         box.back = 1;
 
 
-        if ((dstRect.left_ + dstRect.Width() > stagingWidth_) || (dstRect.top_ + dstRect.Height() > stagingHeight_))
-            return;
-
-        graphics_->GetImpl()->GetDeviceContext()->UpdateSubresource(stagingTexture_, 0, &box, src, srcStride, 0);
-
-        graphics_->GetImpl()->GetDeviceContext()->CopyResource((ID3D11Resource*)webTexture2D_->GetTexture2D()->GetGPUObject(), stagingTexture_);            
-
+        graphics_->GetImpl()->GetDeviceContext()->UpdateSubresource((ID3D11Resource*)webTexture2D_->GetTexture2D()->GetGPUObject(), 0, &box, src, srcStride, 0);
 
 
 #else
 #else
         RECT d3dRect;
         RECT d3dRect;
@@ -399,12 +335,6 @@ public:
 
 
 private:
 private:
 
 
-#ifdef ATOMIC_D3D11
-    ID3D11Texture2D* stagingTexture_;
-    int stagingWidth_;
-    int stagingHeight_;
-#endif
-
     CefRect popupRect_;
     CefRect popupRect_;
     CefRect popupRectOriginal_;
     CefRect popupRectOriginal_;
 
 
@@ -427,10 +357,6 @@ WebTexture2D::WebTexture2D(Context* context) : WebRenderHandler(context), clearC
 WebTexture2D::~WebTexture2D()
 WebTexture2D::~WebTexture2D()
 {
 {
     //d_->Release();
     //d_->Release();
-
-#ifdef ATOMIC_D3D11
-    d_->ReleaseStagingTexture();
-#endif
 }
 }
 
 
 CefRenderHandler* WebTexture2D::GetCEFRenderHandler()
 CefRenderHandler* WebTexture2D::GetCEFRenderHandler()
@@ -461,17 +387,16 @@ void WebTexture2D::SetSize(int width, int height)
         ATOMIC_LOGERRORF("Unable to set WebTexture2D size to %i x %i", width, height);
         ATOMIC_LOGERRORF("Unable to set WebTexture2D size to %i x %i", width, height);
         return;
         return;
     }
     }
+
 #else
 #else
     
     
+    // D3D11 uses a static texture (in BGRA format), required for subresource update with rectangle
     if (!texture_->SetSize(width, height, DXGI_FORMAT_B8G8R8A8_UNORM, TEXTURE_STATIC))
     if (!texture_->SetSize(width, height, DXGI_FORMAT_B8G8R8A8_UNORM, TEXTURE_STATIC))
     {
     {
         ATOMIC_LOGERRORF("Unable to set WebTexture2D size to %i x %i", width, height);
         ATOMIC_LOGERRORF("Unable to set WebTexture2D size to %i x %i", width, height);
         return;
         return;
     }
     }
 
 
-    d_->UpdateStagingTexture();
-
-
 #endif
 #endif
 
 
     SharedArrayPtr<unsigned> cleardata(new unsigned[width * height]);
     SharedArrayPtr<unsigned> cleardata(new unsigned[width * height]);