[Mesa-dev] [PATCH 4/8] radeonsi: implement SAMPLEID fragment shader input
Marek Olšák
maraeo at gmail.com
Wed May 7 07:00:32 PDT 2014
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/drivers/radeonsi/si_shader.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 440bcba..0195e54 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -531,6 +531,18 @@ static void declare_input_fs(
}
}
+static LLVMValueRef get_sample_id(struct radeon_llvm_context *radeon_bld)
+{
+ struct gallivm_state *gallivm = &radeon_bld->gallivm;
+ LLVMValueRef value = LLVMGetParam(radeon_bld->main_fn,
+ SI_PARAM_ANCILLARY);
+ value = LLVMBuildLShr(gallivm->builder, value,
+ lp_build_const_int32(gallivm, 8), "");
+ value = LLVMBuildAnd(gallivm->builder, value,
+ lp_build_const_int32(gallivm, 0xf), "");
+ return value;
+}
+
static LLVMValueRef load_const(LLVMBuilderRef builder, LLVMValueRef resource,
LLVMValueRef offset, LLVMTypeRef return_type)
{
@@ -560,6 +572,10 @@ static void declare_system_value(
si_shader_ctx->param_vertex_id);
break;
+ case TGSI_SEMANTIC_SAMPLEID:
+ value = get_sample_id(radeon_bld);
+ break;
+
default:
assert(!"unknown system value");
return;
@@ -2189,7 +2205,7 @@ static void create_function(struct si_shader_context *si_shader_ctx)
params[SI_PARAM_POS_Z_FLOAT] = f32;
params[SI_PARAM_POS_W_FLOAT] = f32;
params[SI_PARAM_FRONT_FACE] = f32;
- params[SI_PARAM_ANCILLARY] = f32;
+ params[SI_PARAM_ANCILLARY] = i32;
params[SI_PARAM_SAMPLE_COVERAGE] = f32;
params[SI_PARAM_POS_FIXED_PT] = f32;
num_params = SI_PARAM_POS_FIXED_PT+1;
--
1.9.1
More information about the mesa-dev
mailing list