예제 #1
0
static void
lower_load_sample_pos(lower_wpos_ytransform_state *state,
                      nir_intrinsic_instr *intr)
{
   nir_builder *b = &state->b;
   b->cursor = nir_after_instr(&intr->instr);

   nir_ssa_def *pos = &intr->dest.ssa;
   nir_ssa_def *scale = nir_channel(b, get_transform(state), 0);
   nir_ssa_def *neg_scale = nir_channel(b, get_transform(state), 2);
   /* Either y or 1-y for scale equal to 1 or -1 respectively. */
   nir_ssa_def *flipped_y =
               nir_fadd(b, nir_fmax(b, neg_scale, nir_imm_float(b, 0.0)),
                        nir_fmul(b, nir_channel(b, pos, 1), scale));
   nir_ssa_def *flipped_pos = nir_vec2(b, nir_channel(b, pos, 0), flipped_y);

   nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, nir_src_for_ssa(flipped_pos),
                                  flipped_pos->parent_instr);
}
예제 #2
0
static void
lower_load_pointcoord(lower_wpos_ytransform_state *state,
                      nir_intrinsic_instr *intr)
{
   nir_builder *b = &state->b;
   b->cursor = nir_after_instr(&intr->instr);

   nir_ssa_def *pntc = &intr->dest.ssa;
   nir_ssa_def *transform = get_transform(state);
   nir_ssa_def *y = nir_channel(b, pntc, 1);
   /* The offset is 1 if we're flipping, 0 otherwise. */
   nir_ssa_def *offset = nir_fmax(b, nir_channel(b, transform, 2),
                                  nir_imm_float(b, 0.0));
   /* Flip the sign of y if we're flipping. */
   nir_ssa_def *scaled = nir_fmul(b, y, nir_channel(b, transform, 0));

   /* Reassemble the vector. */
   nir_ssa_def *flipped_pntc = nir_vec2(b,
                                        nir_channel(b, pntc, 0),
                                        nir_fadd(b, offset, scaled));

   nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, nir_src_for_ssa(flipped_pntc),
                                  flipped_pntc->parent_instr);
}
예제 #3
0
파일: vtn_glsl450.c 프로젝트: etnaviv/mesa
static inline nir_ssa_def *
build_fclamp(nir_builder *b,
             nir_ssa_def *x, nir_ssa_def *min_val, nir_ssa_def *max_val)
{
   return nir_fmin(b, nir_fmax(b, x, min_val), max_val);
}