radeon: add tile size getter
authorMaciej Cencora <m.cencora@gmail.com>
Sat, 16 Jan 2010 22:11:10 +0000 (23:11 +0100)
committerMaciej Cencora <m.cencora@gmail.com>
Sun, 7 Mar 2010 11:07:36 +0000 (12:07 +0100)
src/mesa/drivers/dri/radeon/radeon_tile.c
src/mesa/drivers/dri/radeon/radeon_tile.h

index 56f2fc46d9c57cda5bac50811757754bef2a3d51..b998baf0a2f7b31c75e31e701a120adcdfab5fa2 100644 (file)
@@ -243,4 +243,42 @@ void tile_image(const void * src, unsigned src_pitch,
             assert(0);
             break;
     }
-}
\ No newline at end of file
+}
+
+void get_tile_size(gl_format format, unsigned *block_width, unsigned *block_height)
+{
+    switch (_mesa_get_format_bytes(format))
+    {
+        case 16:
+            *block_width = 1;
+            *block_height = 1;
+            break;
+        case 8:
+            *block_width = 2;
+            *block_height = 2;
+            break;
+        case 4:
+            *block_width = 4;
+            *block_height = 2;
+            break;
+        case 2:
+            if (_mesa_get_format_bits(format, GL_DEPTH_BITS))
+            {
+                *block_width = 4;
+                *block_height = 4;
+            }
+            else
+            {
+                *block_width = 8;
+                *block_height = 2;
+            }
+            break;
+        case 1:
+            *block_width = 8;
+            *block_height = 4;
+            break;
+        default:
+            assert(0);
+            break;
+    }
+}
index 4985e55204559683966bc8a2f3d291ca4241d38a..06850b361d6419220dbb0955c113dbfeb1028797 100644 (file)
@@ -30,3 +30,5 @@
 void tile_image(const void * src, unsigned src_pitch,
                 void *dst, unsigned dst_pitch,
                 gl_format format, unsigned width, unsigned height);
+
+void get_tile_size(gl_format format, unsigned *block_width, unsigned *block_height);