llvmpipe: consolidate code in lp_rast_linear_fallback.c
Combine shade_quads_all() and shade_quads_mask() into new shade_quads() function which takes a mask parameter. It calls either jit_function[RAST_WHOLE] or jit_function[RAST_EDGE_TEST] depending on the mask argument. Signed-off-by: Brian Paul <brianp@vmware.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17561>
This commit is contained in:
parent
593282a9cd
commit
c7239dfe5d
|
@ -86,52 +86,12 @@ static unsigned bottom_mask_tab[STAMP_SIZE] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shade all pixels in a 4x4 block. The fragment code omits the
|
|
||||||
* triangle in/out tests.
|
|
||||||
* \param x, y location of 4x4 block in window coords
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
shade_quads_all(struct lp_rasterizer_task *task,
|
|
||||||
const struct lp_rast_shader_inputs *inputs,
|
|
||||||
unsigned x, unsigned y)
|
|
||||||
{
|
|
||||||
const struct lp_scene *scene = task->scene;
|
|
||||||
const struct lp_rast_state *state = task->state;
|
|
||||||
struct lp_fragment_shader_variant *variant = state->variant;
|
|
||||||
uint8_t *color = scene->cbufs[0].map;
|
|
||||||
unsigned stride = scene->cbufs[0].stride;
|
|
||||||
uint8_t *cbufs[1];
|
|
||||||
unsigned strides[1];
|
|
||||||
|
|
||||||
color += x * 4;
|
|
||||||
color += y * stride;
|
|
||||||
cbufs[0] = color;
|
|
||||||
strides[0] = stride;
|
|
||||||
|
|
||||||
assert(!variant->key.depth.enabled);
|
|
||||||
|
|
||||||
/* run shader on 4x4 block */
|
|
||||||
BEGIN_JIT_CALL(state, task);
|
|
||||||
variant->jit_function[RAST_WHOLE](&state->jit_context,
|
|
||||||
x, y,
|
|
||||||
inputs->frontfacing,
|
|
||||||
GET_A0(inputs),
|
|
||||||
GET_DADX(inputs),
|
|
||||||
GET_DADY(inputs),
|
|
||||||
cbufs,
|
|
||||||
NULL,
|
|
||||||
0xffff,
|
|
||||||
&task->thread_data,
|
|
||||||
strides, 0, 0, 0);
|
|
||||||
END_JIT_CALL();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shade_quads_mask(struct lp_rasterizer_task *task,
|
shade_quads(struct lp_rasterizer_task *task,
|
||||||
const struct lp_rast_shader_inputs *inputs,
|
const struct lp_rast_shader_inputs *inputs,
|
||||||
unsigned x, unsigned y,
|
unsigned x, unsigned y,
|
||||||
unsigned mask)
|
unsigned mask)
|
||||||
{
|
{
|
||||||
const struct lp_rast_state *state = task->state;
|
const struct lp_rast_state *state = task->state;
|
||||||
struct lp_fragment_shader_variant *variant = state->variant;
|
struct lp_fragment_shader_variant *variant = state->variant;
|
||||||
|
@ -153,35 +113,22 @@ shade_quads_mask(struct lp_rasterizer_task *task,
|
||||||
|
|
||||||
/* run shader on 4x4 block */
|
/* run shader on 4x4 block */
|
||||||
BEGIN_JIT_CALL(state, task);
|
BEGIN_JIT_CALL(state, task);
|
||||||
variant->jit_function[RAST_EDGE_TEST](&state->jit_context,
|
const unsigned fn_index = mask == 0xffff ? RAST_WHOLE : RAST_EDGE_TEST;
|
||||||
x, y,
|
variant->jit_function[fn_index](&state->jit_context,
|
||||||
inputs->frontfacing,
|
x, y,
|
||||||
GET_A0(inputs),
|
inputs->frontfacing,
|
||||||
GET_DADX(inputs),
|
GET_A0(inputs),
|
||||||
GET_DADY(inputs),
|
GET_DADX(inputs),
|
||||||
cbufs,
|
GET_DADY(inputs),
|
||||||
NULL,
|
cbufs,
|
||||||
mask,
|
NULL,
|
||||||
&task->thread_data,
|
mask,
|
||||||
strides, 0, 0, 0);
|
&task->thread_data,
|
||||||
|
strides, 0, 0, 0);
|
||||||
END_JIT_CALL();
|
END_JIT_CALL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Shade a 4x4 stamp completely within the rectangle.
|
|
||||||
*/
|
|
||||||
static inline void
|
|
||||||
full(struct lp_rasterizer_task *task,
|
|
||||||
const struct lp_rast_shader_inputs *inputs,
|
|
||||||
unsigned ix, unsigned iy)
|
|
||||||
{
|
|
||||||
shade_quads_all(task,
|
|
||||||
inputs,
|
|
||||||
ix * STAMP_SIZE,
|
|
||||||
iy * STAMP_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Shade a 4x4 stamp which may be partially outside the rectangle,
|
/* Shade a 4x4 stamp which may be partially outside the rectangle,
|
||||||
* according to the mask parameter.
|
* according to the mask parameter.
|
||||||
*/
|
*/
|
||||||
|
@ -194,16 +141,8 @@ partial(struct lp_rasterizer_task *task,
|
||||||
/* Unfortunately we can end up generating full blocks on this path,
|
/* Unfortunately we can end up generating full blocks on this path,
|
||||||
* need to catch them.
|
* need to catch them.
|
||||||
*/
|
*/
|
||||||
if (mask == 0xffff)
|
assert(mask != 0x0);
|
||||||
full(task, inputs, ix, iy);
|
shade_quads(task, inputs, ix * STAMP_SIZE, iy * STAMP_SIZE, mask);
|
||||||
else {
|
|
||||||
assert(mask);
|
|
||||||
shade_quads_mask(task,
|
|
||||||
inputs,
|
|
||||||
ix * STAMP_SIZE,
|
|
||||||
iy * STAMP_SIZE,
|
|
||||||
mask);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,7 +230,7 @@ lp_rast_linear_rect_fallback(struct lp_rasterizer_task *task,
|
||||||
*/
|
*/
|
||||||
for (unsigned j = iy0 + 1; j < iy1; j++) {
|
for (unsigned j = iy0 + 1; j < iy1; j++) {
|
||||||
for (unsigned i = ix0 + 1; i < ix1; i++) {
|
for (unsigned i = ix0 + 1; i < ix1; i++) {
|
||||||
full(task, inputs, i, j);
|
shade_quads(task, inputs, i * STAMP_SIZE, j * STAMP_SIZE, 0xffff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue