[WebGL] Validation function for compressed formats incorrect
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jan 2014 20:13:01 +0000 (20:13 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jan 2014 20:13:01 +0000 (20:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127023

Reviewed by Dean Jackson.

No new tests. Covered by existing WebGL compressed texture tests.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateCompressedTexFuncData): Revise to match specifications.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162085 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGLRenderingContext.cpp

index 5ceb7b3..551c64e 100644 (file)
@@ -1,3 +1,15 @@
+2014-01-15  Brent Fulgham  <bfulgham@apple.com>
+
+        [WebGL] Validation function for compressed formats incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=127023
+
+        Reviewed by Dean Jackson.
+
+        No new tests. Covered by existing WebGL compressed texture tests.
+
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::validateCompressedTexFuncData): Revise to match specifications.
+
 2014-01-15  Andreas Kling  <akling@apple.com>
 
         Remove the CSS selector profiler.
index fc14cae..8455777 100644 (file)
@@ -5318,51 +5318,48 @@ bool WebGLRenderingContext::validateCompressedTexFuncData(const char* functionNa
 
     unsigned int bytesRequired = 0;
 
-    const int kBlockWidth = 4;
-    const int kBlockHeight = 4;
-
     switch (format) {
     case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
     case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
+    case Extensions3D::COMPRESSED_ATC_RGB_AMD:
         {
             const int kBlockSize = 8;
+            const int kBlockWidth = 4;
+            const int kBlockHeight = 4;
             int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
             int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
-            int numBlocks = numBlocksAcross * numBlocksDown;
-            bytesRequired = numBlocks * kBlockSize;
+            bytesRequired = numBlocksAcross * numBlocksDown * kBlockSize;
         }
         break;
     case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
     case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT:
+    case Extensions3D::COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD:
+    case Extensions3D::COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
         {
             const int kBlockSize = 16;
+            const int kBlockWidth = 4;
+            const int kBlockHeight = 4;
             int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
             int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
-            int numBlocks = numBlocksAcross * numBlocksDown;
-            bytesRequired = numBlocks * kBlockSize;
-        }
-        break;
-    case Extensions3D::COMPRESSED_ATC_RGB_AMD:
-        {
-            bytesRequired = floor(static_cast<double>((width + kBlockWidth - 1) / 4)) * floor(static_cast<double>((height + 3) / 4)) * 8;
-        }
-        break;
-    case Extensions3D::COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD:
-    case Extensions3D::COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
-        {
-            bytesRequired = floor(static_cast<double>((width + kBlockWidth - 1) / 4)) * floor(static_cast<double>((height + 3) / 4)) * 16;
+            bytesRequired = numBlocksAcross * numBlocksDown * kBlockSize;
         }
         break;
     case Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
     case Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
         {
-            bytesRequired = std::max(width, 8) * std::max(height, 8) / 2;
+            const int kBlockSize = 8;
+            const int kBlockWidth = 8;
+            const int kBlockHeight = 8;
+            bytesRequired = (std::max(width, kBlockWidth) * std::max(height, kBlockHeight) * 4 + 7) / kBlockSize;
         }
         break;
     case Extensions3D::COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
     case Extensions3D::COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
         {
-            bytesRequired = std::max(width, 8) * std::max(height, 8) / 4;
+            const int kBlockSize = 8;
+            const int kBlockWidth = 16;
+            const int kBlockHeight = 8;
+            bytesRequired = (std::max(width, kBlockWidth) * std::max(height, kBlockHeight) * 2 + 7) / kBlockSize;
         }
         break;
     default: