Ejemplo n.º 1
0
static void
fs_lower_opcode_fb_write(struct toy_compiler *tc, struct toy_inst *inst)
{
   /* fs_write_fb() has set up the message registers */
   toy_compiler_lower_to_send(tc, inst, true,
         GEN6_SFID_DATAPORT_RENDER_CACHE);
}
Ejemplo n.º 2
0
static void
gs_lower_virtual_opcodes(struct gs_compile_context *gcc)
{
   struct toy_compiler *tc = &gcc->tc;
   struct toy_inst *inst;

   tc_head(tc);
   while ((inst = tc_next(tc)) != NULL) {
      switch (inst->opcode) {
      case TOY_OPCODE_TGSI_IN:
      case TOY_OPCODE_TGSI_CONST:
      case TOY_OPCODE_TGSI_SV:
      case TOY_OPCODE_TGSI_IMM:
         gs_lower_opcode_tgsi_direct(gcc, inst);
         break;
      case TOY_OPCODE_TGSI_INDIRECT_FETCH:
      case TOY_OPCODE_TGSI_INDIRECT_STORE:
         /* TODO similar to VS */
         tc_fail(tc, "no indirection support");
         tc_discard_inst(tc, inst);
         break;
      case TOY_OPCODE_TGSI_TEX:
      case TOY_OPCODE_TGSI_TXB:
      case TOY_OPCODE_TGSI_TXD:
      case TOY_OPCODE_TGSI_TXL:
      case TOY_OPCODE_TGSI_TXP:
      case TOY_OPCODE_TGSI_TXF:
      case TOY_OPCODE_TGSI_TXQ:
      case TOY_OPCODE_TGSI_TXQ_LZ:
      case TOY_OPCODE_TGSI_TEX2:
      case TOY_OPCODE_TGSI_TXB2:
      case TOY_OPCODE_TGSI_TXL2:
      case TOY_OPCODE_TGSI_SAMPLE:
      case TOY_OPCODE_TGSI_SAMPLE_I:
      case TOY_OPCODE_TGSI_SAMPLE_I_MS:
      case TOY_OPCODE_TGSI_SAMPLE_B:
      case TOY_OPCODE_TGSI_SAMPLE_C:
      case TOY_OPCODE_TGSI_SAMPLE_C_LZ:
      case TOY_OPCODE_TGSI_SAMPLE_D:
      case TOY_OPCODE_TGSI_SAMPLE_L:
      case TOY_OPCODE_TGSI_GATHER4:
      case TOY_OPCODE_TGSI_SVIEWINFO:
      case TOY_OPCODE_TGSI_SAMPLE_POS:
      case TOY_OPCODE_TGSI_SAMPLE_INFO:
         /* TODO similar to VS */
         tc_fail(tc, "no sampling support");
         tc_discard_inst(tc, inst);
         break;
      case TOY_OPCODE_EMIT:
         gs_lower_opcode_emit(gcc, inst);
         tc_discard_inst(tc, inst);
         break;
      case TOY_OPCODE_ENDPRIM:
         gs_lower_opcode_endprim(gcc, inst);
         tc_discard_inst(tc, inst);
         break;
      default:
         break;
      }
   }

   tc_head(tc);
   while ((inst = tc_next(tc)) != NULL) {
      switch (inst->opcode) {
      case TOY_OPCODE_INV:
      case TOY_OPCODE_LOG:
      case TOY_OPCODE_EXP:
      case TOY_OPCODE_SQRT:
      case TOY_OPCODE_RSQ:
      case TOY_OPCODE_SIN:
      case TOY_OPCODE_COS:
      case TOY_OPCODE_FDIV:
      case TOY_OPCODE_POW:
      case TOY_OPCODE_INT_DIV_QUOTIENT:
      case TOY_OPCODE_INT_DIV_REMAINDER:
         toy_compiler_lower_math(tc, inst);
         break;
      case TOY_OPCODE_URB_WRITE:
         toy_compiler_lower_to_send(tc, inst, false, GEN6_SFID_URB);
         break;
      default:
         if (inst->opcode > 127)
            tc_fail(tc, "unhandled virtual opcode");
         break;
      }
   }
}
Ejemplo n.º 3
0
static void
vs_lower_opcode_urb_write(struct toy_compiler *tc, struct toy_inst *inst)
{
   /* vs_write_vue() has set up the message registers */
   toy_compiler_lower_to_send(tc, inst, false, GEN6_SFID_URB);
}
Ejemplo n.º 4
0
static void
vs_lower_opcode_tgsi_sampling(struct vs_compile_context *vcc,
                              struct toy_inst *inst)
{
   struct toy_compiler *tc = &vcc->tc;
   struct toy_src desc;
   struct toy_dst dst, tmp;
   unsigned sampler_index;
   int swizzles[4], i;
   unsigned swizzle_zero_mask, swizzle_one_mask, swizzle_normal_mask;
   bool need_filter;

   desc = vs_prepare_tgsi_sampling(vcc, inst,
         vcc->first_free_mrf, &sampler_index);

   switch (inst->opcode) {
   case TOY_OPCODE_TGSI_TXF:
   case TOY_OPCODE_TGSI_TXQ:
   case TOY_OPCODE_TGSI_TXQ_LZ:
      need_filter = false;
      break;
   default:
      need_filter = true;
      break;
   }

