radeonsi: make use of ac_get_spi_shader_z_format()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 14 Dec 2017 12:51:46 +0000 (13:51 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 14 Dec 2017 21:23:25 +0000 (22:23 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 0077054749914fa9c492aeb1f7272882f0525185..5e49d655fc61a9c5dca2ac21f17cb4fe4d7d40f0 100644 (file)
@@ -37,6 +37,7 @@
 #include "ac_binary.h"
 #include "ac_llvm_util.h"
 #include "ac_exp_param.h"
+#include "ac_shader_util.h"
 #include "si_shader_internal.h"
 #include "si_pipe.h"
 #include "sid.h"
@@ -3419,25 +3420,6 @@ struct si_ps_exports {
        struct ac_export_args args[10];
 };
 
-unsigned si_get_spi_shader_z_format(bool writes_z, bool writes_stencil,
-                                   bool writes_samplemask)
-{
-       if (writes_z) {
-               /* Z needs 32 bits. */
-               if (writes_samplemask)
-                       return V_028710_SPI_SHADER_32_ABGR;
-               else if (writes_stencil)
-                       return V_028710_SPI_SHADER_32_GR;
-               else
-                       return V_028710_SPI_SHADER_32_R;
-       } else if (writes_stencil || writes_samplemask) {
-               /* Both stencil and sample mask need only 16 bits. */
-               return V_028710_SPI_SHADER_UINT16_ABGR;
-       } else {
-               return V_028710_SPI_SHADER_ZERO;
-       }
-}
-
 static void si_export_mrt_z(struct lp_build_tgsi_context *bld_base,
                            LLVMValueRef depth, LLVMValueRef stencil,
                            LLVMValueRef samplemask, struct si_ps_exports *exp)
@@ -3446,7 +3428,7 @@ static void si_export_mrt_z(struct lp_build_tgsi_context *bld_base,
        struct lp_build_context *base = &bld_base->base;
        struct ac_export_args args;
        unsigned mask = 0;
-       unsigned format = si_get_spi_shader_z_format(depth != NULL,
+       unsigned format = ac_get_spi_shader_z_format(depth != NULL,
                                                     stencil != NULL,
                                                     samplemask != NULL);
 
index bcb5c9da4cea77750858eea18988718abc93e42d..c981d3562e22d12fc3f2e7a214b8a532d219e374 100644 (file)
@@ -647,8 +647,6 @@ void si_shader_apply_scratch_relocs(struct si_shader *shader,
 void si_shader_binary_read_config(struct ac_shader_binary *binary,
                                  struct si_shader_config *conf,
                                  unsigned symbol_offset);
-unsigned si_get_spi_shader_z_format(bool writes_z, bool writes_stencil,
-                                   bool writes_samplemask);
 const char *si_get_shader_name(const struct si_shader *shader, unsigned processor);
 
 /* si_shader_nir.c */
index 4f683b85144152b7cfaf889cbfe5fceb852acb20..25854a1fde1a92bbc14e9416fb7fabec9278a31d 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/disk_cache.h"
 #include "util/mesa-sha1.h"
 #include "ac_exp_param.h"
+#include "ac_shader_util.h"
 
 /* SHADER_CACHE */
 
@@ -1123,7 +1124,7 @@ static void si_shader_ps(struct si_shader *shader)
        si_pm4_set_reg(pm4, R_0286D8_SPI_PS_IN_CONTROL, spi_ps_in_control);
 
        si_pm4_set_reg(pm4, R_028710_SPI_SHADER_Z_FORMAT,
-                      si_get_spi_shader_z_format(info->writes_z,
+                      ac_get_spi_shader_z_format(info->writes_z,
                                                  info->writes_stencil,
                                                  info->writes_samplemask));