amd/common: add ac_get_cb_shader_mask() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 15 Dec 2017 14:37:18 +0000 (15:37 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 18 Dec 2017 10:50:48 +0000 (11:50 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_shader_util.c
src/amd/common/ac_shader_util.h
src/amd/vulkan/radv_pipeline.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index 9d33a465591bcaedc36f0fb6924c35c7d8c39e78..ab8d3ed49bcfc3f862f280636ab8036599c87b85 100644 (file)
@@ -21,6 +21,8 @@
  * IN THE SOFTWARE.
  */
 
+#include <assert.h>
+
 #include "ac_shader_util.h"
 #include "sid.h"
 
@@ -43,3 +45,36 @@ ac_get_spi_shader_z_format(bool writes_z, bool writes_stencil,
                return V_028710_SPI_SHADER_ZERO;
        }
 }
+
+unsigned
+ac_get_cb_shader_mask(unsigned spi_shader_col_format)
+{
+       unsigned i, cb_shader_mask = 0;
+
+       for (i = 0; i < 8; i++) {
+               switch ((spi_shader_col_format >> (i * 4)) & 0xf) {
+               case V_028714_SPI_SHADER_ZERO:
+                       break;
+               case V_028714_SPI_SHADER_32_R:
+                       cb_shader_mask |= 0x1 << (i * 4);
+                       break;
+               case V_028714_SPI_SHADER_32_GR:
+                       cb_shader_mask |= 0x3 << (i * 4);
+                       break;
+               case V_028714_SPI_SHADER_32_AR:
+                       cb_shader_mask |= 0x9 << (i * 4);
+                       break;
+               case V_028714_SPI_SHADER_FP16_ABGR:
+               case V_028714_SPI_SHADER_UNORM16_ABGR:
+               case V_028714_SPI_SHADER_SNORM16_ABGR:
+               case V_028714_SPI_SHADER_UINT16_ABGR:
+               case V_028714_SPI_SHADER_SINT16_ABGR:
+               case V_028714_SPI_SHADER_32_ABGR:
+                       cb_shader_mask |= 0xf << (i * 4);
+                       break;
+               default:
+                       assert(0);
+               }
+       }
+       return cb_shader_mask;
+}
index 1f971e76f1623db635a8aaae04486c6f1afba784..d3804b8fb1352897c7f97ffa0dfd8bd2126adf7e 100644 (file)
@@ -30,4 +30,7 @@ unsigned
 ac_get_spi_shader_z_format(bool writes_z, bool writes_stencil,
                           bool writes_samplemask);
 
+unsigned
+ac_get_cb_shader_mask(unsigned spi_shader_col_format);
+
 #endif
index 903a2945e99b4172a5d4ae6b81b38c70c82b174d..66675c9b4b0b83aa45ea3d23426b346a7ae15ad2 100644 (file)
@@ -416,38 +416,6 @@ static unsigned si_choose_spi_color_format(VkFormat vk_format,
                return normal;
 }
 
-static unsigned si_get_cb_shader_mask(unsigned spi_shader_col_format)
-{
-       unsigned i, cb_shader_mask = 0;
-
-       for (i = 0; i < 8; i++) {
-               switch ((spi_shader_col_format >> (i * 4)) & 0xf) {
-               case V_028714_SPI_SHADER_ZERO:
-                       break;
-               case V_028714_SPI_SHADER_32_R:
-                       cb_shader_mask |= 0x1 << (i * 4);
-                       break;
-               case V_028714_SPI_SHADER_32_GR:
-                       cb_shader_mask |= 0x3 << (i * 4);
-                       break;
-               case V_028714_SPI_SHADER_32_AR:
-                       cb_shader_mask |= 0x9 << (i * 4);
-                       break;
-               case V_028714_SPI_SHADER_FP16_ABGR:
-               case V_028714_SPI_SHADER_UNORM16_ABGR:
-               case V_028714_SPI_SHADER_SNORM16_ABGR:
-               case V_028714_SPI_SHADER_UINT16_ABGR:
-               case V_028714_SPI_SHADER_SINT16_ABGR:
-               case V_028714_SPI_SHADER_32_ABGR:
-                       cb_shader_mask |= 0xf << (i * 4);
-                       break;
-               default:
-                       assert(0);
-               }
-       }
-       return cb_shader_mask;
-}
-
 static void
 radv_pipeline_compute_spi_color_formats(struct radv_pipeline *pipeline,
                                        const VkGraphicsPipelineCreateInfo *pCreateInfo,
@@ -477,7 +445,7 @@ radv_pipeline_compute_spi_color_formats(struct radv_pipeline *pipeline,
                col_format |= cf << (4 * i);
        }
 
-       blend->cb_shader_mask = si_get_cb_shader_mask(col_format);
+       blend->cb_shader_mask = ac_get_cb_shader_mask(col_format);
 
        if (blend_mrt0_is_dual_src)
                col_format |= (col_format & 0xf) << 4;
index 25854a1fde1a92bbc14e9416fb7fabec9278a31d..d33008cdda77f3470d17bfa15611aa43494c83d2 100644 (file)
@@ -981,38 +981,6 @@ static unsigned si_get_spi_shader_col_format(struct si_shader *shader)
        return value;
 }
 
-static unsigned si_get_cb_shader_mask(unsigned spi_shader_col_format)
-{
-       unsigned i, cb_shader_mask = 0;
-
-       for (i = 0; i < 8; i++) {
-               switch ((spi_shader_col_format >> (i * 4)) & 0xf) {
-               case V_028714_SPI_SHADER_ZERO:
-                       break;
-               case V_028714_SPI_SHADER_32_R:
-                       cb_shader_mask |= 0x1 << (i * 4);
-                       break;
-               case V_028714_SPI_SHADER_32_GR:
-                       cb_shader_mask |= 0x3 << (i * 4);
-                       break;
-               case V_028714_SPI_SHADER_32_AR:
-                       cb_shader_mask |= 0x9 << (i * 4);
-                       break;
-               case V_028714_SPI_SHADER_FP16_ABGR:
-               case V_028714_SPI_SHADER_UNORM16_ABGR:
-               case V_028714_SPI_SHADER_SNORM16_ABGR:
-               case V_028714_SPI_SHADER_UINT16_ABGR:
-               case V_028714_SPI_SHADER_SINT16_ABGR:
-               case V_028714_SPI_SHADER_32_ABGR:
-                       cb_shader_mask |= 0xf << (i * 4);
-                       break;
-               default:
-                       assert(0);
-               }
-       }
-       return cb_shader_mask;
-}
-
 static void si_shader_ps(struct si_shader *shader)
 {
        struct tgsi_shader_info *info = &shader->selector->info;
@@ -1095,7 +1063,7 @@ static void si_shader_ps(struct si_shader *shader)
                spi_baryc_cntl |= S_0286E0_POS_FLOAT_ULC(1);
 
        spi_shader_col_format = si_get_spi_shader_col_format(shader);
-       cb_shader_mask = si_get_cb_shader_mask(spi_shader_col_format);
+       cb_shader_mask = ac_get_cb_shader_mask(spi_shader_col_format);
 
        /* Ensure that some export memory is always allocated, for two reasons:
         *