ilo: switch to ilo states for CLIP and SF stages

Define and use

 struct ilo_viewport_state;
 struct ilo_scissor_state;

in ilo_context.
This commit is contained in:
Chia-I Wu 2013-05-29 14:42:13 +08:00
parent 3bc8289f49
commit 130364ad1d
6 changed files with 49 additions and 19 deletions

View file

@ -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;
}

View file

@ -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);

View file

@ -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];

View file

@ -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 */

View file

@ -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;

View file

@ -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;
}