/* 3DSTATE_CLIP */
if (DIRTY(RASTERIZER) || DIRTY(FS) ||
DIRTY(VIEWPORT) || DIRTY(FRAMEBUFFER)) {
+ const struct pipe_viewport_state *vp = &ilo->viewport.states[0];
bool enable_guardband;
float x1, x2, y1, y2;
* We do not do 2D clipping yet. Guard band test should only be enabled
* when the viewport is larger than the framebuffer.
*/
- x1 = fabs(ilo->viewport.scale[0]) * -1.0f + ilo->viewport.translate[0];
- x2 = fabs(ilo->viewport.scale[0]) * 1.0f + ilo->viewport.translate[0];
- y1 = fabs(ilo->viewport.scale[1]) * -1.0f + ilo->viewport.translate[1];
- y2 = fabs(ilo->viewport.scale[1]) * 1.0f + ilo->viewport.translate[1];
+ x1 = fabs(vp->scale[0]) * -1.0f + vp->translate[0];
+ x2 = fabs(vp->scale[0]) * 1.0f + vp->translate[0];
+ y1 = fabs(vp->scale[1]) * -1.0f + vp->translate[1];
+ y2 = fabs(vp->scale[1]) * 1.0f + vp->translate[1];
enable_guardband =
(x1 <= 0.0f && x2 >= (float) ilo->framebuffer.width &&
y1 <= 0.0f && y2 >= (float) ilo->framebuffer.height);
/* SF_CLIP_VIEWPORT and CC_VIEWPORT */
if (p->dev->gen >= ILO_GEN(7) && DIRTY(VIEWPORT)) {
p->state.SF_CLIP_VIEWPORT = p->gen7_SF_CLIP_VIEWPORT(p->dev,
- &ilo->viewport, 1, p->cp);
+ ilo->viewport.states, ilo->viewport.count, p->cp);
p->state.CC_VIEWPORT = p->gen6_CC_VIEWPORT(p->dev,
- &ilo->viewport, 1, p->cp);
+ ilo->viewport.states, ilo->viewport.count, p->cp);
session->viewport_state_changed = true;
}
/* SF_VIEWPORT, CLIP_VIEWPORT, and CC_VIEWPORT */
else if (DIRTY(VIEWPORT)) {
p->state.CLIP_VIEWPORT = p->gen6_CLIP_VIEWPORT(p->dev,
- &ilo->viewport, 1, p->cp);
+ ilo->viewport.states, ilo->viewport.count, p->cp);
p->state.SF_VIEWPORT = p->gen6_SF_VIEWPORT(p->dev,
- &ilo->viewport, 1, p->cp);
+ ilo->viewport.states, ilo->viewport.count, p->cp);
p->state.CC_VIEWPORT = p->gen6_CC_VIEWPORT(p->dev,
- &ilo->viewport, 1, p->cp);
+ ilo->viewport.states, ilo->viewport.count, p->cp);
session->viewport_state_changed = true;
}
struct gen6_pipeline_session *session)
{
/* SCISSOR_RECT */
- if (DIRTY(SCISSOR)) {
+ if (DIRTY(SCISSOR) || DIRTY(VIEWPORT)) {
+ /* there should be as many scissors as there are viewports */
p->state.SCISSOR_RECT = p->gen6_SCISSOR_RECT(p->dev,
- &ilo->scissor, 1, p->cp);
+ ilo->scissor.states, ilo->viewport.count, p->cp);
session->scissor_state_changed = true;
}
struct ilo_so_state so;
+ struct pipe_clip_state clip;
+ struct ilo_viewport_state viewport;
+ struct ilo_scissor_state scissor;
+
struct pipe_blend_state *blend;
struct pipe_rasterizer_state *rasterizer;
struct pipe_depth_stencil_alpha_state *depth_stencil_alpha;
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
unsigned sample_mask;
- struct pipe_clip_state clip;
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
- struct pipe_scissor_state scissor;
- struct pipe_viewport_state viewport;
struct {
struct pipe_sampler_state *samplers[ILO_MAX_SAMPLERS];
ilo_set_scissor_states(struct pipe_context *pipe,
unsigned start_slot,
unsigned num_scissors,
- const struct pipe_scissor_state *state)
+ const struct pipe_scissor_state *scissors)
{
struct ilo_context *ilo = ilo_context(pipe);
+ unsigned i;
- ilo->scissor = *state;
+ for (i = 0; i < num_scissors; i++)
+ ilo->scissor.states[start_slot + i] = scissors[i];
ilo->dirty |= ILO_DIRTY_SCISSOR;
}
ilo_set_viewport_states(struct pipe_context *pipe,
unsigned start_slot,
unsigned num_viewports,
- const struct pipe_viewport_state *state)
+ const struct pipe_viewport_state *viewports)
{
struct ilo_context *ilo = ilo_context(pipe);
- ilo->viewport = *state;
+ if (viewports) {
+ unsigned i;
+
+ for (i = 0; i < num_viewports; i++)
+ ilo->viewport.states[start_slot + i] = viewports[i];
+
+ if (ilo->viewport.count < start_slot + num_viewports)
+ ilo->viewport.count = start_slot + num_viewports;
+ }
+ else {
+ if (ilo->viewport.count <= start_slot + num_viewports &&
+ ilo->viewport.count > start_slot)
+ ilo->viewport.count = start_slot;
+ }
ilo->dirty |= ILO_DIRTY_VIEWPORT;
}