[Mesa-dev] [PATCH] radeonsi: do per-pixel clipping based on viewport states
Marek Olšák
maraeo at gmail.com
Thu Apr 7 19:17:23 UTC 2016
On Thu, Apr 7, 2016 at 7:56 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> On 06.04.2016 19:06, Marek Olšák wrote:
>>
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> In other words, vport scissors are derived from viewport states.
>> If the scissor test is enabled, the intersection of both is used.
>>
>> The guard band will disable clipping, so we have to clip per-pixel.
>> ---
>> src/gallium/drivers/radeonsi/si_state.c | 95
>> +++++++++++++++++++++++++++++----
>> src/gallium/drivers/radeonsi/si_state.h | 1 +
>> 2 files changed, 85 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/gallium/drivers/radeonsi/si_state.c
>> b/src/gallium/drivers/radeonsi/si_state.c
>> index 10d691a..462dc63 100644
>> --- a/src/gallium/drivers/radeonsi/si_state.c
>> +++ b/src/gallium/drivers/radeonsi/si_state.c
>> @@ -830,25 +830,93 @@ static void si_set_scissor_states(struct
>> pipe_context *ctx,
>> for (i = 0; i < num_scissors; i++)
>> sctx->scissors.states[start_slot + i] = state[i];
>>
>> + if (!sctx->queued.named.rasterizer ||
>> + !sctx->queued.named.rasterizer->scissor_enable)
>> + return;
>> +
>> sctx->scissors.dirty_mask |= ((1 << num_scissors) - 1) <<
>> start_slot;
>> si_mark_atom_dirty(sctx, &sctx->scissors.atom);
>> }
>>
>> +static void si_get_scissor_from_viewport(struct pipe_viewport_state *vp,
>> + struct pipe_scissor_state
>> *scissor)
>> +{
>> + /* These must be signed, unlike pipe_scissor_state. */
>> + int minx, miny, maxx, maxy, tmp;
>> +
>> + /* Convert (-1, -1) and (1, 1) from clip space into window space.
>> */
>> + minx = -vp->scale[0] + vp->translate[0];
>> + miny = -vp->scale[1] + vp->translate[1];
>> + maxx = vp->scale[0] + vp->translate[0];
>> + maxy = vp->scale[1] + vp->translate[1];
>> +
>> + /* r600_draw_rectangle sets this. Disable the scissor. */
>> + if (minx == -1 && miny == -1 && maxx == 1 && maxy == 1) {
>> + minx = miny = 0;
>> + maxx = maxy = 16384;
>> + }
>> +
>> + /* Handle inverted viewports. */
>> + if (minx > maxx) {
>> + tmp = minx;
>> + minx = maxx;
>> + maxx = tmp;
>> + }
>> + if (miny > maxy) {
>> + tmp = miny;
>> + miny = maxy;
>> + maxy = tmp;
>> + }
>> +
>> + scissor->minx = CLAMP(minx, 0, 16384);
>> + scissor->miny = CLAMP(miny, 0, 16384);
>> + scissor->maxx = CLAMP(maxx, 0, 16384);
>> + scissor->maxy = CLAMP(maxy, 0, 16384);
>
>
> I believe these should be 16383 (also above).
The maximum value for VPORT_SCISSOR is really 16384. not 16383.
Marek
More information about the mesa-dev
mailing list