From: Nicolai Hähnle Date: Thu, 30 Mar 2017 12:15:10 +0000 (+0200) Subject: radeonsi: implement TGSI_SEMANTIC_SUBGROUP_* X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a3075f479917d5685705e0a92ab4405012c1ff56;p=mesa.git radeonsi: implement TGSI_SEMANTIC_SUBGROUP_* 64-bit system values are stored as v2i32 to simplify the fetch logic. Reviewed-by: Marek Olšák --- diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 600f2e31029..6e8b6746b9d 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1586,6 +1586,46 @@ static void declare_system_value(struct si_shader_context *ctx, } break; + case TGSI_SEMANTIC_SUBGROUP_SIZE: + value = LLVMConstInt(ctx->i32, 64, 0); + break; + + case TGSI_SEMANTIC_SUBGROUP_INVOCATION: + value = ac_get_thread_id(&ctx->ac); + break; + + case TGSI_SEMANTIC_SUBGROUP_EQ_MASK: + { + LLVMValueRef id = ac_get_thread_id(&ctx->ac); + id = LLVMBuildZExt(gallivm->builder, id, ctx->i64, ""); + value = LLVMBuildShl(gallivm->builder, LLVMConstInt(ctx->i64, 1, 0), id, ""); + value = LLVMBuildBitCast(gallivm->builder, value, ctx->v2i32, ""); + break; + } + + case TGSI_SEMANTIC_SUBGROUP_GE_MASK: + case TGSI_SEMANTIC_SUBGROUP_GT_MASK: + case TGSI_SEMANTIC_SUBGROUP_LE_MASK: + case TGSI_SEMANTIC_SUBGROUP_LT_MASK: + { + LLVMValueRef id = ac_get_thread_id(&ctx->ac); + if (decl->Semantic.Name == TGSI_SEMANTIC_SUBGROUP_GT_MASK || + decl->Semantic.Name == TGSI_SEMANTIC_SUBGROUP_LE_MASK) { + /* All bits set except LSB */ + value = LLVMConstInt(ctx->i64, -2, 0); + } else { + /* All bits set */ + value = LLVMConstInt(ctx->i64, -1, 0); + } + id = LLVMBuildZExt(gallivm->builder, id, ctx->i64, ""); + value = LLVMBuildShl(gallivm->builder, value, id, ""); + if (decl->Semantic.Name == TGSI_SEMANTIC_SUBGROUP_LE_MASK || + decl->Semantic.Name == TGSI_SEMANTIC_SUBGROUP_LT_MASK) + value = LLVMBuildNot(gallivm->builder, value, ""); + value = LLVMBuildBitCast(gallivm->builder, value, ctx->v2i32, ""); + break; + } + default: assert(!"unknown system value"); return;