[Mesa-dev] [PATCH] ac: fix get_image_coords() for radeonsi
Timothy Arceri
tarceri at itsqueeze.com
Fri Jul 27 09:40:47 UTC 2018
On 27/07/18 19:10, Bas Nieuwenhuizen wrote:
> On Fri, Jul 27, 2018 at 7:32 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
>> Because this was setting image to true we would end up calling
>> si_load_image_desc() when we sould be calling
>> si_load_sampler_desc().
>
> Since the descriptor is part of an image, not a sampler,
> get_image_descriptor looks like the right thing to me?
>
> What assertion are you getting?
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->ac.builder;
LLVMValueRef rsrc;
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,
ac_array_in_const32_addr_space(ctx->v4i32), "");
} else {
assert(desc_type == AC_DESC_IMAGE);
}
rsrc = ac_build_load_to_sgpr(&ctx->ac, list, index);
if (desc_type == AC_DESC_IMAGE && dcc_off)
rsrc = force_dcc_off(ctx, rsrc);
return rsrc;
}
vs
LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx,
LLVMValueRef list, LLVMValueRef index,
enum ac_descriptor_type type)
{
LLVMBuilderRef builder = ctx->ac.builder;
switch (type) {
case AC_DESC_IMAGE:
/* The image is at [0:7]. */
index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->i32, 2, 0), "");
break;
case AC_DESC_BUFFER:
/* The buffer is in [4:7]. */
index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->i32, 4, 0), "");
index = LLVMBuildAdd(builder, index, ctx->i32_1, "");
list = LLVMBuildPointerCast(builder, list,
ac_array_in_const32_addr_space(ctx->v4i32), "");
break;
case AC_DESC_FMASK:
/* The FMASK is at [8:15]. */
index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->i32, 2, 0), "");
index = LLVMBuildAdd(builder, index, ctx->i32_1, "");
break;
case AC_DESC_SAMPLER:
/* The sampler state is at [12:15]. */
index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->i32, 4, 0), "");
index = LLVMBuildAdd(builder, index, LLVMConstInt(ctx->i32, 3, 0), "");
list = LLVMBuildPointerCast(builder, list,
ac_array_in_const32_addr_space(ctx->v4i32), "");
break;
}
return ac_build_load_to_sgpr(&ctx->ac, list, index);
}
>
>>
>> This fixes an assert() in Deus Ex: MD
>> ---
>> src/amd/common/ac_nir_to_llvm.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
>> index cffc980e51f..fa934e6702e 100644
>> --- a/src/amd/common/ac_nir_to_llvm.c
>> +++ b/src/amd/common/ac_nir_to_llvm.c
>> @@ -2250,7 +2250,8 @@ static void get_image_coords(struct ac_nir_context *ctx,
>> fmask_load_address[1],
>> fmask_load_address[2],
>> sample_index,
>> - get_image_descriptor(ctx, instr, AC_DESC_FMASK, false));
>> + get_sampler_desc(ctx, nir_instr_as_deref(instr->src[0].ssa->parent_instr),
>> + AC_DESC_FMASK, NULL, false, false));
>> }
>> if (count == 1 && !gfx9_1d) {
>> if (instr->src[1].ssa->num_components)
>> --
>> 2.17.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list