broadcom/vc5: Turn the output image format into an enum.
authorEric Anholt <eric@anholt.net>
Thu, 28 Dec 2017 00:36:09 +0000 (16:36 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 3 Jan 2018 22:25:23 +0000 (14:25 -0800)
src/broadcom/cle/v3d_packet_v33.xml
src/gallium/drivers/vc5/vc5_formats.c

index 4c701db5fb132ce06ed70a2cb09275135a8a228a..e3c35de68b4b162ecf94e297a20617c57cd11aef 100644 (file)
     <value name="UIF (XOR)" value="5"/>
   </enum>
 
+  <enum name="Output Image Format" prefix="V3D_OUTPUT_IMAGE_FORMAT">
+    <!--
+       Formats appear with their channels named from the low bits to
+       the high bits.
+    -->
+    <value name="srgb8_alpha8" value="0"/>
+    <value name="srgb" value="1"/>
+    <value name="rgb10_a2ui" value="2"/>
+    <value name="rgb10_a2" value="3"/>
+    <value name="abgr1555" value="4"/>
+    <value name="alpha-masked abgr1555" value="5"/>
+    <value name="abgr4444" value="6"/>
+    <value name="bgr565" value="7"/>
+    <value name="r11f_g11f_b10f" value="8"/>
+    <value name="rgba32f"  value="9"/>
+    <value name="rg32f"    value="10"/>
+    <value name="r32f"     value="11"/>
+    <value name="rgba32i"  value="12"/>
+    <value name="rg32i"    value="13"/>
+    <value name="r32i"     value="14"/>
+    <value name="rgba32ui" value="15"/>
+    <value name="rg32ui"   value="16"/>
+    <value name="r32ui"    value="17"/>
+    <value name="rgba16f"  value="18"/>
+    <value name="rg16f"    value="19"/>
+    <value name="r16f"     value="20"/>
+    <value name="rgba16i"  value="21"/>
+    <value name="rg16i"    value="22"/>
+    <value name="r16i"     value="23"/>
+    <value name="rgba16ui" value="24"/>
+    <value name="rg16ui"   value="25"/>
+    <value name="r16ui"    value="26"/>
+    <value name="rgba8"    value="27"/>
+    <value name="rgb8"     value="28"/>
+    <value name="rg8"      value="29"/>
+    <value name="r8"       value="30"/>
+    <value name="rgba8i"   value="31"/>
+    <value name="rg8i"     value="32"/>
+    <value name="r8i"      value="33"/>
+    <value name="rgba8ui"  value="34"/>
+    <value name="rg8ui"    value="35"/>
+    <value name="r8ui"     value="36"/>
+    <value name="srgbx8"   value="37"/>
+    <value name="rgbx8"    value="38"/>
+  </enum>
+
+  <enum name="Z/S Output Image Format" prefix="V3D_OUTPUT_IMAGE_FORMAT_ZS">
+    <value name="depth_component32f" value="0"/>
+    <value name="depth_component24" value="1"/> <!-- depth low, pad high -->
+    <value name="depth_component16" value="2"/>
+    <value name="depth24_stencil8" value="3"/> <!-- stencil low, depth high -->
+  </enum>
+
   <packet code="0" name="Halt"/>
   <packet code="1" name="NOP"/>
   <packet code="4" name="Flush"/>
     <field name="A dithered" size="1" start="23" type="bool"/>
     <field name="BGR dithered" size="1" start="22" type="bool"/>
 
-    <field name="Output image format" size="6" start="16" type="uint" prefix="Output Image Format">
-    <!--
-       Formats appear with their channels named from the low bits to
-       the high bits.
-    -->
-      <value name="srgb8_alpha8" value="0"/>
-      <value name="srgb" value="1"/>
-      <value name="rgb10_a2ui" value="2"/>
-      <value name="rgb10_a2" value="3"/>
-      <value name="abgr1555" value="4"/>
-      <value name="alpha-masked abgr1555" value="5"/>
-      <value name="abgr4444" value="6"/>
-      <value name="bgr565" value="7"/>
-      <value name="r11f_g11f_b10f" value="8"/>
-      <value name="rgba32f"  value="9"/>
-      <value name="rg32f"    value="10"/>
-      <value name="r32f"     value="11"/>
-      <value name="rgba32i"  value="12"/>
-      <value name="rg32i"    value="13"/>
-      <value name="r32i"     value="14"/>
-      <value name="rgba32ui" value="15"/>
-      <value name="rg32ui"   value="16"/>
-      <value name="r32ui"    value="17"/>
-      <value name="rgba16f"  value="18"/>
-      <value name="rg16f"    value="19"/>
-      <value name="r16f"     value="20"/>
-      <value name="rgba16i"  value="21"/>
-      <value name="rg16i"    value="22"/>
-      <value name="r16i"     value="23"/>
-      <value name="rgba16ui" value="24"/>
-      <value name="rg16ui"   value="25"/>
-      <value name="r16ui"    value="26"/>
-      <value name="rgba8"    value="27"/>
-      <value name="rgb8"     value="28"/>
-      <value name="rg8"      value="29"/>
-      <value name="r8"       value="30"/>
-      <value name="rgba8i"   value="31"/>
-      <value name="rg8i"     value="32"/>
-      <value name="r8i"      value="33"/>
-      <value name="rgba8ui"  value="34"/>
-      <value name="rg8ui"    value="35"/>
-      <value name="r8ui"     value="36"/>
-      <value name="srgbx8"   value="37"/>
-      <value name="rgbx8"    value="38"/>
-    </field>
+    <field name="Output image format" size="6" start="16" type="Output Image Format"/>
 
     <field name="Decimate mode" size="2" start="14" type="uint"/>
 
 
     <field name="Memory Format" size="3" start="22" type="Memory Format"/>
 
-    <field name="Output image format" size="6" start="16" type="uint" prefix="Output Image Format">
-      <value name="depth_component32f" value="0"/>
-      <value name="depth_component24" value="1"/> <!-- depth low, pad high -->
-      <value name="depth_component16" value="2"/>
-      <value name="depth24_stencil8" value="3"/> <!-- stencil low, depth high -->
-    </field>
+    <field name="Output image format" size="6" start="16" type="Z/S Output Image Format"/>
 
     <field name="Decimate mode" size="2" start="14" type="uint"/>
 
index 6c541ea47ea5a00dfd8a18accb1acbc7dc4d2e0d..b16ac1db3f8a6bd95773ed0e49c82eb210f1fc20 100644 (file)
@@ -38,7 +38,7 @@
 #include "vc5_context.h"
 #include "broadcom/cle/v3d_packet_v33_pack.h"
 
-#define OUTPUT_IMAGE_FORMAT_NO 255
+#define V3D_OUTPUT_IMAGE_FORMAT_NO 255
 
 struct vc5_format {
         /** Set if the pipe format is defined in the table. */
@@ -77,7 +77,7 @@ struct vc5_format {
 #define FORMAT(pipe, rt, tex, swiz, return_size, return_channels)       \
         [PIPE_FORMAT_##pipe] = {                                        \
                 true,                                                   \
-                OUTPUT_IMAGE_FORMAT_##rt,                               \
+                V3D_OUTPUT_IMAGE_FORMAT_##rt,                           \
                 TEXTURE_DATA_FORMAT_##tex,                              \
                 swiz,                                                   \
                 return_size,                                            \
@@ -182,14 +182,14 @@ static const struct vc5_format vc5_format_table[] = {
         FORMAT(R11G11B10_FLOAT,   R11F_G11F_B10F, R11F_G11F_B10F, SWIZ_XYZW, 16, 0),
         FORMAT(R9G9B9E5_FLOAT,    NO,           RGB9_E5,     SWIZ_XYZW, 16, 0),
 
-        FORMAT(S8_UINT_Z24_UNORM, DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
-        FORMAT(X8Z24_UNORM,       DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
+        FORMAT(S8_UINT_Z24_UNORM, ZS_DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
+        FORMAT(X8Z24_UNORM,       ZS_DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
         FORMAT(S8X24_UINT,        NO,           R32F,        SWIZ_XXXX, 32, 1),
-        FORMAT(Z32_FLOAT,         DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
-        FORMAT(Z16_UNORM,         DEPTH_COMPONENT16,  DEPTH_COMP16, SWIZ_XXXX, 32, 1),
+        FORMAT(Z32_FLOAT,         ZS_DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
+        FORMAT(Z16_UNORM,         ZS_DEPTH_COMPONENT16,  DEPTH_COMP16, SWIZ_XXXX, 32, 1),
 
         /* Pretend we support this, but it'll be separate Z32F depth and S8. */
-        FORMAT(Z32_FLOAT_S8X24_UINT, DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
+        FORMAT(Z32_FLOAT_S8X24_UINT, ZS_DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
 
         FORMAT(ETC2_RGB8,         NO,           RGB8_ETC2,   SWIZ_XYZ1, 16, 0),
         FORMAT(ETC2_SRGB8,        NO,           RGB8_ETC2,   SWIZ_XYZ1, 16, 0),
@@ -225,7 +225,7 @@ vc5_rt_format_supported(enum pipe_format f)
         if (!vf)
                 return false;
 
-        return vf->rt_type != OUTPUT_IMAGE_FORMAT_NO;
+        return vf->rt_type != V3D_OUTPUT_IMAGE_FORMAT_NO;
 }
 
 uint8_t
@@ -301,38 +301,38 @@ vc5_get_internal_type_bpp_for_output_format(uint32_t format,
                                             uint32_t *bpp)
 {
         switch (format) {
-        case OUTPUT_IMAGE_FORMAT_RGBA8:
-        case OUTPUT_IMAGE_FORMAT_RGBX8:
-        case OUTPUT_IMAGE_FORMAT_RGB8:
-        case OUTPUT_IMAGE_FORMAT_RG8:
-        case OUTPUT_IMAGE_FORMAT_R8:
-        case OUTPUT_IMAGE_FORMAT_ABGR4444:
-        case OUTPUT_IMAGE_FORMAT_BGR565:
-        case OUTPUT_IMAGE_FORMAT_ABGR1555:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA8:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBX8:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGB8:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG8:
+        case V3D_OUTPUT_IMAGE_FORMAT_R8:
+        case V3D_OUTPUT_IMAGE_FORMAT_ABGR4444:
+        case V3D_OUTPUT_IMAGE_FORMAT_BGR565:
+        case V3D_OUTPUT_IMAGE_FORMAT_ABGR1555:
                 *type = INTERNAL_TYPE_8;
                 *bpp = INTERNAL_BPP_32;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RGBA8I:
-        case OUTPUT_IMAGE_FORMAT_RG8I:
-        case OUTPUT_IMAGE_FORMAT_R8I:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA8I:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG8I:
+        case V3D_OUTPUT_IMAGE_FORMAT_R8I:
                 *type = INTERNAL_TYPE_8I;
                 *bpp = INTERNAL_BPP_32;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RGBA8UI:
-        case OUTPUT_IMAGE_FORMAT_RG8UI:
-        case OUTPUT_IMAGE_FORMAT_R8UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA8UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG8UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_R8UI:
                 *type = INTERNAL_TYPE_8UI;
                 *bpp = INTERNAL_BPP_32;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_SRGB8_ALPHA8:
-        case OUTPUT_IMAGE_FORMAT_SRGB:
-        case OUTPUT_IMAGE_FORMAT_RGB10_A2:
-        case OUTPUT_IMAGE_FORMAT_R11F_G11F_B10F:
-        case OUTPUT_IMAGE_FORMAT_SRGBX8:
-        case OUTPUT_IMAGE_FORMAT_RGBA16F:
+        case V3D_OUTPUT_IMAGE_FORMAT_SRGB8_ALPHA8:
+        case V3D_OUTPUT_IMAGE_FORMAT_SRGB:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGB10_A2:
+        case V3D_OUTPUT_IMAGE_FORMAT_R11F_G11F_B10F:
+        case V3D_OUTPUT_IMAGE_FORMAT_SRGBX8:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA16F:
                 /* Note that sRGB RTs are stored in the tile buffer at 16F,
                  * and the conversion to sRGB happens at tilebuffer
                  * load/store.
@@ -341,8 +341,8 @@ vc5_get_internal_type_bpp_for_output_format(uint32_t format,
                 *bpp = INTERNAL_BPP_64;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RG16F:
-        case OUTPUT_IMAGE_FORMAT_R16F:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG16F:
+        case V3D_OUTPUT_IMAGE_FORMAT_R16F:
                 *type = INTERNAL_TYPE_16F;
                 /* Use 64bpp to make sure the TLB doesn't throw away the alpha
                  * channel before alpha test happens.
@@ -350,61 +350,61 @@ vc5_get_internal_type_bpp_for_output_format(uint32_t format,
                 *bpp = INTERNAL_BPP_64;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RGBA16I:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA16I:
                 *type = INTERNAL_TYPE_16I;
                 *bpp = INTERNAL_BPP_64;
                 break;
-        case OUTPUT_IMAGE_FORMAT_RG16I:
-        case OUTPUT_IMAGE_FORMAT_R16I:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG16I:
+        case V3D_OUTPUT_IMAGE_FORMAT_R16I:
                 *type = INTERNAL_TYPE_16I;
                 *bpp = INTERNAL_BPP_32;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RGBA16UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA16UI:
                 *type = INTERNAL_TYPE_16UI;
                 *bpp = INTERNAL_BPP_64;
                 break;
-        case OUTPUT_IMAGE_FORMAT_RG16UI:
-        case OUTPUT_IMAGE_FORMAT_R16UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG16UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_R16UI:
                 *type = INTERNAL_TYPE_16UI;
                 *bpp = INTERNAL_BPP_32;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RGBA32I:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA32I:
                 *type = INTERNAL_TYPE_32I;
                 *bpp = INTERNAL_BPP_128;
                 break;
-        case OUTPUT_IMAGE_FORMAT_RG32I:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG32I:
                 *type = INTERNAL_TYPE_32I;
                 *bpp = INTERNAL_BPP_64;
                 break;
-        case OUTPUT_IMAGE_FORMAT_R32I:
+        case V3D_OUTPUT_IMAGE_FORMAT_R32I:
                 *type = INTERNAL_TYPE_32I;
                 *bpp = INTERNAL_BPP_32;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RGBA32UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA32UI:
                 *type = INTERNAL_TYPE_32UI;
                 *bpp = INTERNAL_BPP_128;
                 break;
-        case OUTPUT_IMAGE_FORMAT_RG32UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG32UI:
                 *type = INTERNAL_TYPE_32UI;
                 *bpp = INTERNAL_BPP_64;
                 break;
-        case OUTPUT_IMAGE_FORMAT_R32UI:
+        case V3D_OUTPUT_IMAGE_FORMAT_R32UI:
                 *type = INTERNAL_TYPE_32UI;
                 *bpp = INTERNAL_BPP_32;
                 break;
 
-        case OUTPUT_IMAGE_FORMAT_RGBA32F:
+        case V3D_OUTPUT_IMAGE_FORMAT_RGBA32F:
                 *type = INTERNAL_TYPE_32F;
                 *bpp = INTERNAL_BPP_128;
                 break;
-        case OUTPUT_IMAGE_FORMAT_RG32F:
+        case V3D_OUTPUT_IMAGE_FORMAT_RG32F:
                 *type = INTERNAL_TYPE_32F;
                 *bpp = INTERNAL_BPP_64;
                 break;
-        case OUTPUT_IMAGE_FORMAT_R32F:
+        case V3D_OUTPUT_IMAGE_FORMAT_R32F:
                 *type = INTERNAL_TYPE_32F;
                 *bpp = INTERNAL_BPP_32;
                 break;