From 6520a64c4dadf03e2991a997c2399e3cc181b5c2 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 10 Nov 2016 10:32:08 +1000 Subject: radv: fix texturesamples to handle single sample case We can only read the valid samples if this is an MSAA texture, which means the type field must be 0x14 or 0x15. This fixes: dEQP-VK.glsl.texture_functions.query.texturesamples.* Cc: "13.0" Reviewed-by: Bas Nieuwenhuizen Signed-off-by: Dave Airlie (cherry picked from commit 2de85eb97ab2ef45ec23f694a566cd0ec8192885) --- src/amd/common/ac_nir_to_llvm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/amd/common/ac_nir_to_llvm.c') diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index f235cc2..d76f3fc 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -3299,17 +3299,25 @@ static void visit_tex(struct nir_to_llvm_context *ctx, nir_tex_instr *instr) } if (instr->op == nir_texop_texture_samples) { - LLVMValueRef res, samples; + LLVMValueRef res, samples, is_msaa; res = LLVMBuildBitCast(ctx->builder, res_ptr, ctx->v8i32, ""); samples = LLVMBuildExtractElement(ctx->builder, res, LLVMConstInt(ctx->i32, 3, false), ""); + is_msaa = LLVMBuildLShr(ctx->builder, samples, + LLVMConstInt(ctx->i32, 28, false), ""); + is_msaa = LLVMBuildAnd(ctx->builder, is_msaa, + LLVMConstInt(ctx->i32, 0xe, false), ""); + is_msaa = LLVMBuildICmp(ctx->builder, LLVMIntEQ, is_msaa, + LLVMConstInt(ctx->i32, 0xe, false), ""); + samples = LLVMBuildLShr(ctx->builder, samples, LLVMConstInt(ctx->i32, 16, false), ""); samples = LLVMBuildAnd(ctx->builder, samples, LLVMConstInt(ctx->i32, 0xf, false), ""); samples = LLVMBuildShl(ctx->builder, ctx->i32one, samples, ""); - + samples = LLVMBuildSelect(ctx->builder, is_msaa, samples, + ctx->i32one, ""); result = samples; goto write_result; } -- cgit v1.1 From 145ecf60dd303d4c55949d5c437d1b307e9ba254 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 15 Nov 2016 07:30:09 +0000 Subject: ac/nir/llvm: fix channel in texture gather lowering code. This fixes a number of CTS tests like: dEQP-VK.glsl.texture_gather.basic.2d.rgba8ui.size_npot.clamp_to_edge_repeat Cc: "13.0" Signed-off-by: Dave Airlie (cherry picked from commit 713522fb8d4366d29be18edc3d5f33faba1cb7c4) --- src/amd/common/ac_nir_to_llvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/amd/common/ac_nir_to_llvm.c') diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index d76f3fc..0b73e06 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1683,7 +1683,7 @@ static LLVMValueRef radv_lower_gather4_integer(struct nir_to_llvm_context *ctx, for (c = 0; c < 2; c++) { half_texel[c] = LLVMBuildExtractElement(ctx->builder, size, - ctx->i32zero, ""); + LLVMConstInt(ctx->i32, c, false), ""); half_texel[c] = LLVMBuildUIToFP(ctx->builder, half_texel[c], ctx->f32, ""); half_texel[c] = emit_fdiv(ctx, ctx->f32one, half_texel[c]); half_texel[c] = LLVMBuildFMul(ctx->builder, half_texel[c], -- cgit v1.1 From 6a3b5f32c23d3c901598ba8ec626086df9c79203 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 18 Nov 2016 03:58:30 +0000 Subject: radv: spir-v allows texture size query with and without lod. The translation to llvm was failing here due to required lod. This fixes some new SteamVR shaders. Cc: "13.0" Reviewed-by: Edward O'Callaghan Signed-off-by: Dave Airlie (cherry picked from commit b1340fd708bb873617b8a529ac45cbc9507bd6c4) --- src/amd/common/ac_nir_to_llvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/amd/common/ac_nir_to_llvm.c') diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 0b73e06..31d7b6e 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -3416,7 +3416,10 @@ static void visit_tex(struct nir_to_llvm_context *ctx, nir_tex_instr *instr) address[count++] = sample_index; } else if(instr->op == nir_texop_txs) { count = 0; - address[count++] = lod; + if (lod) + address[count++] = lod; + else + address[count++] = ctx->i32zero; } for (chan = 0; chan < count; chan++) { -- cgit v1.1