   toy_compiler_lower_to_send(tc, inst, false, GEN6_SFID_SAMPLER);
   inst->src[0] = tsrc(TOY_FILE_MRF, vcc->first_free_mrf, 0);
   inst->src[1] = desc;

   /* write to a temp first */
   tmp = tc_alloc_tmp(tc);
   tmp.type = inst->dst.type;
   dst = inst->dst;
   inst->dst = tmp;

   tc_move_inst(tc, inst);

   if (need_filter) {
      assert(sampler_index < vcc->variant->num_sampler_views);
      swizzles[0] = vcc->variant->sampler_view_swizzles[sampler_index].r;
      swizzles[1] = vcc->variant->sampler_view_swizzles[sampler_index].g;
      swizzles[2] = vcc->variant->sampler_view_swizzles[sampler_index].b;
      swizzles[3] = vcc->variant->sampler_view_swizzles[sampler_index].a;
   }
   else {
      swizzles[0] = PIPE_SWIZZLE_RED;
      swizzles[1] = PIPE_SWIZZLE_GREEN;
      swizzles[2] = PIPE_SWIZZLE_BLUE;
      swizzles[3] = PIPE_SWIZZLE_ALPHA;
   }

   swizzle_zero_mask = 0;
   swizzle_one_mask = 0;
   swizzle_normal_mask = 0;
   for (i = 0; i < 4; i++) {
      switch (swizzles[i]) {
      case PIPE_SWIZZLE_ZERO:
         swizzle_zero_mask |= 1 << i;
         swizzles[i] = i;
         break;
      case PIPE_SWIZZLE_ONE:
         swizzle_one_mask |= 1 << i;
         swizzles[i] = i;
         break;
      default:
         swizzle_normal_mask |= 1 << i;
         break;
      }
   }

   /* swizzle the results */
   if (swizzle_normal_mask) {
      tc_MOV(tc, tdst_writemask(dst, swizzle_normal_mask),
            tsrc_swizzle(tsrc_from(tmp), swizzles[0],
               swizzles[1], swizzles[2], swizzles[3]));
   }
   if (swizzle_zero_mask)
      tc_MOV(tc, tdst_writemask(dst, swizzle_zero_mask), tsrc_imm_f(0.0f));
   if (swizzle_one_mask)
      tc_MOV(tc, tdst_writemask(dst, swizzle_one_mask), tsrc_imm_f(1.0f));
}
Ejemplo n.º 5
0
static void
fs_lower_opcode_tgsi_sampling(struct fs_compile_context *fcc,
                              struct toy_inst *inst)
{
   struct toy_compiler *tc = &fcc->tc;
   struct toy_dst dst[4], tmp[4];
   struct toy_src desc;
   unsigned sampler_index;
   int swizzles[4], i;
   bool need_filter;

   desc = fs_prepare_tgsi_sampling(tc, inst,
         fcc->first_free_mrf,
         fcc->variant->saturate_tex_coords,
         &sampler_index);

   switch (inst->opcode) {
   case TOY_OPCODE_TGSI_TXF:
   case TOY_OPCODE_TGSI_TXQ:
   case TOY_OPCODE_TGSI_TXQ_LZ:
      need_filter = false;
      break;
   default:
      need_filter = true;
      break;
   }

   toy_compiler_lower_to_send(tc, inst, false, BRW_SFID_SAMPLER);
   inst->src[0] = tsrc(TOY_FILE_MRF, fcc->first_free_mrf, 0);
   inst->src[1] = desc;
   for (i = 2; i < Elements(inst->src); i++)
      inst->src[i] = tsrc_null();

   /* write to temps first */
   tc_alloc_tmp4(tc, tmp);
   tdst_transpose(inst->dst, dst);
   inst->dst = tmp[0];

   tc_move_inst(tc, inst);

   if (need_filter) {
      assert(sampler_index < fcc->variant->num_sampler_views);
      swizzles[0] = fcc->variant->sampler_view_swizzles[sampler_index].r;
      swizzles[1] = fcc->variant->sampler_view_swizzles[sampler_index].g;
      swizzles[2] = fcc->variant->sampler_view_swizzles[sampler_index].b;
      swizzles[3] = fcc->variant->sampler_view_swizzles[sampler_index].a;
   }
   else {
      swizzles[0] = PIPE_SWIZZLE_RED;
      swizzles[1] = PIPE_SWIZZLE_GREEN;
      swizzles[2] = PIPE_SWIZZLE_BLUE;
      swizzles[3] = PIPE_SWIZZLE_ALPHA;
   }

   /* swizzle the results */
   for (i = 0; i < 4; i++) {
      switch (swizzles[i]) {
      case PIPE_SWIZZLE_ZERO:
         tc_MOV(tc, dst[i], tsrc_imm_f(0.0f));
         break;
      case PIPE_SWIZZLE_ONE:
         tc_MOV(tc, dst[i], tsrc_imm_f(1.0f));
         break;
      default:
         tc_MOV(tc, dst[i], tsrc_from(tmp[swizzles[i]]));
         break;
      }
   }
}