diff options
author | Nicolai Hähnle <[email protected]> | 2017-03-30 14:15:10 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-04-05 15:29:43 +0200 |
commit | a3075f479917d5685705e0a92ab4405012c1ff56 (patch) | |
tree | dbad08c390578c941025384575cb306e6f6244aa | |
parent | 4cf29427770f6900c5e84e3b30f2e72e65954548 (diff) |
radeonsi: implement TGSI_SEMANTIC_SUBGROUP_*
64-bit system values are stored as v2i32 to simplify the fetch logic.
Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 40 |
1 files changed, 40 insertions, 0 deletions
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; |