diff options
author | Bas Nieuwenhuizen <[email protected]> | 2017-07-02 02:48:41 +0200 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2017-08-24 19:20:47 +0200 |
commit | eec5578158c7e6c53c4744c354ae6256f100befc (patch) | |
tree | b3efa5398451ab8290057ee649a02eb4c1b5025a /src | |
parent | 64164a1313fcdf1084b0f8a9499165ee22a13aa7 (diff) |
ac/nir: Make shader key a struct.
Some bits can be passed to almost every shader, and I don't like
adding 5 variables.
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.h | 14 | ||||
-rw-r--r-- | src/amd/vulkan/radv_pipeline.c | 26 | ||||
-rw-r--r-- | src/amd/vulkan/radv_pipeline_cache.c | 2 | ||||
-rw-r--r-- | src/amd/vulkan/radv_private.h | 4 |
4 files changed, 24 insertions, 22 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h index 53ea238c3c9..a6e01782ba8 100644 --- a/src/amd/common/ac_nir_to_llvm.h +++ b/src/amd/common/ac_nir_to_llvm.h @@ -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; diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 477abfe4915..90ab985af17 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -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], diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index 3995434d903..99a614dc104 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -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; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index c2a4cfb04bc..b12b05f0453 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -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 |