diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-06-09 17:48:11 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-07-31 14:55:39 +0200 |
commit | 8d23575c9634878eff093b3656e3dcdfe66d28f2 (patch) | |
tree | 172d1bcb3adddd2e8fb66a4b1d5b449feae62605 /src | |
parent | f37f9aed84b53b1bd7892fa4b0029407248c4fd0 (diff) |
radeonsi/nir: add image descriptor loading
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_internal.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_nir.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 22 |
3 files changed, 32 insertions, 8 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 1483ebc5db..26d7d09fa2 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -317,6 +317,9 @@ void si_shader_context_init_mem(struct si_shader_context *ctx); LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, LLVMValueRef list, LLVMValueRef index, enum ac_descriptor_type type); +LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, + LLVMValueRef list, LLVMValueRef index, + enum ac_descriptor_type desc_type, bool dcc_off); void si_llvm_load_input_vs( struct si_shader_context *ctx, diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index d9893bca56..076fce818a 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -363,6 +363,21 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi, LLVMConstInt(ctx->ac.i32, base_index + constant_index, false), ""); + if (image) { + assert(desc_type == AC_DESC_IMAGE || desc_type == AC_DESC_BUFFER); + assert(base_index + constant_index < ctx->num_images); + + if (dynamic_index) + index = si_llvm_bound_index(ctx, index, ctx->num_images); + + index = LLVMBuildSub(ctx->gallivm.builder, + LLVMConstInt(ctx->i32, SI_NUM_IMAGES - 1, 0), + index, ""); + + /* TODO: be smarter about when we use dcc_off */ + return si_load_image_desc(ctx, list, index, desc_type, write); + } + assert(base_index + constant_index < ctx->num_samplers); if (dynamic_index) diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c index e5afeb0644..e04a8796fd 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c @@ -143,22 +143,28 @@ static LLVMValueRef force_dcc_off(struct si_shader_context *ctx, } } -static LLVMValueRef load_image_desc(struct si_shader_context *ctx, - LLVMValueRef list, LLVMValueRef index, - unsigned target) +LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, + LLVMValueRef list, LLVMValueRef index, + enum ac_descriptor_type desc_type, bool dcc_off) { LLVMBuilderRef builder = ctx->gallivm.builder; + LLVMValueRef rsrc; - if (target == TGSI_TEXTURE_BUFFER) { + if (desc_type == AC_DESC_BUFFER) { index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->i32, 2, 0), ""); index = LLVMBuildAdd(builder, index, ctx->i32_1, ""); list = LLVMBuildPointerCast(builder, list, si_const_array(ctx->v4i32, 0), ""); + } else { + assert(desc_type == AC_DESC_IMAGE); } - return ac_build_indexed_load_const(&ctx->ac, list, index); + rsrc = ac_build_indexed_load_const(&ctx->ac, list, index); + if (dcc_off) + rsrc = force_dcc_off(ctx, rsrc); + return rsrc; } /** @@ -217,9 +223,9 @@ image_fetch_rsrc( index = LLVMConstInt(ctx->i32, 0, 0); } - *rsrc = load_image_desc(ctx, rsrc_ptr, index, target); - if (dcc_off && target != TGSI_TEXTURE_BUFFER) - *rsrc = force_dcc_off(ctx, *rsrc); + *rsrc = si_load_image_desc(ctx, rsrc_ptr, index, + target == TGSI_TEXTURE_BUFFER ? AC_DESC_BUFFER : AC_DESC_IMAGE, + dcc_off); } static LLVMValueRef image_fetch_coords( |