Lines Matching refs:setup

55    float dx;		/**< X(v1) - X(v0), used only during setup */
56 float dy; /**< Y(v1) - Y(v0), used only during setup */
72 * Triangle setup info.
126 * Clip setup->quad against the scissor/surface bounds.
129 quad_clip(struct setup_context *setup, struct quad_header *quad)
132 const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect[viewport_index];
161 clip_emit_quad(struct setup_context *setup, struct quad_header *quad)
163 quad_clip(setup, quad);
166 struct softpipe_context *sp = setup->softpipe;
169 setup->numFragsEmitted += util_bitcount(quad->inout.mask);
200 flush_spans(struct setup_context *setup)
203 const int xleft0 = setup->span.left[0];
204 const int xleft1 = setup->span.left[1];
205 const int xright0 = setup->span.right[0];
206 const int xright1 = setup->span.right[1];
207 struct quad_stage *pipe = setup->softpipe->quad.first;
237 setup->quad[q].input.x0 = lx;
238 setup->quad[q].input.y0 = setup->span.y;
239 setup->quad[q].input.facing = setup->facing;
240 setup->quad[q].inout.mask = quadmask;
241 setup->quad_ptrs[q] = &setup->quad[q];
244 setup->numFragsEmitted += util_bitcount(quadmask);
252 pipe->run( pipe, setup->quad_ptrs, q );
257 setup->span.y = 0;
258 setup->span.right[0] = 0;
259 setup->span.right[1] = 0;
260 setup->span.left[0] = 1000000; /* greater than right[0] */
261 setup->span.left[1] = 1000000; /* greater than right[1] */
267 print_vertex(const struct setup_context *setup,
272 for (i = 0; i < setup->nr_vertex_attrs; i++) {
289 setup_sort_vertices(struct setup_context *setup,
295 if (setup->softpipe->rasterizer->flatshade_first)
296 setup->vprovoke = v0;
298 setup->vprovoke = v2;
308 setup->vmin = v0;
309 setup->vmid = v1;
310 setup->vmax = v2;
314 setup->vmin = v2;
315 setup->vmid = v0;
316 setup->vmax = v1;
320 setup->vmin = v0;
321 setup->vmid = v2;
322 setup->vmax = v1;
328 setup->vmin = v1;
329 setup->vmid = v0;
330 setup->vmax = v2;
334 setup->vmin = v2;
335 setup->vmid = v1;
336 setup->vmax = v0;
340 setup->vmin = v1;
341 setup->vmid = v2;
342 setup->vmax = v0;
347 setup->ebot.dx = setup->vmid[0][0] - setup->vmin[0][0];
348 setup->ebot.dy = setup->vmid[0][1] - setup->vmin[0][1];
349 setup->emaj.dx = setup->vmax[0][0] - setup->vmin[0][0];
350 setup->emaj.dy = setup->vmax[0][1] - setup->vmin[0][1];
351 setup->etop.dx = setup->vmax[0][0] - setup->vmid[0][0];
352 setup->etop.dy = setup->vmax[0][1] - setup->vmid[0][1];
365 const float area = (setup->emaj.dx * setup->ebot.dy -
366 setup->ebot.dx * setup->emaj.dy);
368 setup->oneoverarea = 1.0f / area;
372 __FUNCTION__, setup->oneoverarea, area, det );
374 if (util_is_inf_or_nan(setup->oneoverarea))
383 setup->facing =
385 (setup->softpipe->rasterizer->front_ccw));
388 unsigned face = setup->facing == 0 ? PIPE_FACE_FRONT : PIPE_FACE_BACK;
390 if (face & setup->cull_face)
401 * The result will be put into setup->coef[slot].a0[i].
406 const_coeff(struct setup_context *setup,
417 coef->a0[i] = setup->vprovoke[vertSlot][i];
427 tri_linear_coeff(struct setup_context *setup,
434 float a = setup->ebot.dy * majda - botda * setup->emaj.dy;
435 float b = setup->emaj.dx * botda - majda * setup->ebot.dx;
436 float dadx = a * setup->oneoverarea;
437 float dady = b * setup->oneoverarea;
457 (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
458 dady * (setup->vmin[0][1] - setup->pixel_offset)));
472 tri_persp_coeff(struct setup_context *setup,
479 float mina = v[0] * setup->vmin[0][3];
480 float mida = v[1] * setup->vmid[0][3];
481 float maxa = v[2] * setup->vmax[0][3];
484 float a = setup->ebot.dy * majda - botda * setup->emaj.dy;
485 float b = setup->emaj.dx * botda - majda * setup->ebot.dx;
486 float dadx = a * setup->oneoverarea;
487 float dady = b * setup->oneoverarea;
494 (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
495 dady * (setup->vmin[0][1] - setup->pixel_offset)));
500 * Special coefficient setup for gl_FragCoord.
506 setup_fragcoord_coeff(struct setup_context *setup, uint slot)
508 const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
515 setup->coef[slot].a0[0] = pixel_center_integer ? 0.0f : 0.5f;
516 setup->coef[slot].dadx[0] = 1.0f;
517 setup->coef[slot].dady[0] = 0.0f;
519 setup->coef[slot].a0[1] =
520 (origin_lower_left ? setup->softpipe->framebuffer.height-1 : 0)
522 setup->coef[slot].dadx[1] = 0.0f;
523 setup->coef[slot].dady[1] = origin_lower_left ? -1.0f : 1.0f;
525 setup->coef[slot].a0[2] = setup->posCoef.a0[2];
526 setup->coef[slot].dadx[2] = setup->posCoef.dadx[2];
527 setup->coef[slot].dady[2] = setup->posCoef.dady[2];
529 setup->coef[slot].a0[3] = setup->posCoef.a0[3];
530 setup->coef[slot].dadx[3] = setup->posCoef.dadx[3];
531 setup->coef[slot].dady[3] = setup->posCoef.dady[3];
537 * Compute the setup->coef[] array dadx, dady, a0 values.
538 * Must be called after setup->vmin,vmid,vmax,vprovoke are initialized.
541 setup_tri_coefficients(struct setup_context *setup)
543 struct softpipe_context *softpipe = setup->softpipe;
544 const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
553 v[0] = setup->vmin[0][2];
554 v[1] = setup->vmid[0][2];
555 v[2] = setup->vmax[0][2];
556 tri_linear_coeff(setup, &setup->posCoef, 2, v);
558 v[0] = setup->vmin[0][3];
559 v[1] = setup->vmid[0][3];
560 v[2] = setup->vmax[0][3];
561 tri_linear_coeff(setup, &setup->posCoef, 3, v);
563 /* setup interpolation for all the remaining attributes:
572 const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
577 v[0] = setup->vmin[vertSlot][j];
578 v[1] = setup->vmid[vertSlot][j];
579 v[2] = setup->vmax[vertSlot][j];
580 tri_linear_coeff(setup, &setup->coef[fragSlot], j, v);
585 v[0] = setup->vmin[vertSlot][j];
586 v[1] = setup->vmid[vertSlot][j];
587 v[2] = setup->vmax[vertSlot][j];
588 tri_persp_coeff(setup, &setup->coef[fragSlot], j, v);
592 setup_fragcoord_coeff(setup, fragSlot);
600 setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
601 setup->coef[fragSlot].dadx[0] = 0.0;
602 setup->coef[fragSlot].dady[0] = 0.0;
609 setup->coef[fragSlot].a0[j],
610 setup->coef[fragSlot].dadx[j],
611 setup->coef[fragSlot].dady[j]);
619 setup_tri_edges(struct setup_context *setup)
621 float vmin_x = setup->vmin[0][0] + setup->pixel_offset;
622 float vmid_x = setup->vmid[0][0] + setup->pixel_offset;
624 float vmin_y = setup->vmin[0][1] - setup->pixel_offset;
625 float vmid_y = setup->vmid[0][1] - setup->pixel_offset;
626 float vmax_y = setup->vmax[0][1] - setup->pixel_offset;
628 setup->emaj.sy = ceilf(vmin_y);
629 setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy);
630 setup->emaj.dxdy = setup->emaj.dy ? setup->emaj.dx / setup->emaj.dy : .0f;
631 setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy;
633 setup->etop.sy = ceilf(vmid_y);
634 setup->etop.lines = (int) ceilf(vmax_y - setup->etop.sy);
635 setup->etop.dxdy = setup->etop.dy ? setup->etop.dx / setup->etop.dy : .0f;
636 setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy;
638 setup->ebot.sy = ceilf(vmin_y);
639 setup->ebot.lines = (int) ceilf(vmid_y - setup->ebot.sy);
640 setup->ebot.dxdy = setup->ebot.dy ? setup->ebot.dx / setup->ebot.dy : .0f;
641 setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy;
650 subtriangle(struct setup_context *setup,
656 const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect[viewport_index];
702 if (block(_y) != setup->span.y) {
703 flush_spans(setup);
704 setup->span.y = block(_y);
707 setup->span.left[_y&1] = left;
708 setup->span.right[_y&1] = right;
744 * Do setup for triangle rasterization, then render the triangle.
747 sp_setup_tri(struct setup_context *setup,
757 print_vertex(setup, v0);
758 print_vertex(setup, v1);
759 print_vertex(setup, v2);
763 setup->softpipe->rasterizer->rasterizer_discard)
772 setup->numFragsEmitted = 0;
773 setup->numFragsWritten = 0;
776 if (!setup_sort_vertices( setup, det, v0, v1, v2 ))
779 setup_tri_coefficients( setup );
780 setup_tri_edges( setup );
782 assert(setup->softpipe->reduced_prim == PIPE_PRIM_TRIANGLES);
784 setup->span.y = 0;
785 setup->span.right[0] = 0;
786 setup->span.right[1] = 0;
787 /* setup->span.z_mode = tri_z_mode( setup->ctx ); */
788 if (setup->softpipe->layer_slot > 0) {
789 layer = *(unsigned *)setup->vprovoke[setup->softpipe->layer_slot];
790 layer = MIN2(layer, setup->max_layer);
792 setup->quad[0].input.layer = layer;
794 if (setup->softpipe->viewport_index_slot > 0) {
795 unsigned *udata = (unsigned*)v0[setup->softpipe->viewport_index_slot];
798 setup->quad[0].input.viewport_index = viewport_index;
800 /* init_constant_attribs( setup ); */
802 if (setup->oneoverarea < 0.0) {
805 subtriangle(setup, &setup->emaj, &setup->ebot, setup->ebot.lines, viewport_index);
806 subtriangle(setup, &setup->emaj, &setup->etop, setup->etop.lines, viewport_index);
811 subtriangle(setup, &setup->ebot, &setup->emaj, setup->ebot.lines, viewport_index);
812 subtriangle(setup, &setup->etop, &setup->emaj, setup->etop.lines, viewport_index);
815 flush_spans( setup );
817 if (setup->softpipe->active_statistics_queries) {
818 setup->softpipe->pipeline_statistics.c_primitives++;
823 setup->numFragsEmitted,
824 setup->numFragsWritten);
835 line_linear_coeff(const struct setup_context *setup,
841 const float dadx = da * setup->emaj.dx * setup->oneoverarea;
842 const float dady = da * setup->emaj.dy * setup->oneoverarea;
846 (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
847 dady * (setup->vmin[0][1] - setup->pixel_offset)));
857 line_persp_coeff(const struct setup_context *setup,
862 const float a0 = v[0] * setup->vmin[0][3];
863 const float a1 = v[1] * setup->vmax[0][3];
865 const float dadx = da * setup->emaj.dx * setup->oneoverarea;
866 const float dady = da * setup->emaj.dy * setup->oneoverarea;
870 (dadx * (setup->vmin[0][0] - setup->pixel_offset) +
871 dady * (setup->vmin[0][1] - setup->pixel_offset)));
876 * Compute the setup->coef[] array dadx, dady, a0 values.
877 * Must be called after setup->vmin,vmax are initialized.
880 setup_line_coefficients(struct setup_context *setup,
884 struct softpipe_context *softpipe = setup->softpipe;
885 const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
893 /* use setup->vmin, vmax to point to vertices */
895 setup->vprovoke = v0;
897 setup->vprovoke = v1;
898 setup->vmin = v0;
899 setup->vmax = v1;
901 setup->emaj.dx = setup->vmax[0][0] - setup->vmin[0][0];
902 setup->emaj.dy = setup->vmax[0][1] - setup->vmin[0][1];
905 area = setup->emaj.dx * setup->emaj.dx + setup->emaj.dy * setup->emaj.dy;
908 setup->oneoverarea = 1.0f / area;
912 v[0] = setup->vmin[0][2];
913 v[1] = setup->vmax[0][2];
914 line_linear_coeff(setup, &setup->posCoef, 2, v);
916 v[0] = setup->vmin[0][3];
917 v[1] = setup->vmax[0][3];
918 line_linear_coeff(setup, &setup->posCoef, 3, v);
920 /* setup interpolation for all the remaining attributes:
929 const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
933 v[0] = setup->vmin[vertSlot][j];
934 v[1] = setup->vmax[vertSlot][j];
935 line_linear_coeff(setup, &setup->coef[fragSlot], j, v);
940 v[0] = setup->vmin[vertSlot][j];
941 v[1] = setup->vmax[vertSlot][j];
942 line_persp_coeff(setup, &setup->coef[fragSlot], j, v);
946 setup_fragcoord_coeff(setup, fragSlot);
954 setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
955 setup->coef[fragSlot].dadx[0] = 0.0;
956 setup->coef[fragSlot].dady[0] = 0.0;
967 plot(struct setup_context *setup, int x, int y)
975 if (quadX != setup->quad[0].input.x0 ||
976 quadY != setup->quad[0].input.y0)
980 if (setup->quad[0].input.x0 != -1)
981 clip_emit_quad(setup, &setup->quad[0]);
983 setup->quad[0].input.x0 = quadX;
984 setup->quad[0].input.y0 = quadY;
985 setup->quad[0].inout.mask = 0x0;
988 setup->quad[0].inout.mask |= mask;
993 * Do setup for line rasterization, then render the line.
998 sp_setup_line(struct setup_context *setup,
1014 print_vertex(setup, v0);
1015 print_vertex(setup, v1);
1019 setup->softpipe->rasterizer->rasterizer_discard)
1025 if (!setup_line_coefficients(setup, v0, v1))
1051 assert(setup->softpipe->reduced_prim == PIPE_PRIM_LINES);
1053 setup->quad[0].input.x0 = setup->quad[0].input.y0 = -1;
1054 setup->quad[0].inout.mask = 0x0;
1055 if (setup->softpipe->layer_slot > 0) {
1056 layer = *(unsigned *)setup->vprovoke[setup->softpipe->layer_slot];
1057 layer = MIN2(layer, setup->max_layer);
1059 setup->quad[0].input.layer = layer;
1061 if (setup->softpipe->viewport_index_slot > 0) {
1062 unsigned *udata = (unsigned*)setup->vprovoke[setup->softpipe->viewport_index_slot];
1065 setup->quad[0].input.viewport_index = viewport_index;
1070 setup->quad[0].input.coverage[0] =
1071 setup->quad[0].input.coverage[1] =
1072 setup->quad[0].input.coverage[2] =
1073 setup->quad[0].input.coverage[3] = 1.0;
1083 plot(setup, x0, y0);
1103 plot(setup, x0, y0);
1117 if (setup->quad[0].inout.mask) {
1118 clip_emit_quad(setup, &setup->quad[0]);
1124 point_persp_coeff(const struct setup_context *setup,
1137 * Do setup for point rasterization, then render the point.
1142 sp_setup_point(struct setup_context *setup,
1145 struct softpipe_context *softpipe = setup->softpipe;
1146 const struct tgsi_shader_info *fsInfo = &setup->softpipe->fs_variant->info;
1147 const int sizeAttr = setup->softpipe->psize_slot;
1150 : setup->softpipe->rasterizer->point_size;
1152 const boolean round = (boolean) setup->softpipe->rasterizer->point_smooth;
1161 print_vertex(setup, v0);
1167 setup->softpipe->rasterizer->rasterizer_discard)
1170 assert(setup->softpipe->reduced_prim == PIPE_PRIM_POINTS);
1172 if (setup->softpipe->layer_slot > 0) {
1173 layer = *(unsigned *)v0[setup->softpipe->layer_slot];
1174 layer = MIN2(layer, setup->max_layer);
1176 setup->quad[0].input.layer = layer;
1178 if (setup->softpipe->viewport_index_slot > 0) {
1179 unsigned *udata = (unsigned*)v0[setup->softpipe->viewport_index_slot];
1182 setup->quad[0].input.viewport_index = viewport_index;
1185 * However, for point sprites, we'll need to setup texcoords appropriately.
1200 setup->vprovoke = v0;
1202 /* setup Z, W */
1203 const_coeff(setup, &setup->posCoef, 0, 2);
1204 const_coeff(setup, &setup->posCoef, 0, 3);
1215 const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
1219 point_persp_coeff(setup, setup->vprovoke,
1220 &setup->coef[fragSlot], vertSlot, j);
1223 setup_fragcoord_coeff(setup, fragSlot);
1231 setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
1232 setup->coef[fragSlot].dadx[0] = 0.0;
1233 setup->coef[fragSlot].dady[0] = 0.0;
1242 setup->quad[0].input.x0 = (int) x - ix;
1243 setup->quad[0].input.y0 = (int) y - iy;
1244 setup->quad[0].inout.mask = (1 << ix) << (2 * iy);
1245 clip_emit_quad(setup, &setup->quad[0]);
1265 setup->quad[0].inout.mask = 0x0;
1272 setup->quad[0].input.coverage[QUAD_TOP_LEFT] = MIN2(cover, 1.0f);
1273 setup->quad[0].inout.mask |= MASK_TOP_LEFT;
1281 setup->quad[0].input.coverage[QUAD_TOP_RIGHT] = MIN2(cover, 1.0f);
1282 setup->quad[0].inout.mask |= MASK_TOP_RIGHT;
1290 setup->quad[0].input.coverage[QUAD_BOTTOM_LEFT] = MIN2(cover, 1.0f);
1291 setup->quad[0].inout.mask |= MASK_BOTTOM_LEFT;
1299 setup->quad[0].input.coverage[QUAD_BOTTOM_RIGHT] = MIN2(cover, 1.0f);
1300 setup->quad[0].inout.mask |= MASK_BOTTOM_RIGHT;
1303 if (setup->quad[0].inout.mask) {
1304 setup->quad[0].input.x0 = ix;
1305 setup->quad[0].input.y0 = iy;
1306 clip_emit_quad(setup, &setup->quad[0]);
1350 setup->quad[0].inout.mask = mask;
1351 setup->quad[0].input.x0 = ix;
1352 setup->quad[0].input.y0 = iy;
1353 clip_emit_quad(setup, &setup->quad[0]);
1365 sp_setup_prepare(struct setup_context *setup)
1367 struct softpipe_context *sp = setup->softpipe;
1375 setup->nr_vertex_attrs = draw_num_shader_outputs(sp->draw);
1383 for (i = 0; i < setup->softpipe->framebuffer.nr_cbufs; i++) {
1384 struct pipe_surface *cbuf = setup->softpipe->framebuffer.cbufs[i];
1396 if (setup->softpipe->rasterizer->half_pixel_center) {
1397 setup->pixel_offset = 0.5f;
1399 setup->pixel_offset = 0.0f;
1402 setup->max_layer = max_layer;
1410 setup->cull_face = sp->rasterizer->cull_face;
1414 setup->cull_face = PIPE_FACE_NONE;
1420 sp_setup_destroy_context(struct setup_context *setup)
1422 FREE( setup );
1427 * Create a new primitive setup/render stage.
1432 struct setup_context *setup = CALLOC_STRUCT(setup_context);
1435 setup->softpipe = softpipe;
1438 setup->quad[i].coef = setup->coef;
1439 setup->quad[i].posCoef = &setup->posCoef;
1442 setup->span.left[0] = 1000000; /* greater than right[0] */
1443 setup->span.left[1] = 1000000; /* greater than right[1] */
1445 return setup;