From: Marek Olšák <marek.ol...@amd.com> Please test RADV. --- src/amd/common/ac_nir_to_llvm.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 0ab16c4..428764b 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -3596,28 +3596,33 @@ static LLVMValueRef visit_image_load(struct ac_nir_context *ctx, const nir_variable *var = instr->variables[0]->var; const struct glsl_type *type = var->type; if(instr->variables[0]->deref.child) type = instr->variables[0]->deref.child->type; type = glsl_without_array(type); const enum glsl_sampler_dim dim = glsl_get_sampler_dim(type); if (dim == GLSL_SAMPLER_DIM_BUF) { - params[0] = get_sampler_desc(ctx, instr->variables[0], AC_DESC_BUFFER, NULL, true, false); - params[1] = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[0]), - ctx->ac.i32_0, ""); /* vindex */ - params[2] = ctx->ac.i32_0; /* voffset */ - params[3] = ctx->ac.i1false; /* glc */ - params[4] = ctx->ac.i1false; /* slc */ - res = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.buffer.load.format.v4f32", ctx->ac.v4f32, - params, 5, 0); + unsigned mask = nir_ssa_def_components_read(&instr->dest.ssa); + unsigned num_channels = util_last_bit(mask); + LLVMValueRef rsrc, vindex; + + rsrc = get_sampler_desc(ctx, instr->variables[0], AC_DESC_BUFFER, NULL, true, false); + vindex = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[0]), + ctx->ac.i32_0, ""); + + /* TODO: set "glc" and "can_speculate" when OpenGL needs it. */ + res = ac_build_buffer_load_format(&ctx->ac, rsrc, vindex, + ctx->ac.i32_0, num_channels, + false, false); + res = ac_build_expand_to_vec4(&ctx->ac, res, num_channels); res = trim_vector(&ctx->ac, res, instr->dest.ssa.num_components); res = ac_to_integer(&ctx->ac, res); } else { bool is_da = glsl_sampler_type_is_array(type) || dim == GLSL_SAMPLER_DIM_CUBE || dim == GLSL_SAMPLER_DIM_3D || dim == GLSL_SAMPLER_DIM_SUBPASS || dim == GLSL_SAMPLER_DIM_SUBPASS_MS; LLVMValueRef da = is_da ? ctx->ac.i1true : ctx->ac.i1false; -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev