From 130364ad1d5010e9320aaa312309f83746d751d3 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 29 May 2013 14:42:13 +0800 Subject: [PATCH] ilo: switch to ilo states for CLIP and SF stages Define and use struct ilo_viewport_state; struct ilo_scissor_state; in ilo_context. --- .../drivers/ilo/ilo_3d_pipeline_gen6.c | 24 ++++++++++--------- src/gallium/drivers/ilo/ilo_blit.c | 2 +- src/gallium/drivers/ilo/ilo_context.h | 7 +++--- src/gallium/drivers/ilo/ilo_gpe.h | 10 ++++++++ src/gallium/drivers/ilo/ilo_screen.c | 2 ++ src/gallium/drivers/ilo/ilo_state.c | 23 ++++++++++++++---- 6 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c index e725df8c9c6..e0ce20711da 100644 --- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c +++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c @@ -598,6 +598,7 @@ gen6_pipeline_clip(struct ilo_3d_pipeline *p, /* 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; @@ -605,10 +606,10 @@ gen6_pipeline_clip(struct ilo_3d_pipeline *p, * 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); @@ -778,23 +779,23 @@ gen6_pipeline_state_viewports(struct ilo_3d_pipeline *p, /* 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; } @@ -840,9 +841,10 @@ gen6_pipeline_state_scissors(struct ilo_3d_pipeline *p, 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; } diff --git a/src/gallium/drivers/ilo/ilo_blit.c b/src/gallium/drivers/ilo/ilo_blit.c index 4c851fcef63..899ccace9c3 100644 --- a/src/gallium/drivers/ilo/ilo_blit.c +++ b/src/gallium/drivers/ilo/ilo_blit.c @@ -554,7 +554,7 @@ ilo_blitter_begin(struct ilo_context *ilo, enum ilo_blitter_op op) util_blitter_save_blend(ilo->blitter, ilo->blend); /* undocumented? */ - util_blitter_save_viewport(ilo->blitter, &ilo->viewport); + util_blitter_save_viewport(ilo->blitter, &ilo->viewport.states[0]); util_blitter_save_stencil_ref(ilo->blitter, &ilo->stencil_ref); util_blitter_save_sample_mask(ilo->blitter, ilo->sample_mask); diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h index 52225c8eacc..6bd3e48ef90 100644 --- a/src/gallium/drivers/ilo/ilo_context.h +++ b/src/gallium/drivers/ilo/ilo_context.h @@ -62,6 +62,10 @@ struct ilo_context { 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; @@ -72,11 +76,8 @@ struct ilo_context { 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]; diff --git a/src/gallium/drivers/ilo/ilo_gpe.h b/src/gallium/drivers/ilo/ilo_gpe.h index 468398e2e4b..9bf1114e9dc 100644 --- a/src/gallium/drivers/ilo/ilo_gpe.h +++ b/src/gallium/drivers/ilo/ilo_gpe.h @@ -39,6 +39,7 @@ #define ILO_MAX_SAMPLERS 16 #define ILO_MAX_SO_BINDINGS 64 #define ILO_MAX_SO_BUFFERS 4 +#define ILO_MAX_VIEWPORTS 1 #define ILO_MAX_VS_SURFACES (ILO_MAX_CONST_BUFFERS + ILO_MAX_SAMPLER_VIEWS) #define ILO_VS_CONST_SURFACE(i) (i) @@ -74,4 +75,13 @@ struct ilo_so_state { bool enabled; }; +struct ilo_viewport_state { + struct pipe_viewport_state states[ILO_MAX_VIEWPORTS]; + unsigned count; +}; + +struct ilo_scissor_state { + struct pipe_scissor_state states[ILO_MAX_VIEWPORTS]; +}; + #endif /* ILO_GPE_H */ diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index 264c338816a..c4a5e9444b6 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -421,6 +421,8 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE: /* a BRW_SURFACE_BUFFER can have up to 2^27 elements */ return 1 << 27; + case PIPE_CAP_MAX_VIEWPORTS: + return ILO_MAX_VIEWPORTS; default: return 0; diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c index 76a82ac7a9c..dfee07f4825 100644 --- a/src/gallium/drivers/ilo/ilo_state.c +++ b/src/gallium/drivers/ilo/ilo_state.c @@ -568,11 +568,13 @@ static void 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; } @@ -581,11 +583,24 @@ static void 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; } -- 2.30.2