[Mesa-dev] [PATCH 7/9] radv: remove some now unused shader compile code

Timothy Arceri tarceri at itsqueeze.com
Sat Oct 14 23:36:45 UTC 2017


---
 src/amd/vulkan/radv_pipeline.c       | 220 -----------------------------------
 src/amd/vulkan/radv_pipeline_cache.c |  26 -----
 src/amd/vulkan/radv_private.h        |   8 --
 3 files changed, 254 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 446e14226f..4bb9fbb15b 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -92,240 +92,20 @@ static uint32_t get_hash_flags(struct radv_device *device)
 {
 	uint32_t hash_flags = 0;
 
 	if (device->instance->debug_flags & RADV_DEBUG_UNSAFE_MATH)
 		hash_flags |= RADV_HASH_SHADER_UNSAFE_MATH;
 	if (device->instance->perftest_flags & RADV_PERFTEST_SISCHED)
 		hash_flags |= RADV_HASH_SHADER_SISCHED;
 	return hash_flags;
 }
 
-static struct radv_shader_variant *
-radv_pipeline_compile(struct radv_pipeline *pipeline,
-		      struct radv_pipeline_cache *cache,
-		      struct radv_shader_module *module,
-		      const char *entrypoint,
-		      gl_shader_stage stage,
-		      const VkSpecializationInfo *spec_info,
-		      struct radv_pipeline_layout *layout,
-		      const struct ac_shader_variant_key *key)
-{
-	unsigned char sha1[20];
-	unsigned char gs_copy_sha1[20];
-	struct radv_shader_variant *variant;
-	nir_shader *nir;
-	void *code = NULL;
-	unsigned code_size = 0;
-	unsigned hash_flags = get_hash_flags(pipeline->device);
-	if (module->nir)
-		_mesa_sha1_compute(module->nir->info.name,
-				   strlen(module->nir->info.name),
-				   module->sha1);
-
-	radv_hash_shader(sha1, module, entrypoint, spec_info, layout, key, hash_flags);
-	if (stage == MESA_SHADER_GEOMETRY)
-		radv_hash_shader(gs_copy_sha1, module, entrypoint, spec_info,
-				 layout, key, hash_flags | RADV_HASH_SHADER_IS_GEOM_COPY_SHADER);
-
-	variant = radv_create_shader_variant_from_pipeline_cache(pipeline->device,
-								 cache,
-								 sha1);
-
-	if (stage == MESA_SHADER_GEOMETRY) {
-		pipeline->gs_copy_shader =
-			radv_create_shader_variant_from_pipeline_cache(
-				pipeline->device,
-				cache,
-				gs_copy_sha1);
-	}
-
-	if (variant &&
-	    (stage != MESA_SHADER_GEOMETRY || pipeline->gs_copy_shader))
-		return variant;
-
-	nir = radv_shader_compile_to_nir(pipeline->device,
-				         module, entrypoint, stage,
-					 spec_info);
-	if (nir == NULL)
-		return NULL;
-
-	if (!variant) {
-		variant = radv_shader_variant_create(pipeline->device, module, nir,
-						     layout, key, &code,
-						     &code_size);
-	}
-
-	if (stage == MESA_SHADER_GEOMETRY && !pipeline->gs_copy_shader) {
-		void *gs_copy_code = NULL;
-		unsigned gs_copy_code_size = 0;
-		pipeline->gs_copy_shader = radv_create_gs_copy_shader(
-			pipeline->device, nir, &gs_copy_code,
-			&gs_copy_code_size, key->has_multiview_view_index);
-
-		if (pipeline->gs_copy_shader) {
-			pipeline->gs_copy_shader =
-				radv_pipeline_cache_insert_shader(pipeline->device,
-								  cache,
-								  gs_copy_sha1,
-								  pipeline->gs_copy_shader,
-								  gs_copy_code,
-								  gs_copy_code_size);
-		}
-
-		free(gs_copy_code);
-	}
-	if (!module->nir && !pipeline->device->trace_bo)
-		ralloc_free(nir);
-
-	if (variant)
-		variant = radv_pipeline_cache_insert_shader(pipeline->device,
-							    cache, sha1,
-							    variant, code,
-							    code_size);
-
-	if (code)
-		free(code);
-	return variant;
-}
-
-static struct ac_shader_variant_key
-radv_compute_tes_key(bool as_es, bool export_prim_id)
-{
-	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 */
-	if (!as_es)
-		key.tes.export_prim_id = export_prim_id;
-	return key;
-}
-
-static struct ac_shader_variant_key
-radv_compute_tcs_key(unsigned primitive_mode, unsigned input_vertices)
-{
-	struct ac_shader_variant_key key;
-	memset(&key, 0, sizeof(key));
-	key.tcs.primitive_mode = primitive_mode;
-	key.tcs.input_vertices = input_vertices;
-	return key;
-}
-
-static void
-radv_tess_pipeline_compile(struct radv_pipeline *pipeline,
-			   struct radv_pipeline_cache *cache,
-			   struct radv_shader_module *tcs_module,
-			   struct radv_shader_module *tes_module,
-			   const char *tcs_entrypoint,
-			   const char *tes_entrypoint,
-			   const VkSpecializationInfo *tcs_spec_info,
-			   const VkSpecializationInfo *tes_spec_info,
-			   struct radv_pipeline_layout *layout,
-			   unsigned input_vertices,
-			   bool has_view_index)
-{
-	unsigned char tcs_sha1[20], tes_sha1[20];
-	struct radv_shader_variant *tes_variant = NULL, *tcs_variant = NULL;
-	nir_shader *tes_nir, *tcs_nir;
-	void *tes_code = NULL, *tcs_code = NULL;
-	unsigned tes_code_size = 0, tcs_code_size = 0;
-	struct ac_shader_variant_key tes_key;
-	struct ac_shader_variant_key tcs_key;
-	unsigned hash_flags = get_hash_flags(pipeline->device);
-
-	tes_key = radv_compute_tes_key(radv_pipeline_has_gs(pipeline),
-				       pipeline->shaders[MESA_SHADER_FRAGMENT]->info.fs.prim_id_input);
-	tes_key.has_multiview_view_index = has_view_index;
-	if (tes_module->nir)
-		_mesa_sha1_compute(tes_module->nir->info.name,
-				   strlen(tes_module->nir->info.name),
-				   tes_module->sha1);
-	radv_hash_shader(tes_sha1, tes_module, tes_entrypoint, tes_spec_info, layout, &tes_key, hash_flags);
-
-	tes_variant = radv_create_shader_variant_from_pipeline_cache(pipeline->device,
-								     cache,
-								     tes_sha1);
-
-	if (tes_variant) {
-		tcs_key = radv_compute_tcs_key(tes_variant->info.tes.primitive_mode, input_vertices);
-
-		if (tcs_module->nir)
-			_mesa_sha1_compute(tcs_module->nir->info.name,
-					   strlen(tcs_module->nir->info.name),
-					   tcs_module->sha1);
-
-		radv_hash_shader(tcs_sha1, tcs_module, tcs_entrypoint, tcs_spec_info, layout, &tcs_key, hash_flags);
-
-		tcs_variant = radv_create_shader_variant_from_pipeline_cache(pipeline->device,
-									     cache,
-									     tcs_sha1);
-	}
-
-	if (tcs_variant && tes_variant) {
-		pipeline->shaders[MESA_SHADER_TESS_CTRL] = tcs_variant;
-		pipeline->shaders[MESA_SHADER_TESS_EVAL] = tes_variant;
-		return;
-	}
-
-	tes_nir = radv_shader_compile_to_nir(pipeline->device,
-					     tes_module, tes_entrypoint, MESA_SHADER_TESS_EVAL,
-					     tes_spec_info);
-	if (tes_nir == NULL)
-		return;
-
-	tcs_nir = radv_shader_compile_to_nir(pipeline->device,
-					     tcs_module, tcs_entrypoint, MESA_SHADER_TESS_CTRL,
-					     tcs_spec_info);
-	if (tcs_nir == NULL)
-		return;
-
-	nir_lower_tes_patch_vertices(tes_nir,
-				     tcs_nir->info.tess.tcs_vertices_out);
-
-	tes_variant = radv_shader_variant_create(pipeline->device, tes_module, tes_nir,
-						 layout, &tes_key, &tes_code,
-						 &tes_code_size);
-
-	tcs_key = radv_compute_tcs_key(tes_nir->info.tess.primitive_mode, input_vertices);
-	if (tcs_module->nir)
-		_mesa_sha1_compute(tcs_module->nir->info.name,
-				   strlen(tcs_module->nir->info.name),
-				   tcs_module->sha1);
-
-	radv_hash_shader(tcs_sha1, tcs_module, tcs_entrypoint, tcs_spec_info, layout, &tcs_key, hash_flags);
-
-	tcs_variant = radv_shader_variant_create(pipeline->device, tcs_module, tcs_nir,
-						 layout, &tcs_key, &tcs_code,
-						 &tcs_code_size);
-
-	if (!tes_module->nir && !pipeline->device->trace_bo)
-		ralloc_free(tes_nir);
-
-	if (!tcs_module->nir && !pipeline->device->trace_bo)
-		ralloc_free(tcs_nir);
-
-	if (tes_variant)
-		tes_variant = radv_pipeline_cache_insert_shader(pipeline->device, cache, tes_sha1, tes_variant,
-								tes_code, tes_code_size);
-
-	if (tcs_variant)
-		tcs_variant = radv_pipeline_cache_insert_shader(pipeline->device, cache, tcs_sha1, tcs_variant,
-								tcs_code, tcs_code_size);
-
-	if (tes_code)
-		free(tes_code);
-	if (tcs_code)
-		free(tcs_code);
-	pipeline->shaders[MESA_SHADER_TESS_CTRL] = tcs_variant;
-	pipeline->shaders[MESA_SHADER_TESS_EVAL] = tes_variant;
-	return;
-}
-
 static VkResult
 radv_pipeline_scratch_init(struct radv_device *device,
                            struct radv_pipeline *pipeline)
 {
 	unsigned scratch_bytes_per_wave = 0;
 	unsigned max_waves = 0;
 	unsigned min_waves = 1;
 
 	for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
 		if (pipeline->shaders[i]) {
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index 7924be0c90..d29098eea0 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -90,46 +90,20 @@ static uint32_t
 entry_size(struct cache_entry *entry)
 {
 	size_t ret = sizeof(*entry);
 	for (int i = 0; i < MESA_SHADER_STAGES; ++i)
 		if (entry->code_sizes[i])
 			ret += sizeof(struct cache_entry_variant_info) + entry->code_sizes[i];
 	return ret;
 }
 
 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 struct ac_shader_variant_key *key,
-		 uint32_t flags)
-{
-	struct mesa_sha1 ctx;
-
-	_mesa_sha1_init(&ctx);
-	if (key)
-		_mesa_sha1_update(&ctx, key, sizeof(*key));
-	_mesa_sha1_update(&ctx, module->sha1, sizeof(module->sha1));
-	_mesa_sha1_update(&ctx, entrypoint, strlen(entrypoint));
-	if (layout)
-		_mesa_sha1_update(&ctx, layout->sha1, sizeof(layout->sha1));
-	if (spec_info) {
-		_mesa_sha1_update(&ctx, spec_info->pMapEntries,
-				  spec_info->mapEntryCount * sizeof spec_info->pMapEntries[0]);
-		_mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
-	}
-	_mesa_sha1_update(&ctx, &flags, 4);
-	_mesa_sha1_final(&ctx, hash);
-}
-
-void
 radv_hash_shaders(unsigned char *hash,
 		  const VkPipelineShaderStageCreateInfo **stages,
 		  const struct radv_pipeline_layout *layout,
 		  const struct ac_shader_variant_key *keys,
 		  uint32_t flags)
 {
 	struct mesa_sha1 ctx;
 
 	_mesa_sha1_init(&ctx);
 	if (keys)
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 110d141085..683ea3155e 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -973,28 +973,20 @@ struct radv_event {
 	uint64_t *map;
 };
 
 struct radv_shader_module;
 struct ac_shader_variant_key;
 
 #define RADV_HASH_SHADER_IS_GEOM_COPY_SHADER (1 << 0)
 #define RADV_HASH_SHADER_SISCHED             (1 << 1)
 #define RADV_HASH_SHADER_UNSAFE_MATH         (1 << 2)
 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 struct ac_shader_variant_key *key,
-		 uint32_t flags);
-
-void
 radv_hash_shaders(unsigned char *hash,
 		  const VkPipelineShaderStageCreateInfo **stages,
 		  const struct radv_pipeline_layout *layout,
 		  const struct ac_shader_variant_key *keys,
 		  uint32_t flags);
 
 static inline gl_shader_stage
 vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage)
 {
 	assert(__builtin_popcount(vk_stage) == 1);
-- 
2.13.6



More information about the mesa-dev mailing list