radeonsi: implement SAMPLEPOS system value without a constant buffer load
authorMarek Olšák <marek.olsak@amd.com>
Wed, 20 Jan 2016 00:45:21 +0000 (01:45 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 22 Jan 2016 14:02:40 +0000 (15:02 +0100)
We always get per-sample input position.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c

index 0c5fd326a5d0ab5861fb0f6032da1f24183600a5..1bd617fa147a20634b62a5d6d560cd2c3cefab4e 100644 (file)
@@ -1119,9 +1119,20 @@ static void declare_system_value(
                value = get_sample_id(radeon_bld);
                break;
 
-       case TGSI_SEMANTIC_SAMPLEPOS:
-               value = load_sample_position(radeon_bld, get_sample_id(radeon_bld));
+       case TGSI_SEMANTIC_SAMPLEPOS: {
+               LLVMValueRef pos[4] = {
+                       LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_X_FLOAT),
+                       LLVMGetParam(radeon_bld->main_fn, SI_PARAM_POS_Y_FLOAT),
+                       lp_build_const_float(gallivm, 0),
+                       lp_build_const_float(gallivm, 0)
+               };
+               pos[0] = lp_build_emit_llvm_unary(&radeon_bld->soa.bld_base,
+                                                 TGSI_OPCODE_FRC, pos[0]);
+               pos[1] = lp_build_emit_llvm_unary(&radeon_bld->soa.bld_base,
+                                                 TGSI_OPCODE_FRC, pos[1]);
+               value = lp_build_gather_values(gallivm, pos, 4);
                break;
+       }
 
        case TGSI_SEMANTIC_SAMPLEMASK:
                /* Smoothing isn't MSAA in GL, but it's MSAA in hardware.