Path: blob/21.2-virgl/src/gallium/drivers/softpipe/sp_quad_stipple.c
4570 views
1/**2* quad polygon stipple stage3*/45#include "sp_context.h"6#include "sp_quad.h"7#include "sp_quad_pipe.h"8#include "pipe/p_defines.h"9#include "util/u_memory.h"101112/**13* Apply polygon stipple to quads produced by triangle rasterization14*/15static void16stipple_quad(struct quad_stage *qs, struct quad_header *quads[], unsigned nr)17{18static const uint bit31 = 1u << 31;19static const uint bit30 = 1u << 30;20unsigned pass = nr;2122struct softpipe_context *softpipe = qs->softpipe;23unsigned q;2425pass = 0;2627for (q = 0; q < nr; q++) {28struct quad_header *quad = quads[q];2930const int col0 = quad->input.x0 % 32;31const int y0 = quad->input.y0;32const int y1 = y0 + 1;33const uint stipple0 = softpipe->poly_stipple.stipple[y0 % 32];34const uint stipple1 = softpipe->poly_stipple.stipple[y1 % 32];3536/* turn off quad mask bits that fail the stipple test */37if ((stipple0 & (bit31 >> col0)) == 0)38quad->inout.mask &= ~MASK_TOP_LEFT;3940if ((stipple0 & (bit30 >> col0)) == 0)41quad->inout.mask &= ~MASK_TOP_RIGHT;4243if ((stipple1 & (bit31 >> col0)) == 0)44quad->inout.mask &= ~MASK_BOTTOM_LEFT;4546if ((stipple1 & (bit30 >> col0)) == 0)47quad->inout.mask &= ~MASK_BOTTOM_RIGHT;4849if (quad->inout.mask)50quads[pass++] = quad;51}5253qs->next->run(qs->next, quads, pass);54}555657static void stipple_begin(struct quad_stage *qs)58{59qs->next->begin(qs->next);60}616263static void stipple_destroy(struct quad_stage *qs)64{65FREE( qs );66}676869struct quad_stage *70sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe )71{72struct quad_stage *stage = CALLOC_STRUCT(quad_stage);7374stage->softpipe = softpipe;75stage->begin = stipple_begin;76stage->run = stipple_quad;77stage->destroy = stipple_destroy;7879return stage;80}818283