ac/nir: Make shader key a struct.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sun, 2 Jul 2017 00:48:41 +0000 (02:48 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 24 Aug 2017 17:20:47 +0000 (19:20 +0200)
Some bits can be passed to almost every shader, and I don't like
adding 5 variables.

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.h
src/amd/vulkan/radv_pipeline.c
src/amd/vulkan/radv_pipeline_cache.c
src/amd/vulkan/radv_private.h

index 53ea238c3c96c9b121ef319c817b5e9284cd6c20..a6e01782ba8f3acf03934c770adc964bfcbb164e 100644 (file)
@@ -63,16 +63,18 @@ struct ac_fs_variant_key {
        uint32_t multisample : 1;
 };
 
-union ac_shader_variant_key {
-       struct ac_vs_variant_key vs;
-       struct ac_fs_variant_key fs;
-       struct ac_tes_variant_key tes;
-       struct ac_tcs_variant_key tcs;
+struct ac_shader_variant_key {
+       union {
+               struct ac_vs_variant_key vs;
+               struct ac_fs_variant_key fs;
+               struct ac_tes_variant_key tes;
+               struct ac_tcs_variant_key tcs;
+       };
 };
 
 struct ac_nir_compiler_options {
        struct radv_pipeline_layout *layout;
-       union ac_shader_variant_key key;
+       struct ac_shader_variant_key key;
        bool unsafe_math;
        bool supports_spill;
        enum radeon_family family;
index 477abfe491582930b0700bbb33ebe5e0a88c73fc..90ab985af17dac8bdd7098983797af6291d09bce 100644 (file)
@@ -441,7 +441,7 @@ static void radv_fill_shader_variant(struct radv_device *device,
 static struct radv_shader_variant *radv_shader_variant_create(struct radv_device *device,
                                                              struct nir_shader *shader,
                                                              struct radv_pipeline_layout *layout,
-                                                             const union ac_shader_variant_key *key,
+                                                             const struct ac_shader_variant_key *key,
                                                              void** code_out,
                                                              unsigned *code_size_out,
                                                              bool dump)
@@ -538,7 +538,7 @@ radv_pipeline_compile(struct radv_pipeline *pipeline,
                      gl_shader_stage stage,
                      const VkSpecializationInfo *spec_info,
                      struct radv_pipeline_layout *layout,
-                     const union ac_shader_variant_key *key)
+                     const struct ac_shader_variant_key *key)
 {
        unsigned char sha1[20];
        unsigned char gs_copy_sha1[20];
@@ -613,10 +613,10 @@ radv_pipeline_compile(struct radv_pipeline *pipeline,
        return variant;
 }
 
-static union ac_shader_variant_key
+static struct ac_shader_variant_key
 radv_compute_tes_key(bool as_es, bool export_prim_id)
 {
-       union ac_shader_variant_key key;
+       struct ac_shader_variant_key key;
        memset(&key, 0, sizeof(key));
        key.tes.as_es = as_es;
        /* export prim id only happens when no geom shader */
@@ -625,10 +625,10 @@ radv_compute_tes_key(bool as_es, bool export_prim_id)
        return key;
 }
 
-static union ac_shader_variant_key
+static struct ac_shader_variant_key
 radv_compute_tcs_key(unsigned primitive_mode, unsigned input_vertices)
 {
-       union ac_shader_variant_key key;
+       struct ac_shader_variant_key key;
        memset(&key, 0, sizeof(key));
        key.tcs.primitive_mode = primitive_mode;
        key.tcs.input_vertices = input_vertices;
@@ -652,8 +652,8 @@ radv_tess_pipeline_compile(struct radv_pipeline *pipeline,
        nir_shader *tes_nir, *tcs_nir;
        void *tes_code = NULL, *tcs_code = NULL;
        unsigned tes_code_size = 0, tcs_code_size = 0;
-       union ac_shader_variant_key tes_key;
-       union ac_shader_variant_key tcs_key;
+       struct ac_shader_variant_key tes_key;
+       struct ac_shader_variant_key tcs_key;
        bool dump = (pipeline->device->debug_flags & RADV_DEBUG_DUMP_SHADERS);
 
        tes_key = radv_compute_tes_key(radv_pipeline_has_gs(pipeline),
@@ -1780,10 +1780,10 @@ radv_pipeline_init_dynamic_state(struct radv_pipeline *pipeline,
        pipeline->dynamic_state_mask = states;
 }
 
-static union ac_shader_variant_key
+static struct ac_shader_variant_key
 radv_compute_vs_key(const VkGraphicsPipelineCreateInfo *pCreateInfo, bool as_es, bool as_ls, bool export_prim_id)
 {
-       union ac_shader_variant_key key;
+       struct ac_shader_variant_key key;
        const VkPipelineVertexInputStateCreateInfo *input_state =
                                                 pCreateInfo->pVertexInputState;
 
@@ -2192,7 +2192,7 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
        }
 
        if (modules[MESA_SHADER_FRAGMENT]) {
-               union ac_shader_variant_key key = {0};
+               struct ac_shader_variant_key key = {0};
                key.fs.col_format = pipeline->graphics.blend.spi_shader_col_format;
                if (pCreateInfo->pMultisampleState &&
                    pCreateInfo->pMultisampleState->rasterizationSamples > 1)
@@ -2225,7 +2225,7 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
                        as_es = true;
                else if (pipeline->shaders[MESA_SHADER_FRAGMENT]->info.fs.prim_id_input)
                        export_prim_id = true;
-               union ac_shader_variant_key key = radv_compute_vs_key(pCreateInfo, as_es, as_ls, export_prim_id);
+               struct ac_shader_variant_key key = radv_compute_vs_key(pCreateInfo, as_es, as_ls, export_prim_id);
 
                pipeline->shaders[MESA_SHADER_VERTEX] =
                         radv_pipeline_compile(pipeline, cache, modules[MESA_SHADER_VERTEX],
@@ -2238,7 +2238,7 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
        }
 
        if (modules[MESA_SHADER_GEOMETRY]) {
-               union ac_shader_variant_key key = radv_compute_vs_key(pCreateInfo, false, false, false);
+               struct ac_shader_variant_key key = radv_compute_vs_key(pCreateInfo, false, false, false);
 
                pipeline->shaders[MESA_SHADER_GEOMETRY] =
                         radv_pipeline_compile(pipeline, cache, modules[MESA_SHADER_GEOMETRY],
index 3995434d9038693607ff2202ea2d59635cc48cba..99a614dc1049876b32e1befb4e1f4c674ce7b615 100644 (file)
@@ -89,7 +89,7 @@ radv_hash_shader(unsigned char *hash, struct radv_shader_module *module,
                 const char *entrypoint,
                 const VkSpecializationInfo *spec_info,
                 const struct radv_pipeline_layout *layout,
-                const union ac_shader_variant_key *key,
+                const struct ac_shader_variant_key *key,
                 uint32_t is_geom_copy_shader)
 {
        struct mesa_sha1 ctx;
index c2a4cfb04bc543d09a54ccfa253267e3f8a7f09c..b12b05f04535ae50385692827005b489f6f1f67a 100644 (file)
@@ -956,14 +956,14 @@ struct radv_shader_module {
        char                                         data[0];
 };
 
-union ac_shader_variant_key;
+struct ac_shader_variant_key;
 
 void
 radv_hash_shader(unsigned char *hash, struct radv_shader_module *module,
                 const char *entrypoint,
                 const VkSpecializationInfo *spec_info,
                 const struct radv_pipeline_layout *layout,
-                const union ac_shader_variant_key *key,
+                const struct ac_shader_variant_key *key,
                 uint32_t is_geom_copy_shader);
 
 static inline gl_shader_stage