- return 1;
-}
-
-static void
-emit_declaration(
- struct lp_build_tgsi_soa_context *bld,
- struct tgsi_full_declaration *decl )
-{
- if( decl->Declaration.File == TGSI_FILE_INPUT ) {
- LLVMBuilderRef builder = bld->base.builder;
- unsigned first, last, mask;
- unsigned attrib, chan;
-
- first = decl->DeclarationRange.First;
- last = decl->DeclarationRange.Last;
- mask = decl->Declaration.UsageMask;
-
- for( attrib = first; attrib <= last; attrib++ ) {
- for( chan = 0; chan < NUM_CHANNELS; chan++ ) {
- LLVMValueRef input = bld->base.undef;
-
- if( mask & (1 << chan) ) {
- LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), attrib*NUM_CHANNELS + chan, 0);
- LLVMValueRef a0;
- LLVMValueRef dadx;
- LLVMValueRef dady;
-
- switch( decl->Declaration.Interpolate ) {
- case TGSI_INTERPOLATE_PERSPECTIVE:
- /* fall-through */
-
- case TGSI_INTERPOLATE_LINEAR: {
- LLVMValueRef dadx_ptr = LLVMBuildGEP(builder, bld->dadx_ptr, &index, 1, "");
- LLVMValueRef dady_ptr = LLVMBuildGEP(builder, bld->dady_ptr, &index, 1, "");
- dadx = LLVMBuildLoad(builder, dadx_ptr, "");
- dady = LLVMBuildLoad(builder, dady_ptr, "");
- dadx = lp_build_broadcast_scalar(&bld->base, dadx);
- dady = lp_build_broadcast_scalar(&bld->base, dady);
- lp_build_name(dadx, "dadx_%u.%c", attrib, "xyzw"[chan]);
- lp_build_name(dady, "dady_%u.%c", attrib, "xyzw"[chan]);
- /* fall-through */
- }
-
- case TGSI_INTERPOLATE_CONSTANT: {
- LLVMValueRef a0_ptr = LLVMBuildGEP(builder, bld->a0_ptr, &index, 1, "");
- a0 = LLVMBuildLoad(builder, a0_ptr, "");
- a0 = lp_build_broadcast_scalar(&bld->base, a0);
- lp_build_name(a0, "a0_%u.%c", attrib, "xyzw"[chan]);
- break;
- }
-
- default:
- assert(0);
- break;
- }
-
- input = a0;
-
- if (decl->Declaration.Interpolate != TGSI_INTERPOLATE_CONSTANT) {
- input = lp_build_add(&bld->base, input, lp_build_mul(&bld->base, bld->x, dadx));
- input = lp_build_add(&bld->base, input, lp_build_mul(&bld->base, bld->y, dady));
- }
-
- if (decl->Declaration.Interpolate == TGSI_INTERPOLATE_PERSPECTIVE) {
- if(!bld->oow)
- bld->oow = lp_build_rcp(&bld->base, bld->w);
- input = lp_build_mul(&bld->base, input, bld->oow);
- }
-
- lp_build_name(input, "input%u.%c", attrib, "xyzw"[chan]);
- }
-
- bld->inputs[attrib][chan] = input;
- }