[Mesa-dev] [PATCH] radv: don't pass shader key by copy

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Oct 5 07:28:34 UTC 2018


Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

On 10/5/18 1:18 AM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> Coverity pointed out we were copying 168 bytes here unnecessarily.
> ---
>   src/amd/vulkan/radv_pipeline.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
> index 4b626a59af2..c1fe4ece396 100644
> --- a/src/amd/vulkan/radv_pipeline.c
> +++ b/src/amd/vulkan/radv_pipeline.c
> @@ -1989,7 +1989,7 @@ static
>   void radv_create_shaders(struct radv_pipeline *pipeline,
>                            struct radv_device *device,
>                            struct radv_pipeline_cache *cache,
> -                         struct radv_pipeline_key key,
> +                         const struct radv_pipeline_key *key,
>                            const VkPipelineShaderStageCreateInfo **pStages,
>                            const VkPipelineCreateFlags flags)
>   {
> @@ -2013,7 +2013,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
>   		}
>   	}
>   
> -	radv_hash_shaders(hash, pStages, pipeline->layout, &key, get_hash_flags(device));
> +	radv_hash_shaders(hash, pStages, pipeline->layout, key, get_hash_flags(device));
>   	memcpy(gs_copy_hash, hash, 20);
>   	gs_copy_hash[0] ^= 1;
>   
> @@ -2094,7 +2094,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
>   			nir_print_shader(nir[i], stderr);
>   	}
>   
> -	radv_fill_shader_keys(keys, &key, nir);
> +	radv_fill_shader_keys(keys, key, nir);
>   
>   	if (nir[MESA_SHADER_FRAGMENT]) {
>   		if (!pipeline->shaders[MESA_SHADER_FRAGMENT]) {
> @@ -3496,9 +3496,8 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
>   		pStages[stage] = &pCreateInfo->pStages[i];
>   	}
>   
> -	radv_create_shaders(pipeline, device, cache,
> -	                    radv_generate_graphics_pipeline_key(pipeline, pCreateInfo, &blend, has_view_index),
> -	                    pStages, pCreateInfo->flags);
> +	struct radv_pipeline_key key = radv_generate_graphics_pipeline_key(pipeline, pCreateInfo, &blend, has_view_index);
> +	radv_create_shaders(pipeline, device, cache, &key, pStages, pCreateInfo->flags);
>   
>   	pipeline->graphics.spi_baryc_cntl = S_0286E0_FRONT_FACE_ALL_BITS(1);
>   	radv_pipeline_init_multisample_state(pipeline, &blend, pCreateInfo);
> @@ -3731,7 +3730,7 @@ static VkResult radv_compute_pipeline_create(
>   	assert(pipeline->layout);
>   
>   	pStages[MESA_SHADER_COMPUTE] = &pCreateInfo->stage;
> -	radv_create_shaders(pipeline, device, cache, (struct radv_pipeline_key) {0}, pStages, pCreateInfo->flags);
> +	radv_create_shaders(pipeline, device, cache, &(struct radv_pipeline_key) {0}, pStages, pCreateInfo->flags);
>   
>   	pipeline->user_data_0[MESA_SHADER_COMPUTE] = radv_pipeline_stage_to_user_data_0(pipeline, MESA_SHADER_COMPUTE, device->physical_device->rad_info.chip_class);
>   	pipeline->need_indirect_descriptor_sets |= pipeline->shaders[MESA_SHADER_COMPUTE]->info.need_indirect_descriptor_sets;
> 


More information about the mesa-dev mailing list