radeonsi: implement SAMPLEID fragment shader input
authorMarek Olšák <marek.olsak@amd.com>
Tue, 6 May 2014 16:12:40 +0000 (18:12 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 2 Jun 2014 10:58:22 +0000 (12:58 +0200)
src/gallium/drivers/radeonsi/si_shader.c

index 5f4f1bf0f4af0b72b64de24aaa0cd13b8d3f12e3..d021caaa6c424011927d589ce5ebcf125975da20 100644 (file)
@@ -529,6 +529,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)
 {
@@ -558,6 +570,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;
@@ -2186,7 +2202,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;