Browse Source

Fix update of smallest compressed texture miplevels on D3D11.

Lasse Öörni 10 years ago
parent
commit
e7f83624aa
1 changed files with 11 additions and 6 deletions
  1. 11 6
      Source/Urho3D/Graphics/Direct3D11/D3D11Texture2D.cpp

+ 11 - 6
Source/Urho3D/Graphics/Direct3D11/D3D11Texture2D.cpp

@@ -184,12 +184,6 @@ bool Texture2D::SetData(unsigned level, int x, int y, int width, int height, con
         return false;
         return false;
     }
     }
     
     
-    if (IsCompressed())
-    {
-        x &= ~3;
-        y &= ~3;
-    }
-    
     int levelWidth = GetLevelWidth(level);
     int levelWidth = GetLevelWidth(level);
     int levelHeight = GetLevelHeight(level);
     int levelHeight = GetLevelHeight(level);
     if (x < 0 || x + width > levelWidth || y < 0 || y + height > levelHeight || width <= 0 || height <= 0)
     if (x < 0 || x + width > levelWidth || y < 0 || y + height > levelHeight || width <= 0 || height <= 0)
@@ -198,6 +192,17 @@ bool Texture2D::SetData(unsigned level, int x, int y, int width, int height, con
         return false;
         return false;
     }
     }
     
     
+    // If compressed, align the update region on a block
+    if (IsCompressed())
+    {
+        x &= ~3;
+        y &= ~3;
+        width += 3;
+        width &= 0xfffffffc;
+        height += 3;
+        height &= 0xfffffffc;
+    }
+
     unsigned char* src = (unsigned char*)data;
     unsigned char* src = (unsigned char*)data;
     unsigned rowSize = GetRowDataSize(width);
     unsigned rowSize = GetRowDataSize(width);
     unsigned rowStart = GetRowDataSize(x);
     unsigned rowStart = GetRowDataSize(x);