Mesa (master): radv: clone meta shaders before linking

Timothy Arceri tarceri at kemper.freedesktop.org
Mon Oct 23 22:29:02 UTC 2017


Module: Mesa
Branch: master
Commit: 013313cf895e4d47b2631d5f4dd32fcbce2b0a17
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=013313cf895e4d47b2631d5f4dd32fcbce2b0a17

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Mon Oct 23 11:10:47 2017 +1100

radv: clone meta shaders before linking

The IR is reused in different pipeline combinations so we need
to clone it to avoid link time optimistaions messing up the
original copy.

Fixes: 06f05040eb73 (radv: Link shaders)

Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/vulkan/radv_pipeline.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 669d9a4858..30a90ac960 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1766,6 +1766,13 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
 						    stage ? stage->pName : "main", i,
 						    stage ? stage->pSpecializationInfo : NULL);
 		pipeline->active_stages |= mesa_to_vk_shader_stage(i);
+		/* We don't want to alter meta shaders IR directly so clone it
+		 * first.
+		 */
+		if (nir[i]->info.name) {
+			nir[i] = nir_shader_clone(NULL, nir[i]);
+		}
+
 	}
 
 	if (nir[MESA_SHADER_TESS_CTRL]) {
@@ -1863,7 +1870,7 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
 
 	for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
 		free(codes[i]);
-		if (modules[i] && !modules[i]->nir && !pipeline->device->trace_bo)
+		if (modules[i] && !pipeline->device->trace_bo)
 			ralloc_free(nir[i]);
 	}
 




More information about the mesa-commit mailing list