ac: add ac_build_image_get_sample_count from radeonsi
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
@@ -2492,6 +2492,25 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
|
||||
return result;
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_image_get_sample_count(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc)
|
||||
{
|
||||
LLVMValueRef samples;
|
||||
|
||||
/* Read the samples from the descriptor directly.
|
||||
* Hardware doesn't have any instruction for this.
|
||||
*/
|
||||
samples = LLVMBuildExtractElement(ctx->builder, rsrc,
|
||||
LLVMConstInt(ctx->i32, 3, 0), "");
|
||||
samples = LLVMBuildLShr(ctx->builder, samples,
|
||||
LLVMConstInt(ctx->i32, 16, 0), "");
|
||||
samples = LLVMBuildAnd(ctx->builder, samples,
|
||||
LLVMConstInt(ctx->i32, 0xf, 0), "");
|
||||
samples = LLVMBuildShl(ctx->builder, ctx->i32_1,
|
||||
samples, "");
|
||||
return samples;
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef args[2])
|
||||
{
|
||||
|
||||
@@ -552,6 +552,8 @@ struct ac_image_args {
|
||||
|
||||
LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx,
|
||||
struct ac_image_args *a);
|
||||
LLVMValueRef ac_build_image_get_sample_count(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef rsrc);
|
||||
LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef args[2]);
|
||||
LLVMValueRef ac_build_cvt_pknorm_i16(struct ac_llvm_context *ctx,
|
||||
|
||||
@@ -1685,23 +1685,13 @@ static void si_llvm_emit_txqs(
|
||||
struct lp_build_emit_data *emit_data)
|
||||
{
|
||||
struct si_shader_context *ctx = si_shader_context(bld_base);
|
||||
LLVMValueRef res, samples;
|
||||
LLVMValueRef res_ptr, samp_ptr, fmask_ptr = NULL;
|
||||
LLVMValueRef rsrc;
|
||||
|
||||
tex_fetch_ptrs(bld_base, emit_data, &res_ptr, &samp_ptr, &fmask_ptr);
|
||||
tex_fetch_ptrs(bld_base, emit_data, &rsrc, NULL, NULL);
|
||||
|
||||
/* Read the samples from the descriptor directly. */
|
||||
res = LLVMBuildBitCast(ctx->ac.builder, res_ptr, ctx->v8i32, "");
|
||||
samples = LLVMBuildExtractElement(ctx->ac.builder, res,
|
||||
LLVMConstInt(ctx->i32, 3, 0), "");
|
||||
samples = LLVMBuildLShr(ctx->ac.builder, samples,
|
||||
LLVMConstInt(ctx->i32, 16, 0), "");
|
||||
samples = LLVMBuildAnd(ctx->ac.builder, samples,
|
||||
LLVMConstInt(ctx->i32, 0xf, 0), "");
|
||||
samples = LLVMBuildShl(ctx->ac.builder, ctx->i32_1,
|
||||
samples, "");
|
||||
|
||||
emit_data->output[emit_data->chan] = samples;
|
||||
rsrc = LLVMBuildBitCast(ctx->ac.builder, rsrc, ctx->v8i32, "");
|
||||
emit_data->output[emit_data->chan] =
|
||||
ac_build_image_get_sample_count(&ctx->ac, rsrc);
|
||||
}
|
||||
|
||||
static LLVMValueRef si_llvm_emit_fbfetch(struct si_shader_context *ctx)
|
||||
|
||||
Reference in New Issue
Block a user