mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
ilo: construct 3DSTATE_CLIP in create_rasterizer_state()
Add ilo_rasterizer_clip and initialize it in create_rasterizer_state().
This commit is contained in:
parent
4006f4ce26
commit
3c2fea206f
5 changed files with 87 additions and 51 deletions
|
|
@ -615,7 +615,7 @@ gen6_pipeline_clip(struct ilo_3d_pipeline *p,
|
|||
}
|
||||
|
||||
p->gen6_3DSTATE_CLIP(p->dev,
|
||||
&ilo->rasterizer->state,
|
||||
ilo->rasterizer,
|
||||
(ilo->fs && ilo->fs->shader->in.has_linear_interp),
|
||||
enable_guardband, 1, p->cp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,8 +111,17 @@ struct ilo_scissor_state {
|
|||
uint32_t payload[ILO_MAX_VIEWPORTS * 2];
|
||||
};
|
||||
|
||||
struct ilo_rasterizer_clip {
|
||||
/* 3DSTATE_CLIP */
|
||||
uint32_t payload[3];
|
||||
|
||||
uint32_t can_enable_guardband;
|
||||
};
|
||||
|
||||
struct ilo_rasterizer_state {
|
||||
struct pipe_rasterizer_state state;
|
||||
|
||||
struct ilo_rasterizer_clip clip;
|
||||
};
|
||||
|
||||
struct ilo_dsa_state {
|
||||
|
|
@ -253,6 +262,19 @@ void
|
|||
ilo_gpe_set_scissor_null(const struct ilo_dev_info *dev,
|
||||
struct ilo_scissor_state *scissor);
|
||||
|
||||
void
|
||||
ilo_gpe_init_rasterizer_clip(const struct ilo_dev_info *dev,
|
||||
const struct pipe_rasterizer_state *state,
|
||||
struct ilo_rasterizer_clip *clip);
|
||||
|
||||
static inline void
|
||||
ilo_gpe_init_rasterizer(const struct ilo_dev_info *dev,
|
||||
const struct pipe_rasterizer_state *state,
|
||||
struct ilo_rasterizer_state *rasterizer)
|
||||
{
|
||||
ilo_gpe_init_rasterizer_clip(dev, state, &rasterizer->clip);
|
||||
}
|
||||
|
||||
void
|
||||
ilo_gpe_init_dsa(const struct ilo_dev_info *dev,
|
||||
const struct pipe_depth_stencil_alpha_state *state,
|
||||
|
|
|
|||
|
|
@ -1350,31 +1350,15 @@ gen6_emit_3DSTATE_GS(const struct ilo_dev_info *dev,
|
|||
ilo_cp_end(cp);
|
||||
}
|
||||
|
||||
static void
|
||||
gen6_emit_3DSTATE_CLIP(const struct ilo_dev_info *dev,
|
||||
const struct pipe_rasterizer_state *rasterizer,
|
||||
bool has_linear_interp,
|
||||
bool enable_guardband,
|
||||
int num_viewports,
|
||||
struct ilo_cp *cp)
|
||||
void
|
||||
ilo_gpe_init_rasterizer_clip(const struct ilo_dev_info *dev,
|
||||
const struct pipe_rasterizer_state *state,
|
||||
struct ilo_rasterizer_clip *clip)
|
||||
{
|
||||
const uint32_t cmd = ILO_GPE_CMD(0x3, 0x0, 0x12);
|
||||
const uint8_t cmd_len = 4;
|
||||
uint32_t dw1, dw2, dw3;
|
||||
|
||||
ILO_GPE_VALID_GEN(dev, 6, 7);
|
||||
|
||||
if (!rasterizer) {
|
||||
ilo_cp_begin(cp, cmd_len);
|
||||
ilo_cp_write(cp, cmd | (cmd_len - 2));
|
||||
ilo_cp_write(cp, 0);
|
||||
ilo_cp_write(cp, 0);
|
||||
ilo_cp_write(cp, 0);
|
||||
ilo_cp_end(cp);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
dw1 = GEN6_CLIP_STATISTICS_ENABLE;
|
||||
|
||||
if (dev->gen >= ILO_GEN(7)) {
|
||||
|
|
@ -1390,10 +1374,10 @@ gen6_emit_3DSTATE_CLIP(const struct ilo_dev_info *dev,
|
|||
dw1 |= 0 << 19 |
|
||||
GEN7_CLIP_EARLY_CULL;
|
||||
|
||||
if (rasterizer->front_ccw)
|
||||
if (state->front_ccw)
|
||||
dw1 |= GEN7_CLIP_WINDING_CCW;
|
||||
|
||||
switch (rasterizer->cull_face) {
|
||||
switch (state->cull_face) {
|
||||
case PIPE_FACE_NONE:
|
||||
dw1 |= GEN7_CLIP_CULLMODE_NONE;
|
||||
break;
|
||||
|
|
@ -1411,38 +1395,18 @@ gen6_emit_3DSTATE_CLIP(const struct ilo_dev_info *dev,
|
|||
|
||||
dw2 = GEN6_CLIP_ENABLE |
|
||||
GEN6_CLIP_XY_TEST |
|
||||
rasterizer->clip_plane_enable << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT |
|
||||
state->clip_plane_enable << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT |
|
||||
GEN6_CLIP_MODE_NORMAL;
|
||||
|
||||
if (rasterizer->clip_halfz)
|
||||
if (state->clip_halfz)
|
||||
dw2 |= GEN6_CLIP_API_D3D;
|
||||
else
|
||||
dw2 |= GEN6_CLIP_API_OGL;
|
||||
|
||||
if (rasterizer->depth_clip)
|
||||
if (state->depth_clip)
|
||||
dw2 |= GEN6_CLIP_Z_TEST;
|
||||
|
||||
/*
|
||||
* There are several reasons that guard band test should be disabled
|
||||
*
|
||||
* - when the renderer does not perform 2D clipping
|
||||
* - GL wide points (to avoid partially visibie object)
|
||||
* - GL wide or AA lines (to avoid partially visibie object)
|
||||
*/
|
||||
if (enable_guardband && true /* API_GL */) {
|
||||
if (rasterizer->point_size_per_vertex || rasterizer->point_size > 1.0f)
|
||||
enable_guardband = false;
|
||||
if (rasterizer->line_smooth || rasterizer->line_width > 1.0f)
|
||||
enable_guardband = false;
|
||||
}
|
||||
|
||||
if (enable_guardband)
|
||||
dw2 |= GEN6_CLIP_GB_TEST;
|
||||
|
||||
if (has_linear_interp)
|
||||
dw2 |= GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE;
|
||||
|
||||
if (rasterizer->flatshade_first) {
|
||||
if (state->flatshade_first) {
|
||||
dw2 |= 0 << GEN6_CLIP_TRI_PROVOKE_SHIFT |
|
||||
0 << GEN6_CLIP_LINE_PROVOKE_SHIFT |
|
||||
1 << GEN6_CLIP_TRIFAN_PROVOKE_SHIFT;
|
||||
|
|
@ -1454,9 +1418,57 @@ gen6_emit_3DSTATE_CLIP(const struct ilo_dev_info *dev,
|
|||
}
|
||||
|
||||
dw3 = 0x1 << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
|
||||
0x7ff << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
|
||||
GEN6_CLIP_FORCE_ZERO_RTAINDEX |
|
||||
(num_viewports - 1);
|
||||
0x7ff << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT;
|
||||
|
||||
clip->payload[0] = dw1;
|
||||
clip->payload[1] = dw2;
|
||||
clip->payload[2] = dw3;
|
||||
|
||||
clip->can_enable_guardband = true;
|
||||
|
||||
/*
|
||||
* There are several reasons that guard band test should be disabled
|
||||
*
|
||||
* - GL wide points (to avoid partially visibie object)
|
||||
* - GL wide or AA lines (to avoid partially visibie object)
|
||||
*/
|
||||
if (state->point_size_per_vertex || state->point_size > 1.0f)
|
||||
clip->can_enable_guardband = false;
|
||||
if (state->line_smooth || state->line_width > 1.0f)
|
||||
clip->can_enable_guardband = false;
|
||||
}
|
||||
|
||||
static void
|
||||
gen6_emit_3DSTATE_CLIP(const struct ilo_dev_info *dev,
|
||||
const struct ilo_rasterizer_state *rasterizer,
|
||||
bool has_linear_interp,
|
||||
bool enable_guardband,
|
||||
int num_viewports,
|
||||
struct ilo_cp *cp)
|
||||
{
|
||||
const uint32_t cmd = ILO_GPE_CMD(0x3, 0x0, 0x12);
|
||||
const uint8_t cmd_len = 4;
|
||||
uint32_t dw1, dw2, dw3;
|
||||
|
||||
if (rasterizer) {
|
||||
dw1 = rasterizer->clip.payload[0];
|
||||
dw2 = rasterizer->clip.payload[1];
|
||||
dw3 = rasterizer->clip.payload[2];
|
||||
|
||||
if (enable_guardband && rasterizer->clip.can_enable_guardband)
|
||||
dw2 |= GEN6_CLIP_GB_TEST;
|
||||
|
||||
if (has_linear_interp)
|
||||
dw2 |= GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE;
|
||||
|
||||
dw3 |= GEN6_CLIP_FORCE_ZERO_RTAINDEX |
|
||||
(num_viewports - 1);
|
||||
}
|
||||
else {
|
||||
dw1 = 0;
|
||||
dw2 = 0;
|
||||
dw3 = 0;
|
||||
}
|
||||
|
||||
ilo_cp_begin(cp, cmd_len);
|
||||
ilo_cp_write(cp, cmd | (cmd_len - 2));
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ typedef void
|
|||
|
||||
typedef void
|
||||
(*ilo_gpe_gen6_3DSTATE_CLIP)(const struct ilo_dev_info *dev,
|
||||
const struct pipe_rasterizer_state *rasterizer,
|
||||
const struct ilo_rasterizer_state *rasterizer,
|
||||
bool has_linear_interp,
|
||||
bool enable_guardband,
|
||||
int num_viewports,
|
||||
|
|
|
|||
|
|
@ -303,12 +303,14 @@ static void *
|
|||
ilo_create_rasterizer_state(struct pipe_context *pipe,
|
||||
const struct pipe_rasterizer_state *state)
|
||||
{
|
||||
struct ilo_context *ilo = ilo_context(pipe);
|
||||
struct ilo_rasterizer_state *rast;
|
||||
|
||||
rast = MALLOC_STRUCT(ilo_rasterizer_state);
|
||||
assert(rast);
|
||||
|
||||
rast->state = *state;
|
||||
ilo_gpe_init_rasterizer(ilo->dev, state, rast);
|
||||
|
||||
return rast;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue