From 639f247862167f9300eda7832453ed9803ae2d35 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 22 Aug 2013 10:46:50 -0700 Subject: [PATCH] radeonsi: Use invariant loads for preloading samplers --- src/gallium/drivers/radeonsi/radeonsi_shader.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c index a1dec17..4c5f8c1 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c @@ -1449,6 +1449,9 @@ static void preload_samplers(struct si_shader_context *si_shader_ctx) const struct tgsi_shader_info * info = bld_base->info; unsigned i, num_samplers = info->file_max[TGSI_FILE_SAMPLER] + 1; + unsigned md_invariant_load = LLVMGetMDKindIDInContext( + gallivm->context, "invariant.load", 14); + LLVMValueRef md = LLVMMDNodeInContext(gallivm->context, NULL, 0); LLVMValueRef res_ptr, samp_ptr; LLVMValueRef offset; @@ -1465,19 +1468,27 @@ static void preload_samplers(struct si_shader_context *si_shader_ctx) /* Load the resources and samplers, we rely on the code sinking to do the rest */ for (i = 0; i < num_samplers; ++i) { + LLVMValueRef resource, sampler, fmask_resource; /* Resource */ offset = lp_build_const_int32(gallivm, i); - si_shader_ctx->resources[i] = build_indexed_load(si_shader_ctx, res_ptr, offset); + resource = build_indexed_load(si_shader_ctx, res_ptr, offset); + LLVMSetMetadata(resource, md_invariant_load, md); + si_shader_ctx->resources[i] = resource; /* Sampler */ offset = lp_build_const_int32(gallivm, i); - si_shader_ctx->samplers[i] = build_indexed_load(si_shader_ctx, samp_ptr, offset); + sampler = build_indexed_load(si_shader_ctx, samp_ptr, offset); + LLVMSetMetadata(sampler, md_invariant_load, md); + si_shader_ctx->samplers[i] = sampler; /* FMASK resource */ if (info->is_msaa_sampler[i]) { offset = lp_build_const_int32(gallivm, FMASK_TEX_OFFSET + i); - si_shader_ctx->resources[FMASK_TEX_OFFSET + i] = + fmask_resource = build_indexed_load(si_shader_ctx, res_ptr, offset); + LLVMSetMetadata(fmask_resource, md_invariant_load, md); + si_shader_ctx->resources[FMASK_TEX_OFFSET + i] = + fmask_resource; } } } -- 1.8.1.5