static void gs_lower_opcode_emit_so_static(struct gs_compile_context *gcc) { struct toy_compiler *tc = &gcc->tc; struct toy_inst *inst; int i, j; if (gcc->static_data.num_vertices_in_prim < gcc->out_vue_min_count) return; inst = tc_MOV(tc, tdst_w(gcc->vars.tmp), tsrc_imm_v(0x03020100)); inst->exec_size = GEN6_EXECSIZE_8; inst->mask_ctrl = GEN6_MASKCTRL_NOMASK; tc_ADD(tc, tdst_d(gcc->vars.tmp), tsrc_from(tdst_d(gcc->vars.tmp)), tsrc_rect(tsrc_from(gcc->vars.so_index), TOY_RECT_010)); tc_IF(tc, tdst_null(), tsrc_rect(tsrc_offset(tsrc_from(tdst_d(gcc->vars.tmp)), 0, gcc->out_vue_min_count - 1), TOY_RECT_010), tsrc_rect(tsrc_offset(gcc->payload.svbi, 0, 4), TOY_RECT_010), GEN6_COND_LE); { for (i = 0; i < gcc->out_vue_min_count; i++) { for (j = 0; j < gcc->so_info->num_outputs; j++) { const int idx = gcc->so_info->output[j].register_index; struct toy_src index, out; int binding_table_index; bool write_commit; index = tsrc_d(tsrc_offset(tsrc_from(gcc->vars.tmp), 0, i)); if (i == gcc->out_vue_min_count - 1) { out = gcc->vars.tgsi_outs[idx]; } else { /* gcc->vars.buffer_cur also points to the first vertex */ const int buf = (gcc->vars.buffer_cur + i) % gcc->vars.buffer_needed; out = tsrc_offset(tsrc_from(gcc->vars.buffers[buf]), idx, 0); } out = tsrc_offset(out, 0, gcc->so_info->output[j].start_component); /* * From the Sandy Bridge PRM, volume 4 part 2, page 19: * * "The Kernel must do a write commit on the last write to DAP * prior to a URB_WRITE with End of Thread." */ write_commit = (gcc->static_data.num_vertices == gcc->static_data.total_vertices && i == gcc->out_vue_min_count - 1 && j == gcc->so_info->num_outputs - 1); binding_table_index = gcc->shader->bt.gen6_so_base + j; gs_write_so(gcc, gcc->vars.tmp, index, out, write_commit, binding_table_index); /* * From the Sandy Bridge PRM, volume 4 part 1, page 168: * * "The write commit does not modify the destination register, but * merely clears the dependency associated with the destination * register. Thus, a simple "mov" instruction using the register as a * source is sufficient to wait for the write commit to occur." */ if (write_commit) tc_MOV(tc, gcc->vars.tmp, tsrc_from(gcc->vars.tmp)); } } /* SONumPrimsWritten occupies the higher word of m0.2 of URB_WRITE */ tc_ADD(tc, gcc->vars.so_written, tsrc_from(gcc->vars.so_written), tsrc_imm_d(1 << 16)); tc_ADD(tc, gcc->vars.so_index, tsrc_from(gcc->vars.so_index), tsrc_imm_d(gcc->out_vue_min_count)); } tc_ENDIF(tc); }
static void fetch_position(struct fs_compile_context *fcc, struct toy_dst dst) { struct toy_compiler *tc = &fcc->tc; const struct toy_src src_z = tsrc(TOY_FILE_GRF, fcc->payloads[0].source_depth, 0); const struct toy_src src_w = tsrc(TOY_FILE_GRF, fcc->payloads[0].source_w, 0); const int fb_height = (fcc->variant->u.fs.fb_height) ? fcc->variant->u.fs.fb_height : 1; const bool origin_upper_left = (fcc->tgsi.props.fs_coord_origin == TGSI_FS_COORD_ORIGIN_UPPER_LEFT); const bool pixel_center_integer = (fcc->tgsi.props.fs_coord_pixel_center == TGSI_FS_COORD_PIXEL_CENTER_INTEGER); struct toy_src subspan_x, subspan_y; struct toy_dst tmp, tmp_uw; struct toy_dst real_dst[4]; tdst_transpose(dst, real_dst); subspan_x = tsrc_uw(tsrc(TOY_FILE_GRF, 1, 2 * 4)); subspan_x = tsrc_rect(subspan_x, TOY_RECT_240); subspan_y = tsrc_offset(subspan_x, 0, 1); tmp_uw = tdst_uw(tc_alloc_tmp(tc)); tmp = tc_alloc_tmp(tc); /* X */ tc_ADD(tc, tmp_uw, subspan_x, tsrc_imm_v(0x10101010)); tc_MOV(tc, tmp, tsrc_from(tmp_uw)); if (pixel_center_integer) tc_MOV(tc, real_dst[0], tsrc_from(tmp)); else tc_ADD(tc, real_dst[0], tsrc_from(tmp), tsrc_imm_f(0.5f)); /* Y */ tc_ADD(tc, tmp_uw, subspan_y, tsrc_imm_v(0x11001100)); tc_MOV(tc, tmp, tsrc_from(tmp_uw)); if (origin_upper_left && pixel_center_integer) { tc_MOV(tc, real_dst[1], tsrc_from(tmp)); } else { struct toy_src y = tsrc_from(tmp); float offset = 0.0f; if (!pixel_center_integer) offset += 0.5f; if (!origin_upper_left) { offset += (float) (fb_height - 1); y = tsrc_negate(y); } tc_ADD(tc, real_dst[1], y, tsrc_imm_f(offset)); } /* Z and W */ tc_MOV(tc, real_dst[2], src_z); tc_INV(tc, real_dst[3], src_w); }