vc4: Convert to using an enum for texture data types
authorEric Anholt <eric@anholt.net>
Tue, 19 Aug 2014 16:47:20 +0000 (09:47 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 22 Aug 2014 17:16:57 +0000 (10:16 -0700)
src/gallium/drivers/vc4/vc4_packet.h
src/gallium/drivers/vc4/vc4_simulator_validate.c

index e455c2fe76a5f6bab41bed1b25c78c505509d3b8..eef5be99a046122b4c2cb2c5b7f2bc2fe6936fed 100644 (file)
@@ -221,4 +221,26 @@ enum vc4_packet {
 #define VC4_RENDER_CONFIG_TILE_BUFFER_64BIT        (1 << 1)
 #define VC4_RENDER_CONFIG_MS_MODE_4X               (1 << 0)
 
+
+enum vc4_texture_data_type {
+        VC4_TEXTURE_TYPE_RGBA8888 = 0,
+        VC4_TEXTURE_TYPE_RGBX8888 = 1,
+        VC4_TEXTURE_TYPE_RGBA4444 = 2,
+        VC4_TEXTURE_TYPE_RGBA5551 = 3,
+        VC4_TEXTURE_TYPE_RGB565 = 4,
+        VC4_TEXTURE_TYPE_LUMINANCE = 5,
+        VC4_TEXTURE_TYPE_ALPHA = 6,
+        VC4_TEXTURE_TYPE_LUMALPHA = 7,
+        VC4_TEXTURE_TYPE_ETC1 = 8,
+        VC4_TEXTURE_TYPE_S16F = 9,
+        VC4_TEXTURE_TYPE_S8 = 10,
+        VC4_TEXTURE_TYPE_S16 = 11,
+        VC4_TEXTURE_TYPE_BW1 = 12,
+        VC4_TEXTURE_TYPE_A4 = 13,
+        VC4_TEXTURE_TYPE_A1 = 14,
+        VC4_TEXTURE_TYPE_RGBA64 = 15,
+        VC4_TEXTURE_TYPE_RGBA32R = 16,
+        VC4_TEXTURE_TYPE_YUV422R = 17,
+};
+
 #endif /* VC4_PACKET_H */
index 038de0fc637aa9a8c629ea08455219ed2e1dcf66..ac5be892376bdbf3a3e2ffc3ed69c177f4f5c8e9 100644 (file)
@@ -706,8 +706,9 @@ reloc_tex(struct exec_info *exec,
        uint32_t miplevels = (p0 & 0x15);
        uint32_t width = (p1 >> 8) & 2047;
        uint32_t height = (p1 >> 20) & 2047;
-       uint32_t type, cpp, tiling_format;
+       uint32_t cpp, tiling_format;
        int i;
+       enum vc4_texture_data_type type;
 
        if (width == 0)
                width = 2048;
@@ -722,36 +723,36 @@ reloc_tex(struct exec_info *exec,
        type = ((p0 >> 4) & 15) | ((p1 >> 31) << 4);
 
        switch (type) {
-       case 0: /* RGBA8888 */
-       case 1: /* RGBX8888 */
-       case 16: /* RGBA32R */
+       case VC4_TEXTURE_TYPE_RGBA8888:
+       case VC4_TEXTURE_TYPE_RGBX8888:
+       case VC4_TEXTURE_TYPE_RGBA32R:
                cpp = 4;
                break;
-       case 2: /* RGBA4444 */
-       case 3: /* RGBA5551 */
-       case 4: /* RGB565 */
-       case 7: /* LUMALPHA */
-       case 9: /* S16F */
-       case 11: /* S16 */
+       case VC4_TEXTURE_TYPE_RGBA4444:
+       case VC4_TEXTURE_TYPE_RGBA5551:
+       case VC4_TEXTURE_TYPE_RGB565:
+       case VC4_TEXTURE_TYPE_LUMALPHA:
+       case VC4_TEXTURE_TYPE_S16F:
+       case VC4_TEXTURE_TYPE_S16:
                cpp = 2;
                break;
-       case 5: /* LUMINANCE */
-       case 6: /* ALPHA */
-       case 10: /* S8 */
+       case VC4_TEXTURE_TYPE_LUMINANCE:
+       case VC4_TEXTURE_TYPE_ALPHA:
+       case VC4_TEXTURE_TYPE_S8:
                cpp = 1;
                break;
-       case 8: /* ETC1 */
-       case 12: /* BW1 */
-       case 13: /* A4 */
-       case 14: /* A1 */
-       case 15: /* RGBA64 */
-       case 17: /* YUV422R */
+       case VC4_TEXTURE_TYPE_ETC1:
+       case VC4_TEXTURE_TYPE_BW1:
+       case VC4_TEXTURE_TYPE_A4:
+       case VC4_TEXTURE_TYPE_A1:
+       case VC4_TEXTURE_TYPE_RGBA64:
+       case VC4_TEXTURE_TYPE_YUV422R:
        default:
                DRM_ERROR("Texture format %d unsupported\n", type);
                return false;
        }
 
-       if (type == 16) {
+       if (type == VC4_TEXTURE_TYPE_RGBA32R) {
                tiling_format = VC4_TILING_FORMAT_LINEAR;
        } else {
                DRM_ERROR("Tiling formats not yet supported\n");